mirror of
https://github.com/Kuingsmile/PicList.git
synced 2025-01-23 14:48:13 -05:00
🐛 Fix: add plugin install failed notice
This commit is contained in:
parent
992ff35936
commit
b05139fc9a
@ -121,12 +121,21 @@ const handleGetPluginList = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const handlePluginInstall = () => {
|
const handlePluginInstall = () => {
|
||||||
ipcMain.on('installPlugin', async (event: IpcMainEvent, msg: string) => {
|
ipcMain.on('installPlugin', async (event: IpcMainEvent, fullName: string) => {
|
||||||
const dispose = handleNPMError()
|
const dispose = handleNPMError()
|
||||||
const res = await picgo.pluginHandler.install([msg])
|
const res = await picgo.pluginHandler.install([fullName])
|
||||||
|
event.sender.send('installPlugin', {
|
||||||
|
success: res.success,
|
||||||
|
body: fullName,
|
||||||
|
errMsg: res.success ? '' : res.body
|
||||||
|
})
|
||||||
if (res.success) {
|
if (res.success) {
|
||||||
event.sender.send('installSuccess', res.body[0])
|
|
||||||
shortKeyHandler.registerPluginShortKey(res.body[0])
|
shortKeyHandler.registerPluginShortKey(res.body[0])
|
||||||
|
} else {
|
||||||
|
showNotification({
|
||||||
|
title: '插件安装失败',
|
||||||
|
body: res.body as string
|
||||||
|
})
|
||||||
}
|
}
|
||||||
event.sender.send('hideLoading')
|
event.sender.send('hideLoading')
|
||||||
dispose()
|
dispose()
|
||||||
@ -140,6 +149,11 @@ const handlePluginUninstall = () => {
|
|||||||
if (res.success) {
|
if (res.success) {
|
||||||
event.sender.send('uninstallSuccess', res.body[0])
|
event.sender.send('uninstallSuccess', res.body[0])
|
||||||
shortKeyHandler.unregisterPluginShortKey(res.body[0])
|
shortKeyHandler.unregisterPluginShortKey(res.body[0])
|
||||||
|
} else {
|
||||||
|
showNotification({
|
||||||
|
title: '插件卸载失败',
|
||||||
|
body: res.body as string
|
||||||
|
})
|
||||||
}
|
}
|
||||||
event.sender.send('hideLoading')
|
event.sender.send('hideLoading')
|
||||||
dispose()
|
dispose()
|
||||||
@ -152,6 +166,11 @@ const handlePluginUpdate = () => {
|
|||||||
const res = await picgo.pluginHandler.update([msg])
|
const res = await picgo.pluginHandler.update([msg])
|
||||||
if (res.success) {
|
if (res.success) {
|
||||||
event.sender.send('updateSuccess', res.body[0])
|
event.sender.send('updateSuccess', res.body[0])
|
||||||
|
} else {
|
||||||
|
showNotification({
|
||||||
|
title: '插件更新失败',
|
||||||
|
body: res.body as string
|
||||||
|
})
|
||||||
}
|
}
|
||||||
event.sender.send('hideLoading')
|
event.sender.send('hideLoading')
|
||||||
dispose()
|
dispose()
|
||||||
|
@ -174,12 +174,15 @@ export default class extends Vue {
|
|||||||
this.pluginNameList = list.map(item => item.fullName)
|
this.pluginNameList = list.map(item => item.fullName)
|
||||||
this.loading = false
|
this.loading = false
|
||||||
})
|
})
|
||||||
ipcRenderer.on('installSuccess', (evt: IpcRendererEvent, plugin: string) => {
|
ipcRenderer.on('installPlugin', (evt: IpcRendererEvent, { success, body }: {
|
||||||
|
success: boolean,
|
||||||
|
body: string
|
||||||
|
}) => {
|
||||||
this.loading = false
|
this.loading = false
|
||||||
this.pluginList.forEach(item => {
|
this.pluginList.forEach(item => {
|
||||||
if (item.fullName === plugin) {
|
if (item.fullName === body) {
|
||||||
item.ing = false
|
item.ing = false
|
||||||
item.hasInstall = true
|
item.hasInstall = success
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@ -315,13 +318,13 @@ export default class extends Vue {
|
|||||||
type: 'warning'
|
type: 'warning'
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
item.ing = true
|
item.ing = true
|
||||||
ipcRenderer.send('installPlugin', item.name)
|
ipcRenderer.send('installPlugin', item.fullName)
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
console.log('Install canceled')
|
console.log('Install canceled')
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
item.ing = true
|
item.ing = true
|
||||||
ipcRenderer.send('installPlugin', item.name)
|
ipcRenderer.send('installPlugin', item.fullName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
uninstallPlugin (val: string) {
|
uninstallPlugin (val: string) {
|
||||||
@ -479,7 +482,7 @@ export default class extends Vue {
|
|||||||
}
|
}
|
||||||
beforeDestroy () {
|
beforeDestroy () {
|
||||||
ipcRenderer.removeAllListeners('pluginList')
|
ipcRenderer.removeAllListeners('pluginList')
|
||||||
ipcRenderer.removeAllListeners('installSuccess')
|
ipcRenderer.removeAllListeners('installPlugin')
|
||||||
ipcRenderer.removeAllListeners('uninstallSuccess')
|
ipcRenderer.removeAllListeners('uninstallSuccess')
|
||||||
ipcRenderer.removeAllListeners('updateSuccess')
|
ipcRenderer.removeAllListeners('updateSuccess')
|
||||||
ipcRenderer.removeAllListeners('hideLoading')
|
ipcRenderer.removeAllListeners('hideLoading')
|
||||||
|
Loading…
Reference in New Issue
Block a user