From d4cca242d2baa48f8cfc782bc90896aefd8a65d0 Mon Sep 17 00:00:00 2001 From: raa0121 Date: Thu, 16 Dec 2021 20:57:59 +0900 Subject: [PATCH] =?UTF-8?q?=E8=B5=B7=E5=8B=95=E6=99=82=E3=83=81=E3=82=A7?= =?UTF-8?q?=E3=83=83=E3=82=AF=E3=82=92=E3=82=AA=E3=83=97=E3=82=B7=E3=83=A7?= =?UTF-8?q?=E3=83=B3=E3=81=AB=E3=81=97=E3=80=81=E3=83=81=E3=82=A7=E3=83=83?= =?UTF-8?q?=E3=82=AF=E3=81=A7=E3=81=AE=E8=87=AA=E5=8B=95=E3=83=80=E3=82=A6?= =?UTF-8?q?=E3=83=B3=E3=83=AD=E3=83=BC=E3=83=89=E3=81=AF=E3=81=97=E3=81=AA?= =?UTF-8?q?=E3=81=84=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/background.ts | 33 +++++++++++++++++++++++++++++++- src/components/MenuBar.vue | 10 ++++++++++ src/components/SettingDialog.vue | 22 +++++++++++++++++++++ src/electron/preload.ts | 8 ++++++++ src/store/type.ts | 6 ++++++ src/store/ui.ts | 21 ++++++++++++++++++++ src/type/ipc.d.ts | 10 ++++++++++ src/type/preload.d.ts | 2 ++ 8 files changed, 111 insertions(+), 1 deletion(-) diff --git a/src/background.ts b/src/background.ts index bc887eb8fe..b0f192324e 100644 --- a/src/background.ts +++ b/src/background.ts @@ -49,6 +49,7 @@ if (isDevelopment) { } autoUpdater.logger = log; +autoUpdater.autoDownload = false; let win: BrowserWindow; @@ -175,6 +176,7 @@ const store = new Store<{ outputStereo: { type: "boolean", default: false }, outputSamplingRate: { type: "number", default: 24000 }, audioOutputDevice: { type: "string", default: "default" }, + enableAutoUpdateCheck: { type: "boolean", default: false }, }, default: { fileEncoding: "UTF-8", @@ -186,6 +188,7 @@ const store = new Store<{ outputStereo: false, outputSamplingRate: 24000, audioOutputDevice: "default", + enableAutoUpdateCheck: false, }, }, // To future developers: if you are to modify the store schema with array type, @@ -568,6 +571,18 @@ ipcMainHandle("INHERIT_AUDIOINFO", (_, { newValue }) => { return store.get("inheritAudioInfo", false); }); +ipcMainHandle("ENABLE_AUTO_UPDATE_CHECK", (_, { newValue }) => { + if (newValue !== undefined) { + store.set("enableAutoUpdateCheck", newValue); + } + + return store.get("enableAutoUpdateCheck", false); +}); + +ipcMainHandle("UPDATE_CHECK", () => { + autoUpdater.checkForUpdatesAndNotify(); +}); + ipcMainHandle("IS_AVAILABLE_GPU_MODE", () => { return hasSupportedGpu(); }); @@ -800,7 +815,10 @@ app.on("ready", async () => { } createWindow().then(() => runEngine()); - autoUpdater.checkForUpdatesAndNotify(); + const enableAutoUpdateCheck = store.get("enableAutoUpdateCheck", false); + if (enableAutoUpdateCheck) { + autoUpdater.checkForUpdatesAndNotify(); + } }); app.on("second-instance", () => { @@ -834,6 +852,19 @@ autoUpdater.on("checking-for-update", () => { // アップデートが見つかった autoUpdater.on("update-available", () => { log.info(process.pid, "Update available."); + const dialogOpts = { + type: "info", + buttons: ["はい", "いいえ"], + message: "アップデート", + detail: + "新しいバージョンをがありました。更新をダウンロードしますか?", + } + // ダイアログを表示しすぐに再起動するか確認 + dialog.showMessageBox(win, dialogOpts).then((returnValue) => { + if (returnValue.response === 0) { + autoUpdater.downloadUpdate(); + } + }); }); // アップデートがなかった(最新版だった) autoUpdater.on("update-not-available", () => { diff --git a/src/components/MenuBar.vue b/src/components/MenuBar.vue index 72daf76ccb..faa04ed21f 100644 --- a/src/components/MenuBar.vue +++ b/src/components/MenuBar.vue @@ -329,6 +329,16 @@ export default defineComponent({ }); }, }, + { type: "separator" }, + { + type: "button", + label: "アップデート確認", + onClick() { + store.dispatch("IS_UPDATE_CHECK_DIALOG_OPEN", { + isUpdateCheckDialogOpen: true, + }); + }, + }, ], }, { diff --git a/src/components/SettingDialog.vue b/src/components/SettingDialog.vue index 352698972b..d45d3f61da 100644 --- a/src/components/SettingDialog.vue +++ b/src/components/SettingDialog.vue @@ -305,6 +305,28 @@ + +
自動アップデートチェック
+ + + + 起動時にアップデートチェックを行います + + +
diff --git a/src/electron/preload.ts b/src/electron/preload.ts index 003d092177..72183fb07a 100644 --- a/src/electron/preload.ts +++ b/src/electron/preload.ts @@ -136,6 +136,14 @@ const api: Sandbox = { return ipcRendererInvoke("INHERIT_AUDIOINFO", { newValue }); }, + enableAutoUpdateCheck: (newValue) => { + return ipcRendererInvoke("ENABLE_AUTO_UPDATE_CHECK", { newValue }); + }, + + updateCheck: () => { + return ipcRendererInvoke("UPDATE_CHECK"); + }, + isAvailableGPUMode: () => { return ipcRendererInvoke("IS_AVAILABLE_GPU_MODE"); }, diff --git a/src/store/type.ts b/src/store/type.ts index 91722b0ffe..1d15c09155 100644 --- a/src/store/type.ts +++ b/src/store/type.ts @@ -661,6 +661,7 @@ export type UiStoreState = { inheritAudioInfo: boolean; isHelpDialogOpen: boolean; isSettingDialogOpen: boolean; + isUpdateCheckDialogOpen: boolean; isDefaultStyleSelectDialogOpen: boolean; isHotkeySettingDialogOpen: boolean; isMaximized: boolean; @@ -714,6 +715,11 @@ type UiStoreTypes = { action(payload: { isSettingDialogOpen: boolean }): void; }; + IS_UPDATE_CHECK_DIALOG_OPEN: { + mutation: { isUpdateCheckDialogOpen: boolean }; + action(payload: { isUpdateCheckDialogOpen: boolean }): void; + }; + IS_HOTKEY_SETTING_DIALOG_OPEN: { mutation: { isHotkeySettingDialogOpen: boolean }; action(payload: { isHotkeySettingDialogOpen: boolean }): void; diff --git a/src/store/ui.ts b/src/store/ui.ts index b7e2df5df1..7f47a337f1 100644 --- a/src/store/ui.ts +++ b/src/store/ui.ts @@ -33,6 +33,7 @@ export const uiStoreState: UiStoreState = { inheritAudioInfo: true, isHelpDialogOpen: false, isSettingDialogOpen: false, + isUpdateCheckDialogOpen: false, isHotkeySettingDialogOpen: false, isDefaultStyleSelectDialogOpen: false, isMaximized: false, @@ -78,6 +79,12 @@ export const uiStore: VoiceVoxStoreOptions = ) { state.isSettingDialogOpen = isSettingDialogOpen; }, + IS_UPDATE_CHECK_DIALOG_OPEN( + state, + { isUpdateCheckDialogOpen }: { isUpdateCheckDialogOpen: boolean } + ) { + state.isUpdateCheckDialogOpen = isUpdateCheckDialogOpen; + }, IS_HOTKEY_SETTING_DIALOG_OPEN(state, { isHotkeySettingDialogOpen }) { state.isHotkeySettingDialogOpen = isHotkeySettingDialogOpen; }, @@ -162,6 +169,20 @@ export const uiStore: VoiceVoxStoreOptions = commit("IS_SETTING_DIALOG_OPEN", { isSettingDialogOpen }); }, + async IS_UPDATE_CHECK_DIALOG_OPEN( + { state, commit }, + { isUpdateCheckDialogOpen }: { isUpdateCheckDialogOpen: boolean } + ) { + const result: number = await window.electron.showInfoDialog({ + title: "自動アップデートチェック", + message: "自動アップデートチェックを行います。\nよろしいですか?", + buttons: ["はい", "いいえ"], + }); + if (result == 1) { + return; + } + window.electron.updateCheck(); + }, IS_HOTKEY_SETTING_DIALOG_OPEN( { state, commit }, { isHotkeySettingDialogOpen } diff --git a/src/type/ipc.d.ts b/src/type/ipc.d.ts index 82aac5e568..34a16828ee 100644 --- a/src/type/ipc.d.ts +++ b/src/type/ipc.d.ts @@ -97,6 +97,16 @@ type IpcIHData = { return: boolean; }; + ENABLE_AUTO_UPDATE_CHECK: { + args: [obj: { newValue?: boolean }]; + return: boolean; + }; + + UPDATE_CHECK: { + args: []; + return: void; + }; + IS_AVAILABLE_GPU_MODE: { args: []; return: boolean; diff --git a/src/type/preload.d.ts b/src/type/preload.d.ts index dbd7615af7..447ca1a438 100644 --- a/src/type/preload.d.ts +++ b/src/type/preload.d.ts @@ -37,6 +37,8 @@ export interface Sandbox { openTextEditContextMenu(): Promise; useGpu(newValue?: boolean): Promise; inheritAudioInfo(newValue?: boolean): Promise; + enableAutoUpdateCheck(newValue?: boolean): Promise; + updateCheck(): void; isAvailableGPUMode(): Promise; onReceivedIPCMsg( channel: T,