before store
This commit is contained in:
@@ -24,26 +24,42 @@ export default defineRouter(function (/* { store, ssrContext } */) {
|
||||
})
|
||||
|
||||
Router.beforeEach(async (to) => {
|
||||
console.log(to)
|
||||
if (to.name === 'settings') return;
|
||||
const projectsStore = useProjectsStore()
|
||||
|
||||
if (to.name === 'settings') return
|
||||
if (to.name === '404') return
|
||||
|
||||
const projectsStore = useProjectsStore()
|
||||
console.log('router mount', projectsStore.startRouteInfo)
|
||||
|
||||
if (projectsStore.startRouteInfo && to.path === '/') {
|
||||
const { id, taskId, meetingId } = projectsStore.startRouteInfo
|
||||
projectsStore.setStartRouteInfo(null)
|
||||
|
||||
if (!projectsStore.isInit) await projectsStore.init()
|
||||
const project = projectsStore.projectById(id)
|
||||
|
||||
if (!project) return { name: '404' }
|
||||
|
||||
return taskId
|
||||
? { name: 'task_info', params: { id, taskId } }
|
||||
: meetingId
|
||||
? { name: 'meeting_info', params: { id, meetingId } }
|
||||
: { name: 'files', params: { id } }
|
||||
}
|
||||
|
||||
if (to.params.id) {
|
||||
const projectId = Number(to.params.id)
|
||||
|
||||
if (!projectsStore.isInit) await projectsStore.init()
|
||||
|
||||
const project = projectsStore.projectById(projectId)
|
||||
if (!project) return { name: 'page404' }
|
||||
|
||||
if (!project) return { name: '404' }
|
||||
|
||||
if (projectsStore.currentProjectId !== projectId) {
|
||||
projectsStore.setCurrentProjectId(projectId)
|
||||
}
|
||||
|
||||
} else {
|
||||
if (!projectsStore.startProjectId) return { name: 'page404' }
|
||||
projectsStore.setCurrentProjectId(projectsStore.startProjectId)
|
||||
return { name: 'files', params: { id: projectsStore.startProjectId }}
|
||||
return { name: '404' }
|
||||
}
|
||||
})
|
||||
|
||||
@@ -61,7 +77,7 @@ export default defineRouter(function (/* { store, ssrContext } */) {
|
||||
}
|
||||
|
||||
Router.afterEach((to) => {
|
||||
const BackButton = window.Telegram?.WebApp?.BackButton;
|
||||
const BackButton = window.Telegram?.WebApp?.BackButton
|
||||
if (BackButton) {
|
||||
// Управление видимостью
|
||||
if (to.meta.hideBackButton) {
|
||||
|
||||
Reference in New Issue
Block a user