chore: import const instead of redeclaring it
This commit is contained in:
parent
59b05e9836
commit
61baf02e26
1
src/helpers/linkShareHash.ts
Normal file
1
src/helpers/linkShareHash.ts
Normal file
@ -0,0 +1 @@
|
|||||||
|
export const LINK_SHARE_HASH_PREFIX = '#linkshare='
|
@ -7,6 +7,7 @@ import {parseDateOrString} from '@/helpers/time/parseDateOrString'
|
|||||||
import {getNextWeekDate} from '@/helpers/time/getNextWeekDate'
|
import {getNextWeekDate} from '@/helpers/time/getNextWeekDate'
|
||||||
import {setTitle} from '@/helpers/setTitle'
|
import {setTitle} from '@/helpers/setTitle'
|
||||||
import {getToken} from '@/helpers/auth'
|
import {getToken} from '@/helpers/auth'
|
||||||
|
import {LINK_SHARE_HASH_PREFIX} from '@/helpers/linkShareHash'
|
||||||
|
|
||||||
import {useProjectStore} from '@/stores/projects'
|
import {useProjectStore} from '@/stores/projects'
|
||||||
import {useAuthStore} from '@/stores/auth'
|
import {useAuthStore} from '@/stores/auth'
|
||||||
@ -72,8 +73,6 @@ const NewProjectComponent = () => import('@/views/project/NewProject.vue')
|
|||||||
const EditTeamComponent = () => import('@/views/teams/EditTeam.vue')
|
const EditTeamComponent = () => import('@/views/teams/EditTeam.vue')
|
||||||
const NewTeamComponent = () => import('@/views/teams/NewTeam.vue')
|
const NewTeamComponent = () => import('@/views/teams/NewTeam.vue')
|
||||||
|
|
||||||
const linkShareHashPrefix = '#linkshare='
|
|
||||||
|
|
||||||
const router = createRouter({
|
const router = createRouter({
|
||||||
history: createWebHistory(import.meta.env.BASE_URL),
|
history: createWebHistory(import.meta.env.BASE_URL),
|
||||||
scrollBehavior(to, from, savedPosition) {
|
scrollBehavior(to, from, savedPosition) {
|
||||||
@ -83,7 +82,7 @@ const router = createRouter({
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Scroll to anchor should still work
|
// Scroll to anchor should still work
|
||||||
if (to.hash && !to.hash.startsWith(linkShareHashPrefix)) {
|
if (to.hash && !to.hash.startsWith(LINK_SHARE_HASH_PREFIX)) {
|
||||||
return {el: to.hash}
|
return {el: to.hash}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -487,18 +486,18 @@ export async function getAuthForRoute(route: RouteLocation) {
|
|||||||
|
|
||||||
router.beforeEach(async (to, from) => {
|
router.beforeEach(async (to, from) => {
|
||||||
|
|
||||||
if(from.hash && from.hash.startsWith(linkShareHashPrefix)) {
|
if(from.hash && from.hash.startsWith(LINK_SHARE_HASH_PREFIX)) {
|
||||||
to.hash = from.hash
|
to.hash = from.hash
|
||||||
}
|
}
|
||||||
|
|
||||||
if (to.hash.startsWith(linkShareHashPrefix)) {
|
if (to.hash.startsWith(LINK_SHARE_HASH_PREFIX)) {
|
||||||
const currentAuthToken = getToken()
|
const currentAuthToken = getToken()
|
||||||
if (currentAuthToken === null) {
|
if (currentAuthToken === null) {
|
||||||
saveLastVisited(to.name as string, to.params, to.query)
|
saveLastVisited(to.name as string, to.params, to.query)
|
||||||
return {
|
return {
|
||||||
name: 'link-share.auth',
|
name: 'link-share.auth',
|
||||||
params: {
|
params: {
|
||||||
share: to.hash.replace(linkShareHashPrefix, ''),
|
share: to.hash.replace(LINK_SHARE_HASH_PREFIX, ''),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,6 +40,7 @@ import {useTitle} from '@vueuse/core'
|
|||||||
|
|
||||||
import Message from '@/components/misc/message.vue'
|
import Message from '@/components/misc/message.vue'
|
||||||
import {PROJECT_VIEWS, type ProjectView} from '@/types/ProjectView'
|
import {PROJECT_VIEWS, type ProjectView} from '@/types/ProjectView'
|
||||||
|
import {LINK_SHARE_HASH_PREFIX} from '@/helpers/linkShareHash'
|
||||||
|
|
||||||
import {useBaseStore} from '@/stores/base'
|
import {useBaseStore} from '@/stores/base'
|
||||||
import {useAuthStore} from '@/stores/auth'
|
import {useAuthStore} from '@/stores/auth'
|
||||||
@ -61,7 +62,6 @@ function useAuth() {
|
|||||||
const password = ref('')
|
const password = ref('')
|
||||||
|
|
||||||
const authLinkShare = computed(() => authStore.authLinkShare)
|
const authLinkShare = computed(() => authStore.authLinkShare)
|
||||||
const linkShareHashPrefix = '#linkshare='
|
|
||||||
|
|
||||||
async function authenticate() {
|
async function authenticate() {
|
||||||
authenticateWithPassword.value = false
|
authenticateWithPassword.value = false
|
||||||
@ -90,7 +90,7 @@ function useAuth() {
|
|||||||
? route.query.view
|
? route.query.view
|
||||||
: 'list'
|
: 'list'
|
||||||
|
|
||||||
const hash = linkShareHashPrefix + route.params.share
|
const hash = LINK_SHARE_HASH_PREFIX + route.params.share
|
||||||
|
|
||||||
const last = getLastVisitedRoute()
|
const last = getLastVisitedRoute()
|
||||||
if (last) {
|
if (last) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user