mirror of
https://github.com/fastapiadmin/FastapiAdmin.git
synced 2026-10-03 00:41:15 +00:00
1、解决在线用户强制退出功能 2、初始化系统配置,应用全局 3、预留功能:将把vuex改用pinia(下次上线)
This commit is contained in:
@@ -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 = {};
|
||||
},
|
||||
},
|
||||
});
|
||||
@@ -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;
|
||||
},
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user