You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

17 lines
386 B
TypeScript

1 month ago
// plugins/auth-init.client.ts
import { defineNuxtPlugin } from '#app'
import { useAuthStore } from '~/stores/auth'
export default defineNuxtPlugin(() => {
// 客户端初始化时恢复认证状态
const authStore = useAuthStore()
// 从Cookie恢复认证状态
authStore.initializeAuth()
return {
provide: {
authInit: true
}
}
})