2025-11-16 23:19:44 +08:00
|
|
|
|
import { createRouter, createWebHistory } from 'vue-router'
|
|
|
|
|
|
import { useUserStore } from '@/stores/user'
|
2025-11-25 00:58:51 +08:00
|
|
|
|
import tokenManager from '@gold/utils/token-manager'
|
2025-11-25 01:24:12 +08:00
|
|
|
|
import MainLayout from '@/layouts/MainLayout.vue'
|
2025-11-16 23:19:44 +08:00
|
|
|
|
|
|
|
|
|
|
const routes = [
|
2025-11-25 01:24:12 +08:00
|
|
|
|
// 登录页面 - 独立渲染,不使用Layout
|
2025-11-25 00:58:51 +08:00
|
|
|
|
{
|
|
|
|
|
|
path: '/login',
|
|
|
|
|
|
name: '登录',
|
|
|
|
|
|
component: () => import('../views/auth/Login.vue'),
|
|
|
|
|
|
meta: {
|
|
|
|
|
|
requiresAuth: false
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
2025-11-25 01:24:12 +08:00
|
|
|
|
// 主布局路由 - 所有需要Layout的页面都在这里
|
2025-11-16 23:19:44 +08:00
|
|
|
|
{
|
2025-11-25 01:24:12 +08:00
|
|
|
|
path: '/',
|
|
|
|
|
|
component: MainLayout,
|
|
|
|
|
|
redirect: '/content-style/benchmark',
|
2025-11-16 23:19:44 +08:00
|
|
|
|
children: [
|
2025-11-25 01:24:12 +08:00
|
|
|
|
{
|
|
|
|
|
|
path: 'content-style',
|
|
|
|
|
|
name: '内容风格分析',
|
|
|
|
|
|
children: [
|
|
|
|
|
|
{ path: '', redirect: '/content-style/benchmark' },
|
|
|
|
|
|
{ path: 'benchmark', name: '对标分析', component: () => import('../views/content-style/Benchmark.vue') },
|
|
|
|
|
|
{ path: 'copywriting', name: '文案创作', component: () => import('../views/content-style/Copywriting.vue') },
|
|
|
|
|
|
]
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
path: 'trends',
|
|
|
|
|
|
name: '热点趋势分析',
|
|
|
|
|
|
children: [
|
|
|
|
|
|
{ path: '', redirect: '/trends/heat' },
|
|
|
|
|
|
{ path: 'heat', name: '热度分析', component: () => import('../views/trends/Heat.vue') },
|
|
|
|
|
|
{ path: 'forecast', name: '热点预测', component: () => import('../views/trends/Forecast.vue') },
|
|
|
|
|
|
]
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
path: 'digital-human',
|
|
|
|
|
|
name: '数字人',
|
|
|
|
|
|
children: [
|
|
|
|
|
|
{ path: '', redirect: '/digital-human/voice-copy' },
|
2025-12-28 00:19:17 +08:00
|
|
|
|
{ path: 'kling', name: '数字人生成', component: () => import('../views/kling/IdentifyFace.vue') },
|
2025-11-25 01:24:12 +08:00
|
|
|
|
{ path: 'voice-copy', name: '人声克隆', component: () => import('../views/dh/VoiceCopy.vue') },
|
|
|
|
|
|
]
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
path: 'material',
|
|
|
|
|
|
name: '素材库',
|
|
|
|
|
|
children: [
|
|
|
|
|
|
{ path: '', redirect: '/material/list' },
|
2026-01-17 14:43:42 +08:00
|
|
|
|
{ path: 'list', name: '素材列表', component: () => import('../views/material/MaterialListNew.vue') },
|
2025-12-15 23:33:02 +08:00
|
|
|
|
{ path: 'mix', name: '智能混剪', component: () => import('../views/material/Mix.vue') },
|
2025-11-25 01:24:12 +08:00
|
|
|
|
{ path: 'mix-task', name: '混剪任务', component: () => import('../views/material/MixTaskList.vue') },
|
|
|
|
|
|
{ path: 'group', name: '素材分组', component: () => import('../views/material/MaterialGroup.vue') },
|
|
|
|
|
|
]
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
path: 'system',
|
|
|
|
|
|
name: '系统',
|
|
|
|
|
|
children: [
|
2026-01-18 01:07:11 +08:00
|
|
|
|
// { path: '', redirect: '/system/style-settings' },
|
|
|
|
|
|
// { path: 'style-settings', name: '风格设置', component: () => import('../views/system/StyleSettings.vue') },
|
2025-12-21 22:24:16 +08:00
|
|
|
|
{
|
|
|
|
|
|
path: 'task-management/:type',
|
|
|
|
|
|
name: '任务中心',
|
|
|
|
|
|
component: () => import('../views/system/task-management/layout/TaskLayout.vue')
|
|
|
|
|
|
}
|
2025-11-25 01:24:12 +08:00
|
|
|
|
],
|
|
|
|
|
|
meta: {
|
|
|
|
|
|
requiresAuth: true
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
2025-11-25 00:58:51 +08:00
|
|
|
|
],
|
|
|
|
|
|
meta: {
|
|
|
|
|
|
requiresAuth: true
|
|
|
|
|
|
}
|
2025-11-16 23:19:44 +08:00
|
|
|
|
},
|
2026-01-17 14:43:42 +08:00
|
|
|
|
|
2025-11-16 23:19:44 +08:00
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
const router = createRouter({
|
|
|
|
|
|
history: createWebHistory(import.meta.env.BASE_URL),
|
|
|
|
|
|
routes,
|
|
|
|
|
|
})
|
|
|
|
|
|
|
2025-11-25 00:58:51 +08:00
|
|
|
|
// 路由守卫
|
2025-11-16 23:19:44 +08:00
|
|
|
|
router.beforeEach(async (to, from, next) => {
|
|
|
|
|
|
const userStore = useUserStore()
|
2026-01-17 14:43:42 +08:00
|
|
|
|
const authenToken = tokenManager.getAccessToken()
|
2025-11-25 00:58:51 +08:00
|
|
|
|
|
|
|
|
|
|
// 路由访问控制
|
2025-11-28 20:26:47 +08:00
|
|
|
|
if (to.meta.requiresAuth && !authenToken) {
|
2025-11-25 00:58:51 +08:00
|
|
|
|
// 需要认证但未登录,跳转到登录页并记录当前路径
|
|
|
|
|
|
next({
|
|
|
|
|
|
path: '/login',
|
|
|
|
|
|
query: { redirect: to.fullPath }
|
|
|
|
|
|
})
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 已登录用户访问登录页,重定向到首页
|
2025-11-28 20:26:47 +08:00
|
|
|
|
if (to.path === '/login' && authenToken) {
|
2025-11-25 00:58:51 +08:00
|
|
|
|
next({ path: '/content-style/benchmark', replace: true })
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-17 14:43:42 +08:00
|
|
|
|
if (authenToken && !userStore.isLoggedIn.value) {
|
|
|
|
|
|
userStore.fetchUserInfo()
|
2025-11-25 00:58:51 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-11-16 23:19:44 +08:00
|
|
|
|
next()
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
export default router
|
|
|
|
|
|
|