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.
- package/README.md +32 -2
- package/dist/index.cjs +19 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +24 -4
- package/dist/index.d.ts +24 -4
- package/dist/index.js +18 -6
- package/dist/index.js.map +1 -1
- package/dist/react/index.cjs +163 -10
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.d.cts +40 -4
- package/dist/react/index.d.ts +40 -4
- package/dist/react/index.js +160 -10
- package/dist/react/index.js.map +1 -1
- package/dist/vue/index.cjs +199 -11
- package/dist/vue/index.cjs.map +1 -1
- package/dist/vue/index.d.cts +83 -4
- package/dist/vue/index.d.ts +83 -4
- package/dist/vue/index.js +196 -11
- package/dist/vue/index.js.map +1 -1
- package/package.json +1 -1
package/dist/react/index.d.cts
CHANGED
|
@@ -168,7 +168,8 @@ type AuthorizationResourceListResult = {
|
|
|
168
168
|
};
|
|
169
169
|
type MenuResource = {
|
|
170
170
|
resourceId: string;
|
|
171
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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: {
|
|
@@ -293,6 +299,36 @@ type MenuManagerProps = {
|
|
|
293
299
|
};
|
|
294
300
|
declare function MenuManager({ api, title, pageSize: initialPageSize, toolbarExtra, }: MenuManagerProps): react.JSX.Element;
|
|
295
301
|
|
|
302
|
+
type SystemAdminMenuKey = 'menu' | 'resource';
|
|
303
|
+
type SystemAdminSubMenu = {
|
|
304
|
+
key: SystemAdminMenuKey;
|
|
305
|
+
label: string;
|
|
306
|
+
};
|
|
307
|
+
type SystemAdminMenuGroup = {
|
|
308
|
+
key: 'system';
|
|
309
|
+
label: string;
|
|
310
|
+
children: SystemAdminSubMenu[];
|
|
311
|
+
};
|
|
312
|
+
/** 系统管理菜单结构:菜单管理、权限点管理为其子菜单 */
|
|
313
|
+
declare const SYSTEM_ADMIN_MENU: SystemAdminMenuGroup;
|
|
314
|
+
declare const SYSTEM_ADMIN_DEFAULT_KEY: SystemAdminMenuKey;
|
|
315
|
+
|
|
316
|
+
type SystemAdminProps = {
|
|
317
|
+
menuApi: MenuResourceApi;
|
|
318
|
+
resourceApi: AuthorizationResourceApi;
|
|
319
|
+
/** 默认选中的子菜单,默认菜单管理 */
|
|
320
|
+
defaultActiveKey?: SystemAdminMenuKey;
|
|
321
|
+
/** 受控选中 key */
|
|
322
|
+
activeKey?: SystemAdminMenuKey;
|
|
323
|
+
onActiveKeyChange?: (key: SystemAdminMenuKey) => void;
|
|
324
|
+
title?: string;
|
|
325
|
+
toolbarExtra?: ReactNode;
|
|
326
|
+
};
|
|
327
|
+
/**
|
|
328
|
+
* 系统管理:侧栏父菜单「系统管理」,子菜单为「菜单管理」「权限点管理」。
|
|
329
|
+
*/
|
|
330
|
+
declare function SystemAdmin({ menuApi, resourceApi, defaultActiveKey, activeKey: controlledKey, onActiveKeyChange, title, toolbarExtra, }: SystemAdminProps): react.JSX.Element;
|
|
331
|
+
|
|
296
332
|
interface SnowyflakeOptions {
|
|
297
333
|
epoch?: bigint;
|
|
298
334
|
workerId?: bigint;
|
|
@@ -323,4 +359,4 @@ declare const snowyflake: ConfigurableSnowflake;
|
|
|
323
359
|
declare function getAppClientId(): string;
|
|
324
360
|
declare function getDeviceWorkerId(): string;
|
|
325
361
|
|
|
326
|
-
export { type ApiResourceType, type AuthorizationResource, type AuthorizationResourceApi, type AuthorizationResourceFormValues, type AuthorizationResourceListResult, Can, type CanProps, 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 MenuManagerProps, type MenuResource, type MenuResourceApi, type MenuResourceFormValues, type MenuResourceListResult, type MenuResourceType, type PageDirection, type PermissionChecker, type PermissionCode, type PermissionListener, PermissionProvider, type PermissionProviderProps, 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 ResourceManagerProps, type ResourceRequestOptions, type ResourceStatus, type ResourceType, type RoleCode, type UpdateAuthorizationResourceBody, type UpdateMenuResourceBody, type UsePermissionResult, appendQueryParam, buildCreateBody, buildCreateMenuBody, buildUpdateBody, buildUpdateMenuBody, createAuthorizationResourceApi, createDefaultResourceRequest, createMenuResourceApi, createPermissionStore, extractPagination, extractRecords, getAppClientId, getDeviceWorkerId, mapAuthorizationResource, mapMenuResource, snowyflake, useHasPermission, useHasRole, usePermission };
|
|
362
|
+
export { type ApiResourceType, type AuthorizationResource, type AuthorizationResourceApi, type AuthorizationResourceFormValues, type AuthorizationResourceListResult, Can, type CanProps, 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 MenuManagerProps, type MenuResource, type MenuResourceApi, type MenuResourceFormValues, type MenuResourceListResult, type MenuResourceType, type PageDirection, type PermissionChecker, type PermissionCode, type PermissionListener, PermissionProvider, type PermissionProviderProps, 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 ResourceManagerProps, type ResourceRequestOptions, type ResourceStatus, type ResourceType, type RoleCode, SYSTEM_ADMIN_DEFAULT_KEY, SYSTEM_ADMIN_MENU, SystemAdmin, type SystemAdminMenuGroup, type SystemAdminMenuKey, type SystemAdminProps, type SystemAdminSubMenu, type UpdateAuthorizationResourceBody, type UpdateMenuResourceBody, type UsePermissionResult, appendQueryParam, buildCreateBody, buildCreateMenuBody, buildUpdateBody, buildUpdateMenuBody, createAuthorizationResourceApi, createDefaultResourceRequest, createMenuResourceApi, createPermissionStore, extractPagination, extractRecords, getAppClientId, getDeviceWorkerId, mapAuthorizationResource, mapMenuResource, snowyflake, useHasPermission, useHasRole, usePermission };
|
package/dist/react/index.d.ts
CHANGED
|
@@ -168,7 +168,8 @@ type AuthorizationResourceListResult = {
|
|
|
168
168
|
};
|
|
169
169
|
type MenuResource = {
|
|
170
170
|
resourceId: string;
|
|
171
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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: {
|
|
@@ -293,6 +299,36 @@ type MenuManagerProps = {
|
|
|
293
299
|
};
|
|
294
300
|
declare function MenuManager({ api, title, pageSize: initialPageSize, toolbarExtra, }: MenuManagerProps): react.JSX.Element;
|
|
295
301
|
|
|
302
|
+
type SystemAdminMenuKey = 'menu' | 'resource';
|
|
303
|
+
type SystemAdminSubMenu = {
|
|
304
|
+
key: SystemAdminMenuKey;
|
|
305
|
+
label: string;
|
|
306
|
+
};
|
|
307
|
+
type SystemAdminMenuGroup = {
|
|
308
|
+
key: 'system';
|
|
309
|
+
label: string;
|
|
310
|
+
children: SystemAdminSubMenu[];
|
|
311
|
+
};
|
|
312
|
+
/** 系统管理菜单结构:菜单管理、权限点管理为其子菜单 */
|
|
313
|
+
declare const SYSTEM_ADMIN_MENU: SystemAdminMenuGroup;
|
|
314
|
+
declare const SYSTEM_ADMIN_DEFAULT_KEY: SystemAdminMenuKey;
|
|
315
|
+
|
|
316
|
+
type SystemAdminProps = {
|
|
317
|
+
menuApi: MenuResourceApi;
|
|
318
|
+
resourceApi: AuthorizationResourceApi;
|
|
319
|
+
/** 默认选中的子菜单,默认菜单管理 */
|
|
320
|
+
defaultActiveKey?: SystemAdminMenuKey;
|
|
321
|
+
/** 受控选中 key */
|
|
322
|
+
activeKey?: SystemAdminMenuKey;
|
|
323
|
+
onActiveKeyChange?: (key: SystemAdminMenuKey) => void;
|
|
324
|
+
title?: string;
|
|
325
|
+
toolbarExtra?: ReactNode;
|
|
326
|
+
};
|
|
327
|
+
/**
|
|
328
|
+
* 系统管理:侧栏父菜单「系统管理」,子菜单为「菜单管理」「权限点管理」。
|
|
329
|
+
*/
|
|
330
|
+
declare function SystemAdmin({ menuApi, resourceApi, defaultActiveKey, activeKey: controlledKey, onActiveKeyChange, title, toolbarExtra, }: SystemAdminProps): react.JSX.Element;
|
|
331
|
+
|
|
296
332
|
interface SnowyflakeOptions {
|
|
297
333
|
epoch?: bigint;
|
|
298
334
|
workerId?: bigint;
|
|
@@ -323,4 +359,4 @@ declare const snowyflake: ConfigurableSnowflake;
|
|
|
323
359
|
declare function getAppClientId(): string;
|
|
324
360
|
declare function getDeviceWorkerId(): string;
|
|
325
361
|
|
|
326
|
-
export { type ApiResourceType, type AuthorizationResource, type AuthorizationResourceApi, type AuthorizationResourceFormValues, type AuthorizationResourceListResult, Can, type CanProps, 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 MenuManagerProps, type MenuResource, type MenuResourceApi, type MenuResourceFormValues, type MenuResourceListResult, type MenuResourceType, type PageDirection, type PermissionChecker, type PermissionCode, type PermissionListener, PermissionProvider, type PermissionProviderProps, 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 ResourceManagerProps, type ResourceRequestOptions, type ResourceStatus, type ResourceType, type RoleCode, type UpdateAuthorizationResourceBody, type UpdateMenuResourceBody, type UsePermissionResult, appendQueryParam, buildCreateBody, buildCreateMenuBody, buildUpdateBody, buildUpdateMenuBody, createAuthorizationResourceApi, createDefaultResourceRequest, createMenuResourceApi, createPermissionStore, extractPagination, extractRecords, getAppClientId, getDeviceWorkerId, mapAuthorizationResource, mapMenuResource, snowyflake, useHasPermission, useHasRole, usePermission };
|
|
362
|
+
export { type ApiResourceType, type AuthorizationResource, type AuthorizationResourceApi, type AuthorizationResourceFormValues, type AuthorizationResourceListResult, Can, type CanProps, 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 MenuManagerProps, type MenuResource, type MenuResourceApi, type MenuResourceFormValues, type MenuResourceListResult, type MenuResourceType, type PageDirection, type PermissionChecker, type PermissionCode, type PermissionListener, PermissionProvider, type PermissionProviderProps, 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 ResourceManagerProps, type ResourceRequestOptions, type ResourceStatus, type ResourceType, type RoleCode, SYSTEM_ADMIN_DEFAULT_KEY, SYSTEM_ADMIN_MENU, SystemAdmin, type SystemAdminMenuGroup, type SystemAdminMenuKey, type SystemAdminProps, type SystemAdminSubMenu, type UpdateAuthorizationResourceBody, type UpdateMenuResourceBody, type UsePermissionResult, appendQueryParam, buildCreateBody, buildCreateMenuBody, buildUpdateBody, buildUpdateMenuBody, createAuthorizationResourceApi, createDefaultResourceRequest, createMenuResourceApi, createPermissionStore, extractPagination, extractRecords, getAppClientId, getDeviceWorkerId, mapAuthorizationResource, mapMenuResource, snowyflake, useHasPermission, useHasRole, usePermission };
|
package/dist/react/index.js
CHANGED
|
@@ -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 = "
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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:
|
|
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
|
|
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) => ({
|
|
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: "\
|
|
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
|
}
|
|
@@ -1793,6 +1797,149 @@ var styles2 = {
|
|
|
1793
1797
|
paddingTop: 4
|
|
1794
1798
|
}
|
|
1795
1799
|
};
|
|
1800
|
+
|
|
1801
|
+
// src/react/SystemAdmin.tsx
|
|
1802
|
+
import { useMemo as useMemo4, useState as useState4 } from "react";
|
|
1803
|
+
|
|
1804
|
+
// src/admin/menu.ts
|
|
1805
|
+
var SYSTEM_ADMIN_MENU = {
|
|
1806
|
+
key: "system",
|
|
1807
|
+
label: "\u7CFB\u7EDF\u7BA1\u7406",
|
|
1808
|
+
children: [
|
|
1809
|
+
{ key: "menu", label: "\u83DC\u5355\u7BA1\u7406" },
|
|
1810
|
+
{ key: "resource", label: "\u6743\u9650\u70B9\u7BA1\u7406" }
|
|
1811
|
+
]
|
|
1812
|
+
};
|
|
1813
|
+
var SYSTEM_ADMIN_DEFAULT_KEY = "menu";
|
|
1814
|
+
|
|
1815
|
+
// src/react/SystemAdmin.tsx
|
|
1816
|
+
import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
1817
|
+
function SystemAdmin({
|
|
1818
|
+
menuApi,
|
|
1819
|
+
resourceApi,
|
|
1820
|
+
defaultActiveKey = SYSTEM_ADMIN_DEFAULT_KEY,
|
|
1821
|
+
activeKey: controlledKey,
|
|
1822
|
+
onActiveKeyChange,
|
|
1823
|
+
title = SYSTEM_ADMIN_MENU.label,
|
|
1824
|
+
toolbarExtra
|
|
1825
|
+
}) {
|
|
1826
|
+
const [innerKey, setInnerKey] = useState4(defaultActiveKey);
|
|
1827
|
+
const activeKey = controlledKey ?? innerKey;
|
|
1828
|
+
const setActiveKey = (key) => {
|
|
1829
|
+
if (controlledKey === void 0) setInnerKey(key);
|
|
1830
|
+
onActiveKeyChange?.(key);
|
|
1831
|
+
};
|
|
1832
|
+
const activeLabel = useMemo4(
|
|
1833
|
+
() => SYSTEM_ADMIN_MENU.children.find((item) => item.key === activeKey)?.label ?? "",
|
|
1834
|
+
[activeKey]
|
|
1835
|
+
);
|
|
1836
|
+
return /* @__PURE__ */ jsxs3("div", { style: styles3.root, children: [
|
|
1837
|
+
/* @__PURE__ */ jsxs3("aside", { style: styles3.sidebar, children: [
|
|
1838
|
+
/* @__PURE__ */ jsx4("div", { style: styles3.sidebarTitle, children: title }),
|
|
1839
|
+
/* @__PURE__ */ jsx4("nav", { style: styles3.nav, children: SYSTEM_ADMIN_MENU.children.map((item) => {
|
|
1840
|
+
const active = item.key === activeKey;
|
|
1841
|
+
return /* @__PURE__ */ jsx4(
|
|
1842
|
+
"button",
|
|
1843
|
+
{
|
|
1844
|
+
type: "button",
|
|
1845
|
+
style: {
|
|
1846
|
+
...styles3.navItem,
|
|
1847
|
+
...active ? styles3.navItemActive : null
|
|
1848
|
+
},
|
|
1849
|
+
onClick: () => setActiveKey(item.key),
|
|
1850
|
+
children: item.label
|
|
1851
|
+
},
|
|
1852
|
+
item.key
|
|
1853
|
+
);
|
|
1854
|
+
}) })
|
|
1855
|
+
] }),
|
|
1856
|
+
/* @__PURE__ */ jsxs3("main", { style: styles3.content, children: [
|
|
1857
|
+
/* @__PURE__ */ jsxs3("div", { style: styles3.contentHeader, children: [
|
|
1858
|
+
/* @__PURE__ */ jsxs3("div", { style: styles3.breadcrumb, children: [
|
|
1859
|
+
/* @__PURE__ */ jsx4("span", { style: styles3.breadcrumbParent, children: title }),
|
|
1860
|
+
/* @__PURE__ */ jsx4("span", { style: styles3.breadcrumbSep, children: "/" }),
|
|
1861
|
+
/* @__PURE__ */ jsx4("span", { style: styles3.breadcrumbCurrent, children: activeLabel })
|
|
1862
|
+
] }),
|
|
1863
|
+
toolbarExtra
|
|
1864
|
+
] }),
|
|
1865
|
+
/* @__PURE__ */ jsx4("div", { style: styles3.panel, children: activeKey === "menu" ? /* @__PURE__ */ jsx4(MenuManager, { api: menuApi, title: "\u83DC\u5355\u7BA1\u7406" }) : /* @__PURE__ */ jsx4(ResourceManager, { api: resourceApi, title: "\u6743\u9650\u70B9\u7BA1\u7406" }) })
|
|
1866
|
+
] })
|
|
1867
|
+
] });
|
|
1868
|
+
}
|
|
1869
|
+
var styles3 = {
|
|
1870
|
+
root: {
|
|
1871
|
+
display: "flex",
|
|
1872
|
+
minHeight: 560,
|
|
1873
|
+
border: "1px solid #eaecf0",
|
|
1874
|
+
borderRadius: 12,
|
|
1875
|
+
overflow: "hidden",
|
|
1876
|
+
background: "#fff",
|
|
1877
|
+
fontFamily: '"PingFang SC", "Microsoft YaHei", -apple-system, BlinkMacSystemFont, sans-serif',
|
|
1878
|
+
color: "#101828"
|
|
1879
|
+
},
|
|
1880
|
+
sidebar: {
|
|
1881
|
+
width: 200,
|
|
1882
|
+
flexShrink: 0,
|
|
1883
|
+
borderRight: "1px solid #eaecf0",
|
|
1884
|
+
background: "#f9fafb",
|
|
1885
|
+
padding: "16px 12px"
|
|
1886
|
+
},
|
|
1887
|
+
sidebarTitle: {
|
|
1888
|
+
fontSize: 14,
|
|
1889
|
+
fontWeight: 600,
|
|
1890
|
+
color: "#344054",
|
|
1891
|
+
padding: "4px 10px 12px"
|
|
1892
|
+
},
|
|
1893
|
+
nav: {
|
|
1894
|
+
display: "flex",
|
|
1895
|
+
flexDirection: "column",
|
|
1896
|
+
gap: 4
|
|
1897
|
+
},
|
|
1898
|
+
navItem: {
|
|
1899
|
+
border: "none",
|
|
1900
|
+
background: "transparent",
|
|
1901
|
+
textAlign: "left",
|
|
1902
|
+
padding: "10px 12px",
|
|
1903
|
+
borderRadius: 8,
|
|
1904
|
+
fontSize: 14,
|
|
1905
|
+
color: "#475467",
|
|
1906
|
+
cursor: "pointer"
|
|
1907
|
+
},
|
|
1908
|
+
navItemActive: {
|
|
1909
|
+
background: "#e6f7f9",
|
|
1910
|
+
color: "#049BAD",
|
|
1911
|
+
fontWeight: 600
|
|
1912
|
+
},
|
|
1913
|
+
content: {
|
|
1914
|
+
flex: 1,
|
|
1915
|
+
minWidth: 0,
|
|
1916
|
+
display: "flex",
|
|
1917
|
+
flexDirection: "column",
|
|
1918
|
+
background: "#fff"
|
|
1919
|
+
},
|
|
1920
|
+
contentHeader: {
|
|
1921
|
+
display: "flex",
|
|
1922
|
+
alignItems: "center",
|
|
1923
|
+
justifyContent: "space-between",
|
|
1924
|
+
gap: 12,
|
|
1925
|
+
padding: "12px 16px",
|
|
1926
|
+
borderBottom: "1px solid #f2f4f7"
|
|
1927
|
+
},
|
|
1928
|
+
breadcrumb: {
|
|
1929
|
+
display: "flex",
|
|
1930
|
+
alignItems: "center",
|
|
1931
|
+
gap: 8,
|
|
1932
|
+
fontSize: 13
|
|
1933
|
+
},
|
|
1934
|
+
breadcrumbParent: { color: "#98a2b3" },
|
|
1935
|
+
breadcrumbSep: { color: "#d0d5dd" },
|
|
1936
|
+
breadcrumbCurrent: { color: "#344054", fontWeight: 600 },
|
|
1937
|
+
panel: {
|
|
1938
|
+
flex: 1,
|
|
1939
|
+
minHeight: 0,
|
|
1940
|
+
overflow: "auto"
|
|
1941
|
+
}
|
|
1942
|
+
};
|
|
1796
1943
|
export {
|
|
1797
1944
|
Can,
|
|
1798
1945
|
MENU_LIST_TYPE_PARAM,
|
|
@@ -1812,6 +1959,9 @@ export {
|
|
|
1812
1959
|
RESOURCE_TYPE_API,
|
|
1813
1960
|
ROOT_PARENT_ID,
|
|
1814
1961
|
ResourceManager,
|
|
1962
|
+
SYSTEM_ADMIN_DEFAULT_KEY,
|
|
1963
|
+
SYSTEM_ADMIN_MENU,
|
|
1964
|
+
SystemAdmin,
|
|
1815
1965
|
appendQueryParam,
|
|
1816
1966
|
buildCreateBody,
|
|
1817
1967
|
buildCreateMenuBody,
|