@jiangood/open-admin 2.5.8 → 3.0.0

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.
Files changed (142) hide show
  1. package/package.json +20 -8
  2. package/src/framework/GlobalData.ts +85 -0
  3. package/src/framework/biz/OrgTree.tsx +2 -7
  4. package/src/framework/biz/Perm.tsx +11 -0
  5. package/src/framework/biz/PermActions.tsx +18 -15
  6. package/src/framework/biz/index.tsx +34 -19
  7. package/src/framework/components/ContextMenu/index.tsx +105 -78
  8. package/src/framework/components/DownloadModal/index.tsx +15 -17
  9. package/src/framework/components/ErrorBoundary/index.tsx +2 -2
  10. package/src/framework/components/FormModal/index.tsx +76 -0
  11. package/src/framework/components/Gap/index.tsx +1 -1
  12. package/src/framework/components/NamedIcon/index.tsx +55 -9
  13. package/src/framework/components/Page/index.less +0 -1
  14. package/src/framework/components/Page/index.tsx +34 -27
  15. package/src/framework/components/PageLoading/index.less +15 -0
  16. package/src/framework/components/PageLoading/index.tsx +32 -16
  17. package/src/framework/components/ProTable/index.tsx +86 -15
  18. package/src/framework/components/index.ts +1 -0
  19. package/src/framework/config/index.ts +1 -0
  20. package/src/framework/config/themeConfig.ts +39 -0
  21. package/src/framework/fields/FieldBoolean/index.tsx +11 -2
  22. package/src/framework/fields/FieldDate/index.tsx +22 -7
  23. package/src/framework/fields/FieldDateRange/index.tsx +24 -6
  24. package/src/framework/fields/FieldDictSelect/index.tsx +1 -0
  25. package/src/framework/fields/FieldEditor/index.tsx +7 -1
  26. package/src/framework/fields/FieldNumberRange/index.tsx +14 -5
  27. package/src/framework/fields/FieldPercent/index.tsx +16 -5
  28. package/src/framework/fields/FieldRemoteSelect/index.tsx +4 -2
  29. package/src/framework/fields/FieldRemoteTreeSelect/index.tsx +2 -1
  30. package/src/framework/fields/FieldSysOrgTree/index.tsx +6 -1
  31. package/src/framework/fields/FieldSysOrgTreeSelect/index.tsx +6 -1
  32. package/src/framework/fields/FieldTable/index.tsx +35 -6
  33. package/src/framework/fields/FieldTableSelect/index.tsx +18 -2
  34. package/src/framework/fields/FieldUploadFile/index.tsx +69 -28
  35. package/src/framework/fields/index.ts +0 -1
  36. package/src/framework/index.ts +2 -0
  37. package/src/framework/router/Link.tsx +26 -0
  38. package/src/framework/router/PageFrame.tsx +31 -0
  39. package/src/framework/router/history.ts +50 -0
  40. package/src/framework/router/index.ts +4 -0
  41. package/src/framework/router/matcher.ts +58 -0
  42. package/src/framework/utils/{ArrayUtils.js → ArrayUtils.ts} +5 -5
  43. package/src/framework/utils/{DateUtils.js → DateUtils.ts} +19 -19
  44. package/src/framework/utils/{DeviceUtils.js → DeviceUtils.ts} +8 -1
  45. package/src/framework/utils/{EventBus.js → EventBus.ts} +13 -6
  46. package/src/framework/utils/MessageApi.ts +5 -0
  47. package/src/framework/utils/ModalApi.ts +5 -0
  48. package/src/framework/utils/ObjectUtils.ts +15 -0
  49. package/src/framework/utils/{StorageUtils.js → StorageUtils.ts} +7 -7
  50. package/src/framework/utils/{StringUtils.js → StringUtils.ts} +15 -15
  51. package/src/framework/utils/{TreeUtils.js → TreeUtils.ts} +19 -12
  52. package/src/framework/utils/{UrlUtils.js → UrlUtils.ts} +10 -10
  53. package/src/framework/utils/index.ts +2 -1
  54. package/src/framework/utils/system/{DictUtils.js → DictUtils.ts} +16 -4
  55. package/src/framework/utils/system/{HttpUtils.js → HttpUtils.ts} +25 -21
  56. package/src/framework/utils/system/PageUtils.ts +49 -0
  57. package/src/framework/utils/system/{PermUtils.js → PermUtils.ts} +5 -6
  58. package/src/framework/utils/system/index.ts +0 -2
  59. package/src/framework/views/ViewBoolean/index.tsx +6 -3
  60. package/src/framework/views/ViewFileButton/index.tsx +13 -8
  61. package/src/framework/views/ViewImage/index.tsx +19 -14
  62. package/src/framework/views/ViewRange/index.tsx +10 -7
  63. package/src/framework/views/ViewText/index.tsx +9 -11
  64. package/src/layouts/admin/AdminTabs.jsx +79 -0
  65. package/src/layouts/admin/AdminTabs.less +63 -0
  66. package/src/layouts/admin/HeaderRight.jsx +66 -33
  67. package/src/layouts/admin/TabLayout.jsx +124 -0
  68. package/src/layouts/admin/index.jsx +12 -5
  69. package/src/layouts/admin/index.less +5 -83
  70. package/src/layouts/index.tsx +148 -0
  71. package/src/main.jsx +8 -0
  72. package/src/pages/account/changePassword.jsx +14 -10
  73. package/src/pages/article/$code.jsx +43 -0
  74. package/src/pages/index.jsx +6 -4
  75. package/src/pages/{login.jsx → public/login.jsx} +7 -10
  76. package/src/pages/public/test.jsx +30 -0
  77. package/src/pages/{forceUpdatePwd.jsx → standalone/forceUpdatePwd.jsx} +3 -32
  78. package/src/pages/system/article/index.jsx +147 -0
  79. package/src/pages/system/dict/index.jsx +60 -91
  80. package/src/pages/system/file/index.jsx +23 -17
  81. package/src/pages/system/job/index.jsx +63 -72
  82. package/src/pages/system/log/index.jsx +11 -8
  83. package/src/pages/system/org/index.jsx +60 -80
  84. package/src/pages/system/role/index.jsx +50 -86
  85. package/src/pages/system/role/rolePerm.jsx +2 -2
  86. package/src/pages/system/user/index.jsx +120 -73
  87. package/src/pages/system/user/userPerm.jsx +2 -2
  88. package/vite-plugin/index.js +107 -0
  89. package/config/common-plugin.js +0 -145
  90. package/config/config.js +0 -5
  91. package/config/utils.js +0 -73
  92. package/src/.umi-production/appData.json +0 -2237
  93. package/src/.umi-production/core/EmptyRoute.tsx +0 -9
  94. package/src/.umi-production/core/defineApp.ts +0 -16
  95. package/src/.umi-production/core/helmet.ts +0 -10
  96. package/src/.umi-production/core/helmetContext.ts +0 -4
  97. package/src/.umi-production/core/history.ts +0 -72
  98. package/src/.umi-production/core/historyIntelli.ts +0 -132
  99. package/src/.umi-production/core/plugin.ts +0 -40
  100. package/src/.umi-production/core/pluginConfig.ts +0 -330
  101. package/src/.umi-production/core/pluginConfigJoi.d.ts +0 -7
  102. package/src/.umi-production/core/polyfill.ts +0 -220
  103. package/src/.umi-production/core/route.tsx +0 -45
  104. package/src/.umi-production/core/routeProps.js +0 -5
  105. package/src/.umi-production/core/routeProps.ts +0 -6
  106. package/src/.umi-production/core/terminal.ts +0 -37
  107. package/src/.umi-production/exports.ts +0 -17
  108. package/src/.umi-production/testBrowser.tsx +0 -90
  109. package/src/.umi-production/tsconfig.json +0 -43
  110. package/src/.umi-production/typings.d.ts +0 -136
  111. package/src/.umi-production/umi.ts +0 -83
  112. package/src/framework/GlobalData.d.ts +0 -8
  113. package/src/framework/GlobalData.js +0 -33
  114. package/src/framework/biz/HasPerm.tsx +0 -14
  115. package/src/framework/fields/FieldRemoteSelectMultiple/index.tsx +0 -29
  116. package/src/framework/utils/ArrayUtils.d.ts +0 -6
  117. package/src/framework/utils/DateUtils.d.ts +0 -20
  118. package/src/framework/utils/DeviceUtils.d.ts +0 -3
  119. package/src/framework/utils/EventBus.d.ts +0 -6
  120. package/src/framework/utils/MessageUtils.d.ts +0 -10
  121. package/src/framework/utils/MessageUtils.js +0 -43
  122. package/src/framework/utils/ObjectUtils.d.ts +0 -14
  123. package/src/framework/utils/ObjectUtils.js +0 -12
  124. package/src/framework/utils/StorageUtils.d.ts +0 -4
  125. package/src/framework/utils/StringUtils.d.ts +0 -17
  126. package/src/framework/utils/TreeUtils.d.ts +0 -13
  127. package/src/framework/utils/UrlUtils.d.ts +0 -6
  128. package/src/framework/utils/system/DictUtils.d.ts +0 -20
  129. package/src/framework/utils/system/FormRegistry.d.ts +0 -8
  130. package/src/framework/utils/system/FormRegistry.js +0 -31
  131. package/src/framework/utils/system/HttpUtils.d.ts +0 -14
  132. package/src/framework/utils/system/PageUtils.d.ts +0 -14
  133. package/src/framework/utils/system/PageUtils.js +0 -59
  134. package/src/framework/utils/system/PermUtils.d.ts +0 -5
  135. package/src/framework/utils/system/ThemeUtils.d.ts +0 -6
  136. package/src/framework/utils/system/ThemeUtils.js +0 -52
  137. package/src/layouts/PageRender.tsx +0 -29
  138. package/src/layouts/admin/TabPageRender.jsx +0 -210
  139. package/src/layouts/index.jsx +0 -119
  140. package/src/loading.jsx +0 -19
  141. package/src/pages/about.jsx +0 -11
  142. /package/src/pages/{login.less → public/login.less} +0 -0
