com-angel-authorization 1.0.6 → 1.0.7

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.
@@ -402,6 +402,79 @@ declare const MenuManager: vue.DefineComponent<vue.ExtractPropTypes<{
402
402
  pageSize: string;
403
403
  }, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
404
404
 
405
+ type SystemAdminMenuKey = 'menu' | 'resource';
406
+ type SystemAdminSubMenu = {
407
+ key: SystemAdminMenuKey;
408
+ label: string;
409
+ };
410
+ type SystemAdminMenuGroup = {
411
+ key: 'system';
412
+ label: string;
413
+ children: SystemAdminSubMenu[];
414
+ };
415
+ /** 系统管理菜单结构:菜单管理、权限点管理为其子菜单 */
416
+ declare const SYSTEM_ADMIN_MENU: SystemAdminMenuGroup;
417
+ declare const SYSTEM_ADMIN_DEFAULT_KEY: SystemAdminMenuKey;
418
+
419
+ /**
420
+ * 系统管理:侧栏父菜单「系统管理」,子菜单为「菜单管理」「权限点管理」。
421
+ */
422
+ declare const SystemAdmin: vue.DefineComponent<vue.ExtractPropTypes<{
423
+ menuApi: {
424
+ type: PropType<MenuResourceApi>;
425
+ required: true;
426
+ };
427
+ resourceApi: {
428
+ type: PropType<AuthorizationResourceApi>;
429
+ required: true;
430
+ };
431
+ defaultActiveKey: {
432
+ type: PropType<SystemAdminMenuKey>;
433
+ default: SystemAdminMenuKey;
434
+ };
435
+ activeKey: {
436
+ type: PropType<SystemAdminMenuKey>;
437
+ default: undefined;
438
+ };
439
+ title: {
440
+ type: StringConstructor;
441
+ default: string;
442
+ };
443
+ }>, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
444
+ [key: string]: any;
445
+ }>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {
446
+ 'update:activeKey': (_key: SystemAdminMenuKey) => true;
447
+ activeKeyChange: (_key: SystemAdminMenuKey) => true;
448
+ }, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
449
+ menuApi: {
450
+ type: PropType<MenuResourceApi>;
451
+ required: true;
452
+ };
453
+ resourceApi: {
454
+ type: PropType<AuthorizationResourceApi>;
455
+ required: true;
456
+ };
457
+ defaultActiveKey: {
458
+ type: PropType<SystemAdminMenuKey>;
459
+ default: SystemAdminMenuKey;
460
+ };
461
+ activeKey: {
462
+ type: PropType<SystemAdminMenuKey>;
463
+ default: undefined;
464
+ };
465
+ title: {
466
+ type: StringConstructor;
467
+ default: string;
468
+ };
469
+ }>> & Readonly<{
470
+ "onUpdate:activeKey"?: ((_key: SystemAdminMenuKey) => any) | undefined;
471
+ onActiveKeyChange?: ((_key: SystemAdminMenuKey) => any) | undefined;
472
+ }>, {
473
+ title: string;
474
+ defaultActiveKey: SystemAdminMenuKey;
475
+ activeKey: SystemAdminMenuKey;
476
+ }, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
477
+
405
478
  interface SnowyflakeOptions {
406
479
  epoch?: bigint;
407
480
  workerId?: bigint;
@@ -432,4 +505,4 @@ declare const snowyflake: ConfigurableSnowflake;
432
505
  declare function getAppClientId(): string;
433
506
  declare function getDeviceWorkerId(): string;
434
507
 
435
- export { type ApiResourceType, type AuthorizationResource, type AuthorizationResourceApi, type AuthorizationResourceFormValues, type AuthorizationResourceListResult, Can, type CheckOptions, type CreateAuthorizationResourceBody, type CreateDefaultResourceRequestOptions, type CreateMenuResourceBody, type FetchAuthorizationResourcesParams, type FetchMenuResourcesParams, type HttpMethod, type ListPaginationParams, type ListPaginationResult, MENU_LIST_TYPE_PARAM, MENU_TYPE_BUTTON, MENU_TYPE_LABEL, MENU_TYPE_MENU, MENU_TYPE_OPTIONS, MENU_TYPE_PAGE, MENU_VISIBILITY_OPTIONS, type MatchMode, MenuManager, type MenuResource, type MenuResourceApi, type MenuResourceFormValues, type MenuResourceListResult, type MenuResourceType, PERMISSION_STORE_KEY, type PageDirection, type PermissionChecker, type PermissionCode, type PermissionDirectiveValue, type PermissionListener, type PermissionPluginOptions, type PermissionState, PermissionStore, RESOURCE_PRIVATE_OPTIONS, RESOURCE_STATUS_DISABLED, RESOURCE_STATUS_ENABLED, RESOURCE_STATUS_OPTIONS, RESOURCE_TYPE_API, ROOT_PARENT_ID, type ResourceHttpRequest, ResourceManager, type ResourceRequestOptions, type ResourceStatus, type ResourceType, type RoleCode, type UpdateAuthorizationResourceBody, type UpdateMenuResourceBody, type UsePermissionResult, appendQueryParam, buildCreateBody, buildCreateMenuBody, buildUpdateBody, buildUpdateMenuBody, createAuthorizationResourceApi, createDefaultResourceRequest, createMenuResourceApi, createPermissionPlugin, createPermissionStore, createVPermission, extractPagination, extractRecords, getAppClientId, getDeviceWorkerId, mapAuthorizationResource, mapMenuResource, snowyflake, useHasPermission, useHasRole, usePermission };
508
+ export { type ApiResourceType, type AuthorizationResource, type AuthorizationResourceApi, type AuthorizationResourceFormValues, type AuthorizationResourceListResult, Can, type CheckOptions, type CreateAuthorizationResourceBody, type CreateDefaultResourceRequestOptions, type CreateMenuResourceBody, type FetchAuthorizationResourcesParams, type FetchMenuResourcesParams, type HttpMethod, type ListPaginationParams, type ListPaginationResult, MENU_LIST_TYPE_PARAM, MENU_TYPE_BUTTON, MENU_TYPE_LABEL, MENU_TYPE_MENU, MENU_TYPE_OPTIONS, MENU_TYPE_PAGE, MENU_VISIBILITY_OPTIONS, type MatchMode, MenuManager, type MenuResource, type MenuResourceApi, type MenuResourceFormValues, type MenuResourceListResult, type MenuResourceType, PERMISSION_STORE_KEY, type PageDirection, type PermissionChecker, type PermissionCode, type PermissionDirectiveValue, type PermissionListener, type PermissionPluginOptions, type PermissionState, PermissionStore, RESOURCE_PRIVATE_OPTIONS, RESOURCE_STATUS_DISABLED, RESOURCE_STATUS_ENABLED, RESOURCE_STATUS_OPTIONS, RESOURCE_TYPE_API, ROOT_PARENT_ID, type ResourceHttpRequest, ResourceManager, type ResourceRequestOptions, type ResourceStatus, type ResourceType, type RoleCode, SYSTEM_ADMIN_DEFAULT_KEY, SYSTEM_ADMIN_MENU, SystemAdmin, type SystemAdminMenuGroup, type SystemAdminMenuKey, type SystemAdminSubMenu, type UpdateAuthorizationResourceBody, type UpdateMenuResourceBody, type UsePermissionResult, appendQueryParam, buildCreateBody, buildCreateMenuBody, buildUpdateBody, buildUpdateMenuBody, createAuthorizationResourceApi, createDefaultResourceRequest, createMenuResourceApi, createPermissionPlugin, createPermissionStore, createVPermission, extractPagination, extractRecords, getAppClientId, getDeviceWorkerId, mapAuthorizationResource, mapMenuResource, snowyflake, useHasPermission, useHasRole, usePermission };
@@ -402,6 +402,79 @@ declare const MenuManager: vue.DefineComponent<vue.ExtractPropTypes<{
402
402
  pageSize: string;
403
403
  }, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
404
404
 
405
+ type SystemAdminMenuKey = 'menu' | 'resource';
406
+ type SystemAdminSubMenu = {
407
+ key: SystemAdminMenuKey;
408
+ label: string;
409
+ };
410
+ type SystemAdminMenuGroup = {
411
+ key: 'system';
412
+ label: string;
413
+ children: SystemAdminSubMenu[];
414
+ };
415
+ /** 系统管理菜单结构:菜单管理、权限点管理为其子菜单 */
416
+ declare const SYSTEM_ADMIN_MENU: SystemAdminMenuGroup;
417
+ declare const SYSTEM_ADMIN_DEFAULT_KEY: SystemAdminMenuKey;
418
+
419
+ /**
420
+ * 系统管理:侧栏父菜单「系统管理」,子菜单为「菜单管理」「权限点管理」。
421
+ */
422
+ declare const SystemAdmin: vue.DefineComponent<vue.ExtractPropTypes<{
423
+ menuApi: {
424
+ type: PropType<MenuResourceApi>;
425
+ required: true;
426
+ };
427
+ resourceApi: {
428
+ type: PropType<AuthorizationResourceApi>;
429
+ required: true;
430
+ };
431
+ defaultActiveKey: {
432
+ type: PropType<SystemAdminMenuKey>;
433
+ default: SystemAdminMenuKey;
434
+ };
435
+ activeKey: {
436
+ type: PropType<SystemAdminMenuKey>;
437
+ default: undefined;
438
+ };
439
+ title: {
440
+ type: StringConstructor;
441
+ default: string;
442
+ };
443
+ }>, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
444
+ [key: string]: any;
445
+ }>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {
446
+ 'update:activeKey': (_key: SystemAdminMenuKey) => true;
447
+ activeKeyChange: (_key: SystemAdminMenuKey) => true;
448
+ }, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
449
+ menuApi: {
450
+ type: PropType<MenuResourceApi>;
451
+ required: true;
452
+ };
453
+ resourceApi: {
454
+ type: PropType<AuthorizationResourceApi>;
455
+ required: true;
456
+ };
457
+ defaultActiveKey: {
458
+ type: PropType<SystemAdminMenuKey>;
459
+ default: SystemAdminMenuKey;
460
+ };
461
+ activeKey: {
462
+ type: PropType<SystemAdminMenuKey>;
463
+ default: undefined;
464
+ };
465
+ title: {
466
+ type: StringConstructor;
467
+ default: string;
468
+ };
469
+ }>> & Readonly<{
470
+ "onUpdate:activeKey"?: ((_key: SystemAdminMenuKey) => any) | undefined;
471
+ onActiveKeyChange?: ((_key: SystemAdminMenuKey) => any) | undefined;
472
+ }>, {
473
+ title: string;
474
+ defaultActiveKey: SystemAdminMenuKey;
475
+ activeKey: SystemAdminMenuKey;
476
+ }, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
477
+
405
478
  interface SnowyflakeOptions {
406
479
  epoch?: bigint;
407
480
  workerId?: bigint;
@@ -432,4 +505,4 @@ declare const snowyflake: ConfigurableSnowflake;
432
505
  declare function getAppClientId(): string;
433
506
  declare function getDeviceWorkerId(): string;
434
507
 
435
- export { type ApiResourceType, type AuthorizationResource, type AuthorizationResourceApi, type AuthorizationResourceFormValues, type AuthorizationResourceListResult, Can, type CheckOptions, type CreateAuthorizationResourceBody, type CreateDefaultResourceRequestOptions, type CreateMenuResourceBody, type FetchAuthorizationResourcesParams, type FetchMenuResourcesParams, type HttpMethod, type ListPaginationParams, type ListPaginationResult, MENU_LIST_TYPE_PARAM, MENU_TYPE_BUTTON, MENU_TYPE_LABEL, MENU_TYPE_MENU, MENU_TYPE_OPTIONS, MENU_TYPE_PAGE, MENU_VISIBILITY_OPTIONS, type MatchMode, MenuManager, type MenuResource, type MenuResourceApi, type MenuResourceFormValues, type MenuResourceListResult, type MenuResourceType, PERMISSION_STORE_KEY, type PageDirection, type PermissionChecker, type PermissionCode, type PermissionDirectiveValue, type PermissionListener, type PermissionPluginOptions, type PermissionState, PermissionStore, RESOURCE_PRIVATE_OPTIONS, RESOURCE_STATUS_DISABLED, RESOURCE_STATUS_ENABLED, RESOURCE_STATUS_OPTIONS, RESOURCE_TYPE_API, ROOT_PARENT_ID, type ResourceHttpRequest, ResourceManager, type ResourceRequestOptions, type ResourceStatus, type ResourceType, type RoleCode, type UpdateAuthorizationResourceBody, type UpdateMenuResourceBody, type UsePermissionResult, appendQueryParam, buildCreateBody, buildCreateMenuBody, buildUpdateBody, buildUpdateMenuBody, createAuthorizationResourceApi, createDefaultResourceRequest, createMenuResourceApi, createPermissionPlugin, createPermissionStore, createVPermission, extractPagination, extractRecords, getAppClientId, getDeviceWorkerId, mapAuthorizationResource, mapMenuResource, snowyflake, useHasPermission, useHasRole, usePermission };
508
+ export { type ApiResourceType, type AuthorizationResource, type AuthorizationResourceApi, type AuthorizationResourceFormValues, type AuthorizationResourceListResult, Can, type CheckOptions, type CreateAuthorizationResourceBody, type CreateDefaultResourceRequestOptions, type CreateMenuResourceBody, type FetchAuthorizationResourcesParams, type FetchMenuResourcesParams, type HttpMethod, type ListPaginationParams, type ListPaginationResult, MENU_LIST_TYPE_PARAM, MENU_TYPE_BUTTON, MENU_TYPE_LABEL, MENU_TYPE_MENU, MENU_TYPE_OPTIONS, MENU_TYPE_PAGE, MENU_VISIBILITY_OPTIONS, type MatchMode, MenuManager, type MenuResource, type MenuResourceApi, type MenuResourceFormValues, type MenuResourceListResult, type MenuResourceType, PERMISSION_STORE_KEY, type PageDirection, type PermissionChecker, type PermissionCode, type PermissionDirectiveValue, type PermissionListener, type PermissionPluginOptions, type PermissionState, PermissionStore, RESOURCE_PRIVATE_OPTIONS, RESOURCE_STATUS_DISABLED, RESOURCE_STATUS_ENABLED, RESOURCE_STATUS_OPTIONS, RESOURCE_TYPE_API, ROOT_PARENT_ID, type ResourceHttpRequest, ResourceManager, type ResourceRequestOptions, type ResourceStatus, type ResourceType, type RoleCode, SYSTEM_ADMIN_DEFAULT_KEY, SYSTEM_ADMIN_MENU, SystemAdmin, type SystemAdminMenuGroup, type SystemAdminMenuKey, type SystemAdminSubMenu, type UpdateAuthorizationResourceBody, type UpdateMenuResourceBody, type UsePermissionResult, appendQueryParam, buildCreateBody, buildCreateMenuBody, buildUpdateBody, buildUpdateMenuBody, createAuthorizationResourceApi, createDefaultResourceRequest, createMenuResourceApi, createPermissionPlugin, createPermissionStore, createVPermission, extractPagination, extractRecords, getAppClientId, getDeviceWorkerId, mapAuthorizationResource, mapMenuResource, snowyflake, useHasPermission, useHasRole, usePermission };
package/dist/vue/index.js CHANGED
@@ -495,7 +495,7 @@ function toStringArray(value) {
495
495
  }).filter(Boolean);
