- 新增 API 模块统一封装所有 IPC 调用,提高代码可维护性 - 创建 `src/types/index.ts` 集中定义核心业务类型(Game, NodeConfig 等) - 新增组合式函数 `useFilePicker`、`useGameScanner` 和 `useAppUpdater` 以复用逻辑 - 改进设置页面,新增侧边栏导航和多个设置模块(通用、网络、日志、关于) - 优化本地代理逻辑,增加节点列表变化监听和自动重启机制 - 扩展协议解析测试用例,覆盖更多 VMess、VLESS Reality 等场景 - 更新项目结构文档 `docs/src-structure.md` 说明模块职责 - 修复 Electron 主进程预加载路径兼容性问题
78 lines
2.1 KiB
TypeScript
78 lines
2.1 KiB
TypeScript
import { createApp, watch } from 'vue'
|
|
import 'virtual:uno.css'
|
|
import '@unocss/reset/tailwind.css'
|
|
import './assets/main.css'
|
|
import App from './App.vue'
|
|
import router from './router'
|
|
import pinia from './stores'
|
|
import i18n from './i18n'
|
|
import { initLatencySessionStore } from './utils/latency-session'
|
|
import { setupRuntimeLogging } from './utils/runtime-logger'
|
|
import { useLocalProxyStore } from './stores/local-proxy'
|
|
import { useNodeStore } from './stores/nodes'
|
|
import { useSettingsStore } from './stores/settings'
|
|
|
|
setupRuntimeLogging()
|
|
|
|
void initLatencySessionStore().catch((e) => {
|
|
console.error('Failed to init latency session store:', e)
|
|
})
|
|
|
|
const app = createApp(App)
|
|
app.use(router)
|
|
app.use(pinia)
|
|
app.use(i18n)
|
|
|
|
const localProxyStore = useLocalProxyStore()
|
|
const nodeStore = useNodeStore()
|
|
const settingsStore = useSettingsStore()
|
|
let pendingStartAfterStarting = false
|
|
|
|
void localProxyStore.startLocalProxy('startup').catch((e) => {
|
|
console.error('Failed to start local proxy on startup:', e)
|
|
})
|
|
|
|
watch(
|
|
() => nodeStore.nodes.length,
|
|
(len) => {
|
|
if (len <= 0) {
|
|
pendingStartAfterStarting = false
|
|
if (localProxyStore.running || localProxyStore.starting) {
|
|
void localProxyStore.stopLocalProxy().catch((e) => {
|
|
console.error('Failed to stop local proxy after nodes became unavailable:', e)
|
|
})
|
|
}
|
|
return
|
|
}
|
|
|
|
if (!settingsStore.localProxyEnabled) return
|
|
if (localProxyStore.starting) {
|
|
pendingStartAfterStarting = true
|
|
return
|
|
}
|
|
|
|
void localProxyStore.handleNodeListChanged().catch((e) => {
|
|
console.error('Failed to handle node list change for local proxy:', e)
|
|
})
|
|
}
|
|
)
|
|
|
|
watch(
|
|
() => localProxyStore.starting,
|
|
(starting, prev) => {
|
|
if (!prev || starting) return
|
|
if (!pendingStartAfterStarting) return
|
|
|
|
pendingStartAfterStarting = false
|
|
if (!settingsStore.localProxyEnabled) return
|
|
if (localProxyStore.running) return
|
|
if (nodeStore.nodes.length <= 0) return
|
|
|
|
void localProxyStore.startLocalProxy('settings').catch((e) => {
|
|
console.error('Failed to resume local proxy auto-start after pending start:', e)
|
|
})
|
|
}
|
|
)
|
|
|
|
app.mount('#app')
|