From d7352c33789e06f1fb35f60e1d8a606bebea9836 Mon Sep 17 00:00:00 2001 From: k-chop Date: Tue, 6 Dec 2022 23:58:45 +0900 Subject: [PATCH 01/17] =?UTF-8?q?electron=E5=81=B4=E3=81=A7=E3=83=97?= =?UTF-8?q?=E3=83=AD=E3=82=B0=E3=83=AC=E3=82=B9=E3=83=90=E3=83=BC=E3=82=92?= =?UTF-8?q?=E8=A1=A8=E7=A4=BA=E3=81=A7=E3=81=8D=E3=82=8B=E3=82=88=E3=81=86?= =?UTF-8?q?=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/background.ts | 4 ++++ src/electron/preload.ts | 4 ++++ src/type/ipc.ts | 5 +++++ src/type/preload.ts | 1 + 4 files changed, 14 insertions(+) diff --git a/src/background.ts b/src/background.ts index d3c703e591..96f7a3d14b 100644 --- a/src/background.ts +++ b/src/background.ts @@ -1318,6 +1318,10 @@ ipcMainHandle("RESTART_APP", async (_, { isSafeMode }) => { win.close(); }); +ipcMainHandle("SET_PROGRESS_BAR", (_, { progress }) => { + win.setProgressBar(progress); +}); + // app callback app.on("web-contents-created", (e, contents) => { // リンククリック時はブラウザを開く diff --git a/src/electron/preload.ts b/src/electron/preload.ts index 747dfaa640..cf33ee636d 100644 --- a/src/electron/preload.ts +++ b/src/electron/preload.ts @@ -262,6 +262,10 @@ const api: Sandbox = { restartApp: ({ isSafeMode }: { isSafeMode: boolean }) => { ipcRendererInvoke("RESTART_APP", { isSafeMode }); }, + + setProgressBar: ({ progress }: { progress: number }) => { + ipcRendererInvoke("SET_PROGRESS_BAR", { progress }); + }, }; contextBridge.exposeInMainWorld("electron", api); diff --git a/src/type/ipc.ts b/src/type/ipc.ts index 000fe4b2fc..933ee7b34a 100644 --- a/src/type/ipc.ts +++ b/src/type/ipc.ts @@ -259,6 +259,11 @@ export type IpcIHData = { args: [obj: { isSafeMode: boolean }]; return: void; }; + + SET_PROGRESS_BAR: { + args: [obj: { progress: number }]; + return: void; + }; }; /** diff --git a/src/type/preload.ts b/src/type/preload.ts index aa72e3a79f..6d337d06d2 100644 --- a/src/type/preload.ts +++ b/src/type/preload.ts @@ -99,6 +99,7 @@ export interface Sandbox { ): Promise; validateEngineDir(engineDir: string): Promise; restartApp(obj: { isSafeMode: boolean }): void; + setProgressBar(obj: { progress: number }): void; } export type AppInfos = { From c026c6e29fa677d1d8482273a50db84494812050 Mon Sep 17 00:00:00 2001 From: k-chop Date: Wed, 7 Dec 2022 15:08:47 +0900 Subject: [PATCH 02/17] =?UTF-8?q?uiStore=E3=81=AB=E3=83=97=E3=83=AD?= =?UTF-8?q?=E3=82=B0=E3=83=AC=E3=82=B9=E3=83=90=E3=83=BC=E3=82=92=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E3=81=99=E3=82=8B=E3=81=9F=E3=82=81=E3=81=AE=E3=82=A2?= =?UTF-8?q?=E3=82=AF=E3=82=B7=E3=83=A7=E3=83=B3=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/store/type.ts | 27 +++++++++++++++++++++++++++ src/store/ui.ts | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+) diff --git a/src/store/type.ts b/src/store/type.ts index c50453c21a..7ac974a28f 100644 --- a/src/store/type.ts +++ b/src/store/type.ts @@ -979,6 +979,8 @@ export type UiStoreState = { isMaximized: boolean; isPinned: boolean; isFullscreen: boolean; + progress: number; + progressCount: number; }; export type UiStoreTypes = { @@ -1109,6 +1111,31 @@ export type UiStoreTypes = { RESTART_APP: { action(obj: { isSafeMode?: boolean }): void; }; + + START_PROGRESS: { + action(payload: { count: number }): void; + }; + + START_AUDIO_ITEMS_PROGRESS: { + action(): void; + }; + + START_INDETERMINATE_PROGRESS: { + action(): void; + }; + + INCREMENT_PROGRESS: { + action(): void; + }; + + SET_PROGRESS: { + mutation: { progress: number; count?: number }; + action(payload: { progress: number; count?: number }): void; + }; + + RESET_PROGRESS: { + action(): void; + }; }; /* diff --git a/src/store/ui.ts b/src/store/ui.ts index 3b685a8f1d..40c5fb8331 100644 --- a/src/store/ui.ts +++ b/src/store/ui.ts @@ -44,6 +44,8 @@ export const uiStoreState: UiStoreState = { isMaximized: false, isPinned: false, isFullscreen: false, + progress: -1, + progressCount: 0, }; export const uiStore = createPartialStore({ @@ -322,4 +324,49 @@ export const uiStore = createPartialStore({ window.electron.restartApp({ isSafeMode: !!isSafeMode }); }, }, + + START_PROGRESS: { + action({ dispatch }, { count }) { + dispatch("SET_PROGRESS", { progress: 0, count }); + }, + }, + + START_AUDIO_ITEMS_PROGRESS: { + action({ dispatch, state }) { + dispatch("START_PROGRESS", { count: state.audioKeys.length }); + }, + }, + + INCREMENT_PROGRESS: { + action({ dispatch, state }) { + const step = 1.0 / state.progressCount; + dispatch("SET_PROGRESS", { progress: state.progress + step }); + }, + }, + + START_INDETERMINATE_PROGRESS: { + action({ dispatch }) { + // electron.setProgressBarに1より大きい値を渡すとindeterminateなプログレスバーになる + dispatch("SET_PROGRESS", { progress: 1.1 }); + }, + }, + + SET_PROGRESS: { + mutation(state, { progress, count }) { + state.progress = progress; + if (count != null) { + state.progressCount = count; + } + }, + action({ commit }, { progress, count }) { + window.electron.setProgressBar({ progress }); + commit("SET_PROGRESS", { progress, count }); + }, + }, + + RESET_PROGRESS: { + action({ dispatch }) { + dispatch("SET_PROGRESS", { progress: -1 }); + }, + }, }); From 63ec74c61fe3ebc8f1d7739c67b33ea0a89ee804 Mon Sep 17 00:00:00 2001 From: k-chop Date: Wed, 7 Dec 2022 15:09:22 +0900 Subject: [PATCH 03/17] =?UTF-8?q?=E5=AE=9F=E9=9A=9B=E3=81=AB=E7=94=9F?= =?UTF-8?q?=E6=88=90=E6=99=82=E3=81=AB=E3=83=97=E3=83=AD=E3=82=B0=E3=83=AC?= =?UTF-8?q?=E3=82=B9=E3=83=90=E3=83=BC=E3=82=92=E6=9B=B4=E6=96=B0=E3=81=99?= =?UTF-8?q?=E3=82=8B=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/components/Dialog.ts | 14 +++++++++++--- src/store/audio.ts | 21 ++++++++++++++++++--- src/store/type.ts | 2 ++ 3 files changed, 31 insertions(+), 6 deletions(-) diff --git a/src/components/Dialog.ts b/src/components/Dialog.ts index f002cac022..bb4b157873 100644 --- a/src/components/Dialog.ts +++ b/src/components/Dialog.ts @@ -23,11 +23,13 @@ export async function generateAndSaveOneAudioWithDialog({ filePath?: string; encoding?: EncodingType; }): Promise { + await dispatch("START_INDETERMINATE_PROGRESS"); const result: SaveResultObject = await dispatch("GENERATE_AND_SAVE_AUDIO", { audioKey, filePath, encoding, - }); + }).finally(() => dispatch("RESET_PROGRESS")); + if (result.result === "SUCCESS" || result.result === "CANCELED") return; let msg = ""; switch (result.result) { @@ -65,13 +67,17 @@ export async function generateAndSaveAllAudioWithDialog({ dirPath?: string; encoding?: EncodingType; }): Promise { + await dispatch("START_AUDIO_ITEMS_PROGRESS"); const result = await dispatch("GENERATE_AND_SAVE_ALL_AUDIO", { dirPath, encoding, - }); + callback: () => dispatch("INCREMENT_PROGRESS"), + }).finally(() => dispatch("RESET_PROGRESS")); + const successArray: Array = []; const writeErrorArray: Array = []; const engineErrorArray: Array = []; + if (result) { for (const item of result) { let msg = ""; @@ -121,10 +127,12 @@ export async function generateAndConnectAndSaveAudioWithDialog({ filePath?: string; encoding?: EncodingType; }): Promise { + await dispatch("START_AUDIO_ITEMS_PROGRESS"); const result = await dispatch("GENERATE_AND_CONNECT_AND_SAVE_AUDIO", { filePath, encoding, - }); + callback: () => dispatch("INCREMENT_PROGRESS"), + }).finally(() => dispatch("RESET_PROGRESS")); if ( result === undefined || diff --git a/src/store/audio.ts b/src/store/audio.ts index 480abba69a..25072a6dce 100644 --- a/src/store/audio.ts +++ b/src/store/audio.ts @@ -1232,7 +1232,11 @@ export const audioStore = createPartialStore({ action: createUILockAction( async ( { state, dispatch }, - { dirPath, encoding }: { dirPath?: string; encoding?: EncodingType } + { + dirPath, + encoding, + callback, + }: { dirPath?: string; encoding?: EncodingType; callback?: () => void } ) => { if (state.savingSetting.fixedExportEnabled) { dirPath = state.savingSetting.fixedExportDir; @@ -1249,6 +1253,9 @@ export const audioStore = createPartialStore({ audioKey, filePath: path.join(_dirPath, name), encoding, + }).then((value) => { + callback?.(); + return value; }); }); return Promise.all(promises); @@ -1261,7 +1268,11 @@ export const audioStore = createPartialStore({ action: createUILockAction( async ( { state, dispatch }, - { filePath, encoding }: { filePath?: string; encoding?: EncodingType } + { + filePath, + encoding, + callback, + }: { filePath?: string; encoding?: EncodingType; callback?: () => void } ): Promise => { const defaultFileName = buildProjectFileName(state, "wav"); @@ -1317,6 +1328,7 @@ export const audioStore = createPartialStore({ let blob = await dispatch("GET_AUDIO_CACHE", { audioKey }); if (!blob) { blob = await dispatch("GENERATE_AUDIO", { audioKey }); + callback?.(); } if (blob === null) { return { result: "ENGINE_ERROR", path: filePath }; @@ -1517,11 +1529,14 @@ export const audioStore = createPartialStore({ // 音声用意 let blob = await dispatch("GET_AUDIO_CACHE", { audioKey }); if (!blob) { + dispatch("START_INDETERMINATE_PROGRESS"); commit("SET_AUDIO_NOW_GENERATING", { audioKey, nowGenerating: true, }); - blob = await dispatch("GENERATE_AUDIO", { audioKey }); + blob = await dispatch("GENERATE_AUDIO", { audioKey }).finally(() => + dispatch("RESET_PROGRESS") + ); commit("SET_AUDIO_NOW_GENERATING", { audioKey, nowGenerating: false, diff --git a/src/store/type.ts b/src/store/type.ts index 7ac974a28f..2e5864c162 100644 --- a/src/store/type.ts +++ b/src/store/type.ts @@ -365,6 +365,7 @@ export type AudioStoreTypes = { action(payload: { dirPath?: string; encoding?: EncodingType; + callback?: () => void; }): SaveResultObject[] | undefined; }; @@ -372,6 +373,7 @@ export type AudioStoreTypes = { action(payload: { filePath?: string; encoding?: EncodingType; + callback?: () => void; }): SaveResultObject | undefined; }; From 24f9a853ebf6707a0f2aa296f4006492c1e55e0a Mon Sep 17 00:00:00 2001 From: k-chop Date: Wed, 7 Dec 2022 15:22:40 +0900 Subject: [PATCH 04/17] =?UTF-8?q?1.1=E3=81=AF=E5=AE=9A=E6=95=B0=E3=81=AB?= =?UTF-8?q?=E3=81=97=E3=81=A6=E3=81=8A=E3=81=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/store/ui.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/store/ui.ts b/src/store/ui.ts index 40c5fb8331..b86bf182a9 100644 --- a/src/store/ui.ts +++ b/src/store/ui.ts @@ -9,6 +9,9 @@ import { import { ActivePointScrollMode } from "@/type/preload"; import { createPartialStore } from "./vuex"; +// electron.setProgressBarに1より大きい値を渡すとindeterminateなプログレスバーになる +const INDETERMINATE_PROGRESS_NUMBER = 1.1; + export function createUILockAction( action: ( context: ActionContext, @@ -346,8 +349,7 @@ export const uiStore = createPartialStore({ START_INDETERMINATE_PROGRESS: { action({ dispatch }) { - // electron.setProgressBarに1より大きい値を渡すとindeterminateなプログレスバーになる - dispatch("SET_PROGRESS", { progress: 1.1 }); + dispatch("SET_PROGRESS", { progress: INDETERMINATE_PROGRESS_NUMBER }); }, }, From 0e6e4f56d407187658eea7a48d64432d7e0a9e97 Mon Sep 17 00:00:00 2001 From: k-chop Date: Wed, 7 Dec 2022 17:36:54 +0900 Subject: [PATCH 05/17] =?UTF-8?q?UI=E3=81=A7=E3=82=82=E8=A1=A8=E7=A4=BA?= =?UTF-8?q?=E3=81=99=E3=82=8B=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/components/ProgressDialog.vue | 93 +++++++++++++++++++++++++++++++ src/store/type.ts | 4 ++ src/store/ui.ts | 6 ++ src/views/EditorHome.vue | 4 ++ 4 files changed, 107 insertions(+) create mode 100644 src/components/ProgressDialog.vue diff --git a/src/components/ProgressDialog.vue b/src/components/ProgressDialog.vue new file mode 100644 index 0000000000..d32676e249 --- /dev/null +++ b/src/components/ProgressDialog.vue @@ -0,0 +1,93 @@ + + + + + diff --git a/src/store/type.ts b/src/store/type.ts index 2e5864c162..f629142dfb 100644 --- a/src/store/type.ts +++ b/src/store/type.ts @@ -994,6 +994,10 @@ export type UiStoreTypes = { getter: boolean; }; + PROGRESS: { + getter: number; + }; + ASYNC_UI_LOCK: { action(payload: { callback: () => Promise }): void; }; diff --git a/src/store/ui.ts b/src/store/ui.ts index b86bf182a9..7c4cceb862 100644 --- a/src/store/ui.ts +++ b/src/store/ui.ts @@ -64,6 +64,12 @@ export const uiStore = createPartialStore({ }, }, + PROGRESS: { + getter(state) { + return state.progress; + }, + }, + ASYNC_UI_LOCK: { action: createUILockAction( async (_, { callback }: { callback: () => Promise }) => { diff --git a/src/views/EditorHome.vue b/src/views/EditorHome.vue index e15e4e6f89..1251651f8f 100644 --- a/src/views/EditorHome.vue +++ b/src/views/EditorHome.vue @@ -6,6 +6,8 @@ + +
Date: Wed, 7 Dec 2022 17:46:14 +0900 Subject: [PATCH 06/17] =?UTF-8?q?3=E7=A7=92=E5=BE=8C=E3=81=AB=E5=87=BA?= =?UTF-8?q?=E3=81=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/ProgressDialog.vue | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/components/ProgressDialog.vue b/src/components/ProgressDialog.vue index d32676e249..a1a4d72b05 100644 --- a/src/components/ProgressDialog.vue +++ b/src/components/ProgressDialog.vue @@ -31,7 +31,7 @@