refactor: 使用accessMenus增强用户存储
-更新了用户存储以包含新的状态属性“accessMenus”,并添加了相应的操作来设置它。 -修改了codegen.data.ts,以利用ApiTreeSelect组件中的新accessMenus来改进菜单处理。pull/55/head
parent
2b04e1e4ef
commit
0d17a86c10
|
@ -123,15 +123,6 @@ watch(
|
||||||
},
|
},
|
||||||
{ deep: true },
|
{ deep: true },
|
||||||
);
|
);
|
||||||
|
|
||||||
watch(
|
|
||||||
() => mValue.value,
|
|
||||||
(newValue) => {
|
|
||||||
if (typeof newValue === 'number') {
|
|
||||||
mValue.value = `${newValue}`;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
);
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|
|
@ -125,15 +125,6 @@ watch(
|
||||||
},
|
},
|
||||||
{ deep: true },
|
{ deep: true },
|
||||||
);
|
);
|
||||||
|
|
||||||
watch(
|
|
||||||
() => mValue.value,
|
|
||||||
(newValue) => {
|
|
||||||
if (typeof newValue === 'number') {
|
|
||||||
mValue.value = `${newValue}`;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
);
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|
|
@ -119,15 +119,6 @@ watch(
|
||||||
},
|
},
|
||||||
{ deep: true },
|
{ deep: true },
|
||||||
);
|
);
|
||||||
|
|
||||||
watch(
|
|
||||||
() => mValue.value,
|
|
||||||
(newValue) => {
|
|
||||||
if (typeof newValue === 'number') {
|
|
||||||
mValue.value = `${newValue}`;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
);
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|
|
@ -111,6 +111,7 @@ export const useAuthStore = defineStore('auth', () => {
|
||||||
authPermissionInfo = await getAuthPermissionInfoApi();
|
authPermissionInfo = await getAuthPermissionInfoApi();
|
||||||
userStore.setUserInfo(authPermissionInfo.user);
|
userStore.setUserInfo(authPermissionInfo.user);
|
||||||
userStore.setUserRoles(authPermissionInfo.roles);
|
userStore.setUserRoles(authPermissionInfo.roles);
|
||||||
|
userStore.setAccessMenus(authPermissionInfo.menus as []);
|
||||||
accessStore.setAccessCodes(authPermissionInfo.permissions);
|
accessStore.setAccessCodes(authPermissionInfo.permissions);
|
||||||
return authPermissionInfo;
|
return authPermissionInfo;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ import type { VxeGridProps } from '#/adapter/vxe-table';
|
||||||
import type { CodegenApi } from '#/api/infra/codegen';
|
import type { CodegenApi } from '#/api/infra/codegen';
|
||||||
|
|
||||||
import { type VbenFormProps, z } from '@vben/common-ui';
|
import { type VbenFormProps, z } from '@vben/common-ui';
|
||||||
|
import { useUserStore } from '@vben/stores';
|
||||||
|
|
||||||
import { getDataSourceConfigList } from '#/api/infra/data-source-config';
|
import { getDataSourceConfigList } from '#/api/infra/data-source-config';
|
||||||
import { $t } from '#/locales';
|
import { $t } from '#/locales';
|
||||||
|
@ -207,9 +208,16 @@ export namespace CodegenOptionsModalData {
|
||||||
component: 'ApiTreeSelect',
|
component: 'ApiTreeSelect',
|
||||||
componentProps: {
|
componentProps: {
|
||||||
class: 'w-full',
|
class: 'w-full',
|
||||||
|
api: () => {
|
||||||
|
const { accessMenus } = useUserStore();
|
||||||
|
return accessMenus;
|
||||||
|
},
|
||||||
|
labelField: 'name',
|
||||||
|
valueField: 'id',
|
||||||
placeholder: '请选择上级菜单',
|
placeholder: '请选择上级菜单',
|
||||||
},
|
},
|
||||||
rules: z.string().min(1, { message: '上级菜单不能为空' }),
|
rules: z.number().min(1, { message: '上级菜单不能为空' }),
|
||||||
|
defaultValue: null,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: '模块名',
|
label: '模块名',
|
||||||
|
|
|
@ -25,6 +25,10 @@ interface BasicUserInfo {
|
||||||
}
|
}
|
||||||
|
|
||||||
interface AccessState {
|
interface AccessState {
|
||||||
|
/**
|
||||||
|
* 用户菜单
|
||||||
|
*/
|
||||||
|
accessMenus: [];
|
||||||
/**
|
/**
|
||||||
* 用户信息
|
* 用户信息
|
||||||
*/
|
*/
|
||||||
|
@ -40,6 +44,9 @@ interface AccessState {
|
||||||
*/
|
*/
|
||||||
export const useUserStore = defineStore('core-user', {
|
export const useUserStore = defineStore('core-user', {
|
||||||
actions: {
|
actions: {
|
||||||
|
setAccessMenus(menus: []) {
|
||||||
|
this.accessMenus = menus;
|
||||||
|
},
|
||||||
setUserInfo(userInfo: BasicUserInfo | null) {
|
setUserInfo(userInfo: BasicUserInfo | null) {
|
||||||
// 设置用户信息
|
// 设置用户信息
|
||||||
this.userInfo = userInfo;
|
this.userInfo = userInfo;
|
||||||
|
@ -56,6 +63,7 @@ export const useUserStore = defineStore('core-user', {
|
||||||
pick: ['userInfo', 'userRoles'],
|
pick: ['userInfo', 'userRoles'],
|
||||||
},
|
},
|
||||||
state: (): AccessState => ({
|
state: (): AccessState => ({
|
||||||
|
accessMenus: [],
|
||||||
userInfo: null,
|
userInfo: null,
|
||||||
userRoles: [],
|
userRoles: [],
|
||||||
}),
|
}),
|
||||||
|
|
Loading…
Reference in New Issue