Skip to content

启动与数据加载 ​

挂载时做什么 ​

composables/app_bootstrap.ts 在 onMounted 中依次:

  1. 读取启动提权相关提示(若有则 message.warn)
  2. load_music_list() → 写入 player store
  3. load_app_info() → 写入 config store

失败时分别用 Ant Design Vue 的 message.error 提示,互不影响(列表失败仍可尝试拉应用信息)。

全局快捷键不在 bootstrap 里注册,而由演奏模式切换时再注册(见 演奏模式)。

HTTP 封装 ​

api/index.ts 使用 @tauri-apps/plugin-http 的 fetch:

  • 若 base_url 为空,直接抛出配置错误
  • 非 2xx 时带上状态码与正文片段抛错
  • 成功则 JSON.parse,业务函数返回 envelope.data
ts
export const get_music_list = async (): Promise<MusicList> => {
  const res = await fetch_json<Api_Envelope<MusicList>>(music_url);
  return res.data;
};

同文件还提供 get_music_lyrics、get_music_notation、get_app_info。

根组件中的接线 ​

App.vue 负责:

  • 调用 bootstrap 与列表筛选 composable
  • 按 play_mode 调用 sync_shortcuts_with_play_mode
  • 将播放/暂停/Seek 转发给 Lyrics 组件内的 <audio>
  • 宽屏左右分栏、窄屏列表/歌词页切换(断点与 config.desktop_breakpoint 一致,为 1020)