mirror of
https://github.com/LifeArchiveProject/WeChatDataAnalysis.git
synced 2026-06-18 15:54:08 +08:00
b8d0912907
- 新增 dev 启动脚本,自动分配前后端端口并等待 Nuxt 就绪后再启动 Electron - 开发模式忽略持久化 API 覆盖,统一 Nuxt 与桌面端端口配置 - API 健康检查改为挂载后执行,聊天页预取改为 lazy,并隐藏搜索区账号切换
32 lines
867 B
JavaScript
32 lines
867 B
JavaScript
// 客户端插件:检查API连接状态
|
|
export default defineNuxtPlugin((nuxtApp) => {
|
|
const { healthCheck } = useApi()
|
|
const appStore = useAppStore()
|
|
let intervalId = 0
|
|
|
|
// 检查API连接
|
|
const checkApiConnection = async () => {
|
|
try {
|
|
const result = await healthCheck()
|
|
if (result.status === 'healthy') {
|
|
appStore.setApiStatus('connected', '已连接到后端API')
|
|
} else {
|
|
appStore.setApiStatus('error', 'API响应异常')
|
|
}
|
|
} catch (error) {
|
|
appStore.setApiStatus('error', '无法连接到后端API,请确保后端服务已启动')
|
|
console.error('API连接失败:', error)
|
|
}
|
|
}
|
|
|
|
nuxtApp.hook('app:mounted', () => {
|
|
void checkApiConnection()
|
|
|
|
if (!intervalId) {
|
|
intervalId = window.setInterval(() => {
|
|
void checkApiConnection()
|
|
}, 30000)
|
|
}
|
|
})
|
|
})
|