forked from Comfy-Org/ComfyUI_frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.electron.config.mts
66 lines (64 loc) · 2.02 KB
/
vite.electron.config.mts
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
65
66
import { defineConfig, Plugin } from 'vite'
import { mergeConfig } from 'vite'
import type { UserConfig } from 'vitest/config'
import baseConfig from './vite.config.mts'
const mockElectronAPI: Plugin = {
name: 'mock-electron-api',
transformIndexHtml() {
return [
{
tag: 'script',
children: `window.electronAPI = {
restartApp: () => {
alert('restartApp')
},
sendReady: () => {},
onShowSelectDirectory: () => {},
onFirstTimeSetupComplete: () => {},
onProgressUpdate: () => {},
onLogMessage: () => {},
isFirstTimeSetup: () => Promise.resolve(true),
getSystemPaths: () =>
Promise.resolve({
appData: 'C:/Users/username/AppData/Roaming',
appPath: 'C:/Program Files/comfyui-electron/resources/app',
defaultInstallPath: 'bad'
}),
validateInstallPath: (path) => {
if (path === 'bad') {
return { isValid: false, error: 'Bad path!' }
}
return { isValid: true }
},
migrationItems: () =>
Promise.resolve([
{
id: 'user_files',
label: 'User Files',
description: 'Settings and user-created workflows'
}
]),
validateComfyUISource: (path) => {
if (path === 'bad') {
return { isValid: false, error: 'Bad path!' }
}
return { isValid: true }
},
showDirectoryPicker: () => Promise.resolve('C:/Users/username/comfyui-electron/1'),
DownloadManager: {
getAllDownloads: () => Promise.resolve([]),
onDownloadProgress: () => {}
},
getElectronVersion: () => Promise.resolve('1.0.0'),
getComfyUIVersion: () => '9.9.9'
};`
}
]
}
}
export default mergeConfig(
baseConfig as unknown as UserConfig,
defineConfig({
plugins: [mockElectronAPI]
})
)