39 lines
1.3 KiB
JavaScript
39 lines
1.3 KiB
JavaScript
import { createRouter, createWebHistory } from 'vue-router'
|
|
import FormSink from './views/FormSink.vue'
|
|
import OaStart from './views/OaStart.vue'
|
|
import OaDetail from './views/OaDetail.vue'
|
|
import OaHistory from './views/OaHistory.vue'
|
|
import OaMpBind from './views/OaMpBind.vue'
|
|
import { applyMarketDocumentTitle } from './market/document-title.js'
|
|
import { marketRoutes, resolveMarketDocumentTitle } from './market/routes.js'
|
|
|
|
export function createAppRouter() {
|
|
const router = createRouter({
|
|
history: createWebHistory(import.meta.env.BASE_URL),
|
|
routes: [
|
|
{
|
|
path: '/',
|
|
redirect: (to) => ({ path: '/oa-form-sink', query: to.query, hash: to.hash })
|
|
},
|
|
{ path: '/oa-form-sink', component: FormSink },
|
|
{ path: '/oa-start', component: OaStart },
|
|
{ path: '/oa-history', component: OaHistory },
|
|
{ path: '/oa-detail', component: OaDetail },
|
|
{ path: '/oa-mp-bind', component: OaMpBind },
|
|
...marketRoutes
|
|
]
|
|
})
|
|
|
|
router.afterEach((to) => {
|
|
const title = resolveMarketDocumentTitle(to)
|
|
if (title) {
|
|
if (typeof document !== 'undefined') document.title = title
|
|
return
|
|
}
|
|
// 非市场路由不强制改写(OA 页自行设 title);市场子路径兜底再刷一次
|
|
applyMarketDocumentTitle()
|
|
})
|
|
|
|
return router
|
|
}
|