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