feat: 升级stylelint依赖并修复相关问题

- 更新stylelint到16.x版本
- 修复postcss版本冲突
- 解决循环依赖问题
- 优化代码类型定义
This commit is contained in:
2025-06-24 19:46:34 +08:00
parent d1c2d332ab
commit 4d66f8baa7
30 changed files with 2190 additions and 2424 deletions
+30 -5
View File
@@ -32,6 +32,14 @@ const useUserStore = defineStore('user', {
permission: [],
}),
// 配置持久化
persist: {
key: 'user-store',
storage: localStorage,
// 只持久化关键的用户信息,排除敏感信息
pick: ['name', 'avatar', 'role', 'permission', 'accountId', 'email'],
},
getters: {
userInfo(state: UserState): UserState {
return { ...state };
@@ -67,8 +75,22 @@ const useUserStore = defineStore('user', {
try {
const res = await userLogin(loginForm);
setToken(res.data.token);
// 登录成功后立即获取用户权限
// await this.getUserPermissionData();
// 设置基本用户信息
this.setInfo({
name: loginForm.username,
role: 'admin',
});
// 登录成功后获取完整的用户信息和权限
try {
await this.info();
await this.getUserPermissionData();
} catch (infoError) {
// 如果获取用户信息失败,不影响登录流程
// eslint-disable-next-line no-console
console.warn('获取用户详细信息失败:', infoError);
}
} catch (err) {
clearToken();
throw err;
@@ -92,14 +114,17 @@ const useUserStore = defineStore('user', {
async getUserPermissionData() {
try {
const res = await getUserPermission();
console.log(res, '权限数据');
// 将权限数据存储到store中
if (res.data && res.data.length > 0) {
this.setInfo({ permission: res.data[0].permission });
}
} catch (err) {
console.error('获取权限失败:', err);
// 生产环境下可以使用日志服务记录错误
if (process.env.NODE_ENV === 'development') {
// eslint-disable-next-line no-console
console.error('获取权限失败:', err);
}
throw err;
}
},