mirror of
https://gitee.com/dromara/Jpom.git
synced 2024-11-30 02:48:17 +08:00
fix 重新登录未加载管理员菜单
This commit is contained in:
parent
72495297f0
commit
335c0dbbcd
@ -13,6 +13,7 @@
|
||||
3. 【server】优化 自动探测服务端登录验证码是否可用
|
||||
4. 【all】优化 文件编辑后缀识别支持配置文件名或者正则表达式(感谢@MichelleChung)
|
||||
5. 【server】优化 支持自动执行触发器清理
|
||||
6. 【server】优化 重新登录未加载管理员菜单(@A)
|
||||
|
||||
------
|
||||
|
||||
|
@ -289,13 +289,9 @@ export default {
|
||||
dispatchLogin(data) {
|
||||
// 调用 store action 存储当前登录的用户名和 token
|
||||
this.$store.dispatch("login", { token: data.token, longTermToken: data.longTermToken }).then(() => {
|
||||
// 刷新菜单
|
||||
this.$store.dispatch("restLoadSystemMenus").then(() => {
|
||||
//
|
||||
// 跳转主页面
|
||||
this.$router.push({ path: "/" });
|
||||
});
|
||||
});
|
||||
},
|
||||
},
|
||||
};
|
||||
|
@ -3,7 +3,7 @@
|
||||
* 存储所有打开的 tab 窗口,并且记录当前激活的 tab
|
||||
* 另外提供打开新 tab、跳转 tab、移除 tab 功能
|
||||
*/
|
||||
import { MANAGEMENT_ACTIVE_TAB_KEY, MANAGEMENT_TAB_LIST_KEY, MANAGEMENT_ACTIVE_MENU_KEY } from "@/utils/const";
|
||||
import { MANAGEMENT_ACTIVE_MENU_KEY, MANAGEMENT_ACTIVE_TAB_KEY, MANAGEMENT_TAB_LIST_KEY } from "@/utils/const";
|
||||
|
||||
import { getSystemMenu } from "@/api/menu";
|
||||
import routeMenuMap from "@/router/route-menu";
|
||||
@ -37,9 +37,9 @@ const app = {
|
||||
},
|
||||
actions: {
|
||||
// 加载系统菜单 action
|
||||
loadManagementSystemMenus({ commit, state }) {
|
||||
loadManagementSystemMenus({ commit, state }, rest) {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (state.menus.length) {
|
||||
if (state.menus.length && !rest) {
|
||||
// 避免重复加载
|
||||
resolve();
|
||||
return;
|
||||
@ -49,13 +49,12 @@ const app = {
|
||||
.then((res) => {
|
||||
res.data.forEach((element) => {
|
||||
if (element.childs.length > 0) {
|
||||
const childs = element.childs.map((child) => {
|
||||
element.childs = element.childs.map((child) => {
|
||||
return {
|
||||
...child,
|
||||
path: routeMenuMap[child.id],
|
||||
};
|
||||
});
|
||||
element.childs = childs;
|
||||
}
|
||||
});
|
||||
commit("setManagementMenus", res.data);
|
||||
|
@ -43,7 +43,7 @@ const user = {
|
||||
if (res.code === 200) {
|
||||
commit("setUserInfo", res.data);
|
||||
localStorage.setItem(USER_INFO_KEY, JSON.stringify(res.data));
|
||||
resolve();
|
||||
resolve(res.data);
|
||||
}
|
||||
});
|
||||
});
|
||||
@ -62,9 +62,16 @@ const user = {
|
||||
return new Promise((resolve) => {
|
||||
commit("setToken", data);
|
||||
//commit('setUserName', data.userName);
|
||||
dispatch("refreshUserInfo");
|
||||
dispatch("refreshUserInfo").then((userinfo) => {
|
||||
if (userinfo?.systemUser) {
|
||||
// 刷新管理员菜单
|
||||
dispatch("loadManagementSystemMenus", true).then(() => {
|
||||
//
|
||||
});
|
||||
}
|
||||
});
|
||||
// 加载系统菜单 这里需要等待 action 执行完毕返回 promise, 否则第一次登录可能会从 store 里面获取不到 menus 数据而报错
|
||||
dispatch("loadSystemMenus").then(() => {
|
||||
dispatch("restLoadSystemMenus").then(() => {
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user