com-angel-authorization 1.0.7 → 1.0.8

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.
@@ -168,7 +168,8 @@ type AuthorizationResourceListResult = {
168
168
  };
169
169
  type MenuResource = {
170
170
  resourceId: string;
171
- parentId: string;
171
+ /** 上级菜单 ID;无上级时为 null */
172
+ parentId: string | null;
172
173
  type: MenuResourceType;
173
174
  name: string;
174
175
  identification: string;
@@ -178,7 +179,8 @@ type MenuResource = {
178
179
  status: ResourceStatus;
179
180
  };
180
181
  type MenuResourceFormValues = {
181
- parentId: string;
182
+ /** 上级菜单 ID;选择「无」时为 null */
183
+ parentId: string | null;
182
184
  type: MenuResourceType;
183
185
  name: string;
184
186
  identification: string;
@@ -204,7 +206,11 @@ declare const MENU_TYPE_MENU: MenuResourceType;
204
206
  declare const MENU_TYPE_BUTTON: MenuResourceType;
205
207
  /** 菜单列表查询 type 参数 */
206
208
  declare const MENU_LIST_TYPE_PARAM = "page,menu,button";
207
- declare const ROOT_PARENT_ID = "0";
209
+ /**
210
+ * 上级菜单选择「无」时,表单 select 使用的空值。
211
+ * 提交接口时会转换为 parentId: null。
212
+ */
213
+ declare const ROOT_PARENT_ID = "";
208
214
  declare const RESOURCE_STATUS_ENABLED: ResourceStatus;
209
215
  declare const RESOURCE_STATUS_DISABLED: ResourceStatus;
210
216
  declare const RESOURCE_STATUS_OPTIONS: {
@@ -168,7 +168,8 @@ type AuthorizationResourceListResult = {
168
168
  };
169
169
  type MenuResource = {
170
170
  resourceId: string;
171
- parentId: string;
171
+ /** 上级菜单 ID;无上级时为 null */
172
+ parentId: string | null;
172
173
  type: MenuResourceType;
173
174
  name: string;
174
175
  identification: string;
@@ -178,7 +179,8 @@ type MenuResource = {
178
179
  status: ResourceStatus;
179
180
  };
180
181
  type MenuResourceFormValues = {
181
- parentId: string;
182
+ /** 上级菜单 ID;选择「无」时为 null */
183
+ parentId: string | null;
182
184
  type: MenuResourceType;
183
185
  name: string;
184
186
  identification: string;
@@ -204,7 +206,11 @@ declare const MENU_TYPE_MENU: MenuResourceType;
204
206
  declare const MENU_TYPE_BUTTON: MenuResourceType;
205
207
  /** 菜单列表查询 type 参数 */
206
208
  declare const MENU_LIST_TYPE_PARAM = "page,menu,button";
207
- declare const ROOT_PARENT_ID = "0";
209
+ /**
210
+ * 上级菜单选择「无」时,表单 select 使用的空值。
211
+ * 提交接口时会转换为 parentId: null。
212
+ */
213
+ declare const ROOT_PARENT_ID = "";
208
214
  declare const RESOURCE_STATUS_ENABLED: ResourceStatus;
209
215
  declare const RESOURCE_STATUS_DISABLED: ResourceStatus;
210
216
  declare const RESOURCE_STATUS_OPTIONS: {
@@ -237,7 +237,7 @@ var MENU_TYPE_PAGE = "page";
237
237
  var MENU_TYPE_MENU = "menu";
238
238
  var MENU_TYPE_BUTTON = "button";
239
239
  var MENU_LIST_TYPE_PARAM = "page,menu,button";
240
- var ROOT_PARENT_ID = "0";
240
+ var ROOT_PARENT_ID = "";
241
241
  var RESOURCE_STATUS_ENABLED = 1;
242
242
  var RESOURCE_STATUS_DISABLED = 0;
243
243
  var RESOURCE_STATUS_OPTIONS = [
@@ -454,10 +454,11 @@ function mapMenuResource(item) {
454
454
  );
455
455
  const permissionNamesRaw = row.permissionPointNames ?? row.permission_point_names ?? row.permissionNames;
456
456
  const permissionPointNames = Array.isArray(permissionNamesRaw) ? permissionNamesRaw.map((n) => String(n ?? "")).filter(Boolean) : void 0;
457
- const parentId = row.parentId ?? row.parent_id ?? ROOT_PARENT_ID;
457
+ const rawParentId = row.parentId ?? row.parent_id;
458
+ const parentId = rawParentId === void 0 || rawParentId === null || rawParentId === "" || String(rawParentId) === "0" ? null : String(rawParentId);
458
459
  return {
459
460
  resourceId: String(resourceId),
460
- parentId: parentId === void 0 || parentId === null ? ROOT_PARENT_ID : String(parentId),
461
+ parentId,
461
462
  type: toMenuType(row.type),
462
463
  name: String(row.name ?? ""),
463
464
  identification: String(row.identification ?? row.identity ?? row.path ?? ""),
@@ -498,7 +499,7 @@ function buildUpdateBody(values) {
498
499
  function buildCreateMenuBody(values, resourceId = getAppClientId()) {
499
500
  return {
500
501
  resourceId,
501
- parentId: values.parentId || ROOT_PARENT_ID,
502
+ parentId: values.parentId ? values.parentId : null,
502
503
  type: values.type,
503
504
  name: values.name.trim(),
504
505
  identification: values.identification.trim(),
@@ -508,7 +509,7 @@ function buildCreateMenuBody(values, resourceId = getAppClientId()) {
508
509
  }
509
510
  function buildUpdateMenuBody(values) {
510
511
  return {
511
- parentId: values.parentId || ROOT_PARENT_ID,
512
+ parentId: values.parentId ? values.parentId : null,
512
513
  type: values.type,
513
514
  name: values.name.trim(),
514
515
  identification: values.identification.trim(),
@@ -1177,7 +1178,7 @@ import {
1177
1178
  import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
1178
1179
  var PAGE_SIZE_OPTIONS2 = ["10", "20", "50", "100"];
1179
1180
  var emptyForm2 = () => ({
1180
- parentId: ROOT_PARENT_ID,
1181
+ parentId: null,
1181
1182
  type: MENU_TYPE_MENU,
1182
1183
  name: "",
1183
1184
  identification: "",
@@ -1261,7 +1262,7 @@ function MenuManager({
1261
1262
  const openEdit = (row) => {
1262
1263
  setEditing(row);
1263
1264
  setForm({
1264
- parentId: row.parentId || ROOT_PARENT_ID,
1265
+ parentId: row.parentId ?? null,
1265
1266
  type: row.type,
1266
1267
  name: row.name,
1267
1268
  identification: row.identification,
@@ -1437,10 +1438,13 @@ function MenuManager({
1437
1438
  "select",
1438
1439
  {
1439
1440
  style: styles2.input,
1440
- value: form.parentId,
1441
- onChange: (e) => setForm((prev) => ({ ...prev, parentId: e.target.value })),
1441
+ value: form.parentId ?? ROOT_PARENT_ID,
1442
+ onChange: (e) => setForm((prev) => ({
1443
+ ...prev,
1444
+ parentId: e.target.value ? e.target.value : null
1445
+ })),
1442
1446
  children: [
1443
- /* @__PURE__ */ jsx3("option", { value: ROOT_PARENT_ID, children: "\u6839\u76EE\u5F55" }),
1447
+ /* @__PURE__ */ jsx3("option", { value: ROOT_PARENT_ID, children: "\u65E0" }),
1444
1448
  parentOptions.map((opt) => /* @__PURE__ */ jsx3("option", { value: opt.value, children: opt.label }, opt.value))
1445
1449
  ]
1446
1450
  }