Feature: add update all plugins

This commit is contained in:
萌萌哒赫萝
2023-08-16 03:10:04 -07:00
parent 2336483927
commit 3e32cbba33
6 changed files with 43 additions and 5 deletions

View File

@@ -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()