wip: try out to fix beforeAuth issue
This commit is contained in:
parent
6a422ecb62
commit
0ea7425bd6
|
|
@ -117,7 +117,7 @@
|
|||
|
||||
<script setup lang="ts">
|
||||
import {useDebounceFn} from '@vueuse/core'
|
||||
import {computed, onBeforeMount, reactive, ref, toRaw} from 'vue'
|
||||
import {computed, reactive, ref, toRaw} from 'vue'
|
||||
import {useI18n} from 'vue-i18n'
|
||||
|
||||
import router from '@/router'
|
||||
|
|
@ -132,20 +132,19 @@ import {validatePassword} from '@/helpers/validatePasswort'
|
|||
definePage({
|
||||
name: 'user.register',
|
||||
meta: { title: 'user.auth.createAccount' },
|
||||
beforeEnter() {
|
||||
const authStore = useAuthStore()
|
||||
|
||||
if (authStore.authenticated) {
|
||||
router.push({ name: 'home' })
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
const {t} = useI18n()
|
||||
const authStore = useAuthStore()
|
||||
const configStore = useConfigStore()
|
||||
|
||||
// FIXME: use the `beforeEnter` hook of vue-router
|
||||
// Check if the user is already logged in, if so, redirect them to the homepage
|
||||
onBeforeMount(() => {
|
||||
if (authStore.authenticated) {
|
||||
router.push({name: 'home'})
|
||||
}
|
||||
})
|
||||
|
||||
const credentials = reactive({
|
||||
username: '',
|
||||
email: '',
|
||||
|
|
|
|||
|
|
@ -24,15 +24,18 @@ definePage({
|
|||
throw new Error()
|
||||
}
|
||||
|
||||
const projectId = Number(to.params?.projectId)
|
||||
const viewIdFromRoute = Number(to.params?.viewId)
|
||||
|
||||
if (!viewIdFromRoute) {
|
||||
const newViewid = getProjectViewId(projectId) ?? 0
|
||||
|
||||
if (!viewIdFromRoute || viewIdFromRoute !== newViewid) {
|
||||
return {
|
||||
name: 'project',
|
||||
replace: true,
|
||||
params: {
|
||||
projectId: to.params.projectId,
|
||||
viewId: getProjectViewId(Number(to.params?.projectId)) ?? 0,
|
||||
projectId,
|
||||
viewId: newViewid,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
@ -136,16 +139,16 @@ function redirectToDefaultViewIfNecessary() {
|
|||
}
|
||||
}
|
||||
|
||||
watch(
|
||||
() => props.viewId,
|
||||
redirectToDefaultViewIfNecessary,
|
||||
{immediate: true},
|
||||
)
|
||||
// watch(
|
||||
// () => props.viewId,
|
||||
// redirectToDefaultViewIfNecessary,
|
||||
// {immediate: true},
|
||||
// )
|
||||
|
||||
watch(
|
||||
currentProject,
|
||||
redirectToDefaultViewIfNecessary,
|
||||
)
|
||||
// watch(
|
||||
// currentProject,
|
||||
// redirectToDefaultViewIfNecessary,
|
||||
// )
|
||||
|
||||
watchEffect(() => saveProjectToHistory({id: props.projectId}))
|
||||
watchEffect(() => saveProjectView(props.projectId, props.viewId))
|
||||
|
|
|
|||
Loading…
Reference in New Issue