mirror of
https://github.com/OpenSquawk/OpenSquawk
synced 2026-05-15 03:25:40 +08:00
16 lines
411 B
TypeScript
16 lines
411 B
TypeScript
import { defineNuxtPlugin } from '#app'
|
|
import { useAuthStore, AUTH_TOKEN_STORAGE_KEY } from '~/stores/auth'
|
|
|
|
export default defineNuxtPlugin(() => {
|
|
if (typeof window === 'undefined') {
|
|
return
|
|
}
|
|
|
|
const auth = useAuthStore()
|
|
const storedToken = window.localStorage.getItem(AUTH_TOKEN_STORAGE_KEY)
|
|
|
|
if (storedToken && auth.accessToken !== storedToken) {
|
|
auth.setAccessToken(storedToken)
|
|
}
|
|
})
|