mirror of
https://github.com/algerkong/AlgerMusicPlayer.git
synced 2026-05-17 02:07:29 +08:00
✨ feat: 添加统计服务
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { createRouter, createWebHashHistory } from 'vue-router';
|
||||
|
||||
import { recordVisit } from '@/api/stats';
|
||||
import AppLayout from '@/layout/AppLayout.vue';
|
||||
import MiniLayout from '@/layout/MiniLayout.vue';
|
||||
import homeRouter from '@/router/home';
|
||||
@@ -80,4 +81,13 @@ router.beforeEach((to, _, next) => {
|
||||
}
|
||||
});
|
||||
|
||||
// 添加全局后置钩子,记录页面访问
|
||||
router.afterEach((to) => {
|
||||
const pageName = to.name?.toString() || to.path;
|
||||
// 使用setTimeout避免阻塞路由导航
|
||||
setTimeout(() => {
|
||||
recordVisit(pageName).catch((error) => console.error('记录页面访问失败:', error));
|
||||
}, 100);
|
||||
});
|
||||
|
||||
export default router;
|
||||
|
||||
Reference in New Issue
Block a user