@@ -1,83 +0,0 @@
1
- // @ts-nocheck
2
- // This file is generated by Umi automatically
3
- // DO NOT CHANGE IT MANUALLY!
4
- import './core/polyfill';
5
-
6
- import { renderClient } from '/home/runner/work/open-admin/open-admin/web/node_modules/@umijs/renderer-react';
7
- import { getRoutes } from './core/route';
8
- import { createPluginManager } from './core/plugin';
9
- import { createHistory } from './core/history';
10
- import Loading from '/home/runner/work/open-admin/open-admin/web/src/loading.jsx';
11
- import { ApplyPluginsType } from 'umi';
12
- import {FormRegistry} from '/home/runner/work/open-admin/open-admin/web/src/framework';
13
-
14
- const publicPath = "./";
15
- const runtimePublicPath = false;
16
-
17
- async function render() {
18
- const pluginManager = createPluginManager();
19
- const { routes, routeComponents } = await getRoutes(pluginManager);
20
-
21
- // allow user to extend routes
22
- await pluginManager.applyPlugins({
23
- key: 'patchRoutes',
24
- type: ApplyPluginsType.event,
25
- args: {
26
- routes,
27
- routeComponents,
28
- },
29
- });
30
-
31
- const contextOpts = pluginManager.applyPlugins({
32
- key: 'modifyContextOpts',
33
- type: ApplyPluginsType.modify,
34
- initialValue: {},
35
- });
36
-
37
- const basename = contextOpts.basename || '/';
38
- const historyType = contextOpts.historyType || 'hash';
39
-
40
- const history = createHistory({
41
- type: historyType,
42
- basename,
43
- ...contextOpts.historyOpts,
44
- });
45
-
46
- return (pluginManager.applyPlugins({
47
- key: 'render',
48
- type: ApplyPluginsType.compose,
49
- initialValue() {
50
- const context = {
51
- useStream: true,
52
- routes,
53
- routeComponents,
54
- pluginManager,
55
- mountElementId: 'root',
56
- rootElement: contextOpts.rootElement || document.getElementById('root'),
57
- loadingComponent: Loading,
58
- publicPath,
59
- runtimePublicPath,
60
- history,
61
- historyType,
62
- basename,
63
- __INTERNAL_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: {"pureApp":false,"pureHtml":false},
64
- callback: contextOpts.callback,
65
- };
66
- const modifiedContext = pluginManager.applyPlugins({
67
- key: 'modifyClientRenderOpts',
68
- type: ApplyPluginsType.modify,
69
- initialValue: context,
70
- });
71
- return renderClient(modifiedContext);
72
- },
73
- }))();
74
- }
75
-
76
-
77
- render();
78
-
79
- if (typeof window !== 'undefined') {
80
- window.g_umi = {
81
- version: '4.6.57',
82
- };
83
- }
@@ -1,8 +0,0 @@
1
- export class GlobalData {
2
- static setSiteInfo(data: object): void;
3
- static getSiteInfo(): object;
4
- static setLoginInfo(data: object): void;
5
- static getLoginInfo(): object;
6
- static setDictInfo(data: object | null): void;
7
- static getDictInfo(): object | null;
8
- }
@@ -1,33 +0,0 @@
1
- import {StorageUtils} from './utils/StorageUtils';
2
-
3
- const SITE_INFO_KEY = "siteInfo";
4
- const LOGIN_INFO_KEY = "loginInfo";
5
- const DICT_INFO_KEY = "dictInfo";
6
-
7
- export class GlobalData {
8
- static setSiteInfo(data) {
9
- StorageUtils.set(SITE_INFO_KEY, data);
10
- }
11
-
12
- static getSiteInfo() {
13
- return StorageUtils.get(SITE_INFO_KEY) || {};
14
- }
15
-
16
- static setLoginInfo(data) {
17
- StorageUtils.set(LOGIN_INFO_KEY, data);
18
- }
19
-
20
- static getLoginInfo() {
21
- return StorageUtils.get(LOGIN_INFO_KEY) || {};
22
- }
23
-
24
- static setDictInfo(data) {
25
- StorageUtils.set(DICT_INFO_KEY, data);
26
- }
27
-
28
- static getDictInfo() {
29
- return StorageUtils.get(DICT_INFO_KEY);
30
- }
31
- }
32
-
33
- export { SITE_INFO_KEY, LOGIN_INFO_KEY, DICT_INFO_KEY };
@@ -1,14 +0,0 @@
1
- import {ReactNode} from "react";
2
- import {PermUtils} from "../utils";
3
-
4
- /**
5
- * 使用该组件,可以判断权限
6
- */
7
- export function HasPerm(props: { code: string, children: ReactNode }) {
8
- let {code} = props;
9
-
10
- if (PermUtils.hasPermission(code)) {
11
- return props.children;
12
- }
13
-
14
- }
@@ -1,29 +0,0 @@
1
- import React from 'react';
2
- import { Select } from 'antd';
3
- import { BaseRemoteSelect } from '../BaseRemoteSelect';
4
-
5
- export class FieldRemoteSelectMultiple extends BaseRemoteSelect {
6
- static defaultProps = {
7
- placeholder: '请搜索选择',
8
- };
9
-
10
- render() {
11
- const { value, onChange, url, ...selectProps } = this.props;
12
- const { data, loading } = this.state;
13
-
14
- return (
15
- <Select
16
- showSearch={this.getShowSearch()}
17
- value={value}
18
- onChange={onChange}
19
- options={data}
20
- notFoundContent={this.getNotFoundContent()}
21
- style={{ width: '100%', minWidth: 200 }}
22
- allowClear
23
- mode="multiple"
24
- loading={loading}
25
- {...selectProps}
26
- />
27
- );
28
- }
29
- }
@@ -1,6 +0,0 @@
1
- export class ArrayUtils {
2
- static contains<T>(arr: T[], item: T): boolean;
3
- static containsAny<T>(arr: T[], ...items: T[]): boolean;
4
- static maxBy<T extends Record<K, any>, K extends keyof T>(arr: T[], key: K): T | undefined;
5
- static unique<T>(arr: T[]): T[];
6
- }
@@ -1,20 +0,0 @@
1
- export class DateUtils {
2
- static convertTypeToFormat(type: string): string;
3
- static year(date: Date): number;
4
- static month(date: Date): string;
5
- static date(date: Date): string;
6
- static hour(date: Date): string;
7
- static minute(date: Date): string;
8
- static second(date: Date): string;
9
- static formatDate(d: Date): string;
10
- static formatTime(d: Date): string;
11
- static formatDateTime(d: Date): string;
12
- static formatDateCn(d: Date): string;
13
- static now(): string;
14
- static today(): string;
15
- static thisYear(): number;
16
- static thisMonth(): string;
17
- static friendlyTime(pastDate: Date | string | number): string | undefined;
18
- static friendlyTotalTime(time: number | string | null): string | null;
19
- static beginOfMonth(): string;
20
- }
@@ -1,3 +0,0 @@
1
- export class DeviceUtils {
2
- static isMobileDevice(): boolean;
3
- }
@@ -1,6 +0,0 @@
1
- export class EventBus {
2
- static on<T extends any[] = []>(name: string, callback: (...args: T) => void, ctx?: any): void;
3
- static once<T extends any[] = []>(name: string, callback: (...args: T) => void, ctx?: any): void;
4
- static emit<T extends any[] = []>(name: string, ...args: T): void;
5
- static off<T extends any[] = []>(name: string, callback?: (...args: T) => void): void;
6
- }
@@ -1,10 +0,0 @@
1
- import React from 'react';
2
- import type {ModalFuncProps} from 'antd/es/modal/interface';
3
-
4
- export class MessageUtils {
5
- static alert(content: any, config?: Omit<ModalFuncProps, 'content' | 'icon' | 'onOk' | 'onCancel'>): Promise<void>;
6
- static confirm(content: React.ReactNode, config?: Omit<ModalFuncProps, 'content' | 'icon' | 'onOk' | 'onCancel'>): Promise<boolean>;
7
- static success(content: string, duration?: number): void;
8
- static error(content: string, duration?: number): void;
9
- static destroy(): void;
10
- }
@@ -1,43 +0,0 @@
1
- import {message, Modal} from 'antd';
2
-
3
- export class MessageUtils {
4
-
5
- static alert(content, config) {
6
- return new Promise(resolve => {
7
- Modal.info({
8
- title: '提示',
9
- content,
10
- okText: '确定',
11
- onOk: () => resolve(),
12
- icon: null,
13
- ...config,
14
- });
15
- });
16
- }
17
-
18
- static confirm(content, config) {
19
- return new Promise((resolve) => {
20
- Modal.confirm({
21
- title: '确认操作',
22
- content,
23
- okText: '确定',
24
- cancelText: '取消',
25
- onOk: () => resolve(true),
26
- onCancel: () => resolve(false),
27
- ...config,
28
- });
29
- });
30
- }
31
-
32
- static success(content, duration = 3) {
33
- message.success(content, duration);
34
- }
35
-
36
- static error(content, duration = 3) {
37
- message.error(content, duration);
38
- }
39
-
40
- static destroy() {
41
- message.destroy();
42
- }
43
- }
@@ -1,14 +0,0 @@
1
- import {ObjectUtils} from './ObjectUtils';
2
-
3
- declare module './ObjectUtils' {
4
- interface ObjectUtils {
5
- // Empty - no public methods to declare
6
- }
7
- }
8
-
9
- export class ObjectUtils {
10
- static copyPropertyIfPresent<TSource extends object, TTarget extends object>(
11
- source: TSource | null | undefined,
12
- target: TTarget | null | undefined
13
- ): void;
14
- }
@@ -1,12 +0,0 @@
1
- export class ObjectUtils {
2
-
3
- static copyPropertyIfPresent(source, target) {
4
- if (!source || !target || typeof source !== 'object' || typeof target !== 'object') return;
5
- const keys = Object.keys(target);
6
- for (const key of keys) {
7
- if (Object.hasOwn(source, key)) {
8
- target[key] = source[key];
9
- }
10
- }
11
- }
12
- }
@@ -1,4 +0,0 @@
1
- export class StorageUtils {
2
- static get<T>(key: string, defaultValue?: T | null): T | null;
3
- static set<T>(key: string, value: T | null | undefined): void;
4
- }
@@ -1,17 +0,0 @@
1
- export class StringUtils {
2
- static readonly ISO_SPLITTER: string;
3
- static removePrefix(str: string | null | undefined, ch: string): string;
4
- static removeSuffix(str: string | null | undefined, ch: string): string;
5
- static random(length: number): string;
6
- static contains(str: string | null | undefined, subStr: string): boolean;
7
- static subAfter(source: string | null | undefined, str: string): string;
8
- static subAfterLast(source: string | null | undefined, str: string): string;
9
- static subBefore(str: string | null | undefined, sub: string): string;
10
- static pad(input: string | number | null | undefined, totalLen: number, padChar?: string): string;
11
- static getWidth(str: string | null | undefined): number;
12
- static cutByWidth(str: string, maxWidth: number): string;
13
- static ellipsis(str: string | null | undefined, len: number, suffix?: string): string;
14
- static isString(value: any): value is string;
15
- static split(str: any, sp: string): string[];
16
- static join(arr: any, sp: string): string;
17
- }
@@ -1,13 +0,0 @@
1
- export interface TreeNode<T = any> {
2
- id: string | number;
3
- pid: string | number | null;
4
- children?: TreeNode<T>[];
5
- [key: string]: any;
6
- }
7
-
8
- export class TreeUtils {
9
- static walk<T extends TreeNode>(tree: T[], callback: (node: T) => void): void;
10
- static findByKey<T extends TreeNode>(key: string | number, list: T[], keyName?: keyof T | 'id'): T | undefined;
11
- static flattenTree<T extends TreeNode>(treeNodeList: T[]): T[];
12
- static getKeyList<T extends TreeNode>(tree: T[], value: string | number): (string | number)[];
13
- }
@@ -1,6 +0,0 @@
1
- export class UrlUtils {
2
- static getParams(url?: string | null): Record<string, string>;
3
- static setParam(url: string, key: string, value: string | number | boolean | null | undefined): string;
4
- static getWebsocketBaseUrl(): string;
5
- static contextPath(path: string): string;
6
- }
@@ -1,20 +0,0 @@
1
- import React from 'react';
2
- import {Tag} from 'antd';
3
-
4
- export interface DictItem {
5
- code: string | number;
6
- label: string;
7
- color?: string;
8
- }
9
-
10
- export interface DictOption {
11
- value: string | number;
12
- label: string;
13
- }
14
-
15
- export class DictUtils {
16
- static dictList(code: string): DictItem[];
17
- static dictOptions(typeCode: string): DictOption[];
18
- static dictLabel(typeCode: string, code: string | number): string | undefined;
19
- static dictTag(typeCode: string, code: string | number): React.ReactElement | string | null;
20
- }
@@ -1,8 +0,0 @@
1
- import React from 'react';
2
-
3
- export class FormRegistry {
4
- static register(formKey: string, formComponent: React.ComponentType<any>): void;
5
- static get(formKey: string): React.ComponentType<any> | null;
6
- static has(formKey: string): boolean;
7
- static getAllKeys(): string[];
8
- }
@@ -1,31 +0,0 @@
1
- import * as React from 'react';
2
-
3
- export class FormRegistry {
4
- static forms = new Map();
5
-
6
- static register(formKey, formComponent) {
7
- if (!formKey || !formComponent) {
8
- throw new Error("表单 Key 和组件不能为空!");
9
- }
10
- if (FormRegistry.forms.has(formKey)) {
11
- console.warn(`表单 "${formKey}" 已存在,将被覆盖!`);
12
- }
13
- FormRegistry.forms.set(formKey, formComponent);
14
- }
15
-
16
- static get(formKey) {
17
- const formComponent = FormRegistry.forms.get(formKey);
18
- if (!formComponent) {
19
- console.warn(`表单 "${formKey}" 未注册!`);
20
- }
21
- return formComponent ?? null;
22
- }
23
-
24
- static has(formKey) {
25
- return FormRegistry.forms.has(formKey);
26
- }
27
-
28
- static getAllKeys() {
29
- return Array.from(FormRegistry.forms.keys());
30
- }
31
- }
@@ -1,14 +0,0 @@
1
- import {AxiosRequestConfig} from "axios";
2
-
3
- declare const SERVLET_CONTEXT: string | undefined;
4
-
5
- interface RequestOptions extends AxiosRequestConfig {
6
- showError?: boolean;
7
- }
8
-
9
- export class HttpUtils {
10
- static coreRequest<T = any>(config: RequestOptions, transformData?: boolean): Promise<T>;
11
- static get<T = any>(url: string, params?: any, options?: Partial<RequestOptions>): Promise<T>;
12
- static post<T = any>(url: string, data?: any, params?: any, options?: Partial<RequestOptions>): Promise<T>;
13
- static postForm<T = any>(url: string, data: any, options?: Partial<RequestOptions>): Promise<T>;
14
- }
@@ -1,14 +0,0 @@
1
- import {history} from "umi";
2
-
3
- export class PageUtils {
4
- static redirectToLogin(): void;
5
- static currentParams(): Record<string, string | undefined>;
6
- static currentPathname(): string;
7
- static currentUrl(): string;
8
- static currentPathnameLastPart(): string | undefined;
9
- static open(path: string, label?: string): void;
10
- static openNoLayout(path: string): void;
11
- static currentLabel(): string | undefined;
12
- static closeCurrent(): void;
13
- static closeCurrentAndOpenPage(alertMessage: string, path: string, label: string): void;
14
- }
@@ -1,59 +0,0 @@
1
- import {history} from "umi";
2
- import {StringUtils} from "../StringUtils";
3
- import {UrlUtils} from "../UrlUtils";
4
- import {MessageUtils} from "../MessageUtils";
5
-
6
- export class PageUtils {
7
- static redirectToLogin() {
8
- const url = PageUtils.currentUrl();
9
- const encodedUrl = encodeURIComponent(url);
10
- history.push(`/login?redirect=${encodedUrl}`);
11
- }
12
-
13
- static currentParams() {
14
- return UrlUtils.getParams();
15
- }
16
-
17
- static currentPathname() {
18
- const path = window.location.hash.substring(1);
19
- return StringUtils.subBefore(path, '?');
20
- }
21
-
22
- static currentUrl() {
23
- return window.location.hash.substring(1);
24
- }
25
-
26
- static currentPathnameLastPart() {
27
- const path = this.currentPathname();
28
- return StringUtils.subAfterLast(path, '/') || undefined;
29
- }
30
-
31
- static open(path, label = '未命名') {
32
- let targetPath = path;
33
- if (label) {
34
- targetPath = UrlUtils.setParam(targetPath, '_label', label);
35
- }
36
- history.push(targetPath);
37
- }
38
-
39
- static openNoLayout(path) {
40
- const targetPath = UrlUtils.setParam(path, '_noLayout', true);
41
- history.push(targetPath);
42
- }
43
-
44
- static currentLabel() {
45
- return this.currentParams()['_label'];
46
- }
47
-
48
- static closeCurrent() {
49
- const event = new CustomEvent('close-page-event', {detail: {url: PageUtils.currentUrl()}});
50
- document.dispatchEvent(event);
51
- }
52
-
53
- static closeCurrentAndOpenPage(alertMessage, path, label) {
54
- MessageUtils.alert(alertMessage).then(() => {
55
- this.closeCurrent();
56
- this.open(path, label);
57
- });
58
- }
59
- }
@@ -1,5 +0,0 @@
1
- export class PermUtils {
2
- static hasPermission(perm: string | null | undefined): boolean;
3
- static isPermitted(p: string | null | undefined): boolean;
4
- static notPermitted(p: string | null | undefined): boolean;
5
- }
@@ -1,6 +0,0 @@
1
- declare const OPEN_ADMIN_THEME: Record<string, string> | undefined;
2
-
3
- export class ThemeUtils {
4
- static readonly theme: Record<string, string>;
5
- static getColor(key: string): string | undefined;
6
- }
@@ -1,52 +0,0 @@
1
- export class ThemeUtils {
2
- static defaultTheme = {
3
- "primary-color": "#1961AC",
4
- "success-color": "#52c41a",
5
- "warning-color": "#faad14",
6
- "error-color": "#ff4d4f",
7
- "background-color": "#f5f5f5",
8
- "primary-color-hover": "#4990CD",
9
- "primary-color-click": "#124B93"
10
- };
11
-
12
- static cachedTheme = null;
13
-
14
- static get theme() {
15
- if (this.cachedTheme) return this.cachedTheme;
16
- this.cachedTheme = this.loadTheme();
17
- return this.cachedTheme;
18
- }
19
-
20
- /** 调亮/调暗十六进制颜色 */
21
- static _lightenHex(hex, percent) {
22
- const num = parseInt(hex.replace('#', ''), 16);
23
- const r = num >> 16 & 255, g = num >> 8 & 255, b = num & 255;
24
- const t = percent < 0 ? 0 : 255;
25
- const p = Math.abs(percent) / 100;
26
- return '#' + (0x1000000 + (Math.round((t - r) * p) + r) * 0x10000
27
- + (Math.round((t - g) * p) + g) * 0x100 + (Math.round((t - b) * p) + b)).toString(16).slice(1);
28
- }
29
-
30
- static loadTheme() {
31
- let custom = {};
32
- try {
33
- if (typeof OPEN_ADMIN_THEME !== 'undefined' && OPEN_ADMIN_THEME) {
34
- custom = OPEN_ADMIN_THEME;
35
- }
36
- } catch (e) {}
37
- const result = {...this.defaultTheme, ...custom};
38
- if (custom["primary-color"]) {
39
- if (!custom["primary-color-hover"]) {
40
- result["primary-color-hover"] = ThemeUtils._lightenHex(result["primary-color"], 20);
41
- }
42
- if (!custom["primary-color-click"]) {
43
- result["primary-color-click"] = ThemeUtils._lightenHex(result["primary-color"], -10);
44
- }
45
- }
46
- return result;
47
- }
48
-
49
- static getColor(key) {
50
- return ThemeUtils.theme[key];
51
- }
52
- }
@@ -1,29 +0,0 @@
1
- import {matchRoutes, useAppData} from "umi";
2
- import {Result} from "antd";
3
-
4
- interface PageRenderProps {
5
- pathname: string;
6
- }
7
-
8
- /**
9
- * 通过指定 pathname 渲染页面
10
- */
11
- export function PageRender({pathname}: PageRenderProps) {
12
- const appData = useAppData()
13
- const matchArr = matchRoutes(appData.clientRoutes, pathname)
14
-
15
- if (matchArr != null) {
16
- const matchResult = matchArr[matchArr.length - 1].route
17
- if (matchResult && matchResult.element) {
18
- return matchResult.element
19
- }
20
- }
21
-
22
- return (
23
- <Result
24
- status={404}
25
- title='页面不存在!'
26
- subTitle={<div>路由地址:{pathname}</div>}
27
- />
28
- )
29
- }