@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,14 @@
|
|
|
1
|
+
import type { MenuItemType } from "../layout/layout-menu/types";
|
|
2
|
+
import type { AppRouteRecordRaw } from "../router/types";
|
|
3
|
+
interface AccessState {
|
|
4
|
+
wholeMenus: MenuItemType[];
|
|
5
|
+
routeList: AppRouteRecordRaw[];
|
|
6
|
+
flatRouteList: Record<string, AppRouteRecordRaw>;
|
|
7
|
+
isAccessChecked: boolean;
|
|
8
|
+
}
|
|
9
|
+
interface AccessAction {
|
|
10
|
+
setAccessStore: (routes: AppRouteRecordRaw[]) => AccessState;
|
|
11
|
+
reset: () => void;
|
|
12
|
+
}
|
|
13
|
+
export declare const useAccessStore: import("zustand").UseBoundStore<import("zustand").StoreApi<AccessState & AccessAction>>;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { MenuItemType } from "../api/system/menu/types";
|
|
2
|
+
import type { FetchAddRoleItemBody, FetchAddRoleItemData, FetchDeleteRoleItemBody, FetchDeleteRoleItemData, FetchMenuByRoleIdData, FetchMenuByRoleIdQuery, FetchRoleListData, FetchRoleListQuery, FetchRoleMenuData, FetchUpdateRoleItemBody, FetchUpdateRoleItemData } from "../api/system/role/api/client";
|
|
3
|
+
import type { NotificationItem } from "../layout/widgets/notification/types";
|
|
4
|
+
/**
|
|
5
|
+
* 系统 API provider(D9):模块经 ctx.register.systemApi 接管角色/菜单类
|
|
6
|
+
* 内置 API。系统角色/菜单/通知/上传这些原本硬编码在 runtime 根级路径的
|
|
7
|
+
* 内部端点,通过注册表可被模块注入为带自身 apiPrefix 的实现(如 playground
|
|
8
|
+
* 模块把 /system/* 收敛到其 /<dir> 前缀下),消费点(role/menu/notifications/
|
|
9
|
+
* 头像上传)在运行时委托,未注册时回落到内置 root 级实现(沿用既有 fetch*)。
|
|
10
|
+
*
|
|
11
|
+
* 三者全必填——「接管系统 API」是全量接管,不做部分托管(与 authProvider 同规则)。
|
|
12
|
+
* provider 对返回值自负责:runtime 在 provider 路径上不做任何成功/字段校验。
|
|
13
|
+
*/
|
|
14
|
+
export interface SystemApiProvider {
|
|
15
|
+
fetchRoleList: (query: FetchRoleListQuery) => Promise<FetchRoleListData>;
|
|
16
|
+
fetchAddRoleItem: (body: FetchAddRoleItemBody) => Promise<FetchAddRoleItemData>;
|
|
17
|
+
fetchUpdateRoleItem: (body: FetchUpdateRoleItemBody) => Promise<FetchUpdateRoleItemData>;
|
|
18
|
+
fetchDeleteRoleItem: (body: FetchDeleteRoleItemBody) => Promise<FetchDeleteRoleItemData>;
|
|
19
|
+
fetchRoleMenu: () => Promise<FetchRoleMenuData>;
|
|
20
|
+
fetchMenuByRoleId: (query: FetchMenuByRoleIdQuery) => Promise<FetchMenuByRoleIdData>;
|
|
21
|
+
fetchMenuList: (data: any) => Promise<ListData<MenuItemType>>;
|
|
22
|
+
fetchAddMenuItem: (data: MenuItemType) => Promise<string>;
|
|
23
|
+
fetchUpdateMenuItem: (data: MenuItemType) => Promise<string>;
|
|
24
|
+
fetchDeleteMenuItem: (id: number) => Promise<string>;
|
|
25
|
+
}
|
|
26
|
+
/** 通知 provider(D9):模块经 ctx.register.notificationsApi 接管通知拉取 */
|
|
27
|
+
export interface NotificationsApiProvider {
|
|
28
|
+
fetchNotifications: () => Promise<NotificationItem[]>;
|
|
29
|
+
}
|
|
30
|
+
/** 上传 provider(D9):模块经 ctx.register.uploadApi 接管头像/附件上传端点 */
|
|
31
|
+
export interface UploadApiProvider {
|
|
32
|
+
/** 上传 action URL */
|
|
33
|
+
action: string;
|
|
34
|
+
/** 每次上传动态取请求头(如注入 Bearer);返回普通对象 */
|
|
35
|
+
headers: () => Record<string, string>;
|
|
36
|
+
}
|
|
37
|
+
export declare function registerSystemApiProvider(moduleName: string, provider: SystemApiProvider): void;
|
|
38
|
+
export declare function getSystemApiProvider(): SystemApiProvider | undefined;
|
|
39
|
+
export declare function registerNotificationsApiProvider(moduleName: string, provider: NotificationsApiProvider): void;
|
|
40
|
+
export declare function getNotificationsApiProvider(): NotificationsApiProvider | undefined;
|
|
41
|
+
export declare function registerUploadApiProvider(moduleName: string, provider: UploadApiProvider): void;
|
|
42
|
+
export declare function getUploadApiProvider(): UploadApiProvider | undefined;
|
|
43
|
+
/**
|
|
44
|
+
* 卸载模块时复位其登记的全部 API provider(系统/通知/上传)。以 moduleName
|
|
45
|
+
* 作命名隔离——不同模块各自登记互不干扰,卸载只清自己的。
|
|
46
|
+
*/
|
|
47
|
+
export declare function unregisterApiProviders(moduleName: string): void;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { AuthType, LoginInfo, UserInfoType } from "../api/user/types";
|
|
2
|
+
/**
|
|
3
|
+
* 认证 provider(P5):模块经 ctx.register.authProvider 接管登录链路。
|
|
4
|
+
* 三者全必填——「接管认证」是全量接管,不做部分托管(半托管会让两条链路
|
|
5
|
+
* 并存、状态不可推理)。
|
|
6
|
+
*
|
|
7
|
+
* 契约边界(重要):provider 对返回值自负责——runtime 在 provider 路径上
|
|
8
|
+
* 不做任何 success/字段校验,也不弹错误提示。login 返回的 Promise 必须
|
|
9
|
+
* 已归一为 AuthType({ token, refreshToken });认证失败请直接 reject,
|
|
10
|
+
* runtime 会原样透传 rejection(错误提示归 provider 自己处理)。
|
|
11
|
+
*/
|
|
12
|
+
export interface AuthProvider {
|
|
13
|
+
login: (payload: LoginInfo) => Promise<AuthType>;
|
|
14
|
+
logout: () => Promise<void>;
|
|
15
|
+
getUserInfo: () => Promise<UserInfoType>;
|
|
16
|
+
}
|
|
17
|
+
export declare function registerAuthProvider(moduleName: string, provider: AuthProvider): void;
|
|
18
|
+
export declare function getAuthProvider(): AuthProvider | undefined;
|
|
19
|
+
export declare function unregisterAuthProvider(moduleName: string): void;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { AuthType, LoginInfo } from "../api/user/types";
|
|
2
|
+
interface AuthAction {
|
|
3
|
+
login: (loginPayload: LoginInfo) => Promise<void>;
|
|
4
|
+
logout: () => Promise<void>;
|
|
5
|
+
reset: () => void;
|
|
6
|
+
}
|
|
7
|
+
export declare const useAuthStore: import("zustand").UseBoundStore<Omit<import("zustand").StoreApi<AuthType & AuthAction>, "setState" | "persist"> & {
|
|
8
|
+
setState(partial: (AuthType & AuthAction) | Partial<AuthType & AuthAction> | ((state: AuthType & AuthAction) => (AuthType & AuthAction) | Partial<AuthType & AuthAction>), replace?: false | undefined): unknown;
|
|
9
|
+
setState(state: (AuthType & AuthAction) | ((state: AuthType & AuthAction) => AuthType & AuthAction), replace: true): unknown;
|
|
10
|
+
persist: {
|
|
11
|
+
setOptions: (options: Partial<import("zustand/middleware").PersistOptions<AuthType & AuthAction, AuthType & AuthAction, unknown>>) => void;
|
|
12
|
+
clearStorage: () => void;
|
|
13
|
+
rehydrate: () => Promise<void> | void;
|
|
14
|
+
hasHydrated: () => boolean;
|
|
15
|
+
onHydrate: (fn: (state: AuthType & AuthAction) => void) => () => void;
|
|
16
|
+
onFinishHydration: (fn: (state: AuthType & AuthAction) => void) => () => void;
|
|
17
|
+
getOptions: () => Partial<import("zustand/middleware").PersistOptions<AuthType & AuthAction, AuthType & AuthAction, unknown>>;
|
|
18
|
+
};
|
|
19
|
+
}>;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
interface GlobalAction {
|
|
2
|
+
openGlobalSpin: () => void;
|
|
3
|
+
closeGlobalSpin: () => void;
|
|
4
|
+
}
|
|
5
|
+
export declare const useGlobalStore: import("zustand").UseBoundStore<import("zustand").StoreApi<{
|
|
6
|
+
/**
|
|
7
|
+
* @zh 全局加载动画是否显示
|
|
8
|
+
* @en Whether the global spinning animation is shown
|
|
9
|
+
*/
|
|
10
|
+
globalSpin: boolean;
|
|
11
|
+
} & GlobalAction>>;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type { LanguageType } from "../../locales/index";
|
|
2
|
+
import type { PreferencesState, ThemeType } from "./types";
|
|
3
|
+
/**
|
|
4
|
+
* 默认偏好设置
|
|
5
|
+
*/
|
|
6
|
+
export declare const DEFAULT_PREFERENCES: {
|
|
7
|
+
watermark: false;
|
|
8
|
+
watermarkContent: string;
|
|
9
|
+
enableBackTopButton: true;
|
|
10
|
+
pageLayout: "layout-right";
|
|
11
|
+
enableBackendAccess: true;
|
|
12
|
+
enableFrontendAceess: false;
|
|
13
|
+
language: "zh-CN";
|
|
14
|
+
enableDynamicTitle: true;
|
|
15
|
+
enableCheckUpdates: true;
|
|
16
|
+
checkUpdatesInterval: number;
|
|
17
|
+
theme: "auto";
|
|
18
|
+
colorBlindMode: false;
|
|
19
|
+
colorGrayMode: false;
|
|
20
|
+
themeRadius: number;
|
|
21
|
+
builtinTheme: "blue";
|
|
22
|
+
themeColorPrimary: string;
|
|
23
|
+
transitionProgress: true;
|
|
24
|
+
transitionLoading: true;
|
|
25
|
+
transitionEnable: true;
|
|
26
|
+
transitionName: string;
|
|
27
|
+
navigationStyle: "side-navigation";
|
|
28
|
+
tabbarEnable: true;
|
|
29
|
+
tabbarShowIcon: true;
|
|
30
|
+
tabbarPersist: true;
|
|
31
|
+
tabbarDraggable: true;
|
|
32
|
+
tabbarStyleType: "chrome";
|
|
33
|
+
tabbarShowMore: true;
|
|
34
|
+
tabbarShowMaximize: true;
|
|
35
|
+
sidebarEnable: true;
|
|
36
|
+
sidebarWidth: number;
|
|
37
|
+
sideCollapsedWidth: number;
|
|
38
|
+
sidebarCollapsed: false;
|
|
39
|
+
sidebarCollapseShowTitle: true;
|
|
40
|
+
sidebarExtraCollapsedWidth: number;
|
|
41
|
+
firstColumnWidthInTwoColumnNavigation: number;
|
|
42
|
+
sidebarTheme: "light";
|
|
43
|
+
accordion: true;
|
|
44
|
+
enableFooter: true;
|
|
45
|
+
fixedFooter: true;
|
|
46
|
+
companyName: string;
|
|
47
|
+
companyWebsite: string;
|
|
48
|
+
copyrightDate: string;
|
|
49
|
+
ICPNumber: string;
|
|
50
|
+
ICPLink: string;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* 偏好设置操作接口
|
|
54
|
+
*/
|
|
55
|
+
interface PreferencesAction {
|
|
56
|
+
reset: () => void;
|
|
57
|
+
changeSiteTheme: (theme: ThemeType) => void;
|
|
58
|
+
changeLanguage: (language: LanguageType) => void;
|
|
59
|
+
setPreferences: {
|
|
60
|
+
<T>(key: string, value: T): void;
|
|
61
|
+
<T extends Partial<PreferencesState>>(preferences: T): void;
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* 偏好设置状态管理
|
|
66
|
+
*/
|
|
67
|
+
export declare const usePreferencesStore: import("zustand").UseBoundStore<Omit<import("zustand").StoreApi<PreferencesState & PreferencesAction>, "setState" | "persist"> & {
|
|
68
|
+
setState(partial: (PreferencesState & PreferencesAction) | Partial<PreferencesState & PreferencesAction> | ((state: PreferencesState & PreferencesAction) => (PreferencesState & PreferencesAction) | Partial<PreferencesState & PreferencesAction>), replace?: false | undefined): unknown;
|
|
69
|
+
setState(state: (PreferencesState & PreferencesAction) | ((state: PreferencesState & PreferencesAction) => PreferencesState & PreferencesAction), replace: true): unknown;
|
|
70
|
+
persist: {
|
|
71
|
+
setOptions: (options: Partial<import("zustand/middleware").PersistOptions<PreferencesState & PreferencesAction, PreferencesState & PreferencesAction, unknown>>) => void;
|
|
72
|
+
clearStorage: () => void;
|
|
73
|
+
rehydrate: () => Promise<void> | void;
|
|
74
|
+
hasHydrated: () => boolean;
|
|
75
|
+
onHydrate: (fn: (state: PreferencesState & PreferencesAction) => void) => () => void;
|
|
76
|
+
onFinishHydration: (fn: (state: PreferencesState & PreferencesAction) => void) => () => void;
|
|
77
|
+
getOptions: () => Partial<import("zustand/middleware").PersistOptions<PreferencesState & PreferencesAction, PreferencesState & PreferencesAction, unknown>>;
|
|
78
|
+
};
|
|
79
|
+
}>;
|
|
80
|
+
export {};
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
import type { MenuProps } from "antd";
|
|
2
|
+
import type { MIXED_NAVIGATION, SIDE_NAVIGATION, TOP_NAVIGATION, TWO_COLUMN_NAVIGATION } from "../../layout/widgets/preferences/blocks/layout/constants";
|
|
3
|
+
import type { LanguageType } from "../../locales/index";
|
|
4
|
+
/**
|
|
5
|
+
* @zh 登录页面布局
|
|
6
|
+
* @en Login page layout
|
|
7
|
+
*/
|
|
8
|
+
export type PageLayoutType = "layout-left" | "layout-center" | "layout-right";
|
|
9
|
+
/**
|
|
10
|
+
* @zh 标签栏风格
|
|
11
|
+
* @en Tabbar style
|
|
12
|
+
*/
|
|
13
|
+
export type TabsStyleType = "brisk" | "card" | "chrome" | "plain";
|
|
14
|
+
/**
|
|
15
|
+
* @zh 主题类型
|
|
16
|
+
* @en Theme type
|
|
17
|
+
*/
|
|
18
|
+
export type ThemeType = "dark" | "light" | "auto";
|
|
19
|
+
/**
|
|
20
|
+
* @zh 动画类型
|
|
21
|
+
* @en Animation type
|
|
22
|
+
*/
|
|
23
|
+
interface AnimationState {
|
|
24
|
+
/**
|
|
25
|
+
* @zh 是否启用过渡动画
|
|
26
|
+
* @en Whether to enable transition animation
|
|
27
|
+
* @default true
|
|
28
|
+
*/
|
|
29
|
+
transitionProgress: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* @zh 是否启用加载动画
|
|
32
|
+
* @en Whether to enable loading animation
|
|
33
|
+
* @default true
|
|
34
|
+
*/
|
|
35
|
+
transitionLoading: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* @zh 是否启用动画
|
|
38
|
+
* @en Whether to enable animation
|
|
39
|
+
* @default true
|
|
40
|
+
*/
|
|
41
|
+
transitionEnable: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* @zh 过渡动画名称
|
|
44
|
+
* @en Transition animation name
|
|
45
|
+
* @default "fade-slide"
|
|
46
|
+
*/
|
|
47
|
+
transitionName: string;
|
|
48
|
+
}
|
|
49
|
+
export type NavigationType = typeof SIDE_NAVIGATION | typeof TOP_NAVIGATION | typeof TWO_COLUMN_NAVIGATION | typeof MIXED_NAVIGATION;
|
|
50
|
+
export type BuiltinThemeType = "red" | "volcano" | "orange" | "gold" | "yellow" | "lime" | "green" | "cyan" | "blue" | "geekblue" | "purple" | "magenta" | "gray" | "custom";
|
|
51
|
+
interface LayoutState {
|
|
52
|
+
navigationStyle: NavigationType;
|
|
53
|
+
}
|
|
54
|
+
export interface GeneralState {
|
|
55
|
+
/**
|
|
56
|
+
* @zh 是否开启水印
|
|
57
|
+
* @en Whether to enable watermark
|
|
58
|
+
* @default false
|
|
59
|
+
*/
|
|
60
|
+
watermark: boolean;
|
|
61
|
+
/**
|
|
62
|
+
* @zh 水印内容
|
|
63
|
+
* @en Watermark content
|
|
64
|
+
* @default ""
|
|
65
|
+
*/
|
|
66
|
+
watermarkContent: string;
|
|
67
|
+
/**
|
|
68
|
+
* @zh 返回页面顶部的操作按钮
|
|
69
|
+
* @en BackTop makes it easy to go back to the top of the page.
|
|
70
|
+
* @default true
|
|
71
|
+
*/
|
|
72
|
+
enableBackTopButton: boolean;
|
|
73
|
+
/**
|
|
74
|
+
* @zh 登录页面的布局配置
|
|
75
|
+
* @en Login page layout configuration
|
|
76
|
+
* @default "layout-right"
|
|
77
|
+
*/
|
|
78
|
+
pageLayout: PageLayoutType;
|
|
79
|
+
/**
|
|
80
|
+
* @zh 开启前端路由权限
|
|
81
|
+
* @en Enable frontend route permissions
|
|
82
|
+
* @default false
|
|
83
|
+
*/
|
|
84
|
+
enableFrontendAceess: boolean;
|
|
85
|
+
/**
|
|
86
|
+
* @zh 开启后端路由权限
|
|
87
|
+
* @en Enable backend route permissions
|
|
88
|
+
* @default true
|
|
89
|
+
*/
|
|
90
|
+
enableBackendAccess: boolean;
|
|
91
|
+
/**
|
|
92
|
+
* @zh 当前语言
|
|
93
|
+
* @en Current language
|
|
94
|
+
* @default "zh-CN"
|
|
95
|
+
*/
|
|
96
|
+
language: LanguageType;
|
|
97
|
+
/**
|
|
98
|
+
* @zh 是否开启动态标题
|
|
99
|
+
* @en Whether to enable dynamic title
|
|
100
|
+
* @default true
|
|
101
|
+
*/
|
|
102
|
+
enableDynamicTitle: boolean;
|
|
103
|
+
/**
|
|
104
|
+
* @zh 是否开启更新检查
|
|
105
|
+
* @en Whether to enable update check
|
|
106
|
+
* @default true
|
|
107
|
+
*/
|
|
108
|
+
enableCheckUpdates: boolean;
|
|
109
|
+
/**
|
|
110
|
+
* @zh 轮训时间,单位:分钟,默认 1 分钟
|
|
111
|
+
* @en Polling time, unit: minute, default 1 minute
|
|
112
|
+
* @default 1
|
|
113
|
+
*/
|
|
114
|
+
checkUpdatesInterval: number;
|
|
115
|
+
}
|
|
116
|
+
export interface SidebarState {
|
|
117
|
+
/**
|
|
118
|
+
* 侧边栏是否可见
|
|
119
|
+
* @default true
|
|
120
|
+
*/
|
|
121
|
+
sidebarEnable?: boolean;
|
|
122
|
+
/**
|
|
123
|
+
* 侧边菜单宽度
|
|
124
|
+
* @default 210
|
|
125
|
+
*/
|
|
126
|
+
sidebarWidth: number;
|
|
127
|
+
/**
|
|
128
|
+
* 侧边菜单折叠宽度
|
|
129
|
+
* @default 56
|
|
130
|
+
*/
|
|
131
|
+
sideCollapsedWidth: number;
|
|
132
|
+
/**
|
|
133
|
+
* 侧边菜单折叠状态
|
|
134
|
+
* @default false
|
|
135
|
+
*/
|
|
136
|
+
sidebarCollapsed: boolean;
|
|
137
|
+
/**
|
|
138
|
+
* 侧边菜单是否折叠时,是否显示 title
|
|
139
|
+
* @default true
|
|
140
|
+
*/
|
|
141
|
+
sidebarCollapseShowTitle: boolean;
|
|
142
|
+
/**
|
|
143
|
+
* 侧边菜单折叠额外宽度
|
|
144
|
+
* @default 48
|
|
145
|
+
*/
|
|
146
|
+
sidebarExtraCollapsedWidth: number;
|
|
147
|
+
/**
|
|
148
|
+
* 两栏布局时,左侧菜单宽度
|
|
149
|
+
* @default 80
|
|
150
|
+
*/
|
|
151
|
+
firstColumnWidthInTwoColumnNavigation: number;
|
|
152
|
+
/**
|
|
153
|
+
* 侧边栏主题
|
|
154
|
+
* @default dark
|
|
155
|
+
*/
|
|
156
|
+
sidebarTheme: MenuProps["theme"];
|
|
157
|
+
/**
|
|
158
|
+
* @zh 导航菜单手风琴模式
|
|
159
|
+
* @en Accordion mode of navigation menu
|
|
160
|
+
*/
|
|
161
|
+
accordion: boolean;
|
|
162
|
+
}
|
|
163
|
+
export interface FooterState {
|
|
164
|
+
enableFooter: boolean;
|
|
165
|
+
fixedFooter: boolean;
|
|
166
|
+
companyName: string;
|
|
167
|
+
companyWebsite: string;
|
|
168
|
+
copyrightDate: string;
|
|
169
|
+
ICPNumber: string;
|
|
170
|
+
ICPLink: string;
|
|
171
|
+
}
|
|
172
|
+
export interface PreferencesState extends AnimationState, LayoutState, GeneralState, SidebarState, FooterState {
|
|
173
|
+
/**
|
|
174
|
+
* @zh 当前主题
|
|
175
|
+
* @en Current theme
|
|
176
|
+
* @default "auto"
|
|
177
|
+
*/
|
|
178
|
+
theme: ThemeType;
|
|
179
|
+
/**
|
|
180
|
+
* @zh 是否开启色弱模式
|
|
181
|
+
* @en Whether to enable color-blind mode
|
|
182
|
+
* @default false
|
|
183
|
+
*/
|
|
184
|
+
colorBlindMode: boolean;
|
|
185
|
+
/**
|
|
186
|
+
* @zh 是否开启灰色模式
|
|
187
|
+
* @en Whether to enable gray mode
|
|
188
|
+
* @default false
|
|
189
|
+
*/
|
|
190
|
+
colorGrayMode: boolean;
|
|
191
|
+
/**
|
|
192
|
+
* @zh 主题圆角值
|
|
193
|
+
* @en Theme radius value
|
|
194
|
+
* @default 6
|
|
195
|
+
*/
|
|
196
|
+
themeRadius: number;
|
|
197
|
+
/**
|
|
198
|
+
* @zh 主题色
|
|
199
|
+
* @en Theme color
|
|
200
|
+
* @default "#1677ff" - blue
|
|
201
|
+
*/
|
|
202
|
+
themeColorPrimary: string;
|
|
203
|
+
/**
|
|
204
|
+
* @zh 内置主题
|
|
205
|
+
* @en Builtin theme
|
|
206
|
+
* @default "blue"
|
|
207
|
+
*/
|
|
208
|
+
builtinTheme: BuiltinThemeType;
|
|
209
|
+
/**
|
|
210
|
+
* @zh 标签栏风格
|
|
211
|
+
* @en Tabbar style
|
|
212
|
+
* @default "chrome"
|
|
213
|
+
*/
|
|
214
|
+
tabbarStyleType: TabsStyleType;
|
|
215
|
+
/**
|
|
216
|
+
* @zh 是否启用标签栏
|
|
217
|
+
* @en Whether to enable tabbar
|
|
218
|
+
* @default true
|
|
219
|
+
*/
|
|
220
|
+
tabbarEnable: boolean;
|
|
221
|
+
/**
|
|
222
|
+
* @zh 是否显示标签栏图标
|
|
223
|
+
* @en Whether to show tabbar icon
|
|
224
|
+
* @default true
|
|
225
|
+
* @todo 待实现
|
|
226
|
+
*/
|
|
227
|
+
tabbarShowIcon: boolean;
|
|
228
|
+
/**
|
|
229
|
+
* @zh 是否持久化标签栏
|
|
230
|
+
* @en Whether to persist tabbar
|
|
231
|
+
* @default true
|
|
232
|
+
*/
|
|
233
|
+
tabbarPersist: boolean;
|
|
234
|
+
/**
|
|
235
|
+
* @zh 是否可拖拽标签栏
|
|
236
|
+
* @en Whether to drag tabbar
|
|
237
|
+
* @default true
|
|
238
|
+
* @todo 待实现
|
|
239
|
+
*/
|
|
240
|
+
tabbarDraggable: boolean;
|
|
241
|
+
/**
|
|
242
|
+
* @zh 是否显示更多
|
|
243
|
+
* @en Whether to show more
|
|
244
|
+
* @default true
|
|
245
|
+
*/
|
|
246
|
+
tabbarShowMore: boolean;
|
|
247
|
+
/**
|
|
248
|
+
* @zh 是否显示最大化
|
|
249
|
+
* @en Whether to show maximize
|
|
250
|
+
* @default true
|
|
251
|
+
*/
|
|
252
|
+
tabbarShowMaximize: boolean;
|
|
253
|
+
}
|
|
254
|
+
export {};
|