@oj-module/runtime 0.1.5
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/LICENSE +21 -0
- package/README.md +119 -0
- package/dist/api/notifications/index.d.ts +2 -0
- package/dist/api/system/menu/index.d.ts +6 -0
- package/dist/api/system/menu/types.d.ts +19 -0
- package/dist/api/system/role/api/client.d.ts +19 -0
- package/dist/api/system/role/api/client.schemas.d.ts +94 -0
- package/dist/api/system/role/index.d.ts +9 -0
- package/dist/api/system/role/types.d.ts +9 -0
- package/dist/api/user/index.d.ts +12 -0
- package/dist/api/user/types.d.ts +26 -0
- package/dist/components/access-control/index.d.ts +15 -0
- package/dist/components/basic-button/index.d.ts +7 -0
- package/dist/components/basic-content/index.d.ts +7 -0
- package/dist/components/basic-form/form-items/form-avatar-item.d.ts +6 -0
- package/dist/components/basic-form/form-items/form-tree-item.d.ts +13 -0
- package/dist/components/basic-form/form-items/index.d.ts +2 -0
- package/dist/components/basic-form/index.d.ts +1 -0
- package/dist/components/basic-table/constants.d.ts +1 -0
- package/dist/components/basic-table/index.d.ts +12 -0
- package/dist/components/basic-table/styles.d.ts +6 -0
- package/dist/components/exception-page/index.d.ts +3 -0
- package/dist/components/fullscreen-button/index.d.ts +17 -0
- package/dist/components/global-spin/index.d.ts +6 -0
- package/dist/components/iframe/index.d.ts +1 -0
- package/dist/components/jss-theme-provider/index.d.ts +26 -0
- package/dist/components/not-found/index.d.ts +6 -0
- package/dist/components/page-error/index.d.ts +2 -0
- package/dist/components/scrollbar/index.d.ts +7 -0
- package/dist/components/unknown-component/index.d.ts +6 -0
- package/dist/constants/options.d.ts +9 -0
- package/dist/contract/define-api.d.ts +43 -0
- package/dist/contract/define-api.js +44 -0
- package/dist/contract/errors.d.ts +16 -0
- package/dist/contract/errors.js +20 -0
- package/dist/contract/index.d.ts +15 -0
- package/dist/contract/index.js +13 -0
- package/dist/contract/scoped-request-like.d.ts +25 -0
- package/dist/contract/scoped-request-like.js +6 -0
- package/dist/hooks/use-access/constants.d.ts +24 -0
- package/dist/hooks/use-access/index.d.ts +9 -0
- package/dist/hooks/use-css-var/index.d.ts +17 -0
- package/dist/hooks/use-current-route/index.d.ts +6 -0
- package/dist/hooks/use-device-type/index.d.ts +9 -0
- package/dist/hooks/use-language/index.d.ts +5 -0
- package/dist/hooks/use-layout-menu/index.d.ts +6 -0
- package/dist/hooks/use-layout-style/index.d.ts +19 -0
- package/dist/hooks/use-preferences/index.d.ts +61 -0
- package/dist/icons/index.d.ts +3 -0
- package/dist/icons/local-icons.d.ts +17 -0
- package/dist/icons/menu-icons.d.ts +4 -0
- package/dist/icons/ri.d.ts +14 -0
- package/dist/icons/types.d.ts +9 -0
- package/dist/index.d.ts +44 -0
- package/dist/layout/constants.d.ts +50 -0
- package/dist/layout/container-layout/index.d.ts +11 -0
- package/dist/layout/fullscreen-layout/index.d.ts +9 -0
- package/dist/layout/hooks/index.d.ts +1 -0
- package/dist/layout/hooks/use-layout.d.ts +20 -0
- package/dist/layout/keep-alive-layer/index.d.ts +15 -0
- package/dist/layout/layout-content/index.d.ts +3 -0
- package/dist/layout/layout-effects/index.d.ts +9 -0
- package/dist/layout/layout-footer/index.d.ts +5 -0
- package/dist/layout/layout-header/components/fullscreen-button.d.ts +2 -0
- package/dist/layout/layout-header/components/language-button.d.ts +2 -0
- package/dist/layout/layout-header/components/theme-button.d.ts +9 -0
- package/dist/layout/layout-header/components/user-menu.d.ts +2 -0
- package/dist/layout/layout-header/index.d.ts +5 -0
- package/dist/layout/layout-menu/index.d.ts +17 -0
- package/dist/layout/layout-menu/style.d.ts +6 -0
- package/dist/layout/layout-menu/types.d.ts +26 -0
- package/dist/layout/layout-menu/use-menu.d.ts +7 -0
- package/dist/layout/layout-menu/utils.d.ts +49 -0
- package/dist/layout/layout-mixed-sidebar/first-column-menu.d.ts +9 -0
- package/dist/layout/layout-mixed-sidebar/index.d.ts +14 -0
- package/dist/layout/layout-mobile-menu/index.d.ts +1 -0
- package/dist/layout/layout-root/index.d.ts +5 -0
- package/dist/layout/layout-sidebar/index.d.ts +5 -0
- package/dist/layout/layout-tabbar/components/draggable-tab-bar.d.ts +16 -0
- package/dist/layout/layout-tabbar/components/tab-maximize.d.ts +10 -0
- package/dist/layout/layout-tabbar/components/tab-options.d.ts +17 -0
- package/dist/layout/layout-tabbar/hooks/use-dropdown-menu.d.ts +26 -0
- package/dist/layout/layout-tabbar/index.d.ts +5 -0
- package/dist/layout/layout-tabbar/style.d.ts +6 -0
- package/dist/layout/parent-layout/index.d.ts +1 -0
- package/dist/layout/widgets/breadcrumb-views/index.d.ts +1 -0
- package/dist/layout/widgets/global-search/components/search-footer.d.ts +5 -0
- package/dist/layout/widgets/global-search/components/search-panel.d.ts +11 -0
- package/dist/layout/widgets/global-search/index.d.ts +1 -0
- package/dist/layout/widgets/logo/index.d.ts +9 -0
- package/dist/layout/widgets/notification/index.d.ts +19 -0
- package/dist/layout/widgets/notification/notification-container.d.ts +2 -0
- package/dist/layout/widgets/notification/types.d.ts +7 -0
- package/dist/layout/widgets/preferences/blocks/animation/index.d.ts +1 -0
- package/dist/layout/widgets/preferences/blocks/footer/index.d.ts +1 -0
- package/dist/layout/widgets/preferences/blocks/general/index.d.ts +1 -0
- package/dist/layout/widgets/preferences/blocks/general/utils.d.ts +1 -0
- package/dist/layout/widgets/preferences/blocks/index.d.ts +7 -0
- package/dist/layout/widgets/preferences/blocks/layout/constants.d.ts +4 -0
- package/dist/layout/widgets/preferences/blocks/layout/index.d.ts +1 -0
- package/dist/layout/widgets/preferences/blocks/sidebar/index.d.ts +1 -0
- package/dist/layout/widgets/preferences/blocks/tabbar/index.d.ts +1 -0
- package/dist/layout/widgets/preferences/blocks/theme/builtin.d.ts +1 -0
- package/dist/layout/widgets/preferences/blocks/theme/index.d.ts +2 -0
- package/dist/layout/widgets/preferences/blocks/theme/theme.d.ts +1 -0
- package/dist/layout/widgets/preferences/index.d.ts +2 -0
- package/dist/layout/widgets/preferences/number-input-spinner.d.ts +10 -0
- package/dist/layout/widgets/preferences/select-item.d.ts +9 -0
- package/dist/layout/widgets/preferences/switch-item.d.ts +8 -0
- package/dist/layout/widgets/preferences/text-input.d.ts +8 -0
- package/dist/layout/widgets/sider-trigger/index.d.ts +5 -0
- package/dist/locales/helper.d.ts +15 -0
- package/dist/locales/index.d.ts +18 -0
- package/dist/locales/t.d.ts +10 -0
- package/dist/module-loader/define-module.d.ts +11 -0
- package/dist/module-loader/index.d.ts +20 -0
- package/dist/module-loader/keep-alive.d.ts +18 -0
- package/dist/module-loader/semver.d.ts +8 -0
- package/dist/module-loader/slots.d.ts +9 -0
- package/dist/module-loader/types.d.ts +91 -0
- package/dist/pages/login/index.d.ts +1 -0
- package/dist/plugins/hide-loading.d.ts +1 -0
- package/dist/plugins/loading.d.ts +7 -0
- package/dist/router/constants.d.ts +1 -0
- package/dist/router/extra-info/index.d.ts +1 -0
- package/dist/router/extra-info/route-path.d.ts +22 -0
- package/dist/router/guard/auth-guard.d.ts +21 -0
- package/dist/router/guard/index.d.ts +1 -0
- package/dist/router/guard/utils.d.ts +2 -0
- package/dist/router/index.d.ts +12 -0
- package/dist/router/routes/config.d.ts +7 -0
- package/dist/router/routes/core/auth.d.ts +13 -0
- package/dist/router/routes/core/exception.d.ts +12 -0
- package/dist/router/routes/core/fallback.d.ts +3 -0
- package/dist/router/routes/core/index.d.ts +2 -0
- package/dist/router/routes/index.d.ts +118 -0
- package/dist/router/types.d.ts +90 -0
- package/dist/router/utils/add-route-id-by-path.d.ts +81 -0
- package/dist/router/utils/ascending.d.ts +99 -0
- package/dist/router/utils/flatten-routes.d.ts +5 -0
- package/dist/router/utils/generate-menu-items-from-routes.d.ts +10 -0
- package/dist/router/utils/generate-routes-from-backend.d.ts +79 -0
- package/dist/router/utils/generate-routes-from-frontend.d.ts +5 -0
- package/dist/router/utils/merge-route-modules.d.ts +2 -0
- package/dist/router/utils/remove-trailing-slash.d.ts +10 -0
- package/dist/router/utils/resolve-layout.d.ts +17 -0
- package/dist/router/utils/resolve-login-route.d.ts +31 -0
- package/dist/runtime.js +27121 -0
- package/dist/store/access.d.ts +14 -0
- package/dist/store/api-provider.d.ts +47 -0
- package/dist/store/auth-provider.d.ts +19 -0
- package/dist/store/auth.d.ts +20 -0
- package/dist/store/global.d.ts +12 -0
- package/dist/store/preferences/index.d.ts +80 -0
- package/dist/store/preferences/types.d.ts +254 -0
- package/dist/store/tabs.d.ts +343 -0
- package/dist/store/user.d.ts +7 -0
- package/dist/types/app-info.d.ts +18 -0
- package/dist/utils/cn/index.d.ts +2 -0
- package/dist/utils/dom/index.d.ts +14 -0
- package/dist/utils/get-all-expanded-keys/index.d.ts +1 -0
- package/dist/utils/get-app-info/index.d.ts +13 -0
- package/dist/utils/get-app-namespace/index.d.ts +1 -0
- package/dist/utils/get-redirect-path.d.ts +8 -0
- package/dist/utils/iframe-guard.d.ts +18 -0
- package/dist/utils/is/index.d.ts +56 -0
- package/dist/utils/is-dark-theme/index.d.ts +7 -0
- package/dist/utils/is-light-theme/index.d.ts +7 -0
- package/dist/utils/is-windows-os/index.d.ts +6 -0
- package/dist/utils/progress/index.d.ts +3 -0
- package/dist/utils/remember-route/index.d.ts +1 -0
- package/dist/utils/request/constants.d.ts +5 -0
- package/dist/utils/request/envelope.d.ts +5 -0
- package/dist/utils/request/error-response.d.ts +12 -0
- package/dist/utils/request/global-progress.d.ts +21 -0
- package/dist/utils/request/go-login.d.ts +6 -0
- package/dist/utils/request/header-safe.d.ts +1 -0
- package/dist/utils/request/index.d.ts +1 -0
- package/dist/utils/request/refresh.d.ts +11 -0
- package/dist/utils/request/scoped.d.ts +17 -0
- package/dist/utils/request/whitelist.d.ts +1 -0
- package/dist/utils/static-antd/index.d.ts +12 -0
- package/dist/utils/toggle-html-class/index.d.ts +9 -0
- package/dist/utils/tree/index.d.ts +35 -0
- package/package.json +71 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 契约制 client 的统一错误类型(AC-D5/§6.2)。
|
|
3
|
+
*
|
|
4
|
+
* 业务错误(非 2xx,oj json.fail(code,msg))与契约违例(dev 校验失败,
|
|
5
|
+
* code=-1)都收敛为本类型,消费方可 `instanceof` 判别并取 code/msg。
|
|
6
|
+
*
|
|
7
|
+
* 本子路径出口(`@oj-module/runtime/contract/errors`)是**生成 client 在
|
|
8
|
+
* 浏览器侧的唯一入口**(评审 F3):刻意 zod-free——zod 只随 runtime dist
|
|
9
|
+
* 走(AC-D15),不进共享资产。
|
|
10
|
+
*/
|
|
11
|
+
export class ContractApiError extends Error {
|
|
12
|
+
code;
|
|
13
|
+
msg;
|
|
14
|
+
constructor(code, msg) {
|
|
15
|
+
super(msg);
|
|
16
|
+
this.name = "ContractApiError";
|
|
17
|
+
this.code = code;
|
|
18
|
+
this.msg = msg;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @oj-module/runtime/contract —— API 契约 DSL(AC-D11)。
|
|
3
|
+
*
|
|
4
|
+
* 零浏览器依赖(Node codegen 与浏览器运行时双安全):
|
|
5
|
+
* - defineApi:契约端点定义(含定义期校验)
|
|
6
|
+
* - API_DEF:端点品牌标记(旧标记 `ram.api.def` 由 cli 侧自行识别,不在公共出口)
|
|
7
|
+
* - z:zod re-export(契约 schema 书写;v4 钉版,pnpm catalog 单一来源)
|
|
8
|
+
* - ContractApiError:契约制 client 统一错误类型
|
|
9
|
+
* - ScopedRequestLike:生成 client 的 request 最小结构类型
|
|
10
|
+
*/
|
|
11
|
+
export { API_DEF, defineApi } from "./define-api.ts";
|
|
12
|
+
export type { ApiDefinitionInput, HttpMethod } from "./define-api.ts";
|
|
13
|
+
export { ContractApiError } from "./errors.ts";
|
|
14
|
+
export type { ScopedRequestLike } from "./scoped-request-like.ts";
|
|
15
|
+
export { z } from "zod";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @oj-module/runtime/contract —— API 契约 DSL(AC-D11)。
|
|
3
|
+
*
|
|
4
|
+
* 零浏览器依赖(Node codegen 与浏览器运行时双安全):
|
|
5
|
+
* - defineApi:契约端点定义(含定义期校验)
|
|
6
|
+
* - API_DEF:端点品牌标记(旧标记 `ram.api.def` 由 cli 侧自行识别,不在公共出口)
|
|
7
|
+
* - z:zod re-export(契约 schema 书写;v4 钉版,pnpm catalog 单一来源)
|
|
8
|
+
* - ContractApiError:契约制 client 统一错误类型
|
|
9
|
+
* - ScopedRequestLike:生成 client 的 request 最小结构类型
|
|
10
|
+
*/
|
|
11
|
+
export { API_DEF, defineApi } from "./define-api.js";
|
|
12
|
+
export { ContractApiError } from "./errors.js";
|
|
13
|
+
export { z } from "zod";
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 生成 client 对 request 实例的最小结构类型(ISP——不依赖 ky/runtime 类型,
|
|
3
|
+
* 任何满足该形状的对象(runtime 全局 request、模块 scoped client、测试 stub)
|
|
4
|
+
* 都可 bindRequest 注入)。
|
|
5
|
+
*/
|
|
6
|
+
/** ky ResponsePromise 的最小结构:既是 Promise<Response>(raw 通道)又有 .json() */
|
|
7
|
+
export interface ResponsePromiseLike extends Promise<Response> {
|
|
8
|
+
json: <T>() => Promise<T>;
|
|
9
|
+
}
|
|
10
|
+
export interface RequestCall {
|
|
11
|
+
(url: string, options?: {
|
|
12
|
+
/** 与 ky SearchParamsOption 的 Record 形态对齐——宽于它则真 ky 实例无法赋给本接口 */
|
|
13
|
+
searchParams?: Record<string, string | number | boolean>;
|
|
14
|
+
json?: unknown;
|
|
15
|
+
ignoreLoading?: boolean;
|
|
16
|
+
}): ResponsePromiseLike;
|
|
17
|
+
}
|
|
18
|
+
export interface ScopedRequestLike {
|
|
19
|
+
get: RequestCall;
|
|
20
|
+
post: RequestCall;
|
|
21
|
+
put: RequestCall;
|
|
22
|
+
delete: RequestCall;
|
|
23
|
+
patch: RequestCall;
|
|
24
|
+
head: RequestCall;
|
|
25
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 统一管理权限常量,避免在项目中到处写死字符串,便于维护。
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* 按钮权限前缀
|
|
6
|
+
*/
|
|
7
|
+
export declare const permissionPrefix = "permission:button";
|
|
8
|
+
/**
|
|
9
|
+
* 常见按钮权限:
|
|
10
|
+
* - get: 获取
|
|
11
|
+
* - update: 更新
|
|
12
|
+
* - delete: 删除
|
|
13
|
+
* - add: 新增
|
|
14
|
+
*/
|
|
15
|
+
export declare const accessControlCodes: {
|
|
16
|
+
get: string;
|
|
17
|
+
update: string;
|
|
18
|
+
delete: string;
|
|
19
|
+
add: string;
|
|
20
|
+
};
|
|
21
|
+
export declare const AccessControlRoles: {
|
|
22
|
+
admin: string;
|
|
23
|
+
common: string;
|
|
24
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface UseCssVarOptions {
|
|
2
|
+
initialValue?: string;
|
|
3
|
+
}
|
|
4
|
+
export interface UseCssVarProps {
|
|
5
|
+
name: `--${string}`;
|
|
6
|
+
root?: HTMLElement;
|
|
7
|
+
options?: UseCssVarOptions;
|
|
8
|
+
}
|
|
9
|
+
export interface CssVarControls {
|
|
10
|
+
set: (value: string) => void;
|
|
11
|
+
get: () => string;
|
|
12
|
+
remove: () => void;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* @see https://soorria.com/snippets/use-css-var-react
|
|
16
|
+
*/
|
|
17
|
+
export declare function useCssVar(name: `--${string}`, root?: HTMLElement, options?: UseCssVarOptions): CssVarControls;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { PageLayoutType } from "../../store/preferences/types";
|
|
2
|
+
export declare function useLayoutMenu(): {
|
|
3
|
+
pageLayout: PageLayoutType;
|
|
4
|
+
setPageLayout: (value: PageLayoutType) => void;
|
|
5
|
+
layoutButtonTrigger: import("#node_modules/@types/react").JSX.Element;
|
|
6
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { CSSProperties } from "react";
|
|
2
|
+
import type { VisibleDomRect } from "../../utils/dom/index";
|
|
3
|
+
/**
|
|
4
|
+
* @zh 获取布局内容区域的样式
|
|
5
|
+
* @en Get the style of the layout content area
|
|
6
|
+
*/
|
|
7
|
+
export declare function useLayoutContentStyle(): {
|
|
8
|
+
contentElement: import("#node_modules/@types/react").RefObject<HTMLDivElement | null>;
|
|
9
|
+
overlayStyle: CSSProperties;
|
|
10
|
+
visibleDomRect: VisibleDomRect | null;
|
|
11
|
+
};
|
|
12
|
+
export declare function useLayoutHeaderStyle(): {
|
|
13
|
+
getLayoutHeaderHeight: () => number;
|
|
14
|
+
setLayoutHeaderHeight: (height: number) => void;
|
|
15
|
+
};
|
|
16
|
+
export declare function useLayoutFooterStyle(): {
|
|
17
|
+
getLayoutFooterHeight: () => number;
|
|
18
|
+
setLayoutFooterHeight: (height: number) => void;
|
|
19
|
+
};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 包装下用户偏好设置的参数,不需要存储在 localStorage 中,但是为了方便使用的变量可以在这里出现。
|
|
3
|
+
*
|
|
4
|
+
* @returns 返回包含用户偏好设置的对象,包括主题、是否为默认设置、是否为深色主题、是否为浅色主题
|
|
5
|
+
*/
|
|
6
|
+
export declare function usePreferences(): {
|
|
7
|
+
isDefault: boolean;
|
|
8
|
+
isDark: boolean;
|
|
9
|
+
isLight: boolean;
|
|
10
|
+
theme: import("../../store/preferences/types").ThemeType;
|
|
11
|
+
colorBlindMode: boolean;
|
|
12
|
+
colorGrayMode: boolean;
|
|
13
|
+
themeRadius: number;
|
|
14
|
+
themeColorPrimary: string;
|
|
15
|
+
builtinTheme: import("../../store/preferences/types").BuiltinThemeType;
|
|
16
|
+
tabbarStyleType: import("../../store/preferences/types").TabsStyleType;
|
|
17
|
+
tabbarEnable: boolean;
|
|
18
|
+
tabbarShowIcon: boolean;
|
|
19
|
+
tabbarPersist: boolean;
|
|
20
|
+
tabbarDraggable: boolean;
|
|
21
|
+
tabbarShowMore: boolean;
|
|
22
|
+
tabbarShowMaximize: boolean;
|
|
23
|
+
transitionProgress: boolean;
|
|
24
|
+
transitionLoading: boolean;
|
|
25
|
+
transitionEnable: boolean;
|
|
26
|
+
transitionName: string;
|
|
27
|
+
navigationStyle: import("../../store/preferences/types").NavigationType;
|
|
28
|
+
watermark: boolean;
|
|
29
|
+
watermarkContent: string;
|
|
30
|
+
enableBackTopButton: boolean;
|
|
31
|
+
pageLayout: import("../../store/preferences/types").PageLayoutType;
|
|
32
|
+
enableFrontendAceess: boolean;
|
|
33
|
+
enableBackendAccess: boolean;
|
|
34
|
+
language: import("../../locales").LanguageType;
|
|
35
|
+
enableDynamicTitle: boolean;
|
|
36
|
+
enableCheckUpdates: boolean;
|
|
37
|
+
checkUpdatesInterval: number;
|
|
38
|
+
sidebarEnable?: boolean;
|
|
39
|
+
sidebarWidth: number;
|
|
40
|
+
sideCollapsedWidth: number;
|
|
41
|
+
sidebarCollapsed: boolean;
|
|
42
|
+
sidebarCollapseShowTitle: boolean;
|
|
43
|
+
sidebarExtraCollapsedWidth: number;
|
|
44
|
+
firstColumnWidthInTwoColumnNavigation: number;
|
|
45
|
+
sidebarTheme: import("antd").MenuProps["theme"];
|
|
46
|
+
accordion: boolean;
|
|
47
|
+
enableFooter: boolean;
|
|
48
|
+
fixedFooter: boolean;
|
|
49
|
+
companyName: string;
|
|
50
|
+
companyWebsite: string;
|
|
51
|
+
copyrightDate: string;
|
|
52
|
+
ICPNumber: string;
|
|
53
|
+
ICPLink: string;
|
|
54
|
+
reset: () => void;
|
|
55
|
+
changeSiteTheme: (theme: import("../../store/preferences/types").ThemeType) => void;
|
|
56
|
+
changeLanguage: (language: import("../../locales").LanguageType) => void;
|
|
57
|
+
setPreferences: {
|
|
58
|
+
<T>(key: string, value: T): void;
|
|
59
|
+
<T extends Partial<import("../../store/preferences/types").PreferencesState>>(preferences: T): void;
|
|
60
|
+
};
|
|
61
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { IconComponent } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* 本地 SVG 图标集(构建期由 unplugin-icons 内联,P3.1 起包装导出,
|
|
4
|
+
* 避免 `~icons/*` 虚拟模块泄漏进包声明)。
|
|
5
|
+
*/
|
|
6
|
+
export declare const EmbeddedIcon: IconComponent;
|
|
7
|
+
export declare const ExternalIcon: IconComponent;
|
|
8
|
+
export declare const LayoutCenterIcon: IconComponent;
|
|
9
|
+
export declare const LayoutLeftIcon: IconComponent;
|
|
10
|
+
export declare const LayoutRightIcon: IconComponent;
|
|
11
|
+
export declare const MixedNavigationIcon: IconComponent;
|
|
12
|
+
export declare const OutsidePageIcon: IconComponent;
|
|
13
|
+
export declare const ProfileCardIcon: IconComponent;
|
|
14
|
+
export declare const ServerErrorIcon: IconComponent;
|
|
15
|
+
export declare const SideNavigationIcon: IconComponent;
|
|
16
|
+
export declare const TopNavigationIcon: IconComponent;
|
|
17
|
+
export declare const TwoColumnNavigationIcon: IconComponent;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { IconComponent } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Remix Icon 常用子集(构建期由 unplugin-icons 内联,P3.1 起包装导出,
|
|
4
|
+
* 避免 `~icons/*` 虚拟模块泄漏进包声明)。
|
|
5
|
+
*/
|
|
6
|
+
export declare const RiAccountCircleLine: IconComponent;
|
|
7
|
+
export declare const RiContrastFill: IconComponent;
|
|
8
|
+
export declare const RiFullscreenExitLine: IconComponent;
|
|
9
|
+
export declare const RiFullscreenLine: IconComponent;
|
|
10
|
+
export declare const RiMailCheckLine: IconComponent;
|
|
11
|
+
export declare const RiMoonIcon: IconComponent;
|
|
12
|
+
export declare const RiReactjsLine: IconComponent;
|
|
13
|
+
export declare const RiSunIcon: IconComponent;
|
|
14
|
+
export declare const RiUserSettingsLine: IconComponent;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ComponentType, SVGProps } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* 图标组件统一形状(P3.1)。
|
|
4
|
+
*
|
|
5
|
+
* 图标在构建期由 unplugin-icons 内联为组件;运行时出口不直接
|
|
6
|
+
* re-export `~icons/*` 虚拟模块的 default,而是以本类型注解包装,
|
|
7
|
+
* 使 d.ts 声明自足、不泄漏虚拟模块说明符。
|
|
8
|
+
*/
|
|
9
|
+
export type IconComponent = ComponentType<SVGProps<SVGSVGElement>>;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@oj-module/runtime` 主入口。
|
|
3
|
+
*
|
|
4
|
+
* 这是模块工程**唯一**应该 import 的框架入口(设计文档 D3 / §4.3)。
|
|
5
|
+
* 出口已于 P3.1 依据 P1 的实际用量冻结(tests/runtime-exports.test.ts
|
|
6
|
+
* 即冻结契约):components/basic-*、api、hooks、store、icons、
|
|
7
|
+
* utils/tree、constants/options、路由与模块类型。
|
|
8
|
+
*
|
|
9
|
+
* 注意:antd、react、react-router、@tanstack/react-query 等共享依赖
|
|
10
|
+
* 由宿主的 importmap 提供,模块应直接 import 它们,不要从 runtime 转出。
|
|
11
|
+
*/
|
|
12
|
+
import "./styles/index.css";
|
|
13
|
+
export * from "./api/system/menu";
|
|
14
|
+
export * from "./api/system/role";
|
|
15
|
+
export * from "./api/user";
|
|
16
|
+
export { AccessControl } from "./components/access-control";
|
|
17
|
+
export { BasicButton } from "./components/basic-button";
|
|
18
|
+
export { BasicContent } from "./components/basic-content";
|
|
19
|
+
export * from "./components/basic-form";
|
|
20
|
+
export { BasicTable } from "./components/basic-table";
|
|
21
|
+
export type { BasicTableProps } from "./components/basic-table";
|
|
22
|
+
export { Iframe } from "./components/iframe";
|
|
23
|
+
export * from "./constants/options";
|
|
24
|
+
export * from "./hooks/use-access";
|
|
25
|
+
export { usePreferences } from "./hooks/use-preferences";
|
|
26
|
+
export * from "./icons";
|
|
27
|
+
export { LayoutEffects } from "./layout/layout-effects";
|
|
28
|
+
export { setupI18n } from "./locales";
|
|
29
|
+
export { getModule, getModules, getRegisteredApiPrefix, getRegisteredStore, getRoutes, loadAll, unloadModule, } from "./module-loader";
|
|
30
|
+
export { defineModule } from "./module-loader/define-module";
|
|
31
|
+
export { useSlotNodes } from "./module-loader/slots";
|
|
32
|
+
export type { ModuleConfig, ModuleContext, ModuleDefinition, ModuleI18n, ModuleLifecycle, } from "./module-loader/types";
|
|
33
|
+
export type { Manifest, ManifestModuleEntry, ModuleInstance, } from "./module-loader/types";
|
|
34
|
+
export type { AppRouteRecordRaw, RouteMeta } from "./router/types";
|
|
35
|
+
export type { NotificationsApiProvider, SystemApiProvider, UploadApiProvider, } from "./store/api-provider";
|
|
36
|
+
export { useAuthStore } from "./store/auth";
|
|
37
|
+
export type { AuthProvider } from "./store/auth-provider";
|
|
38
|
+
export { useUserStore } from "./store/user";
|
|
39
|
+
export type { AppInfo } from "./types/app-info";
|
|
40
|
+
export { getAllExpandedKeys } from "./utils/get-all-expanded-keys";
|
|
41
|
+
export { getAppInfo } from "./utils/get-app-info";
|
|
42
|
+
export { getRedirectPath } from "./utils/get-redirect-path";
|
|
43
|
+
export * from "./utils/tree";
|
|
44
|
+
export { z } from "zod";
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Layout Header Height
|
|
3
|
+
*/
|
|
4
|
+
export declare const headerHeight = 48;
|
|
5
|
+
/**
|
|
6
|
+
* Layout Footer Height
|
|
7
|
+
*/
|
|
8
|
+
export declare const footerHeight = 40;
|
|
9
|
+
/**
|
|
10
|
+
* Sidebar Title Height
|
|
11
|
+
*/
|
|
12
|
+
export declare const sidebarTitleHeight = 52;
|
|
13
|
+
/**
|
|
14
|
+
* Sider Trigger Height
|
|
15
|
+
*/
|
|
16
|
+
export declare const siderTriggerHeight = 40;
|
|
17
|
+
/**
|
|
18
|
+
* Tabbar Height Height
|
|
19
|
+
*/
|
|
20
|
+
export declare const tabbarHeight = 35;
|
|
21
|
+
/**
|
|
22
|
+
* @zh 默认命名空间
|
|
23
|
+
* @en Default namespace
|
|
24
|
+
*/
|
|
25
|
+
export declare const DEFAULT_NAMESPACE = "react-antd-admin";
|
|
26
|
+
/**
|
|
27
|
+
* @zh 主内容区域的元素 ID
|
|
28
|
+
* @en Main content element ID
|
|
29
|
+
*/
|
|
30
|
+
export declare const ELEMENT_ID_MAIN_CONTENT = "__react-antd-admin_main_content";
|
|
31
|
+
/**
|
|
32
|
+
* @zh layout content 组件的高度
|
|
33
|
+
* @en Height of the layout content component
|
|
34
|
+
*/
|
|
35
|
+
export declare const CSS_VARIABLE_LAYOUT_CONTENT_HEIGHT = "--react-antd-admin-content-height";
|
|
36
|
+
/**
|
|
37
|
+
* @zh layout content 组件的宽度
|
|
38
|
+
* @en Width of the layout content component
|
|
39
|
+
*/
|
|
40
|
+
export declare const CSS_VARIABLE_LAYOUT_CONTENT_WIDTH = "--react-antd-admin-content-width";
|
|
41
|
+
/**
|
|
42
|
+
* @zh layout header 组件的高度
|
|
43
|
+
* @en Height of the layout header component
|
|
44
|
+
*/
|
|
45
|
+
export declare const CSS_VARIABLE_LAYOUT_HEADER_HEIGHT = "--react-antd-admin-header-height";
|
|
46
|
+
/**
|
|
47
|
+
* @zh layout footer 组件的高度
|
|
48
|
+
* @en Height of the layout footer component
|
|
49
|
+
*/
|
|
50
|
+
export declare const CSS_VARIABLE_LAYOUT_FOOTER_HEIGHT = "--react-antd-admin-footer-height";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Please do not use this component through lazy, otherwise the switching routing page will flash.
|
|
3
|
+
* 请不要通过 lazy 使用这个组件,否则切换路由页面会发生闪动。
|
|
4
|
+
*
|
|
5
|
+
* NO:
|
|
6
|
+
* const ContainerLayout = lazy(() => import("./index"));
|
|
7
|
+
*
|
|
8
|
+
* YES:
|
|
9
|
+
* import ContainerLayout from "./index";
|
|
10
|
+
*/
|
|
11
|
+
export default function ContainerLayout(): import("#node_modules/@types/react").JSX.Element;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 全屏布局(P1,login 模块化):框架兜住「占满视口 + 无 chrome + 主题正确 +
|
|
3
|
+
* 品牌位统一」——品牌区(logo + 应用标题)、右上角工具区(布局预览/主题/语言)、
|
|
4
|
+
* 横幅列与页脚全部内置,模块只写内容区(经 Outlet 渲染),零 `#src/` 依赖。
|
|
5
|
+
*
|
|
6
|
+
* 与 `none` 的分工:`none` 是裸 Outlet,框架不保证任何视口。
|
|
7
|
+
* 外壳从原内置登录页(pages/login)平移而来(P2 完成页面侧剥离)。
|
|
8
|
+
*/
|
|
9
|
+
export default function FullscreenLayout(): import("#node_modules/@types/react").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./use-layout";
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 获取当前页面的布局类型信息
|
|
3
|
+
*
|
|
4
|
+
* @returns 返回包含当前布局类型信息的对象,包含:
|
|
5
|
+
* - currentLayout: 当前导航类型
|
|
6
|
+
* - isSideNav: 是否为侧边导航
|
|
7
|
+
* - isTopNav: 是否为顶部导航
|
|
8
|
+
* - isMixedNav: 是否为混合导航
|
|
9
|
+
* - isTwoColumnNav: 是否为双列导航
|
|
10
|
+
*/
|
|
11
|
+
export declare function useLayout(): {
|
|
12
|
+
currentLayout: import("../../store/preferences/types").NavigationType;
|
|
13
|
+
isSideNav: boolean;
|
|
14
|
+
isTopNav: boolean;
|
|
15
|
+
isMixedNav: boolean;
|
|
16
|
+
isTwoColumnNav: boolean;
|
|
17
|
+
sidebarWidth: number;
|
|
18
|
+
sideCollapsedWidth: number;
|
|
19
|
+
firstColumnWidthInTwoColumnNavigation: number;
|
|
20
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* KeepAlive 固定层(P2.1)。
|
|
3
|
+
*
|
|
4
|
+
* 设计要点(设计文档 §4.4 / B13 / R9):
|
|
5
|
+
* - 从 `ContainerLayout → LayoutContent` 上移为 shell 固定层组件,缓存逻辑不再耦合
|
|
6
|
+
* 某个具体布局组件;后续布局去中心化(handle.layout)不会影响缓存是否生效。
|
|
7
|
+
* - `exclude` 改由 module-loader 汇总各模块 `handle.keepAlive` 计算
|
|
8
|
+
* (`getKeepAliveExcludeKeys`),而非 access store 的 flatRouteList。
|
|
9
|
+
* - 只包裹「页面 outlet」本身:顶部 chrome(header / sidebar / tabbar)在 KeepAlive
|
|
10
|
+
* 之外渲染,因此整站 chrome 不进入缓存,避免切回路由时 chrome 状态错位。
|
|
11
|
+
*
|
|
12
|
+
* 注意:这里刻意不把 KeepAlive 直接包在 LayoutRoot 的 <Outlet/> 外层,否则会把
|
|
13
|
+
* chrome 一起缓存,违背「整站 chrome 不消失 / 状态不错位」的约束。
|
|
14
|
+
*/
|
|
15
|
+
export default function KeepAliveLayer(): import("#node_modules/@types/react").JSX.Element;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 全局副作用(不含路由守卫):动态标题、暗色主题 html.dark、NProgress 收尾。
|
|
3
|
+
*
|
|
4
|
+
* 偏差 4(layout e2e H4 暴露):这些 effect 原先只存在于 LayoutRoot,而
|
|
5
|
+
* LayoutRoot 同时携带 AuthGuard——宿主(shell)为免登录能力绕开 LayoutRoot
|
|
6
|
+
* 后,副作用一并丢失:主题切换只改 store、html.dark 永不生效。抽取为本组件
|
|
7
|
+
* 供两条链路共用:App 链 = LayoutRoot 内部使用;宿主链 = 根路由直接挂载。
|
|
8
|
+
*/
|
|
9
|
+
export declare function LayoutEffects(): null;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ButtonProps } from "antd";
|
|
2
|
+
/**
|
|
3
|
+
* @zh 主题切换组件
|
|
4
|
+
* 允许用户通过按钮切换网站的亮色和暗色主题
|
|
5
|
+
*
|
|
6
|
+
* @en Theme Button Component
|
|
7
|
+
* Allows users to toggle between light and dark themes of the website via a button
|
|
8
|
+
*/
|
|
9
|
+
export declare function ThemeButton({ ...restProps }: ButtonProps): import("#node_modules/@types/react").JSX.Element;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { MenuProps } from "antd";
|
|
2
|
+
import type { MenuItemType } from "./types";
|
|
3
|
+
interface LayoutMenuProps {
|
|
4
|
+
mode?: MenuProps["mode"];
|
|
5
|
+
/**
|
|
6
|
+
* 控制是否自动展开当前路由对应的菜单项
|
|
7
|
+
*
|
|
8
|
+
* Why?
|
|
9
|
+
* 注意:当菜单模式为顶部导航模式,菜单 mode 为 horizontal,初次进入页面时,菜单不应自动展开,可以指定 autoExpandCurrentMenu 为 false 关闭自动展开功能
|
|
10
|
+
* @see https://github.com/user-attachments/assets/705ae01d-db7f-4f42-b4dd-66adba0dd68f
|
|
11
|
+
*/
|
|
12
|
+
autoExpandCurrentMenu?: boolean;
|
|
13
|
+
menus?: MenuItemType[];
|
|
14
|
+
handleMenuSelect?: (key: string, mode: MenuProps["mode"]) => void;
|
|
15
|
+
}
|
|
16
|
+
export default function LayoutMenu({ mode, autoExpandCurrentMenu, handleMenuSelect, menus, }: LayoutMenuProps): import("#node_modules/@types/react").JSX.Element;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 菜单项目类型
|
|
3
|
+
*/
|
|
4
|
+
export interface MenuItemType {
|
|
5
|
+
/**
|
|
6
|
+
* 菜单路径,item 的唯一标志
|
|
7
|
+
*/
|
|
8
|
+
key: string;
|
|
9
|
+
/**
|
|
10
|
+
* 菜单项标题
|
|
11
|
+
*/
|
|
12
|
+
label: React.ReactNode;
|
|
13
|
+
/**
|
|
14
|
+
* 子菜单的菜单项
|
|
15
|
+
*/
|
|
16
|
+
children?: MenuItemType[];
|
|
17
|
+
/**
|
|
18
|
+
* 菜单图标
|
|
19
|
+
*/
|
|
20
|
+
icon?: React.ReactNode;
|
|
21
|
+
/**
|
|
22
|
+
* 是否禁用菜单
|
|
23
|
+
* @default false
|
|
24
|
+
*/
|
|
25
|
+
disabled?: boolean;
|
|
26
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { MenuProps } from "antd";
|
|
2
|
+
export declare function useMenu(): {
|
|
3
|
+
handleMenuSelect: (key: string, mode: MenuProps["mode"]) => void;
|
|
4
|
+
sideNavMenuKeyInSplitMode: string;
|
|
5
|
+
topNavItems: import("./types").MenuItemType[];
|
|
6
|
+
sideNavItems: import("./types").MenuItemType[];
|
|
7
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { MenuItemType } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* 将菜单树中的所有 label 转换为国际化文本
|
|
4
|
+
* @param menus 原始菜单数组
|
|
5
|
+
* @param t Translation 函数
|
|
6
|
+
* @returns 转换后的菜单数组
|
|
7
|
+
*/
|
|
8
|
+
export declare function translateMenus(menus: MenuItemType[], t: (key: string) => string): MenuItemType[];
|
|
9
|
+
/**
|
|
10
|
+
* 通过路径查找菜单
|
|
11
|
+
*
|
|
12
|
+
* @param list 菜单列表
|
|
13
|
+
* @param path 菜单路径
|
|
14
|
+
* @returns 找到的菜单对象,未找到则返回 null
|
|
15
|
+
*/
|
|
16
|
+
export declare function findMenuByPath(list: MenuItemType[], path?: string): MenuItemType | null;
|
|
17
|
+
/**
|
|
18
|
+
* 通过路径查找根菜单
|
|
19
|
+
*
|
|
20
|
+
* @param menus 菜单列表
|
|
21
|
+
* @param path 菜单路径,可选
|
|
22
|
+
* @returns 包含查找到的菜单、根菜单和根菜单路径的对象
|
|
23
|
+
*/
|
|
24
|
+
export declare function findRootMenuByPath(menus: MenuItemType[], path?: string): {
|
|
25
|
+
findMenu: MenuItemType | null;
|
|
26
|
+
rootMenu: MenuItemType | null;
|
|
27
|
+
rootMenuPath: string | null;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* 递归查找第一个子菜单路径下的最深层级的第一个菜单项
|
|
31
|
+
*
|
|
32
|
+
* @param splitSideNavItems 菜单列表
|
|
33
|
+
* @returns 找到的最深层级的第一个菜单项
|
|
34
|
+
*/
|
|
35
|
+
export declare function findDeepestFirstItem(splitSideNavItems: MenuItemType[]): MenuItemType | null;
|
|
36
|
+
/**
|
|
37
|
+
* 获取菜单项中所有键及其对应的层级
|
|
38
|
+
*
|
|
39
|
+
* @param menuItems1 菜单项数组
|
|
40
|
+
* @returns 一个对象,键为菜单项的 key,值为菜单项的层级
|
|
41
|
+
*/
|
|
42
|
+
export declare function getLevelKeys(menuItems1: MenuItemType[]): Record<string, number>;
|
|
43
|
+
/**
|
|
44
|
+
* 获取菜单项的父级键
|
|
45
|
+
*
|
|
46
|
+
* @param menuItems 菜单项数组
|
|
47
|
+
* @returns 返回记录每个菜单项键对应的父级键数组的对象
|
|
48
|
+
*/
|
|
49
|
+
export declare function getParentKeys(menuItems: MenuItemType[]): Record<string, string[]>;
|