From a9a86cdbd3fdf4933e21f450fa45ac2f2b171915 Mon Sep 17 00:00:00 2001 From: sabonerune <102559104+sabonerune@users.noreply.github.com> Date: Wed, 25 Jan 2023 23:33:06 +0900 Subject: [PATCH 1/8] =?UTF-8?q?ENH:=20=E3=83=97=E3=83=AD=E3=82=B8=E3=82=A7?= =?UTF-8?q?=E3=82=AF=E3=83=88=E3=83=95=E3=82=A1=E3=82=A4=E3=83=AB=E3=82=92?= =?UTF-8?q?=E3=82=A8=E3=83=B3=E3=82=B8=E3=83=B3=E3=81=8C=E8=B5=B7=E5=8B=95?= =?UTF-8?q?=E3=81=97=E3=81=9F=E5=BE=8C=E3=81=AB=E8=AA=AD=E3=81=BF=E8=BE=BC?= =?UTF-8?q?=E3=81=BE=E3=82=8C=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=E3=81=99?= =?UTF-8?q?=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.vue | 6 +++++ src/background.ts | 57 +++++++++++++++++++++------------------- src/views/EditorHome.vue | 13 ++++++--- 3 files changed, 45 insertions(+), 31 deletions(-) diff --git a/src/App.vue b/src/App.vue index 8f4b23d863..f99c476d09 100644 --- a/src/App.vue +++ b/src/App.vue @@ -28,6 +28,12 @@ export default defineComponent({ watch(query, (newQuery) => { if (newQuery) { store.dispatch("SET_IS_SAFE_MODE", newQuery["isSafeMode"] === "true"); + const filePath = newQuery["projectFilePath"]; + if (typeof filePath === "string" && filePath !== "") { + store.commit("SET_PROJECT_FILEPATH", { + filePath, + }); + } } }); diff --git a/src/background.ts b/src/background.ts index 7c9703e7bc..1cca153b17 100644 --- a/src/background.ts +++ b/src/background.ts @@ -342,15 +342,43 @@ async function createWindow() { icon: path.join(__static, "icon.png"), }); + let projectFilePath = ""; + if (isMac) { + if (filePathOnMac) { + if (filePathOnMac.endsWith(".vvproj")) { + projectFilePath = encodeURI(filePathOnMac); + } + filePathOnMac = undefined; + } + } else { + if (process.argv.length >= 2) { + const filePath = process.argv[1]; + if ( + fs.existsSync(filePath) && + fs.statSync(filePath).isFile() && + filePath.endsWith(".vvproj") + ) { + projectFilePath = encodeURI(filePath); + } + } + } + if (process.env.WEBPACK_DEV_SERVER_URL) { await win.loadURL( (process.env.WEBPACK_DEV_SERVER_URL as string) + "#/home?isSafeMode=" + - appState.isSafeMode + appState.isSafeMode + + "&projectFilePath=" + + projectFilePath ); } else { createProtocol("app"); - win.loadURL("app://./index.html#/home?isSafeMode=" + appState.isSafeMode); + win.loadURL( + "app://./index.html#/home?isSafeMode=" + + appState.isSafeMode + + "&projectFilePath=" + + projectFilePath + ); } if (isDevelopment) win.webContents.openDevTools(); @@ -383,31 +411,6 @@ async function createWindow() { }); }); - win.webContents.once("did-finish-load", () => { - if (isMac) { - if (filePathOnMac) { - if (filePathOnMac.endsWith(".vvproj")) { - ipcMainSend(win, "LOAD_PROJECT_FILE", { - filePath: filePathOnMac, - confirm: false, - }); - } - filePathOnMac = undefined; - } - } else { - if (process.argv.length >= 2) { - const filePath = process.argv[1]; - if ( - fs.existsSync(filePath) && - fs.statSync(filePath).isFile() && - filePath.endsWith(".vvproj") - ) { - ipcMainSend(win, "LOAD_PROJECT_FILE", { filePath, confirm: false }); - } - } - } - }); - mainWindowState.manage(win); } diff --git a/src/views/EditorHome.vue b/src/views/EditorHome.vue index 376092fc1b..38e17c5bdc 100644 --- a/src/views/EditorHome.vue +++ b/src/views/EditorHome.vue @@ -540,11 +540,16 @@ export default defineComponent({ // 辞書を同期 await store.dispatch("SYNC_ALL_USER_DICT"); + const projectFilePath = store.state.projectFilePath; + if (projectFilePath != undefined) { + // プロジェクトファイルの読み込みに失敗したときのために事前にprojectFilePathをundefinedにしておく + store.commit("SET_PROJECT_FILEPATH", { filePath: undefined }); + await store.dispatch("LOAD_PROJECT_FILE", { + filePath: projectFilePath, + }); + } // 最初のAudioCellを作成 - const audioItem: AudioItem = await store.dispatch( - "GENERATE_AUDIO_ITEM", - {} - ); + const audioItem = await store.dispatch("GENERATE_AUDIO_ITEM", {}); const newAudioKey = await store.dispatch("REGISTER_AUDIO_ITEM", { audioItem, }); From 7b8e4c6e8dbfb146d726af8b9e969e3bd6e8b8b1 Mon Sep 17 00:00:00 2001 From: sabonerune <102559104+sabonerune@users.noreply.github.com> Date: Thu, 26 Jan 2023 18:26:05 +0900 Subject: [PATCH 2/8] =?UTF-8?q?FIX:=20=E3=83=91=E3=83=A9=E3=83=A1=E3=83=BC?= =?UTF-8?q?=E3=82=BF=E3=83=BC=E3=81=AE=E8=A4=87=E8=A3=BD=E3=82=92=E9=99=A4?= =?UTF-8?q?=E5=8E=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/background.ts | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/background.ts b/src/background.ts index 1cca153b17..463b5767b2 100644 --- a/src/background.ts +++ b/src/background.ts @@ -363,22 +363,19 @@ async function createWindow() { } } + const parameter = + "#/home?isSafeMode=" + + appState.isSafeMode + + "&projectFilePath=" + + projectFilePath; + if (process.env.WEBPACK_DEV_SERVER_URL) { await win.loadURL( - (process.env.WEBPACK_DEV_SERVER_URL as string) + - "#/home?isSafeMode=" + - appState.isSafeMode + - "&projectFilePath=" + - projectFilePath + (process.env.WEBPACK_DEV_SERVER_URL as string) + parameter ); } else { createProtocol("app"); - win.loadURL( - "app://./index.html#/home?isSafeMode=" + - appState.isSafeMode + - "&projectFilePath=" + - projectFilePath - ); + win.loadURL("app://./index.html" + parameter); } if (isDevelopment) win.webContents.openDevTools(); From 122ba97309466d3ece037f8bc27505e51c5e0e68 Mon Sep 17 00:00:00 2001 From: sabonerune <102559104+sabonerune@users.noreply.github.com> Date: Thu, 26 Jan 2023 20:47:22 +0900 Subject: [PATCH 3/8] =?UTF-8?q?FIX:=20=E3=83=95=E3=82=A1=E3=82=A4=E3=83=AB?= =?UTF-8?q?=E3=83=91=E3=82=B9=E3=82=92prop=E3=81=A7=E6=B8=A1=E3=81=99?= =?UTF-8?q?=E3=82=88=E3=81=86=E3=81=AB=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.vue | 6 ------ src/router/index.ts | 1 + src/views/EditorHome.vue | 13 +++++++------ 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/App.vue b/src/App.vue index f99c476d09..8f4b23d863 100644 --- a/src/App.vue +++ b/src/App.vue @@ -28,12 +28,6 @@ export default defineComponent({ watch(query, (newQuery) => { if (newQuery) { store.dispatch("SET_IS_SAFE_MODE", newQuery["isSafeMode"] === "true"); - const filePath = newQuery["projectFilePath"]; - if (typeof filePath === "string" && filePath !== "") { - store.commit("SET_PROJECT_FILEPATH", { - filePath, - }); - } } }); diff --git a/src/router/index.ts b/src/router/index.ts index af2f37a724..fa7aefe54b 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -10,6 +10,7 @@ const routes: Array = [ { path: "/home", component: EditorHome, + props: (route) => ({ projectFilePath: route.query["projectFilePath"] }), }, ]; diff --git a/src/views/EditorHome.vue b/src/views/EditorHome.vue index 38e17c5bdc..02a7bad6b8 100644 --- a/src/views/EditorHome.vue +++ b/src/views/EditorHome.vue @@ -206,6 +206,10 @@ import cloneDeep from "clone-deep"; export default defineComponent({ name: "EditorHome", + props: { + projectFilePath: { type: String }, + }, + components: { draggable, MenuBar, @@ -227,7 +231,7 @@ export default defineComponent({ ProgressDialog, }, - setup() { + setup(props) { const store = useStore(); const $q = useQuasar(); @@ -540,12 +544,9 @@ export default defineComponent({ // 辞書を同期 await store.dispatch("SYNC_ALL_USER_DICT"); - const projectFilePath = store.state.projectFilePath; - if (projectFilePath != undefined) { - // プロジェクトファイルの読み込みに失敗したときのために事前にprojectFilePathをundefinedにしておく - store.commit("SET_PROJECT_FILEPATH", { filePath: undefined }); + if (props.projectFilePath != undefined && props.projectFilePath !== "") { await store.dispatch("LOAD_PROJECT_FILE", { - filePath: projectFilePath, + filePath: props.projectFilePath, }); } // 最初のAudioCellを作成 From ef50cc94d34de8bea881d8e3019478e14e841631 Mon Sep 17 00:00:00 2001 From: sabonerune <102559104+sabonerune@users.noreply.github.com> Date: Fri, 27 Jan 2023 00:48:36 +0900 Subject: [PATCH 4/8] =?UTF-8?q?ENH:=20LOAD=5FPROJECT=5FFILE=E3=81=AE?= =?UTF-8?q?=E6=88=90=E5=90=A6=E3=81=8C=E5=91=BC=E3=81=B3=E5=87=BA=E3=81=97?= =?UTF-8?q?=E5=81=B4=E3=81=8B=E3=82=89=E5=88=86=E3=81=8B=E3=82=8B=E3=82=88?= =?UTF-8?q?=E3=81=86=E3=81=AB=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/store/project.ts | 6 ++++-- src/store/type.ts | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/store/project.ts b/src/store/project.ts index e77a964eaf..4064d489d4 100755 --- a/src/store/project.ts +++ b/src/store/project.ts @@ -75,7 +75,7 @@ export const projectStore = createPartialStore({ title: "プロジェクトファイルの選択", }); if (ret == undefined || ret?.length == 0) { - return; + return false; } filePath = ret[0]; } @@ -275,7 +275,7 @@ export const projectStore = createPartialStore({ cancelId: 1, }); if (result == 1) { - return; + return false; } } await context.dispatch("REMOVE_ALL_AUDIO_ITEM"); @@ -293,6 +293,7 @@ export const projectStore = createPartialStore({ context.commit("SET_PROJECT_FILEPATH", { filePath }); context.commit("SET_SAVED_LAST_COMMAND_UNIX_MILLISEC", null); context.commit("CLEAR_COMMANDS"); + return true; } catch (err) { window.electron.logError(err); const message = (() => { @@ -307,6 +308,7 @@ export const projectStore = createPartialStore({ title: "エラー", message, }); + return false; } } ), diff --git a/src/store/type.ts b/src/store/type.ts index e0482b508c..d627163bc4 100644 --- a/src/store/type.ts +++ b/src/store/type.ts @@ -943,7 +943,7 @@ export type ProjectStoreTypes = { }; LOAD_PROJECT_FILE: { - action(payload: { filePath?: string; confirm?: boolean }): void; + action(payload: { filePath?: string; confirm?: boolean }): boolean; }; SAVE_PROJECT_FILE: { From 2a2894d9cc44f1914ade643ce0228d37666ed8f7 Mon Sep 17 00:00:00 2001 From: sabonerune <102559104+sabonerune@users.noreply.github.com> Date: Fri, 27 Jan 2023 00:51:02 +0900 Subject: [PATCH 5/8] =?UTF-8?q?ENH:=20=E3=83=97=E3=83=AD=E3=82=B8=E3=82=A7?= =?UTF-8?q?=E3=82=AF=E3=83=88=E3=82=92=E8=AA=AD=E3=81=BF=E8=BE=BC=E3=82=93?= =?UTF-8?q?=E3=81=A0=E6=99=82=E3=81=AEAudioCell=E3=81=AE=E5=88=9D=E6=9C=9F?= =?UTF-8?q?=E5=8C=96=E3=82=92=E6=94=B9=E8=89=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/EditorHome.vue | 47 +++++++++++++++++++++++++--------------- 1 file changed, 30 insertions(+), 17 deletions(-) diff --git a/src/views/EditorHome.vue b/src/views/EditorHome.vue index 02a7bad6b8..2ac2e5b9fe 100644 --- a/src/views/EditorHome.vue +++ b/src/views/EditorHome.vue @@ -521,6 +521,11 @@ export default defineComponent({ // ソフトウェアを初期化 const isCompletedInitialStartup = ref(false); onMounted(async () => { + const projectFilePath = props.projectFilePath; + if (projectFilePath != undefined && projectFilePath !== "") { + // タイトルバーに読み込み中のプロジェクト名を表示 + store.commit("SET_PROJECT_FILEPATH", { filePath: projectFilePath }); + } await store.dispatch("GET_ENGINE_INFOS"); let engineIds: string[]; @@ -544,25 +549,33 @@ export default defineComponent({ // 辞書を同期 await store.dispatch("SYNC_ALL_USER_DICT"); - if (props.projectFilePath != undefined && props.projectFilePath !== "") { - await store.dispatch("LOAD_PROJECT_FILE", { - filePath: props.projectFilePath, + const generateInitAudioCell = async () => { + // 最初のAudioCellを作成 + const audioItem = await store.dispatch("GENERATE_AUDIO_ITEM", {}); + const newAudioKey = await store.dispatch("REGISTER_AUDIO_ITEM", { + audioItem, }); - } - // 最初のAudioCellを作成 - const audioItem = await store.dispatch("GENERATE_AUDIO_ITEM", {}); - const newAudioKey = await store.dispatch("REGISTER_AUDIO_ITEM", { - audioItem, - }); - focusCell({ audioKey: newAudioKey }); - - // 最初の話者を初期化 - if (audioItem.engineId != undefined && audioItem.styleId != undefined) { - store.dispatch("SETUP_SPEAKER", { - audioKey: newAudioKey, - engineId: audioItem.engineId, - styleId: audioItem.styleId, + focusCell({ audioKey: newAudioKey }); + // 最初の話者を初期化 + if (audioItem.engineId != undefined && audioItem.styleId != undefined) { + store.dispatch("SETUP_SPEAKER", { + audioKey: newAudioKey, + engineId: audioItem.engineId, + styleId: audioItem.styleId, + }); + } + }; + + if (projectFilePath != undefined && projectFilePath !== "") { + const result = await store.dispatch("LOAD_PROJECT_FILE", { + filePath: projectFilePath, }); + if (!result) { + store.commit("SET_PROJECT_FILEPATH", {}); + await generateInitAudioCell(); + } + } else { + await generateInitAudioCell(); } // ショートカットキーの設定 From 351dc8c08335af7ce190d6382f5fa6d9258a08a6 Mon Sep 17 00:00:00 2001 From: sabonerune <102559104+sabonerune@users.noreply.github.com> Date: Fri, 27 Jan 2023 07:52:22 +0900 Subject: [PATCH 6/8] =?UTF-8?q?FIX:=20=E8=AA=AD=E3=81=BF=E8=BE=BC=E3=81=BF?= =?UTF-8?q?=E4=B8=AD=E3=81=AE=E3=83=97=E3=83=AD=E3=82=B8=E3=82=A7=E3=82=AF?= =?UTF-8?q?=E3=83=88=E3=83=95=E3=82=A1=E3=82=A4=E3=83=AB=E5=90=8D=E3=81=AE?= =?UTF-8?q?=E8=A1=A8=E7=A4=BA=E3=82=92=E5=BB=83=E6=AD=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 最初のセルの作成を修正 --- src/views/EditorHome.vue | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/src/views/EditorHome.vue b/src/views/EditorHome.vue index 2ac2e5b9fe..0174e59997 100644 --- a/src/views/EditorHome.vue +++ b/src/views/EditorHome.vue @@ -521,11 +521,6 @@ export default defineComponent({ // ソフトウェアを初期化 const isCompletedInitialStartup = ref(false); onMounted(async () => { - const projectFilePath = props.projectFilePath; - if (projectFilePath != undefined && projectFilePath !== "") { - // タイトルバーに読み込み中のプロジェクト名を表示 - store.commit("SET_PROJECT_FILEPATH", { filePath: projectFilePath }); - } await store.dispatch("GET_ENGINE_INFOS"); let engineIds: string[]; @@ -549,13 +544,22 @@ export default defineComponent({ // 辞書を同期 await store.dispatch("SYNC_ALL_USER_DICT"); - const generateInitAudioCell = async () => { + // プロジェクトファイルが指定されていればロード + let projectFileLoaded = false; + if (props.projectFilePath != undefined && props.projectFilePath !== "") { + projectFileLoaded = await store.dispatch("LOAD_PROJECT_FILE", { + filePath: props.projectFilePath, + }); + } + + if (!projectFileLoaded) { // 最初のAudioCellを作成 const audioItem = await store.dispatch("GENERATE_AUDIO_ITEM", {}); const newAudioKey = await store.dispatch("REGISTER_AUDIO_ITEM", { audioItem, }); focusCell({ audioKey: newAudioKey }); + // 最初の話者を初期化 if (audioItem.engineId != undefined && audioItem.styleId != undefined) { store.dispatch("SETUP_SPEAKER", { @@ -564,18 +568,6 @@ export default defineComponent({ styleId: audioItem.styleId, }); } - }; - - if (projectFilePath != undefined && projectFilePath !== "") { - const result = await store.dispatch("LOAD_PROJECT_FILE", { - filePath: projectFilePath, - }); - if (!result) { - store.commit("SET_PROJECT_FILEPATH", {}); - await generateInitAudioCell(); - } - } else { - await generateInitAudioCell(); } // ショートカットキーの設定 From 480f4ad3e2a6bd460d53d3153ae67c5a1c93211f Mon Sep 17 00:00:00 2001 From: sabonerune <102559104+sabonerune@users.noreply.github.com> Date: Thu, 2 Feb 2023 07:25:31 +0900 Subject: [PATCH 7/8] =?UTF-8?q?FIX:=20projectFilePath=E3=82=92string|undef?= =?UTF-8?q?ined=E3=81=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Hiroshiba --- src/background.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/background.ts b/src/background.ts index 463b5767b2..ce970b23db 100644 --- a/src/background.ts +++ b/src/background.ts @@ -342,7 +342,7 @@ async function createWindow() { icon: path.join(__static, "icon.png"), }); - let projectFilePath = ""; + let projectFilePath: string | undefined = ""; if (isMac) { if (filePathOnMac) { if (filePathOnMac.endsWith(".vvproj")) { From c57262126f5d721db0247cf4c385a7a3ac0cd939 Mon Sep 17 00:00:00 2001 From: sabonerune <102559104+sabonerune@users.noreply.github.com> Date: Thu, 2 Feb 2023 07:37:41 +0900 Subject: [PATCH 8/8] =?UTF-8?q?FIX:=20=E3=83=89=E3=82=AD=E3=83=A5=E3=83=A1?= =?UTF-8?q?=E3=83=B3=E3=83=88=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/store/project.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/store/project.ts b/src/store/project.ts index 4064d489d4..f0cb795b1a 100755 --- a/src/store/project.ts +++ b/src/store/project.ts @@ -64,6 +64,9 @@ export const projectStore = createPartialStore({ }, LOAD_PROJECT_FILE: { + /** + * プロジェクトファイルを読み込む。読み込めたかの成否が返る。 + */ action: createUILockAction( async ( context,