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