mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-24 08:44:06 +00:00
[Electron] Fix initial default install location validation (#1592)
This commit is contained in:
@@ -85,6 +85,8 @@ onMounted(async () => {
|
||||
appData.value = paths.appData
|
||||
appPath.value = paths.appPath
|
||||
installPath.value = paths.defaultInstallPath
|
||||
|
||||
await validatePath(paths.defaultInstallPath)
|
||||
})
|
||||
|
||||
const validatePath = async (path: string) => {
|
||||
|
||||
@@ -8,7 +8,9 @@ import {
|
||||
import LayoutDefault from '@/views/layouts/LayoutDefault.vue'
|
||||
import { isElectron } from './utils/envUtil'
|
||||
|
||||
const isFileProtocol = () => window.location.protocol === 'file:'
|
||||
const isFileProtocol = window.location.protocol === 'file:'
|
||||
const basePath = isElectron() ? '/' : window.location.pathname
|
||||
|
||||
const guardElectronAccess = (
|
||||
to: RouteLocationNormalized,
|
||||
from: RouteLocationNormalized,
|
||||
@@ -22,12 +24,12 @@ const guardElectronAccess = (
|
||||
}
|
||||
|
||||
const router = createRouter({
|
||||
history: isFileProtocol()
|
||||
history: isFileProtocol
|
||||
? createWebHashHistory()
|
||||
: // Base path must be specified to ensure correct relative paths
|
||||
// Example: For URL 'http://localhost:7801/ComfyBackendDirect',
|
||||
// we need this base path or assets will incorrectly resolve from 'http://localhost:7801/'
|
||||
createWebHistory(window.location.pathname),
|
||||
createWebHistory(basePath),
|
||||
routes: [
|
||||
{
|
||||
path: '/',
|
||||
|
||||
@@ -20,7 +20,7 @@ const mockElectronAPI: Plugin = {
|
||||
Promise.resolve({
|
||||
appData: 'C:/Users/username/AppData/Roaming',
|
||||
appPath: 'C:/Program Files/comfyui-electron/resources/app',
|
||||
defaultInstallPath: 'C:/Users/username/comfyui-electron'
|
||||
defaultInstallPath: 'bad'
|
||||
}),
|
||||
validateInstallPath: (path) => {
|
||||
if (path === 'bad') {
|
||||
@@ -42,7 +42,12 @@ const mockElectronAPI: Plugin = {
|
||||
}
|
||||
return { isValid: true }
|
||||
},
|
||||
showDirectoryPicker: () => Promise.resolve('C:/Users/username/comfyui-electron/1')
|
||||
showDirectoryPicker: () => Promise.resolve('C:/Users/username/comfyui-electron/1'),
|
||||
DownloadManager: {
|
||||
getAllDownloads: () => Promise.resolve([]),
|
||||
onDownloadProgress: () => {}
|
||||
},
|
||||
getElectronVersion: () => Promise.resolve('1.0.0')
|
||||
};`
|
||||
}
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user