68 lines
2.6 KiB
TypeScript
68 lines
2.6 KiB
TypeScript
import { createRouter, createWebHistory } from 'vue-router'
|
|
import { buildDocumentTitle } from '../lib/document-title'
|
|
|
|
/** 按 graph 分路由,项目布局保留共享数据与长请求状态。 */
|
|
export const router = createRouter({
|
|
history: createWebHistory(import.meta.env.BASE_URL),
|
|
routes: [
|
|
{ path: '/', redirect: '/projects' },
|
|
{
|
|
path: '/projects',
|
|
component: () => import('../features/projects/ProjectsPage.vue'),
|
|
meta: { title: '我的剧本' }
|
|
},
|
|
{
|
|
path: '/projects/:projectId',
|
|
component: () => import('../features/projects/ProjectLayout.vue'),
|
|
redirect: to => `/projects/${String(to.params.projectId)}/create-drama`,
|
|
children: [
|
|
{
|
|
path: 'create-drama',
|
|
component: () => import('../features/create-drama/CreateDramaPage.vue'),
|
|
meta: { title: '剧本创作' }
|
|
},
|
|
{
|
|
path: 'breakdown',
|
|
component: () => import('../features/breakdown/BreakdownPage.vue'),
|
|
meta: { title: '剧本拆解' }
|
|
},
|
|
{
|
|
path: 'visual-style',
|
|
component: () => import('../features/visual-style/VisualStylePage.vue'),
|
|
meta: { title: '视觉风格' }
|
|
},
|
|
{
|
|
path: 'subject-identity',
|
|
component: () => import('../features/subject-identity/SubjectIdentityPage.vue'),
|
|
meta: { title: '主体身份' }
|
|
},
|
|
{
|
|
path: 'subject-images',
|
|
component: () => import('../features/subject-images/SubjectImagesPage.vue'),
|
|
meta: { title: '形态图片' }
|
|
},
|
|
{
|
|
path: 'storyboard',
|
|
component: () => import('../features/storyboard/StoryboardPage.vue'),
|
|
meta: { title: '分镜设计' }
|
|
},
|
|
{
|
|
path: 'production',
|
|
component: () => import('../features/production/ProductionPage.vue'),
|
|
meta: { title: '镜头生产' }
|
|
}
|
|
]
|
|
},
|
|
{
|
|
path: '/:pathMatch(.*)*',
|
|
component: () => import('../components/NotFoundPage.vue'),
|
|
meta: { title: '页面不存在' }
|
|
}
|
|
]
|
|
})
|
|
|
|
/** 路由切换同步浏览器标题,不依赖页面组件主动修改。 */
|
|
router.afterEach(to => {
|
|
document.title = buildDocumentTitle(to.meta.title)
|
|
})
|