first commit

This commit is contained in:
2025-11-01 09:24:26 +08:00
commit 6516d8dc78
87 changed files with 7558 additions and 0 deletions

View File

@@ -0,0 +1,41 @@
import { defineStore } from 'pinia';
type AuthStatus = 'authenticated' | 'guest';
interface UserProfile {
id: string;
email: string;
displayName: string;
avatarUrl?: string;
preferredCurrency: string;
}
interface AuthState {
status: AuthStatus;
accessToken?: string;
refreshToken?: string;
profile?: UserProfile;
}
export const useAuthStore = defineStore('auth', {
state: (): AuthState => ({
status: 'guest'
}),
getters: {
isAuthenticated: (state) => state.status === 'authenticated'
},
actions: {
setSession(tokens: { accessToken: string; refreshToken: string }, profile: UserProfile) {
this.status = 'authenticated';
this.accessToken = tokens.accessToken;
this.refreshToken = tokens.refreshToken;
this.profile = profile;
},
clearSession() {
this.status = 'guest';
this.accessToken = undefined;
this.refreshToken = undefined;
this.profile = undefined;
}
}
});