|
@@ -3,14 +3,50 @@ import Home from '../pages/Home.vue'
|
|
|
import CourseDetail from '../pages/CourseDetail.vue'
|
|
import CourseDetail from '../pages/CourseDetail.vue'
|
|
|
import MyLearning from '../pages/MyLearning.vue'
|
|
import MyLearning from '../pages/MyLearning.vue'
|
|
|
import MyLearningHome from '../pages/MyLearningHome.vue'
|
|
import MyLearningHome from '../pages/MyLearningHome.vue'
|
|
|
|
|
+import Layout from '@/components/Layout.vue'
|
|
|
|
|
|
|
|
const routes = [
|
|
const routes = [
|
|
|
{
|
|
{
|
|
|
path: '/',
|
|
path: '/',
|
|
|
name: 'Home',
|
|
name: 'Home',
|
|
|
component: Home,
|
|
component: Home,
|
|
|
- meta: { title: '首页' }
|
|
|
|
|
|
|
+ redirect: '/index',
|
|
|
|
|
+ meta: { title: 'route.home' },
|
|
|
|
|
+ children: [
|
|
|
|
|
+ {
|
|
|
|
|
+ path: 'index',
|
|
|
|
|
+ name: 'Index',
|
|
|
|
|
+ component: Home,
|
|
|
|
|
+ meta: { title: 'route.home' }
|
|
|
|
|
+ }
|
|
|
|
|
+ ]
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ path: '/search-platform',
|
|
|
|
|
+ name: 'SearchPlatformHome',
|
|
|
|
|
+ component:() => import('@/pages/SearchPlatform.vue'),
|
|
|
|
|
+ meta: { title: 'SearchPlatformHome' },
|
|
|
|
|
+ children: [
|
|
|
|
|
+ // {
|
|
|
|
|
+ // path: 'search-platform',
|
|
|
|
|
+ // name: 'SearchPlatform',
|
|
|
|
|
+ // component: () => import('@/pages/SearchPlatform.vue'),
|
|
|
|
|
+ // meta: { title: '' }
|
|
|
|
|
+ // },
|
|
|
|
|
+ {
|
|
|
|
|
+ path: 'workflow-detail',
|
|
|
|
|
+ name: 'WorkflowDetail',
|
|
|
|
|
+ component: () => import('@/pages/WorkflowDetail.vue'),
|
|
|
|
|
+ meta: { title: '' }
|
|
|
|
|
+ }
|
|
|
|
|
+ ]
|
|
|
},
|
|
},
|
|
|
|
|
+ // {
|
|
|
|
|
+ // path: '/workflow-detail',
|
|
|
|
|
+ // name: 'WorkflowDetail',
|
|
|
|
|
+ // component: () => import('@/pages/WorkflowDetail.vue'),
|
|
|
|
|
+ // meta: { title: '' }
|
|
|
|
|
+ // },
|
|
|
{
|
|
{
|
|
|
path: '/course/:id',
|
|
path: '/course/:id',
|
|
|
name: 'CourseDetail',
|
|
name: 'CourseDetail',
|
|
@@ -20,7 +56,7 @@ const routes = [
|
|
|
{
|
|
{
|
|
|
path: '/my-learning',
|
|
path: '/my-learning',
|
|
|
name: 'MyLearningHome',
|
|
name: 'MyLearningHome',
|
|
|
- component: MyLearningHome,
|
|
|
|
|
|
|
+ component: Layout,
|
|
|
meta: { title: 'route.myLearning' },
|
|
meta: { title: 'route.myLearning' },
|
|
|
children: [
|
|
children: [
|
|
|
{
|
|
{
|
|
@@ -30,7 +66,7 @@ const routes = [
|
|
|
meta: { title: 'route.myLearning' }
|
|
meta: { title: 'route.myLearning' }
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
- path: '/my-learning/course/:id',
|
|
|
|
|
|
|
+ path: 'course/:id',
|
|
|
name: 'MyLearningCourseDetail',
|
|
name: 'MyLearningCourseDetail',
|
|
|
component: CourseDetail,
|
|
component: CourseDetail,
|
|
|
meta: { title: 'route.myLearningCourseDetail' }
|
|
meta: { title: 'route.myLearningCourseDetail' }
|
|
@@ -43,5 +79,19 @@ const router = createRouter({
|
|
|
history: createWebHistory(import.meta.env.BASE_URL),
|
|
history: createWebHistory(import.meta.env.BASE_URL),
|
|
|
routes
|
|
routes
|
|
|
})
|
|
})
|
|
|
|
|
+// 全局路由守卫
|
|
|
|
|
+router.beforeEach((to, from, next) => {
|
|
|
|
|
+ console.log(33333333333, to)
|
|
|
|
|
+ // 设置页面标题
|
|
|
|
|
+ // document.title = to.meta.title || 'Boom Ai'
|
|
|
|
|
+
|
|
|
|
|
+ // 动态设置路由的meta.title
|
|
|
|
|
+ const lastRoute = to.matched?.[to.matched.length - 1]
|
|
|
|
|
+ if (lastRoute && to.query.metaTitle) {
|
|
|
|
|
+ to.meta.title = to.query.metaTitle;
|
|
|
|
|
+ lastRoute.meta.title = to.query.metaTitle;
|
|
|
|
|
+ }
|
|
|
|
|
+ next()
|
|
|
|
|
+})
|
|
|
|
|
|
|
|
export default router
|
|
export default router
|