Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

前回開いていたエディタ(トーク or ソング)画面を起動時に表示 #2355

Merged
merged 9 commits into from
Nov 19, 2024
13 changes: 5 additions & 8 deletions src/components/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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変数を変更する
Expand Down Expand Up @@ -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)));
Expand Down
5 changes: 4 additions & 1 deletion src/components/Menu/MenuBar/TitleBarEditorSwitcher.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});
};
</script>

Expand Down
2 changes: 2 additions & 0 deletions src/store/setting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
import { IsEqual } from "@/type/utility";

export const settingStoreState: SettingStoreState = {
openedEditor: undefined,
savingSetting: {
fileEncoding: "UTF-8",
fileNamePattern: "",
Expand Down Expand Up @@ -148,6 +149,7 @@ export const settingStore = createPartialStore<SettingStoreTypes>({
"undoableTrackOperations",
"showSingCharacterPortrait",
"playheadPositionDisplayFormat",
"openedEditor",
] as const;

// rootMiscSettingKeysに値を足し忘れていたときに型エラーを出す検出用コード
Expand Down
10 changes: 3 additions & 7 deletions src/store/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1825,7 +1825,9 @@ export type SettingStoreState = {
experimentalSetting: ExperimentalSettingType;
confirmedTips: ConfirmedTips;
engineSettings: EngineSettings;
} & RootMiscSettingType;
} & Omit<RootMiscSettingType, "openedEditor"> & {
openedEditor: EditorType | undefined; // undefinedのときはどのエディタを開くか定まっていない
};

// keyとvalueの型を連動するようにしたPayloadを作る
type KeyValuePayload<R, K extends keyof R = keyof R> = K extends keyof R
Expand Down Expand Up @@ -1921,7 +1923,6 @@ export type SettingStoreTypes = {
*/

export type UiStoreState = {
openedEditor: EditorType | undefined; // undefinedのときはどのエディタを開くか定まっていない
uiLockCount: number;
dialogLockCount: number;
reloadingLock: boolean;
Expand Down Expand Up @@ -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;
};
Expand Down
10 changes: 0 additions & 10 deletions src/store/ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ export function withProgress<T>(
}

export const uiStoreState: UiStoreState = {
openedEditor: undefined,
uiLockCount: 0,
dialogLockCount: 0,
reloadingLock: false,
Expand All @@ -90,15 +89,6 @@ export const uiStoreState: UiStoreState = {
};

export const uiStore = createPartialStore<UiStoreTypes>({
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;
Expand Down
1 change: 1 addition & 0 deletions src/type/preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,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),
Expand Down
Loading