65b0bb04f8
把 CarLog v2.8 全套源码 + 配置导入到 i 仓库作为 baseline: - server/src/ (13 个路由 + middleware + services + config) - server/migrations/ (0001~0018 共 18 个迁移 + mysql) - server/test/ (12 文件 101 测试) - client/src/ (20 个 view + components + stores + api + composables) - client/public/ + client/scripts/ - 全部配置文件 (.editorconfig, .eslintrc.json, .prettierrc.json, vitest.config.js, lighthouserc.json, .pa11yci.json, package.json, carlog-init.sql) - .husky/pre-commit (git hooks) - docs/install/ (宝塔部署文档) 不含: - node_modules/ (本地 npm install) - .env (敏感, 走 .env.example) - *.zip / *.log / *.sqlite / .DS_Store 新增文档 docs/DEV-PLAN.md: - Phase 1: 平台基座 (019 migration + 3 个 platform 路由 + 3 个 view) - Phase 2: CarLog 子系统化 (后端 routes/ → subsystems/carlog/ + 前端 views/ → views/subsystems/carlog/ + 元数据驱动菜单) - Phase 3: 验证 (测试 + E2E + DB 完整性) - 交付清单 + commit 模板 + 给 Mavis review 的材料 后续 Trae 实施, 提交后我 code review + 跑测试。
84 lines
2.3 KiB
JavaScript
84 lines
2.3 KiB
JavaScript
// client/src/main.js — 入口
|
|
import { createApp } from 'vue';
|
|
import { createPinia } from 'pinia';
|
|
import App from './App.vue';
|
|
import router from './router';
|
|
import { useDebugStore } from './stores/debug';
|
|
import { usePwaStore } from './stores/pwa';
|
|
import { registerSW } from 'virtual:pwa-register';
|
|
import './style.css';
|
|
|
|
const app = createApp(App);
|
|
app.use(createPinia());
|
|
app.use(router);
|
|
|
|
// PWA Service Worker 注册
|
|
if ('serviceWorker' in navigator) {
|
|
const pwa = usePwaStore();
|
|
const updateSW = registerSW({
|
|
immediate: true,
|
|
onNeedRefresh() {
|
|
console.info('[PWA] 新版本可用');
|
|
pwa.triggerNeedRefresh();
|
|
},
|
|
onOfflineReady() {
|
|
console.info('[PWA] 离线缓存就绪');
|
|
pwa.triggerOfflineReady();
|
|
},
|
|
onRegisterError(err) {
|
|
console.warn('[PWA] SW 注册失败', err);
|
|
},
|
|
});
|
|
pwa.bindRegisterSw(updateSW);
|
|
// 暴露到 window 方便调试 / 强制更新
|
|
window.__pwaUpdate = () => updateSW(true);
|
|
}
|
|
|
|
// 全局错误捕获 → 调试面板
|
|
app.config.errorHandler = (err, instance, info) => {
|
|
const debug = useDebugStore();
|
|
debug.log({
|
|
kind: 'vue',
|
|
title: `[${info}] ${err?.message || err}`,
|
|
detail: {
|
|
message: err?.message,
|
|
stack: err?.stack,
|
|
info,
|
|
component: instance?.$options?.name || instance?.$options?.__name || '<anonymous>',
|
|
},
|
|
});
|
|
console.error('[vue error]', err, info);
|
|
};
|
|
|
|
window.addEventListener('unhandledrejection', (e) => {
|
|
const debug = useDebugStore();
|
|
debug.log({
|
|
kind: 'promise',
|
|
title: `未捕获的 Promise 异常: ${e.reason?.message || e.reason}`,
|
|
detail: {
|
|
message: e.reason?.message || String(e.reason),
|
|
stack: e.reason?.stack,
|
|
},
|
|
});
|
|
console.error('[unhandledrejection]', e.reason);
|
|
});
|
|
|
|
window.addEventListener('error', (e) => {
|
|
const debug = useDebugStore();
|
|
if (e.error) {
|
|
debug.log({
|
|
kind: 'runtime',
|
|
title: `全局错误: ${e.message}`,
|
|
detail: {
|
|
message: e.message,
|
|
filename: e.filename,
|
|
lineno: e.lineno,
|
|
colno: e.colno,
|
|
stack: e.error?.stack,
|
|
},
|
|
});
|
|
}
|
|
});
|
|
|
|
app.mount('#app');
|