@pubinfo/module-rbac 2.1.0 → 2.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{MetaForm-CdjGvTzO.js → MetaForm-BMPtZc0g.js} +1698 -1672
- package/dist/{ResourceEdit-DmhCeCzZ.js → ResourceEdit-D59JUDvG.js} +1 -1
- package/dist/{ResourceEdit.vue_vue_type_script_setup_true_lang-Bf5bFQcG.js → ResourceEdit.vue_vue_type_script_setup_true_lang-IWn27Vz1.js} +1 -1
- package/dist/{index-CW5BpDeG.js → index-DQhQqT_Z.js} +1 -1
- package/dist/index.js +4 -4
- package/dist/utils/validateObjectStructure.d.ts +11 -0
- package/package.json +3 -3
- package/src/components/JsonEditorModal/index.vue +8 -3
- package/src/utils/validateObjectStructure.ts +47 -0
|
@@ -7,7 +7,7 @@ import { u as C } from "./index.js";
|
|
|
7
7
|
import { d as Ue, p as Ee, e as Ce } from "./ziyuanjiekou-BC65-bFK.js";
|
|
8
8
|
import { D as Te, b as Ae } from "./enum-DkSNwGbC.js";
|
|
9
9
|
import { r as D, A as I, R as Me } from "./enum-D5iPiZiT.js";
|
|
10
|
-
import { u as Oe, M as Ve, d as Le } from "./MetaForm-
|
|
10
|
+
import { u as Oe, M as Ve, d as Le } from "./MetaForm-BMPtZc0g.js";
|
|
11
11
|
import { _ as xe } from "./DynamicRoutesForm.vue_vue_type_script_setup_true_lang-bEqJ03T_.js";
|
|
12
12
|
import { _ as ke } from "./IconSelect.vue_vue_type_script_setup_true_lang-D450SiKg.js";
|
|
13
13
|
import we from "./LayoutForm-Pv6UyKl3.js";
|
|
@@ -7,7 +7,7 @@ import { useAuth as j, PubinfoIcon as I, RESOURCE_TYPE as T } from "pubinfo";
|
|
|
7
7
|
import "./index.js";
|
|
8
8
|
import { b as G, c as J } from "./ziyuanjiekou-BC65-bFK.js";
|
|
9
9
|
import { _ as Q } from "./ImportExport.vue_vue_type_script_setup_true_lang-CV0DrMvw.js";
|
|
10
|
-
import { _ as W } from "./ResourceEdit.vue_vue_type_script_setup_true_lang-
|
|
10
|
+
import { _ as W } from "./ResourceEdit.vue_vue_type_script_setup_true_lang-IWn27Vz1.js";
|
|
11
11
|
import { _ as Z } from "./RoleRelation.vue_vue_type_script_setup_true_lang-BjEOlM2g.js";
|
|
12
12
|
import { r as L, A as t, R as ee } from "./enum-D5iPiZiT.js";
|
|
13
13
|
import { c as te } from "./cloneDeep-BOLZdR62.js";
|
package/dist/index.js
CHANGED
|
@@ -75,7 +75,7 @@ import './index17.css';const wa = {
|
|
|
75
75
|
"src/views/page_w_setting/index.vue": () => import("./index-XhYtVVT9.js"),
|
|
76
76
|
"src/views/position/index.vue": () => import("./index-iBmBJd50.js"),
|
|
77
77
|
"src/views/region/index.vue": () => import("./index-BhZNbJp6.js"),
|
|
78
|
-
"src/views/resource/index.vue": () => import("./index-
|
|
78
|
+
"src/views/resource/index.vue": () => import("./index-DQhQqT_Z.js"),
|
|
79
79
|
"src/views/role/index.vue": () => import("./index-ChWnVs6j.js"),
|
|
80
80
|
"src/views/role_group/index.vue": () => import("./index-CJQB8KAz.js"),
|
|
81
81
|
"src/views/safe_setting/index.vue": () => import("./index-VZuizuKs.js"),
|
|
@@ -103,8 +103,8 @@ import './index17.css';const wa = {
|
|
|
103
103
|
"src/views/resource/components/IconSelect.vue": () => import("./IconSelect-DtNpk3Rj.js"),
|
|
104
104
|
"src/views/resource/components/ImportExport.vue": () => import("./ImportExport-DAe_Sl13.js"),
|
|
105
105
|
"src/views/resource/components/LayoutForm.vue": () => import("./LayoutForm-Pv6UyKl3.js"),
|
|
106
|
-
"src/views/resource/components/MetaForm.vue": () => import("./MetaForm-
|
|
107
|
-
"src/views/resource/components/ResourceEdit.vue": () => import("./ResourceEdit-
|
|
106
|
+
"src/views/resource/components/MetaForm.vue": () => import("./MetaForm-BMPtZc0g.js").then((e) => e.a),
|
|
107
|
+
"src/views/resource/components/ResourceEdit.vue": () => import("./ResourceEdit-D59JUDvG.js"),
|
|
108
108
|
"src/views/resource/components/RoleRelation.vue": () => import("./RoleRelation-BuqK0cnl.js"),
|
|
109
109
|
"src/views/role/components/ResourceRelation.vue": () => import("./ResourceRelation-qhIdXLAy.js"),
|
|
110
110
|
"src/views/role/components/drawerRole.vue": () => import("./drawerRole-CfJjf3v_.js"),
|
|
@@ -1455,7 +1455,7 @@ const Qd = {
|
|
|
1455
1455
|
children: [
|
|
1456
1456
|
{
|
|
1457
1457
|
path: "resource",
|
|
1458
|
-
component: () => import("./index-
|
|
1458
|
+
component: () => import("./index-DQhQqT_Z.js"),
|
|
1459
1459
|
name: "Resource",
|
|
1460
1460
|
meta: {
|
|
1461
1461
|
title: "资源管理",
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface ValidateOptions {
|
|
2
|
+
/** 允许的最大嵌套层级(含根层) */
|
|
3
|
+
maxDepth?: number;
|
|
4
|
+
/** 每一层最多 key 数 */
|
|
5
|
+
maxKeysPerLevel?: number;
|
|
6
|
+
}
|
|
7
|
+
export interface ValidateResult {
|
|
8
|
+
valid: boolean;
|
|
9
|
+
errors: string[];
|
|
10
|
+
}
|
|
11
|
+
export declare function validateObjectStructure(obj: any, options?: ValidateOptions): ValidateResult;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pubinfo/module-rbac",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.1.
|
|
4
|
+
"version": "2.1.2",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"@pubinfo/pro-components": "^1.8.0",
|
|
25
25
|
"alova": "^3.3.4",
|
|
26
26
|
"ant-design-vue": "^4.2.6",
|
|
27
|
-
"pubinfo": "2.1.
|
|
27
|
+
"pubinfo": "2.1.2"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@destyler/color-picker": "^0.1.0",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"alova": "^3.3.4",
|
|
50
50
|
"ant-design-vue": "^4.2.6",
|
|
51
51
|
"type-fest": "^4.41.0",
|
|
52
|
-
"pubinfo": "2.1.
|
|
52
|
+
"pubinfo": "2.1.2"
|
|
53
53
|
},
|
|
54
54
|
"scripts": {
|
|
55
55
|
"dev": "pubinfo build -w --sourcemap",
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { useToggle } from '@vueuse/core';
|
|
3
3
|
import { message } from 'ant-design-vue';
|
|
4
4
|
import JsonEditorVue from 'json-editor-vue';
|
|
5
|
+
import { validateObjectStructure } from '@/utils/validateObjectStructure';
|
|
5
6
|
|
|
6
7
|
defineOptions({
|
|
7
8
|
name: 'JsonEditorModal',
|
|
@@ -20,10 +21,14 @@ watchEffect(() => {
|
|
|
20
21
|
function onFinish() {
|
|
21
22
|
try {
|
|
22
23
|
const parseValue = JSON.parse(inputValue.value);
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
const { valid, errors } = validateObjectStructure(parseValue, { maxDepth: 2, maxKeysPerLevel: 8 });
|
|
25
|
+
if (!valid || !parseValue) {
|
|
26
|
+
message.info(errors[0]);
|
|
27
|
+
return;
|
|
26
28
|
}
|
|
29
|
+
|
|
30
|
+
modelValue.value = parseValue;
|
|
31
|
+
toggle(false);
|
|
27
32
|
}
|
|
28
33
|
catch (_) {
|
|
29
34
|
message.info('JSON数据格式错误');
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export interface ValidateOptions {
|
|
2
|
+
/** 允许的最大嵌套层级(含根层) */
|
|
3
|
+
maxDepth?: number
|
|
4
|
+
/** 每一层最多 key 数 */
|
|
5
|
+
maxKeysPerLevel?: number
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface ValidateResult {
|
|
9
|
+
valid: boolean
|
|
10
|
+
errors: string[]
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function validateObjectStructure(
|
|
14
|
+
obj: any,
|
|
15
|
+
options: ValidateOptions = {},
|
|
16
|
+
): ValidateResult {
|
|
17
|
+
const { maxDepth = 3, maxKeysPerLevel = 10 } = options;
|
|
18
|
+
const errors: string[] = [];
|
|
19
|
+
|
|
20
|
+
function traverse(value: any, depth: number, path: string) {
|
|
21
|
+
if (depth > maxDepth) {
|
|
22
|
+
errors.push(`对象嵌套层级超过限制,最大允许 ${maxDepth} 层。问题位置: ${path}`);
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (value && typeof value === 'object' && !Array.isArray(value)) {
|
|
27
|
+
const keys = Object.keys(value);
|
|
28
|
+
|
|
29
|
+
if (keys.length > maxKeysPerLevel) {
|
|
30
|
+
errors.push(
|
|
31
|
+
`对象包含过多字段(${keys.length} 个),最大允许 ${maxKeysPerLevel} 个。位置: ${path}`,
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
keys.forEach((key) => {
|
|
36
|
+
traverse(value[key], depth + 1, `${path}.${key}`);
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
traverse(obj, 1, 'root');
|
|
42
|
+
|
|
43
|
+
return {
|
|
44
|
+
valid: errors.length === 0,
|
|
45
|
+
errors,
|
|
46
|
+
};
|
|
47
|
+
}
|