Skip to content

Commit ebffb97

Browse files
committed
fix: attach token in hash mode
Signed-off-by: Innei <[email protected]>
1 parent 6672e46 commit ebffb97

File tree

3 files changed

+27
-2
lines changed

3 files changed

+27
-2
lines changed

src/utils/auth.ts

+24-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ export function setToken(token: string) {
2525
export function removeToken() {
2626
return Cookies.remove(TokenKey)
2727
}
28-
2928
export const attachTokenFromQuery = () => {
3029
const token = new URLSearchParams(window.location.search).get('token')
3130
if (token) {
@@ -49,5 +48,29 @@ export const attachTokenFromQuery = () => {
4948
query,
5049
})
5150
})
51+
} else {
52+
// hash mode
53+
54+
const hash = window.location.hash.slice(1)
55+
56+
const parsedUrl = new URL(hash, window.location.origin)
57+
const token = parsedUrl.searchParams.get('token')
58+
if (token) {
59+
setToken(token)
60+
setTokenIsUpstream(true)
61+
parsedUrl.searchParams.delete('token')
62+
63+
router.isReady().then(() => {
64+
const query = {} as any
65+
for (const [key, value] of parsedUrl.searchParams.entries()) {
66+
query[key] = value
67+
}
68+
69+
router.replace({
70+
path: parsedUrl.pathname,
71+
query,
72+
})
73+
})
74+
}
5275
}
5376
}

src/views/dashboard/index.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ import { UpdatePanel } from './update-panel'
7171

7272
export const DashBoardView = defineComponent({
7373
name: 'DashboardView',
74+
7475
setup() {
7576
const stat = ref(
7677
new Proxy(

tsconfig.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
"skipDefaultLibCheck": true,
1919
"lib": [
2020
"esnext",
21-
"dom"
21+
"dom",
22+
"dom.iterable"
2223
],
2324
"types": [],
2425
"paths": {

0 commit comments

Comments
 (0)