496
496
  }
497
497
  if (typeof value === "string" && value.trim()) {
498
- return value.split(",").map((s3) => s3.trim()).filter(Boolean);
498
+ return value.split(",").map((s4) => s4.trim()).filter(Boolean);
499
499
  }
500
500
  return [];
501
501
  }
@@ -2174,6 +2174,186 @@ var MenuManager = defineComponent3({
2174
2174
  ]);
2175
2175
  }
2176
2176
  });
2177
+
2178
+ // src/vue/SystemAdmin.ts
2179
+ import { computed as computed4, defineComponent as defineComponent4, h as h3, ref as ref3, watch as watch3 } from "vue";
2180
+
2181
+ // src/admin/menu.ts
2182
+ var SYSTEM_ADMIN_MENU = {
2183
+ key: "system",
2184
+ label: "\u7CFB\u7EDF\u7BA1\u7406",
2185
+ children: [
2186
+ { key: "menu", label: "\u83DC\u5355\u7BA1\u7406" },
2187
+ { key: "resource", label: "\u6743\u9650\u70B9\u7BA1\u7406" }
2188
+ ]
2189
+ };
2190
+ var SYSTEM_ADMIN_DEFAULT_KEY = "menu";
2191
+
2192
+ // src/vue/SystemAdmin.ts
2193
+ var s3 = {
2194
+ root: {
2195
+ display: "flex",
2196
+ minHeight: "560px",
2197
+ border: "1px solid #eaecf0",
2198
+ borderRadius: "12px",
2199
+ overflow: "hidden",
2200
+ background: "#fff",
2201
+ fontFamily: '"PingFang SC", "Microsoft YaHei", -apple-system, BlinkMacSystemFont, sans-serif',
2202
+ color: "#101828"
2203
+ },
2204
+ sidebar: {
2205
+ width: "200px",
2206
+ flexShrink: "0",
2207
+ borderRight: "1px solid #eaecf0",
2208
+ background: "#f9fafb",
2209
+ padding: "16px 12px"
2210
+ },
2211
+ sidebarTitle: {
2212
+ fontSize: "14px",
2213
+ fontWeight: "600",
2214
+ color: "#344054",
2215
+ padding: "4px 10px 12px"
2216
+ },
2217
+ nav: {
2218
+ display: "flex",
2219
+ flexDirection: "column",
2220
+ gap: "4px"
2221
+ },
2222
+ navItem: {
2223
+ border: "none",
2224
+ background: "transparent",
2225
+ textAlign: "left",
2226
+ padding: "10px 12px",
2227
+ borderRadius: "8px",
2228
+ fontSize: "14px",
2229
+ color: "#475467",
2230
+ cursor: "pointer"
2231
+ },
2232
+ navItemActive: {
2233
+ background: "#e6f7f9",
2234
+ color: "#049BAD",
2235
+ fontWeight: "600"
2236
+ },
2237
+ content: {
2238
+ flex: "1",
2239
+ minWidth: "0",
2240
+ display: "flex",
2241
+ flexDirection: "column",
2242
+ background: "#fff"
2243
+ },
2244
+ contentHeader: {
2245
+ display: "flex",
2246
+ alignItems: "center",
2247
+ justifyContent: "space-between",
2248
+ gap: "12px",
2249
+ padding: "12px 16px",
2250
+ borderBottom: "1px solid #f2f4f7"
2251
+ },
2252
+ breadcrumb: {
2253
+ display: "flex",
2254
+ alignItems: "center",
2255
+ gap: "8px",
2256
+ fontSize: "13px"
2257
+ },
2258
+ breadcrumbParent: { color: "#98a2b3" },
2259
+ breadcrumbSep: { color: "#d0d5dd" },
2260
+ breadcrumbCurrent: { color: "#344054", fontWeight: "600" },
2261
+ panel: {
2262
+ flex: "1",
2263
+ minHeight: "0",
2264
+ overflow: "auto"
2265
+ }
2266
+ };
2267
+ var SystemAdmin = defineComponent4({
2268
+ name: "SystemAdmin",
2269
+ props: {
2270
+ menuApi: {
2271
+ type: Object,
2272
+ required: true
2273
+ },
2274
+ resourceApi: {
2275
+ type: Object,
2276
+ required: true
2277
+ },
2278
+ defaultActiveKey: {
2279
+ type: String,
2280
+ default: SYSTEM_ADMIN_DEFAULT_KEY
2281
+ },
2282
+ activeKey: {
2283
+ type: String,
2284
+ default: void 0
2285
+ },
2286
+ title: {
2287
+ type: String,
2288
+ default: SYSTEM_ADMIN_MENU.label
2289
+ }
2290
+ },
2291
+ emits: {
2292
+ "update:activeKey": (_key) => true,
2293
+ activeKeyChange: (_key) => true
2294
+ },
2295
+ setup(props, { emit, slots }) {
2296
+ const innerKey = ref3(props.defaultActiveKey);
2297
+ watch3(
2298
+ () => props.defaultActiveKey,
2299
+ (value) => {
2300
+ if (props.activeKey === void 0) innerKey.value = value;
2301
+ }
2302
+ );
2303
+ const activeKey = computed4(
2304
+ () => props.activeKey ?? innerKey.value
2305
+ );
2306
+ const activeLabel = computed4(
2307
+ () => SYSTEM_ADMIN_MENU.children.find((item) => item.key === activeKey.value)?.label ?? ""
2308
+ );
2309
+ function setActiveKey(key) {
2310
+ if (props.activeKey === void 0) innerKey.value = key;
2311
+ emit("update:activeKey", key);
2312
+ emit("activeKeyChange", key);
2313
+ }
2314
+ return () => h3("div", { style: s3.root }, [
2315
+ h3("aside", { style: s3.sidebar }, [
2316
+ h3("div", { style: s3.sidebarTitle }, props.title),
2317
+ h3(
2318
+ "nav",
2319
+ { style: s3.nav },
2320
+ SYSTEM_ADMIN_MENU.children.map((item) => {
2321
+ const active = item.key === activeKey.value;
2322
+ return h3(
2323
+ "button",
2324
+ {
2325
+ key: item.key,
2326
+ type: "button",
2327
+ style: {
2328
+ ...s3.navItem,
2329
+ ...active ? s3.navItemActive : {}
2330
+ },
2331
+ onClick: () => setActiveKey(item.key)
2332
+ },
2333
+ item.label
2334
+ );
2335
+ })
2336
+ )
2337
+ ]),
2338
+ h3("main", { style: s3.content }, [
2339
+ h3("div", { style: s3.contentHeader }, [
2340
+ h3("div", { style: s3.breadcrumb }, [
2341
+ h3("span", { style: s3.breadcrumbParent }, props.title),
2342
+ h3("span", { style: s3.breadcrumbSep }, "/"),
2343
+ h3("span", { style: s3.breadcrumbCurrent }, activeLabel.value)
2344
+ ]),
2345
+ slots.toolbarExtra?.()
2346
+ ]),
2347
+ h3("div", { style: s3.panel }, [
2348
+ activeKey.value === "menu" ? h3(MenuManager, { api: props.menuApi, title: "\u83DC\u5355\u7BA1\u7406" }) : h3(ResourceManager, {
2349
+ api: props.resourceApi,
2350
+ title: "\u6743\u9650\u70B9\u7BA1\u7406"
2351
+ })
2352
+ ])
2353
+ ])
2354
+ ]);
2355
+ }
2356
+ });
2177
2357
  export {
2178
2358
  Can,
2179
2359
  MENU_LIST_TYPE_PARAM,
@@ -2193,6 +2373,9 @@ export {
2193
2373
  RESOURCE_TYPE_API,
2194
2374
  ROOT_PARENT_ID,
2195
2375
  ResourceManager,
2376
+ SYSTEM_ADMIN_DEFAULT_KEY,
2377
+ SYSTEM_ADMIN_MENU,
2378
+ SystemAdmin,
2196
2379
  appendQueryParam,
2197
2380
  buildCreateBody,
2198
2381
  buildCreateMenuBody,