com-angel-authorization 1.0.6 → 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.
@@ -38,6 +38,9 @@ __export(vue_exports, {
38
38
  RESOURCE_TYPE_API: () => RESOURCE_TYPE_API,
39
39
  ROOT_PARENT_ID: () => ROOT_PARENT_ID,
40
40
  ResourceManager: () => ResourceManager,
41
+ SYSTEM_ADMIN_DEFAULT_KEY: () => SYSTEM_ADMIN_DEFAULT_KEY,
42
+ SYSTEM_ADMIN_MENU: () => SYSTEM_ADMIN_MENU,
43
+ SystemAdmin: () => SystemAdmin,
41
44
  appendQueryParam: () => appendQueryParam,
42
45
  buildCreateBody: () => buildCreateBody,
43
46
  buildCreateMenuBody: () => buildCreateMenuBody,
@@ -366,7 +369,7 @@ var MENU_TYPE_PAGE = "page";
366
369
  var MENU_TYPE_MENU = "menu";
367
370
  var MENU_TYPE_BUTTON = "button";
368
371
  var MENU_LIST_TYPE_PARAM = "page,menu,button";
369
- var ROOT_PARENT_ID = "0";
372
+ var ROOT_PARENT_ID = "";
370
373
  var RESOURCE_STATUS_ENABLED = 1;
371
374
  var RESOURCE_STATUS_DISABLED = 0;
372
375
  var RESOURCE_STATUS_OPTIONS = [
@@ -547,7 +550,7 @@ function toStringArray(value) {
547
550
  }).filter(Boolean);
548
551
  }
549
552
  if (typeof value === "string" && value.trim()) {
550
- return value.split(",").map((s3) => s3.trim()).filter(Boolean);
553
+ return value.split(",").map((s4) => s4.trim()).filter(Boolean);
551
554
  }
552
555
  return [];
553
556
  }
@@ -583,10 +586,11 @@ function mapMenuResource(item) {
583
586
  );
584
587
  const permissionNamesRaw = row.permissionPointNames ?? row.permission_point_names ?? row.permissionNames;
585
588
  const permissionPointNames = Array.isArray(permissionNamesRaw) ? permissionNamesRaw.map((n) => String(n ?? "")).filter(Boolean) : void 0;
