Compare commits

..

No commits in common. "01b5ed1a8f12cea051402fc4d69ad18cf7649f25" and "dae4939390e2e33159b576156e5ee4ef99ebccc2" have entirely different histories.

5 changed files with 47 additions and 83 deletions

View File

@ -160,9 +160,7 @@ async function prepareCore(detached: boolean, skipStop = false): Promise<CoreCon
} }
// 管理 Smart 内核覆写配置 // 管理 Smart 内核覆写配置
if (core === 'mihomo-smart') {
await manageSmartOverride() await manageSmartOverride()
}
// generateProfile 返回实际使用的 current // generateProfile 返回实际使用的 current
const current = await generateProfile() const current = await generateProfile()

View File

@ -9,7 +9,7 @@ const execPromise = promisify(exec)
// 常量 // 常量
const CORE_READY_MAX_RETRIES = 30 const CORE_READY_MAX_RETRIES = 30
const CORE_READY_RETRY_INTERVAL_MS = 100 const CORE_READY_RETRY_INTERVAL_MS = 500
export async function cleanupSocketFile(): Promise<void> { export async function cleanupSocketFile(): Promise<void> {
if (process.platform === 'win32') { if (process.platform === 'win32') {

View File

@ -128,7 +128,9 @@ app.on('open-url', async (_event, url) => {
await handleDeepLink(url) await handleDeepLink(url)
}) })
const initPromise = (async () => { app.whenReady().then(async () => {
electronApp.setAppUserModelId('party.mihomo.app')
await initBasic() await initBasic()
await checkHighPrivilegeCoreEarly() await checkHighPrivilegeCoreEarly()
await initAdminStatus() await initAdminStatus()
@ -142,29 +144,11 @@ const initPromise = (async () => {
appConfig.language = systemLanguage appConfig.language = systemLanguage
} }
await initI18n({ lng: appConfig.language }) await initI18n({ lng: appConfig.language })
return appConfig
} catch (e) { } catch (e) {
safeShowErrorBox('common.error.initFailed', `${e}`) safeShowErrorBox('common.error.initFailed', `${e}`)
app.quit() app.quit()
throw e
} }
})()
app.whenReady().then(async () => {
electronApp.setAppUserModelId('party.mihomo.app')
const appConfig = await initPromise
app.on('browser-window-created', (_, window) => {
optimizer.watchWindowShortcuts(window)
})
registerIpcMainHandlers()
const createWindowPromise = createWindow()
let coreStarted = false
const coreStartPromise = (async (): Promise<void> => {
try { try {
initCoreWatcher() initCoreWatcher()
const startPromises = await startCore() const startPromises = await startCore()
@ -175,47 +159,37 @@ app.whenReady().then(async () => {
await checkAdminRestartForTun() await checkAdminRestartForTun()
}) })
} }
coreStarted = true
} catch (e) { } catch (e) {
safeShowErrorBox('mihomo.error.coreStartFailed', `${e}`) safeShowErrorBox('mihomo.error.coreStartFailed', `${e}`)
} }
})()
const monitorPromise = (async (): Promise<void> => {
try { try {
await startMonitor() await startMonitor()
} catch { } catch {
// ignore // ignore
} }
})()
await createWindowPromise app.on('browser-window-created', (_, window) => {
optimizer.watchWindowShortcuts(window)
})
const { showFloatingWindow: showFloating = false, disableTray = false } = appConfig const { showFloatingWindow: showFloating = false, disableTray = false } = await getAppConfig()
const uiTasks: Promise<void>[] = [initShortcut()] registerIpcMainHandlers()
await createWindow()
if (showFloating) { if (showFloating) {
uiTasks.push(
(async () => {
try { try {
await showFloatingWindow() await showFloatingWindow()
} catch (error) { } catch (error) {
await logger.error('Failed to create floating window on startup', error) await logger.error('Failed to create floating window on startup', error)
} }
})()
)
} }
if (!disableTray) { if (!disableTray) {
uiTasks.push(createTray()) await createTray()
} }
await Promise.all(uiTasks) await initShortcut()
await Promise.all([coreStartPromise, monitorPromise])
if (coreStarted) {
mainWindow?.webContents.send('core-started')
}
app.on('activate', () => { app.on('activate', () => {
showMainWindow() showMainWindow()

View File

@ -165,7 +165,7 @@ async function killOldMihomoProcesses(): Promise<void> {
} }
} }
await new Promise((resolve) => setTimeout(resolve, 200)) await new Promise((resolve) => setTimeout(resolve, 500))
} catch { } catch {
// 忽略错误 // 忽略错误
} }
@ -389,16 +389,10 @@ export async function initBasic(): Promise<void> {
} }
export async function init(): Promise<void> { export async function init(): Promise<void> {
await startSubStoreFrontendServer()
await startSubStoreBackendServer()
const { sysProxy } = await getAppConfig() const { sysProxy } = await getAppConfig()
const initTasks: Promise<void>[] = [
startSubStoreFrontendServer(),
startSubStoreBackendServer(),
startSSIDCheck()
]
initTasks.push(
(async (): Promise<void> => {
try { try {
if (sysProxy.enable) { if (sysProxy.enable) {
await startPacServer() await startPacServer()
@ -407,9 +401,7 @@ export async function init(): Promise<void> {
} catch { } catch {
// ignore // ignore
} }
})()
)
await Promise.all(initTasks) await startSSIDCheck()
initDeeplink() initDeeplink()
} }

View File

@ -58,10 +58,10 @@ const RuleItem: React.FC<RuleItemProps> = (props) => {
{payload} {payload}
</div> </div>
<div className="flex items-center gap-2"> <div className="flex items-center gap-2">
<Chip size="sm" radius="sm" variant="bordered" className="text-xs"> <Chip size="sm" variant="flat" color="default" className="text-xs">
{type} {type}
</Chip> </Chip>
<Chip size="sm" radius="sm" variant="bordered" className="text-xs"> <Chip size="sm" variant="flat" color="default" className="text-xs">
{proxy} {proxy}
</Chip> </Chip>
</div> </div>