-
Notifications
You must be signed in to change notification settings - Fork 829
Expand file tree
/
Copy pathdeploy.ts
More file actions
64 lines (55 loc) · 1.91 KB
/
Copy pathdeploy.ts
File metadata and controls
64 lines (55 loc) · 1.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import { ipcMain, IpcMainEvent } from 'electron'
import Deploy from '../deploy'
import Renderer from '../renderer'
import SftpDeploy from '../plugins/deploys/sftp'
import NetlifyDeploy from '../plugins/deploys/netlify'
export default class DeployEvents {
constructor(appInstance: any) {
const { platform } = appInstance.db.setting
const deploy = new Deploy(appInstance)
const sftp = new SftpDeploy(appInstance)
const renderer = new Renderer(appInstance)
const netlify = new NetlifyDeploy(appInstance)
ipcMain.removeAllListeners('site-publish')
ipcMain.removeAllListeners('site-published')
ipcMain.removeAllListeners('remote-detect')
ipcMain.removeAllListeners('remote-detected')
ipcMain.on('site-publish', async (event: IpcMainEvent, params: any) => {
console.log(platform)
const client = ({
'github': deploy,
'coding': deploy,
'gitee': deploy,
'sftp': sftp,
'netlify': netlify,
} as any)[platform]
// render
renderer.db.themeConfig.domain = renderer.db.setting.domain
await renderer.renderAll()
// publish
const result = await client.publish()
event.sender.send('site-published', result)
})
ipcMain.on('site-render', async (event: IpcMainEvent, params: any) => {
// render
const result = {
success: true,
message: '',
}
renderer.db.themeConfig.domain = renderer.db.setting.domain
await renderer.renderAll()
event.sender.send('site-rendered', result)
})
ipcMain.on('remote-detect', async (event: IpcMainEvent, params: any) => {
const client = ({
'github': deploy,
'coding': deploy,
'gitee': deploy,
'sftp': sftp,
'netlify': netlify,
} as any)[platform]
const result = await client.remoteDetect()
event.sender.send('remote-detected', result)
})
}
}