初始化仓库

This commit is contained in:
tao
2025-12-17 17:00:29 +08:00
commit 71158afc35
44 changed files with 5301 additions and 0 deletions

22
src/store/user.ts Normal file
View File

@@ -0,0 +1,22 @@
import { defineStore } from 'pinia';
import Cookies from 'js-cookie';
const USERNAME_KEY = 'username';
export const useUserStore = defineStore('user', {
state: () => ({
username: Cookies.get(USERNAME_KEY) || null,
}),
actions: {
async fetchUserInfo() {
// Simulate API call
const fetchedUsername = 'mock_user';
this.username = fetchedUsername;
Cookies.set(USERNAME_KEY, fetchedUsername);
},
clearUserInfo() {
this.username = null;
Cookies.remove(USERNAME_KEY);
},
},
});