feat(desktop): 恢复启动加载页并在服务就绪后切换
This commit is contained in:
@@ -40,14 +40,18 @@ const canOpenExternally = (url: string): boolean => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const createWindow = async () => {
|
const loadSplash = async (windowRef: BrowserWindow) => {
|
||||||
if (mainWindow && !mainWindow.isDestroyed()) {
|
if (process.env.ELECTRON_RENDERER_URL) {
|
||||||
mainWindow.focus()
|
await windowRef.loadURL(process.env.ELECTRON_RENDERER_URL)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const targetUrl = await sidecar.resolveUrl()
|
await windowRef.loadFile(join(__dirname, '../renderer/index.html'))
|
||||||
if (isQuitting) {
|
}
|
||||||
|
|
||||||
|
const createWindow = async () => {
|
||||||
|
if (mainWindow && !mainWindow.isDestroyed()) {
|
||||||
|
mainWindow.focus()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -82,7 +86,7 @@ const createWindow = async () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await windowRef.loadURL(targetUrl)
|
await loadSplash(windowRef)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (mainWindow === windowRef) {
|
if (mainWindow === windowRef) {
|
||||||
mainWindow = null
|
mainWindow = null
|
||||||
@@ -98,6 +102,25 @@ const createWindow = async () => {
|
|||||||
if (!windowRef.isDestroyed()) {
|
if (!windowRef.isDestroyed()) {
|
||||||
windowRef.show()
|
windowRef.show()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const targetUrl = await sidecar.resolveUrl()
|
||||||
|
if (isQuitting || windowRef.isDestroyed()) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
await windowRef.loadURL(targetUrl)
|
||||||
|
} catch (error) {
|
||||||
|
if (mainWindow === windowRef) {
|
||||||
|
mainWindow = null
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!windowRef.isDestroyed()) {
|
||||||
|
windowRef.destroy()
|
||||||
|
}
|
||||||
|
|
||||||
|
throw error
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const ensureWindow = async () => {
|
const ensureWindow = async () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user