Skip to content

Commit f65d2d2

Browse files
committed
Fixed: npm ENOENT bug && mini window display -> false by default
1 parent af19de7 commit f65d2d2

File tree

2 files changed

+29
-6
lines changed

2 files changed

+29
-6
lines changed

src/main/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ const createMiniWidow = () => {
219219
let obj = {
220220
height: 64,
221221
width: 64,
222-
show: true,
222+
show: false,
223223
frame: false,
224224
fullscreenable: false,
225225
skipTaskbar: true,

src/main/utils/picgoCoreIPC.js

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import path from 'path'
22
import GuiApi from './guiApi'
3+
import { dialog, shell } from 'electron'
34

45
// eslint-disable-next-line
56
const requireFunc = typeof __webpack_require__ === 'function' ? __non_webpack_require__ : require
@@ -89,41 +90,63 @@ const handleGetPluginList = (ipcMain, STORE_PATH, CONFIG_PATH) => {
8990
}
9091

9192
const handlePluginInstall = (ipcMain, CONFIG_PATH) => {
92-
ipcMain.on('installPlugin', (event, msg) => {
93+
ipcMain.on('installPlugin', async (event, msg) => {
9394
const picgo = new PicGo(CONFIG_PATH)
9495
const pluginHandler = new PluginHandler(picgo)
9596
picgo.on('installSuccess', notice => {
9697
event.sender.send('installSuccess', notice.body[0].replace(/picgo-plugin-/, ''))
9798
})
99+
picgo.on('failed', () => {
100+
handleNPMError()
101+
})
102+
await pluginHandler.uninstall([msg])
98103
pluginHandler.install([msg])
99104
picgo.cmd.program.removeAllListeners()
100105
})
101106
}
102107

103108
const handlePluginUninstall = (ipcMain, CONFIG_PATH) => {
104-
ipcMain.on('uninstallPlugin', (event, msg) => {
109+
ipcMain.on('uninstallPlugin', async (event, msg) => {
105110
const picgo = new PicGo(CONFIG_PATH)
106111
const pluginHandler = new PluginHandler(picgo)
107112
picgo.on('uninstallSuccess', notice => {
108113
event.sender.send('uninstallSuccess', notice.body[0].replace(/picgo-plugin-/, ''))
109114
})
110-
pluginHandler.uninstall([msg])
115+
picgo.on('failed', () => {
116+
handleNPMError()
117+
})
118+
await pluginHandler.uninstall([msg])
111119
picgo.cmd.program.removeAllListeners()
112120
})
113121
}
114122

115123
const handlePluginUpdate = (ipcMain, CONFIG_PATH) => {
116-
ipcMain.on('updatePlugin', (event, msg) => {
124+
ipcMain.on('updatePlugin', async (event, msg) => {
117125
const picgo = new PicGo(CONFIG_PATH)
118126
const pluginHandler = new PluginHandler(picgo)
119127
picgo.on('updateSuccess', notice => {
120128
event.sender.send('updateSuccess', notice.body[0].replace(/picgo-plugin-/, ''))
121129
})
122-
pluginHandler.update([msg])
130+
picgo.on('failed', () => {
131+
handleNPMError()
132+
})
133+
await pluginHandler.update([msg])
123134
picgo.cmd.program.removeAllListeners()
124135
})
125136
}
126137

138+
const handleNPMError = () => {
139+
dialog.showMessageBox({
140+
title: '发生错误',
141+
message: '请安装Node.js并重启PicGo再继续操作',
142+
buttons: ['Yes']
143+
}, (res) => {
144+
if (res === 0) {
145+
shell.openExternal('https://nodejs.org/')
146+
}
147+
})
148+
}
149+
127150
const handleGetPicBedConfig = (ipcMain, CONFIG_PATH) => {
128151
ipcMain.on('getPicBedConfig', (event, type) => {
129152
const picgo = new PicGo(CONFIG_PATH)

0 commit comments

Comments
 (0)