mirror of
https://github.com/OpenSquawk/OpenSquawk
synced 2026-08-06 09:16:26 +08:00
feat: persist pilot monitoring selection
This commit is contained in:
15
plugins/auth-init.client.ts
Normal file
15
plugins/auth-init.client.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
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)
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user