diff --git a/src/components/App.vue b/src/components/App.vue index b4798dead7..e1cc5c9a42 100644 --- a/src/components/App.vue +++ b/src/components/App.vue @@ -72,13 +72,13 @@ watchEffect(() => { }); // エディタの切り替えを監視してショートカットキーの設定を変更する -watch( - () => store.state.openedEditor, - async (openedEditor) => { - if (openedEditor != undefined) { - hotkeyManager.onEditorChange(openedEditor); +watchEffect( + () => { + if (openedEditor.value) { + hotkeyManager.onEditorChange(openedEditor.value); } }, + { flush: "post" }, ); // テーマの変更を監視してCSS変数を変更する @@ -110,9 +110,6 @@ onMounted(async () => { // プロジェクトファイルのパスを取得 const projectFilePath = urlParams.get("projectFilePath"); - // どちらのエディタを開くか設定 - await store.actions.SET_OPENED_EDITOR({ editor: "talk" }); - // ショートカットキーの設定を登録 const hotkeySettings = store.state.hotkeySettings; hotkeyManager.load(structuredClone(toRaw(hotkeySettings))); diff --git a/src/components/Menu/MenuBar/TitleBarEditorSwitcher.vue b/src/components/Menu/MenuBar/TitleBarEditorSwitcher.vue index 6410cdae55..14e217e25f 100644 --- a/src/components/Menu/MenuBar/TitleBarEditorSwitcher.vue +++ b/src/components/Menu/MenuBar/TitleBarEditorSwitcher.vue @@ -30,7 +30,10 @@ const openedEditor = computed(() => store.state.openedEditor); const uiLocked = computed(() => store.getters.UI_LOCKED); const switchEditor = async (editor: EditorType) => { - await store.actions.SET_OPENED_EDITOR({ editor }); + await store.dispatch("SET_ROOT_MISC_SETTING", { + key: "openedEditor", + value: editor, + }); }; diff --git a/src/store/setting.ts b/src/store/setting.ts index 7567a96eb7..ba9c53548d 100644 --- a/src/store/setting.ts +++ b/src/store/setting.ts @@ -18,6 +18,7 @@ import { import { IsEqual } from "@/type/utility"; export const settingStoreState: SettingStoreState = { + openedEditor: undefined, savingSetting: { fileEncoding: "UTF-8", fileNamePattern: "", @@ -148,6 +149,7 @@ export const settingStore = createPartialStore({ "undoableTrackOperations", "showSingCharacterPortrait", "playheadPositionDisplayFormat", + "openedEditor", ] as const; // rootMiscSettingKeysに値を足し忘れていたときに型エラーを出す検出用コード diff --git a/src/store/type.ts b/src/store/type.ts index eebfd77fcc..fae93613da 100644 --- a/src/store/type.ts +++ b/src/store/type.ts @@ -1825,7 +1825,9 @@ export type SettingStoreState = { experimentalSetting: ExperimentalSettingType; confirmedTips: ConfirmedTips; engineSettings: EngineSettings; -} & RootMiscSettingType; +} & Omit & { + openedEditor: EditorType | undefined; // undefinedのときはどのエディタを開くか定まっていない + }; // keyとvalueの型を連動するようにしたPayloadを作る type KeyValuePayload = K extends keyof R @@ -1921,7 +1923,6 @@ export type SettingStoreTypes = { */ export type UiStoreState = { - openedEditor: EditorType | undefined; // undefinedのときはどのエディタを開くか定まっていない uiLockCount: number; dialogLockCount: number; reloadingLock: boolean; @@ -1951,11 +1952,6 @@ export type DialogStates = { }; export type UiStoreTypes = { - SET_OPENED_EDITOR: { - mutation: { editor: EditorType }; - action(palyoad: { editor: EditorType }): void; - }; - UI_LOCKED: { getter: boolean; }; diff --git a/src/store/ui.ts b/src/store/ui.ts index 8eebacd042..aec24a5b47 100644 --- a/src/store/ui.ts +++ b/src/store/ui.ts @@ -63,7 +63,6 @@ export function withProgress( } export const uiStoreState: UiStoreState = { - openedEditor: undefined, uiLockCount: 0, dialogLockCount: 0, reloadingLock: false, @@ -90,15 +89,6 @@ export const uiStoreState: UiStoreState = { }; export const uiStore = createPartialStore({ - SET_OPENED_EDITOR: { - mutation(state, { editor }) { - state.openedEditor = editor; - }, - action({ mutations }, { editor }) { - mutations.SET_OPENED_EDITOR({ editor }); - }, - }, - UI_LOCKED: { getter(state) { return state.uiLockCount > 0; diff --git a/src/type/preload.ts b/src/type/preload.ts index 756d8ac379..d576228a51 100644 --- a/src/type/preload.ts +++ b/src/type/preload.ts @@ -545,6 +545,7 @@ export type ConfirmedTips = { // ルート直下にある雑多な設定値 export const rootMiscSettingSchema = z.object({ + openedEditor: z.enum(["talk", "song"]).default("talk"), editorFont: z.enum(["default", "os"]).default("default"), showTextLineNumber: z.boolean().default(false), showAddAudioItemButton: z.boolean().default(true),