1、解决在线用户强制退出功能 2、初始化系统配置,应用全局 3、预留功能:将把vuex改用pinia(下次上线)

This commit is contained in:
zhangtao
2025-01-10 08:10:12 +08:00
parent 4e15f2ad3d
commit 8d9a64aed3
13 changed files with 136 additions and 32 deletions
+26
View File
@@ -0,0 +1,26 @@
import { defineStore } from 'pinia';
import { getInitConfig } from "@/api/system/config";
export const useConfigStore = defineStore('config', {
state: () => ({
systemConfig: {},
}),
actions: {
async getConfigInfo() {
try {
const response = await getInitConfig();
const result = response.data;
const configData = JSON.parse(result.data);
this.systemConfig = configData;
} catch (error) {
console.error(error);
}
},
setSystemConfig(config) {
this.systemConfig = config;
},
clearConfigInfo() {
this.systemConfig = {};
},
},
});
+36
View File
@@ -0,0 +1,36 @@
import { defineStore } from 'pinia';
import { getCurrentUserInfo } from "@/api/system/user";
export const useUserStore = defineStore('user', {
state: () => ({
basicInfo: {},
routeList: [],
hasGetRoute: false,
}),
actions: {
async getUserInfo() {
try {
const response = await getCurrentUserInfo();
const result = response.data;
const routers = result.data.menus;
delete result.data.menus;
this.setRoute(routers);
this.basicInfo = Object.assign(this.basicInfo || {}, result.data);
} catch (error) {
console.error(error);
}
},
setRoute(routers) {
this.routeList = routers;
this.hasGetRoute = true;
},
setAvatar(avatar) {
this.basicInfo.avatar = avatar;
},
clearUserInfo() {
this.basicInfo = {};
this.routeList = [];
this.hasGetRoute = false;
},
},
});