export const useUserStore = defineStore("user", () => { const token = useCookie("binv_token", { maxAge: 60 * 60 * 24 * 7 }) const userInfo = ref<{ id: number username: string | null nickname: string | null avatar: string | null email: string | null } | null>(null) const isLoggedIn = computed(() => !!token.value) async function fetchProfile() { if (!token.value) return try { const { get } = useApi() userInfo.value = await get("/user/auth/profile") } catch { userInfo.value = null } } function logout() { token.value = null userInfo.value = null } return { token, userInfo, isLoggedIn, fetchProfile, logout } })