From fc0784ea8e3f444cd34128faecc17e99d11a5926 Mon Sep 17 00:00:00 2001 From: X-20A <155217226+X-20A@users.noreply.github.com> Date: Wed, 20 Nov 2024 03:33:53 +0900 Subject: [PATCH] =?UTF-8?q?=E5=89=8D=E5=9B=9E=E9=96=8B=E3=81=84=E3=81=A6?= =?UTF-8?q?=E3=81=84=E3=81=9F=E3=82=A8=E3=83=87=E3=82=A3=E3=82=BF(?= =?UTF-8?q?=E3=83=88=E3=83=BC=E3=82=AF=20or=20=E3=82=BD=E3=83=B3=E3=82=B0)?= =?UTF-8?q?=E7=94=BB=E9=9D=A2=E3=82=92=E8=B5=B7=E5=8B=95=E6=99=82=E3=81=AB?= =?UTF-8?q?=E8=A1=A8=E7=A4=BA=20(#2355)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Hiroshiba --- src/components/App.vue | 13 +++++-------- .../Menu/MenuBar/TitleBarEditorSwitcher.vue | 5 ++++- src/store/setting.ts | 2 ++ src/store/type.ts | 10 +++------- src/store/ui.ts | 10 ---------- src/type/preload.ts | 1 + 6 files changed, 15 insertions(+), 26 deletions(-) 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),