mirror of https://github.com/certd/certd
fix: 修复切换普通用户登录时,左侧菜单没有同步更新的bug
parent
682cb6b71c
commit
12116a89f4
|
@ -47,8 +47,8 @@ provide("fn:router.reload", reload);
|
||||||
provide("fn:locale.changed", localeChanged);
|
provide("fn:locale.changed", localeChanged);
|
||||||
|
|
||||||
//其他初始化
|
//其他初始化
|
||||||
const resourceStore = useResourceStore();
|
// const resourceStore = useResourceStore();
|
||||||
resourceStore.init();
|
// resourceStore.init();
|
||||||
const pageStore = usePageStore();
|
const pageStore = usePageStore();
|
||||||
pageStore.init();
|
pageStore.init();
|
||||||
const settingStore = useSettingStore();
|
const settingStore = useSettingStore();
|
||||||
|
|
|
@ -2,7 +2,6 @@ import Validator from "async-validator";
|
||||||
import { DomainsVerifyPlanInput } from "./type";
|
import { DomainsVerifyPlanInput } from "./type";
|
||||||
|
|
||||||
function checkCnameVerifyPlan(rule, value: DomainsVerifyPlanInput) {
|
function checkCnameVerifyPlan(rule, value: DomainsVerifyPlanInput) {
|
||||||
debugger;
|
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -131,7 +131,7 @@ export default defineComponent({
|
||||||
open(sub.path);
|
open(sub.path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
slots.push(<a-sub-menu key={sub.index} v-slots={subSlots} onTitleClick={onTitleClick} />);
|
slots.push(<a-sub-menu key={sub.path} v-slots={subSlots} onTitleClick={onTitleClick} />);
|
||||||
} else {
|
} else {
|
||||||
slots.push(
|
slots.push(
|
||||||
<a-menu-item key={sub.path} title={sub.title}>
|
<a-menu-item key={sub.path} title={sub.title}>
|
||||||
|
|
|
@ -6,10 +6,17 @@ import { env } from "/@/utils/util.env";
|
||||||
|
|
||||||
//监听注销事件
|
//监听注销事件
|
||||||
mitter.on("app.logout", () => {
|
mitter.on("app.logout", () => {
|
||||||
|
debugger;
|
||||||
const permissionStore = usePermissionStore();
|
const permissionStore = usePermissionStore();
|
||||||
permissionStore.clear();
|
permissionStore.clear();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
mitter.on("app.login", () => {
|
||||||
|
const permissionStore = useResourceStore();
|
||||||
|
permissionStore.clear();
|
||||||
|
permissionStore.init();
|
||||||
|
});
|
||||||
|
|
||||||
interface PermissionState {
|
interface PermissionState {
|
||||||
permissions: [];
|
permissions: [];
|
||||||
inited: boolean;
|
inited: boolean;
|
||||||
|
@ -73,6 +80,7 @@ export const usePermissionStore = defineStore({
|
||||||
resourceStore.filterByPermission(permissions);
|
resourceStore.filterByPermission(permissions);
|
||||||
},
|
},
|
||||||
async loadFromRemote() {
|
async loadFromRemote() {
|
||||||
|
debugger;
|
||||||
let permissionTree = [];
|
let permissionTree = [];
|
||||||
if (env.PM_ENABLED === "false") {
|
if (env.PM_ENABLED === "false") {
|
||||||
console.warn("当前权限模块未开启,权限列表为空");
|
console.warn("当前权限模块未开启,权限列表为空");
|
||||||
|
|
|
@ -22,6 +22,8 @@ router.beforeEach(async (to, from, next) => {
|
||||||
NProgress.start();
|
NProgress.start();
|
||||||
const settingStore = useSettingStore();
|
const settingStore = useSettingStore();
|
||||||
await settingStore.initOnce();
|
await settingStore.initOnce();
|
||||||
|
const resourceStore = useResourceStore();
|
||||||
|
resourceStore.init();
|
||||||
// 修复三级以上路由页面无法缓存的问题
|
// 修复三级以上路由页面无法缓存的问题
|
||||||
if (to.matched && to.matched.length > 2) {
|
if (to.matched && to.matched.length > 2) {
|
||||||
to.matched.splice(1, to.matched.length - 2);
|
to.matched.splice(1, to.matched.length - 2);
|
||||||
|
@ -37,11 +39,11 @@ router.beforeEach(async (to, from, next) => {
|
||||||
// 请根据自身业务需要修改
|
// 请根据自身业务需要修改
|
||||||
const token = userStore.getToken;
|
const token = userStore.getToken;
|
||||||
if (token) {
|
if (token) {
|
||||||
await userStore.init();
|
|
||||||
next();
|
next();
|
||||||
} else {
|
} else {
|
||||||
// 没有登录的时候跳转到登录界面
|
// 没有登录的时候跳转到登录界面
|
||||||
// 携带上登陆成功之后需要跳转的页面完整路径
|
// 携带上登陆成功之后需要跳转的页面完整路径
|
||||||
|
resourceStore.clear();
|
||||||
next({
|
next({
|
||||||
name: "login",
|
name: "login",
|
||||||
query: {
|
query: {
|
||||||
|
@ -73,7 +75,7 @@ router.afterEach((to: any) => {
|
||||||
const matched = to.matched;
|
const matched = to.matched;
|
||||||
if (matched.length > 0) {
|
if (matched.length > 0) {
|
||||||
const resourceStore = useResourceStore();
|
const resourceStore = useResourceStore();
|
||||||
resourceStore.setAsideMenuByCurrentRoute(matched);
|
resourceStore.setCurrentTopMenuByCurrentRoute(matched);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
export default router;
|
export default router;
|
||||||
|
|
|
@ -10,7 +10,7 @@ export const sysResources = [
|
||||||
component: LayoutPass,
|
component: LayoutPass,
|
||||||
meta: {
|
meta: {
|
||||||
icon: "ion:settings-outline",
|
icon: "ion:settings-outline",
|
||||||
permission: "sys"
|
permission: "sys:settings:view"
|
||||||
},
|
},
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
|
|
|
@ -4,46 +4,56 @@ import { frameworkMenus, headerMenus, filterMenus, findMenus } from "/src/router
|
||||||
import _ from "lodash-es";
|
import _ from "lodash-es";
|
||||||
import { mitter } from "/src/utils/util.mitt";
|
import { mitter } from "/src/utils/util.mitt";
|
||||||
//监听注销事件
|
//监听注销事件
|
||||||
mitter.on("app.logout", () => {
|
// mitter.on("app.logout", () => {
|
||||||
const resourceStore = useResourceStore();
|
// debugger;
|
||||||
resourceStore.clear();
|
// const resourceStore = useResourceStore();
|
||||||
});
|
// resourceStore.clear();
|
||||||
|
// });
|
||||||
|
//
|
||||||
|
// mitter.on("app.login", () => {
|
||||||
|
// const resourceStore = useResourceStore();
|
||||||
|
// resourceStore.clear();
|
||||||
|
// resourceStore.init();
|
||||||
|
// });
|
||||||
|
|
||||||
interface ResourceState {
|
interface ResourceState {
|
||||||
frameworkMenus: Array<any>;
|
topMenus: Array<any>;
|
||||||
|
authedTopMenus: Array<any>;
|
||||||
headerMenus: Array<any>;
|
headerMenus: Array<any>;
|
||||||
asideMenus: Array<any>;
|
asideMenus: Array<any>;
|
||||||
fixedAsideMenus: Array<any>;
|
fixedAsideMenus: Array<any>;
|
||||||
inited: boolean;
|
inited: boolean;
|
||||||
currentAsidePath: string;
|
currentTopMenu?: string;
|
||||||
|
currentAsidePath?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const useResourceStore = defineStore({
|
export const useResourceStore = defineStore({
|
||||||
id: "app.resource",
|
id: "app.resource",
|
||||||
state: (): ResourceState => ({
|
state: (): ResourceState => ({
|
||||||
// user info
|
// user info
|
||||||
frameworkMenus: [],
|
topMenus: [],
|
||||||
|
authedTopMenus: [],
|
||||||
headerMenus: [],
|
headerMenus: [],
|
||||||
asideMenus: [],
|
|
||||||
fixedAsideMenus: [],
|
fixedAsideMenus: [],
|
||||||
inited: false,
|
inited: false,
|
||||||
currentAsidePath: ""
|
currentTopMenu: undefined,
|
||||||
|
currentAsidePath: undefined
|
||||||
}),
|
}),
|
||||||
getters: {
|
getters: {
|
||||||
// @ts-ignore
|
|
||||||
getAsideMenus() {
|
getAsideMenus() {
|
||||||
// @ts-ignore
|
let topMenu = this.currentTopMenu;
|
||||||
return this.asideMenus;
|
if (!topMenu && this.authedTopMenus.length > 0) {
|
||||||
|
topMenu = this.authedTopMenus[0];
|
||||||
|
}
|
||||||
|
let asideMenus = topMenu?.children || [];
|
||||||
|
asideMenus = [...this.fixedAsideMenus, ...asideMenus];
|
||||||
|
return asideMenus;
|
||||||
},
|
},
|
||||||
// @ts-ignore
|
|
||||||
getHeaderMenus() {
|
getHeaderMenus() {
|
||||||
// @ts-ignore
|
|
||||||
return this.headerMenus;
|
return this.headerMenus;
|
||||||
},
|
},
|
||||||
// @ts-ignore
|
|
||||||
getFrameworkMenus() {
|
getFrameworkMenus() {
|
||||||
// @ts-ignore
|
return this.authedTopMenus;
|
||||||
return this.frameworkMenus;
|
|
||||||
}
|
}
|
||||||
} as any,
|
} as any,
|
||||||
actions: {
|
actions: {
|
||||||
|
@ -59,28 +69,26 @@ export const useResourceStore = defineStore({
|
||||||
}
|
}
|
||||||
this.inited = true;
|
this.inited = true;
|
||||||
|
|
||||||
const showMenus = _.cloneDeep(frameworkMenus[0].children);
|
const allMenus = _.cloneDeep(frameworkMenus[0].children);
|
||||||
this.frameworkMenus = filterMenus(showMenus, (item: any) => {
|
this.topMenus = filterMenus(allMenus, (item: any) => {
|
||||||
return item?.meta?.showOnHeader !== false;
|
return item?.meta?.showOnHeader !== false;
|
||||||
});
|
});
|
||||||
|
|
||||||
this.fixedAsideMenus = findMenus(showMenus, (item: any) => {
|
this.fixedAsideMenus = findMenus(allMenus, (item: any) => {
|
||||||
return item?.meta?.fixedAside === true;
|
return item?.meta?.fixedAside === true;
|
||||||
});
|
});
|
||||||
this.headerMenus = headerMenus;
|
this.headerMenus = headerMenus;
|
||||||
this.setAsideMenu();
|
|
||||||
},
|
},
|
||||||
setAsideMenu(topMenu?: any) {
|
setCurrentTopMenu(topMenu?: any) {
|
||||||
if (this.frameworkMenus.length === 0) {
|
if (this.frameworkMenus.length === 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (topMenu == null) {
|
if (topMenu == null) {
|
||||||
topMenu = this.frameworkMenus[0];
|
topMenu = this.frameworkMenus[0];
|
||||||
}
|
}
|
||||||
const asideMenus = topMenu?.children || [];
|
this.currentTopMenu = topMenu;
|
||||||
this.asideMenus = [...this.fixedAsideMenus, ...asideMenus];
|
|
||||||
},
|
},
|
||||||
setAsideMenuByCurrentRoute(matched: any) {
|
setCurrentTopMenuByCurrentRoute(matched: any) {
|
||||||
const menuHeader = this.frameworkMenus;
|
const menuHeader = this.frameworkMenus;
|
||||||
if (matched?.length <= 1) {
|
if (matched?.length <= 1) {
|
||||||
return;
|
return;
|
||||||
|
@ -109,11 +117,11 @@ export const useResourceStore = defineStore({
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.currentAsidePath = _side[0];
|
this.currentAsidePath = _side[0];
|
||||||
this.setAsideMenu(_side[0]);
|
this.setCurrentTopMenu(_side[0]);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
filterByPermission(permissions: any) {
|
filterByPermission(permissions: any) {
|
||||||
this.frameworkMenus = this.filterChildrenByPermission(this.frameworkMenus, permissions);
|
this.authedTopMenus = this.filterChildrenByPermission(this.topMenus, permissions);
|
||||||
},
|
},
|
||||||
filterChildrenByPermission(list: any, permissions: any) {
|
filterChildrenByPermission(list: any, permissions: any) {
|
||||||
const menus = list.filter((item: any) => {
|
const menus = list.filter((item: any) => {
|
||||||
|
|
|
@ -15,7 +15,6 @@ import { mitter } from "/src/utils/util.mitt";
|
||||||
interface UserState {
|
interface UserState {
|
||||||
userInfo: Nullable<UserInfoRes>;
|
userInfo: Nullable<UserInfoRes>;
|
||||||
token?: string;
|
token?: string;
|
||||||
inited: boolean;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const USER_INFO_KEY = "USER_INFO";
|
const USER_INFO_KEY = "USER_INFO";
|
||||||
|
@ -26,8 +25,7 @@ export const useUserStore = defineStore({
|
||||||
// user info
|
// user info
|
||||||
userInfo: null,
|
userInfo: null,
|
||||||
// token
|
// token
|
||||||
token: undefined,
|
token: undefined
|
||||||
inited: false
|
|
||||||
}),
|
}),
|
||||||
getters: {
|
getters: {
|
||||||
getUserInfo(): UserInfoRes {
|
getUserInfo(): UserInfoRes {
|
||||||
|
@ -114,16 +112,6 @@ export const useUserStore = defineStore({
|
||||||
await this.logout(true);
|
await this.logout(true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
|
||||||
async init() {
|
|
||||||
if (this.inited) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.inited = true;
|
|
||||||
},
|
|
||||||
async reInit() {
|
|
||||||
this.inited = false;
|
|
||||||
await this.init();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -76,7 +76,6 @@ export default function (certPluginGroup: PluginGroup, formWrapperRef: any): Cre
|
||||||
},
|
},
|
||||||
valueChange: {
|
valueChange: {
|
||||||
handle: async ({ form, value }) => {
|
handle: async ({ form, value }) => {
|
||||||
debugger;
|
|
||||||
const config = await api.GetPluginConfig({
|
const config = await api.GetPluginConfig({
|
||||||
name: value,
|
name: value,
|
||||||
type: "builtIn"
|
type: "builtIn"
|
||||||
|
|
|
@ -256,7 +256,6 @@ export default {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//设置系统初始值
|
//设置系统初始值
|
||||||
debugger;
|
|
||||||
const pluginSysConfig = await pluginApi.GetPluginConfig({ name: pluginDefine.name, type: "builtIn" });
|
const pluginSysConfig = await pluginApi.GetPluginConfig({ name: pluginDefine.name, type: "builtIn" });
|
||||||
if (pluginSysConfig.sysSetting?.input) {
|
if (pluginSysConfig.sysSetting?.input) {
|
||||||
for (const key in pluginSysConfig.sysSetting?.input) {
|
for (const key in pluginSysConfig.sysSetting?.input) {
|
||||||
|
|
|
@ -130,6 +130,7 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
|
||||||
component: {
|
component: {
|
||||||
name: "access-selector",
|
name: "access-selector",
|
||||||
vModel: "modelValue",
|
vModel: "modelValue",
|
||||||
|
from: "sys",
|
||||||
type: compute(({ form }) => {
|
type: compute(({ form }) => {
|
||||||
return form.dnsProviderType;
|
return form.dnsProviderType;
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue