From 3e32cbba332c5a941c61bb5d0c837fe9fec3702d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=90=8C=E8=90=8C=E5=93=92=E8=B5=AB=E8=90=9D?= Date: Wed, 16 Aug 2023 03:10:04 -0700 Subject: [PATCH] :sparkles: Feature: add update all plugins --- public/i18n/en.yml | 1 + public/i18n/zh-CN.yml | 1 + public/i18n/zh-TW.yml | 1 + src/main/events/picgoCoreIPC.ts | 12 ++++++++++-- src/renderer/pages/Plugin.vue | 32 +++++++++++++++++++++++++++++--- src/universal/types/i18n.d.ts | 1 + 6 files changed, 43 insertions(+), 5 deletions(-) diff --git a/public/i18n/en.yml b/public/i18n/en.yml index 9c8f0fb6..440748c4 100644 --- a/public/i18n/en.yml +++ b/public/i18n/en.yml @@ -323,6 +323,7 @@ PLUGIN_INSTALLED: Installed PLUGIN_DOING_SOMETHING: Doing... PLUGIN_LIST: Plugin List PLUGIN_IMPORT_LOCAL: Import Local Plugins +PLUGIN_UPDATE_ALL: Update All Plugins # tips diff --git a/public/i18n/zh-CN.yml b/public/i18n/zh-CN.yml index 6d034378..2ea741a3 100644 --- a/public/i18n/zh-CN.yml +++ b/public/i18n/zh-CN.yml @@ -325,6 +325,7 @@ PLUGIN_INSTALLED: 已安装 PLUGIN_DOING_SOMETHING: 进行中 PLUGIN_LIST: 插件列表 PLUGIN_IMPORT_LOCAL: 导入本地插件 +PLUGIN_UPDATE_ALL: 更新全部插件 # tips diff --git a/public/i18n/zh-TW.yml b/public/i18n/zh-TW.yml index c49c84db..715524f5 100644 --- a/public/i18n/zh-TW.yml +++ b/public/i18n/zh-TW.yml @@ -323,6 +323,7 @@ PLUGIN_INSTALLED: 已安裝 PLUGIN_DOING_SOMETHING: 進行中 PLUGIN_LIST: 插件列表 PLUGIN_IMPORT_LOCAL: 導入本地插件 +PLUGIN_UPDATE_ALL: 更新全部插件 # tips diff --git a/src/main/events/picgoCoreIPC.ts b/src/main/events/picgoCoreIPC.ts index 6db93b94..43f45f11 100644 --- a/src/main/events/picgoCoreIPC.ts +++ b/src/main/events/picgoCoreIPC.ts @@ -196,10 +196,10 @@ const handlePluginUninstall = async (fullName: string) => { dispose() } -const handlePluginUpdate = async (fullName: string) => { +const handlePluginUpdate = async (fullName: string | string[]) => { const window = windowManager.get(IWindowList.SETTING_WINDOW)! const dispose = handleNPMError() - const res = await picgo.pluginHandler.update([fullName]) + const res = await picgo.pluginHandler.update(typeof fullName === 'string' ? [fullName] : fullName) if (res.success) { window.webContents.send('updateSuccess', res.body[0]) } else { @@ -212,6 +212,13 @@ const handlePluginUpdate = async (fullName: string) => { dispose() } +const handleUpdateAllPlugin = () => { + ipcMain.on('updateAllPlugin', async (event: IpcMainEvent, list: string[]) => { + console.log(list) + handlePluginUpdate(list) + }) +} + const handleNPMError = (): IDispose => { const handler = (msg: string) => { if (msg === 'NPM is not installed') { @@ -419,6 +426,7 @@ export default { handlePicGoGetConfig() handlePicGoGalleryDB() handleImportLocalPlugin() + handleUpdateAllPlugin() handleOpenFile() handleOpenWindow() handleI18n() diff --git a/src/renderer/pages/Plugin.vue b/src/renderer/pages/Plugin.vue index 3d553495..6b72331e 100644 --- a/src/renderer/pages/Plugin.vue +++ b/src/renderer/pages/Plugin.vue @@ -13,6 +13,17 @@ + + + + +