Skip to content

演奏模式 ​

模式切换 ​

store/config.ts 中的 play_mode 区分听歌与演奏。App.vue 监听该值并调用 sync_shortcuts_with_play_mode:

  • 演奏模式:注册全局 F1 / F2
  • 听歌模式:unregisterAll(),不占用功能键

实现见 composables/global_shortcuts.ts(@tauri-apps/plugin-global-shortcut)。

F1 / F2 ​

按键行为
F1若无当前曲则提示;否则 get_music_notation(id) → music_store.play(notation)
F2music_store.stop(),结束演奏循环

仅处理 Pressed 状态,忽略重复触发中的其它 state。

谱面回放(store/player.ts) ​

play(song_notation):

  1. 校验已选曲;若已在 continue_play 则直接返回
  2. 置 continue_play = true
  3. 遍历谱面:数字 → delay(ms);字符串 → click(chars)(util 封装的按键模拟)
  4. 循环中若 continue_play 被 F2 清掉则 break
  5. 结束时将 continue_play 置回 false
ts
for (const item of song_notation) {
  if (!continue_play.value) break;
  if (typeof item === "number") await delay(item);
  if (typeof item === "string") await click(item);
}

谱面元素类型与后端 notation、GPUI 端解析规则一致:延时用数字,按键用字符串。