feat: 添加全局错误处理逻辑,优化 PrimeVue 插件导入和路由设置
All checks were successful
/ build-and-deploy-to-vercel (push) Successful in 1m37s
/ playwright (push) Successful in 2m1s
/ depcheck (push) Successful in 1m45s

This commit is contained in:
严浩
2024-12-17 09:21:08 +08:00
parent 1dc0230a3e
commit a5c1cf38f6
3 changed files with 25 additions and 13 deletions

View File

@ -3,7 +3,7 @@ import { createLogGuard, createProgressGuard, createStackGuard } from 'utils4u/v
import { createRouter, createWebHistory } from 'vue-router';
import { handleHotUpdate, routes } from 'vue-router/auto-routes';
export const router = createRouter({
const router = createRouter({
history: createWebHistory(import.meta.env.BASE_URL),
routes,
strict: true,
@ -11,10 +11,11 @@ export const router = createRouter({
router.onError((error) => {
console.debug('🚨 [router error]: ', error);
});
if (import.meta.hot) handleHotUpdate(router);
if ($__DEV__) Object.assign(window, { router });
export function setupRouter(app: import('vue').App) {
function setupRouter(app: import('vue').App) {
app
// Register the plugin before the router
.use(DataLoaderPlugin, { router })
@ -26,3 +27,5 @@ export function setupRouter(app: import('vue').App) {
createLogGuard(router);
Object.assign(window, { stack: createStackGuard(router) });
}
export { router, setupRouter };