릴리스: v1.3.60 관리자 공개 토글과 인증 새로고침 안정화

This commit is contained in:
2026-04-02 13:41:14 +09:00
parent aa114a170e
commit e3559f4a84
12 changed files with 291 additions and 47 deletions

View File

@@ -1,6 +1,8 @@
import { defineStore } from 'pinia'
import { api } from '../lib/api'
let refreshPromise = null
export const useAuthStore = defineStore('auth', {
state: () => ({
user: null,
@@ -9,19 +11,23 @@ export const useAuthStore = defineStore('auth', {
}),
actions: {
async refresh() {
if (this.status === 'loading') return this.user
if (refreshPromise) return refreshPromise
this.status = 'loading'
try {
const data = await api.me()
this.user = data.user
return this.user
} catch (error) {
this.user = null
return null
} finally {
this.status = 'idle'
this.hydrated = true
}
refreshPromise = (async () => {
try {
const data = await api.me()
this.user = data.user
return this.user
} catch (error) {
this.user = null
return null
} finally {
this.status = 'idle'
this.hydrated = true
refreshPromise = null
}
})()
return refreshPromise
},
async signup(email, password) {
const user = await api.signup({ email, password })
@@ -42,4 +48,3 @@ export const useAuthStore = defineStore('auth', {
},
},
})