586
- const parentId = row.parentId ?? row.parent_id ?? ROOT_PARENT_ID;
589
+ const rawParentId = row.parentId ?? row.parent_id;
590
+ const parentId = rawParentId === void 0 || rawParentId === null || rawParentId === "" || String(rawParentId) === "0" ? null : String(rawParentId);
587
591
  return {
588
592
  resourceId: String(resourceId),
589
- parentId: parentId === void 0 || parentId === null ? ROOT_PARENT_ID : String(parentId),
593
+ parentId,
590
594
  type: toMenuType(row.type),
591
595
  name: String(row.name ?? ""),
592
596
  identification: String(row.identification ?? row.identity ?? row.path ?? ""),
@@ -627,7 +631,7 @@ function buildUpdateBody(values) {
627
631
  function buildCreateMenuBody(values, resourceId = getAppClientId()) {
628
632
  return {
629
633
  resourceId,
630
- parentId: values.parentId || ROOT_PARENT_ID,
634
+ parentId: values.parentId ? values.parentId : null,
631
635
  type: values.type,
632
636
  name: values.name.trim(),
633
637
  identification: values.identification.trim(),
@@ -637,7 +641,7 @@ function buildCreateMenuBody(values, resourceId = getAppClientId()) {
637
641
  }
638
642
  function buildUpdateMenuBody(values) {
639
643
  return {
640
- parentId: values.parentId || ROOT_PARENT_ID,
644
+ parentId: values.parentId ? values.parentId : null,
641
645
  type: values.type,
642
646
  name: values.name.trim(),
643
647
  identification: values.identification.trim(),
@@ -1435,7 +1439,7 @@ var import_vue4 = require("vue");
1435
1439
  var PAGE_SIZE_OPTIONS2 = ["10", "20", "50", "100"];
1436
1440
  function emptyForm2() {
1437
1441
  return {
1438
- parentId: ROOT_PARENT_ID,
1442
+ parentId: null,
1439
1443
  type: MENU_TYPE_MENU,
1440
1444
  name: "",
1441
1445
  identification: "",
@@ -1756,7 +1760,7 @@ var MenuManager = (0, import_vue4.defineComponent)({
1756
1760
  function openEdit(row) {
1757
1761
  editing.value = row;
1758
1762
  Object.assign(form, {
1759
- parentId: row.parentId || ROOT_PARENT_ID,
1763
+ parentId: row.parentId ?? null,
1760
1764
  type: row.type,
1761
1765
  name: row.name,
1762
1766
  identification: row.identification,
@@ -2001,13 +2005,14 @@ var MenuManager = (0, import_vue4.defineComponent)({
2001
2005
  "select",
2002
2006
  {
2003
2007
  style: s2.input,
2004
- value: form.parentId,
2008
+ value: form.parentId ?? ROOT_PARENT_ID,
2005
2009
  onChange: (e) => {
2006
- form.parentId = e.target.value;
2010
+ const value = e.target.value;
2011
+ form.parentId = value ? value : null;
2007
2012
  }
2008
2013
  },
2009
2014
  [
2010
- (0, import_vue4.h)("option", { value: ROOT_PARENT_ID }, "\u6839\u76EE\u5F55"),
2015
+ (0, import_vue4.h)("option", { value: ROOT_PARENT_ID }, "\u65E0"),
2011
2016
  ...parentOptions.value.map(
2012
2017
  (opt) => (0, import_vue4.h)(
2013
2018
  "option",
@@ -2218,6 +2223,186 @@ var MenuManager = (0, import_vue4.defineComponent)({
2218
2223
  ]);
2219
2224
  }
2220
2225
  });
2226
+
2227
+ // src/vue/SystemAdmin.ts
2228
+ var import_vue5 = require("vue");
2229
+
2230
+ // src/admin/menu.ts
2231
+ var SYSTEM_ADMIN_MENU = {
2232
+ key: "system",
2233
+ label: "\u7CFB\u7EDF\u7BA1\u7406",
2234
+ children: [
2235
+ { key: "menu", label: "\u83DC\u5355\u7BA1\u7406" },
2236
+ { key: "resource", label: "\u6743\u9650\u70B9\u7BA1\u7406" }
2237
+ ]
2238
+ };
2239
+ var SYSTEM_ADMIN_DEFAULT_KEY = "menu";
2240
+
2241
+ // src/vue/SystemAdmin.ts
2242
+ var s3 = {
2243
+ root: {
2244
+ display: "flex",
2245
+ minHeight: "560px",
2246
+ border: "1px solid #eaecf0",
2247
+ borderRadius: "12px",
2248
+ overflow: "hidden",
2249
+ background: "#fff",
2250
+ fontFamily: '"PingFang SC", "Microsoft YaHei", -apple-system, BlinkMacSystemFont, sans-serif',
2251
+ color: "#101828"
2252
+ },
2253
+ sidebar: {
2254
+ width: "200px",
2255
+ flexShrink: "0",
2256
+ borderRight: "1px solid #eaecf0",
2257
+ background: "#f9fafb",
2258
+ padding: "16px 12px"
2259
+ },
2260
+ sidebarTitle: {
2261
+ fontSize: "14px",
2262
+ fontWeight: "600",
2263
+ color: "#344054",
2264
+ padding: "4px 10px 12px"
2265
+ },
2266
+ nav: {
2267
+ display: "flex",
2268
+ flexDirection: "column",
2269
+ gap: "4px"
2270
+ },
2271
+ navItem: {
2272
+ border: "none",
2273
+ background: "transparent",
2274
+ textAlign: "left",
2275
+ padding: "10px 12px",
2276
+ borderRadius: "8px",
2277
+ fontSize: "14px",
2278
+ color: "#475467",
2279
+ cursor: "pointer"
2280
+ },
2281
+ navItemActive: {
2282
+ background: "#e6f7f9",
2283
+ color: "#049BAD",
2284
+ fontWeight: "600"
2285
+ },
2286
+ content: {
2287
+ flex: "1",
2288
+ minWidth: "0",
2289
+ display: "flex",
2290
+ flexDirection: "column",
2291
+ background: "#fff"
2292
+ },
2293
+ contentHeader: {
2294
+ display: "flex",
2295
+ alignItems: "center",
2296
+ justifyContent: "space-between",
2297
+ gap: "12px",
2298
+ padding: "12px 16px",
2299
+ borderBottom: "1px solid #f2f4f7"
2300
+ },
2301
+ breadcrumb: {
2302
+ display: "flex",
2303
+ alignItems: "center",
2304
+ gap: "8px",
2305
+ fontSize: "13px"
2306
+ },
2307
+ breadcrumbParent: { color: "#98a2b3" },
2308
+ breadcrumbSep: { color: "#d0d5dd" },
2309
+ breadcrumbCurrent: { color: "#344054", fontWeight: "600" },
2310
+ panel: {
2311
+ flex: "1",
2312
+ minHeight: "0",
2313
+ overflow: "auto"
2314
+ }
2315
+ };
2316
+ var SystemAdmin = (0, import_vue5.defineComponent)({
2317
+ name: "SystemAdmin",
2318
+ props: {
2319
+ menuApi: {
2320
+ type: Object,
2321
+ required: true
2322
+ },
2323
+ resourceApi: {
2324
+ type: Object,
2325
+ required: true
2326
+ },
2327
+ defaultActiveKey: {
2328
+ type: String,
2329
+ default: SYSTEM_ADMIN_DEFAULT_KEY
2330
+ },
2331
+ activeKey: {
2332
+ type: String,
2333
+ default: void 0
2334
+ },
2335
+ title: {
2336
+ type: String,
2337
+ default: SYSTEM_ADMIN_MENU.label
2338
+ }
2339
+ },
2340
+ emits: {
2341
+ "update:activeKey": (_key) => true,
2342
+ activeKeyChange: (_key) => true
2343
+ },
2344
+ setup(props, { emit, slots }) {
2345
+ const innerKey = (0, import_vue5.ref)(props.defaultActiveKey);
2346
+ (0, import_vue5.watch)(
2347
+ () => props.defaultActiveKey,
2348
+ (value) => {
2349
+ if (props.activeKey === void 0) innerKey.value = value;
2350
+ }
2351
+ );
2352
+ const activeKey = (0, import_vue5.computed)(
2353
+ () => props.activeKey ?? innerKey.value
2354
+ );
2355
+ const activeLabel = (0, import_vue5.computed)(
2356
+ () => SYSTEM_ADMIN_MENU.children.find((item) => item.key === activeKey.value)?.label ?? ""
2357
+ );
2358
+ function setActiveKey(key) {
2359
+ if (props.activeKey === void 0) innerKey.value = key;
2360
+ emit("update:activeKey", key);
2361
+ emit("activeKeyChange", key);
2362
+ }
2363
+ return () => (0, import_vue5.h)("div", { style: s3.root }, [
2364
+ (0, import_vue5.h)("aside", { style: s3.sidebar }, [
2365
+ (0, import_vue5.h)("div", { style: s3.sidebarTitle }, props.title),
2366
+ (0, import_vue5.h)(
2367
+ "nav",
2368
+ { style: s3.nav },
2369
+ SYSTEM_ADMIN_MENU.children.map((item) => {
2370
+ const active = item.key === activeKey.value;
2371
+ return (0, import_vue5.h)(
2372
+ "button",
2373
+ {
2374
+ key: item.key,
2375
+ type: "button",
2376
+ style: {
2377
+ ...s3.navItem,
2378
+ ...active ? s3.navItemActive : {}
2379
+ },
2380
+ onClick: () => setActiveKey(item.key)
2381
+ },
2382
+ item.label
2383
+ );
2384
+ })
2385
+ )
2386
+ ]),
2387
+ (0, import_vue5.h)("main", { style: s3.content }, [
2388
+ (0, import_vue5.h)("div", { style: s3.contentHeader }, [
2389
+ (0, import_vue5.h)("div", { style: s3.breadcrumb }, [
2390
+ (0, import_vue5.h)("span", { style: s3.breadcrumbParent }, props.title),
2391
+ (0, import_vue5.h)("span", { style: s3.breadcrumbSep }, "/"),
2392
+ (0, import_vue5.h)("span", { style: s3.breadcrumbCurrent }, activeLabel.value)
2393
+ ]),
2394
+ slots.toolbarExtra?.()
2395
+ ]),
2396
+ (0, import_vue5.h)("div", { style: s3.panel }, [
2397
+ activeKey.value === "menu" ? (0, import_vue5.h)(MenuManager, { api: props.menuApi, title: "\u83DC\u5355\u7BA1\u7406" }) : (0, import_vue5.h)(ResourceManager, {
2398
+ api: props.resourceApi,
2399
+ title: "\u6743\u9650\u70B9\u7BA1\u7406"
2400
+ })
2401
+ ])
2402
+ ])
2403
+ ]);
2404
+ }
2405
+ });
2221
2406
  // Annotate the CommonJS export names for ESM import in node:
2222
2407
  0 && (module.exports = {
2223
2408
  Can,
@@ -2238,6 +2423,9 @@ var MenuManager = (0, import_vue4.defineComponent)({
2238
2423
  RESOURCE_TYPE_API,
2239
2424
  ROOT_PARENT_ID,
2240
2425
  ResourceManager,
2426
+ SYSTEM_ADMIN_DEFAULT_KEY,
2427
+ SYSTEM_ADMIN_MENU,
2428
+ SystemAdmin,
2241
2429
  appendQueryParam,
2242
2430
  buildCreateBody,
2243
2431
  buildCreateMenuBody,