before delete 3software

This commit is contained in:
2025-06-29 18:55:59 +03:00
parent ebd77a3e66
commit b51a472738
147 changed files with 257326 additions and 3151 deletions

View File

@@ -8,6 +8,7 @@ import {
import routes from './routes'
import { useAuthStore } from 'stores/auth'
import { useProjectsStore } from 'stores/projects'
import { computed } from 'vue'
const tg = window.Telegram?.WebApp
declare module 'vue-router' {
@@ -32,8 +33,9 @@ export default defineRouter(function (/* { store, ssrContext } */) {
history: createHistory(process.env.VUE_ROUTER_BASE)
})
Router.beforeEach((to) => {
Router.beforeEach(async (to) => {
const authStore = useAuthStore()
const projectsStore = useProjectsStore()
if (to.meta.guestOnly && authStore.isAuth) {
return { name: 'projects' }
@@ -45,6 +47,22 @@ export default defineRouter(function (/* { store, ssrContext } */) {
replace: true
}
}
if (to.params.id) {
if (!projectsStore.isInit) await projectsStore.init()
const currentProjectId = computed(() => projectsStore.currentProjectId)
if (to.params.id) {
if (currentProjectId.value !== Number(to.params.id)) {
if (!projectsStore.projectById(Number(to.params.id)))
projectsStore.setCurrentProjectId(Number(to.params.id))
}
} else {
projectsStore.setCurrentProjectId(null)
return { name: 'projects' }
}
}
})
const handleBackButton = async () => {
@@ -67,9 +85,7 @@ export default defineRouter(function (/* { store, ssrContext } */) {
}
}
if (!to.params.id) {
useProjectsStore().setCurrentProjectId(null)
}
useProjectsStore().setCurrentProjectId(to.params.id ? Number(to.params.id) : null)
})
return Router