42 lines
1.2 KiB
TypeScript
42 lines
1.2 KiB
TypeScript
import { createRouter, createWebHistory } from 'vue-router'
|
|
|
|
import { signingState } from '@/composables/useSignFlow'
|
|
import ConsentView from '@/views/consent/ConsentView.vue'
|
|
import EntryView from '@/views/entry/EntryView.vue'
|
|
import ResultView from '@/views/result/ResultView.vue'
|
|
import SignerView from '@/views/signer/SignerView.vue'
|
|
|
|
const router = createRouter({
|
|
history: createWebHistory(import.meta.env.BASE_URL),
|
|
routes: [
|
|
{ path: '/', redirect: '/entry' },
|
|
{ path: '/entry', component: EntryView, meta: { title: '签署入口' } },
|
|
{ path: '/consent', component: ConsentView, meta: { title: '阅读文书' } },
|
|
{ path: '/signer', component: SignerView, meta: { title: '确认并签署' } },
|
|
{ path: '/result', component: ResultView, meta: { title: '签署结果' } },
|
|
{ path: '/:pathMatch(.*)*', redirect: '/entry' },
|
|
],
|
|
})
|
|
|
|
router.beforeEach((to) => {
|
|
if (to.path === '/entry') {
|
|
return true
|
|
}
|
|
|
|
if (signingState.status === 'idle') {
|
|
return '/entry'
|
|
}
|
|
|
|
if (to.path === '/signer' && !signingState.consentAccepted) {
|
|
return '/consent'
|
|
}
|
|
|
|
if (to.path === '/result' && !signingState.signatureCaptured) {
|
|
return '/entry'
|
|
}
|
|
|
|
return true
|
|
})
|
|
|
|
export default router
|