@jiangood/open-admin 2.0.1 → 2.2.4

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 (33) hide show
  1. package/config/config.js +9 -14
  2. package/package.json +5 -1
  3. package/src/.umi-production/appData.json +75 -90
  4. package/src/.umi-production/umi.ts +2 -2
  5. package/src/framework/components/Page/index.less +1 -1
  6. package/src/framework/components/Page/index.tsx +19 -22
  7. package/src/framework/fields/FieldEditor/index.tsx +3 -2
  8. package/src/framework/fields/FieldUploadFile/index.tsx +8 -4
  9. package/src/framework/utils/MessageUtils.tsx +21 -99
  10. package/src/framework/utils/system/HttpUtils.ts +2 -1
  11. package/src/framework/utils/system/SysUtils.ts +8 -0
  12. package/src/layouts/PageRender.d.ts +2 -17
  13. package/src/layouts/PageRender.jsx +14 -76
  14. package/src/layouts/admin/TabPageRender.jsx +138 -158
  15. package/src/layouts/admin/index.jsx +120 -17
  16. package/src/layouts/admin/index.less +123 -5
  17. package/src/layouts/index.jsx +78 -161
  18. package/src/pages/404.jsx +7 -5
  19. package/src/pages/about.jsx +3 -3
  20. package/src/pages/index.jsx +4 -5
  21. package/src/pages/login.jsx +16 -9
  22. package/src/pages/login.less +0 -1
  23. package/src/pages/system/dict/index.jsx +7 -10
  24. package/src/pages/system/file/index.jsx +5 -5
  25. package/src/pages/system/job/index.jsx +9 -7
  26. package/src/pages/system/log/index.jsx +4 -5
  27. package/src/pages/system/manual/index.jsx +6 -4
  28. package/src/pages/system/org/index.jsx +4 -2
  29. package/src/pages/system/role/index.jsx +9 -7
  30. package/src/pages/system/role/perm.jsx +3 -4
  31. package/src/pages/system/user/index.jsx +8 -6
  32. package/src/pages/userCenter/index.jsx +1 -1
  33. package/src/pages/userCenter/message.jsx +4 -2
@@ -11,7 +11,7 @@ import Loading from '/home/runner/work/open-admin/open-admin/web/src/loading.jsx
11
11
  import { ApplyPluginsType } from 'umi';
12
12
  import {FormRegistryUtils} from '/home/runner/work/open-admin/open-admin/web/src/framework';
13
13
 
14
- const publicPath = "/";
14
+ const publicPath = "./";
15
15
  const runtimePublicPath = false;
16
16
 
17
17
  async function render() {
@@ -78,6 +78,6 @@ render();
78
78
 
79
79
  if (typeof window !== 'undefined') {
80
80
  window.g_umi = {
81
- version: '4.6.55',
81
+ version: '4.6.57',
82
82
  };
83
83
  }
@@ -2,7 +2,7 @@
2
2
  width: 100%;
3
3
 
4
4
  // header 48 footer 43, tab 36
5
- height: calc(100vh - 127px);
5
+ height: 100%;
6
6
 
7
7
  overflow: auto;
8
8
 
@@ -2,29 +2,26 @@ import React from "react";
2
2
  import './index.less'
3
3
  import {ThemeUtils} from "../../utils";
4
4
 
5
- /**
6
- * 上下间隔
7
- */
8
- export class Page extends React.Component {
5
+ interface PageProps {
6
+ padding?: boolean;
7
+ backgroundGray?: boolean;
8
+ debug?: boolean;
9
+ children?: React.ReactNode;
10
+ }
9
11
 
10
- static defaultProps = {
11
- padding: false,
12
- backgroundGray:false
12
+ export const Page: React.FC<PageProps> = ({ padding = true, backgroundGray = false, debug = false, children }) => {
13
+ const style: React.CSSProperties = {};
14
+ if (padding) {
15
+ style.padding = 16;
13
16
  }
14
-
15
- render() {
16
- const style = {}
17
- if(this.props.padding){
18
- style.padding = 16
19
- }
20
- if(this.props.backgroundGray){
21
- style.backgroundColor = ThemeUtils.getColor("background-color")
22
- }
23
-
24
-
25
- return <div className={'tmgg-page'} style={style}>
26
- {this.props.children}
27
- </div>
17
+ if (backgroundGray) {
18
+ style.backgroundColor = ThemeUtils.getColor("background-color");
19
+ }
20
+ if (debug) {
21
+ style.backgroundColor = 'rgba(255, 0, 0, 0.08)';
28
22
  }
29
23
 
30
- }
24
+ return <div className={'tmgg-page'} style={style}>
25
+ {children}
26
+ </div>
27
+ };
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
  import {Editor as TinyMceEditor} from '@tinymce/tinymce-react';
3
+ import {SysUtils} from '../../utils';
3
4
 
4
5
  /**
5
6
  * 富文本编辑器
@@ -8,8 +9,8 @@ import {Editor as TinyMceEditor} from '@tinymce/tinymce-react';
8
9
  */
9
10
  export class FieldEditor extends React.Component {
10
11
  render() {
11
- const uploadUrl = 'admin/sysFile/upload';
12
- const jsUrl = 'admin/tinymce/tinymce.min.js';
12
+ const uploadUrl = SysUtils.contextPath('/admin/sysFile/upload');
13
+ const jsUrl = SysUtils.contextPath('/admin/tinymce/tinymce.min.js');
13
14
  const {value, onChange, height} = this.props;
14
15
 
15
16
  return (
@@ -1,9 +1,9 @@
1
1
  import React from "react";
2
2
  import ImgCrop from "antd-img-crop";
3
- import {Modal, Upload} from "antd";
3
+ import {Modal, Upload, message} from "antd";
4
4
  import { UploadOutlined } from "@ant-design/icons";
5
5
  import {ViewFile} from "../../views";
6
- import {ObjectUtils} from "../../utils";
6
+ import {ObjectUtils, SysUtils} from "../../utils";
7
7
 
8
8
  /**
9
9
  * 上传图片前裁切, 单张图片
@@ -33,7 +33,7 @@ export class FieldUploadFile extends React.Component {
33
33
  if (value && value.length > 0) {
34
34
  const arr = value.split(",");
35
35
  for (const id of arr) {
36
- const url = 'admin/sysFile/preview/' + id;
36
+ const url = SysUtils.contextPath('/admin/sysFile/preview/' + id);
37
37
  const file = {id, url, uid: id, name: id, status: 'done', fileName: id};
38
38
  list.push(file);
39
39
  }
@@ -73,6 +73,10 @@ export class FieldUploadFile extends React.Component {
73
73
  return;
74
74
  }
75
75
 
76
+ if (file.status === 'done' && rs?.success) {
77
+ message.success(`文件「${rs.data?.name || ''}」上传成功`);
78
+ }
79
+
76
80
  this.setState({fileList});
77
81
 
78
82
  const newIds = this.convertComponentValueToOutput(fileList);
@@ -109,7 +113,7 @@ export class FieldUploadFile extends React.Component {
109
113
  const {accept, fileList, maxCount} = this.state;
110
114
 
111
115
  return <Upload
112
- action={'admin/sysFile/upload'}
116
+ action={SysUtils.contextPath('/admin/sysFile/upload')}
113
117
  listType={this.props.listType || 'picture-card'}
114
118
  fileList={fileList}
115
119
  onChange={this.handleChange}
@@ -1,44 +1,29 @@
1
1
  import {Form, Input, InputNumber, message, Modal} from 'antd';
2
2
  import type {ModalFuncProps} from 'antd/es/modal/interface';
3
3
  import React from 'react';
4
- import {MessageInstance} from "antd/lib/message/interface";
5
- import {HookAPI} from "antd/lib/modal/useModal";
6
- import {Logger} from "./Logger";
7
-
8
-
9
4
 
10
5
  /**
11
- * 消息工具类 (MsgUtils)
12
- * 封装了 Ant Design 的 Modal, message, 和 notification 静态方法
6
+ * 消息工具类
7
+ * 直接使用 Ant Design 6 的静态方法,无需 hook 初始化
13
8
  */
14
9
  export class MessageUtils {
15
10
 
16
- /**
17
- * 弹出 Alert 提示框
18
- */
19
11
  static alert(content: any, config?: Omit<ModalFuncProps, 'content' | 'icon' | 'onOk' | 'onCancel'>) {
20
12
  return new Promise(resolve => {
21
- this.modalApi.info({
13
+ Modal.info({
22
14
  title: '提示',
23
15
  content,
24
16
  okText: '确定',
25
- onOk: (close)=>{
26
- close()
27
- resolve()
28
- },
17
+ onOk: () => resolve(),
29
18
  icon: null,
30
19
  ...config,
31
20
  });
32
21
  })
33
-
34
22
  }
35
23
 
36
- /**
37
- * 弹出 Confirm 确认框
38
- */
39
24
  static confirm(content: React.ReactNode, config?: Omit<ModalFuncProps, 'content' | 'icon' | 'onOk' | 'onCancel'>) {
40
25
  return new Promise((resolve) => {
41
- this.modalApi.confirm({
26
+ Modal.confirm({
42
27
  title: '确认操作',
43
28
  content,
44
29
  okText: '确定',
@@ -48,29 +33,25 @@ export class MessageUtils {
48
33
  ...config,
49
34
  });
50
35
  })
51
-
52
36
  }
53
37
 
54
- /**
55
- * 弹出 Prompt 输入框对话框, 如果默认值是数字, 则使用 InputNumber 输入框
56
- */
57
- static prompt(message: React.ReactNode, initialValue?: string|number, placeholder?: string, config?: Omit<ModalFuncProps, 'content' | 'title' | 'icon' | 'onOk'>) {
38
+ static prompt(msg: React.ReactNode, initialValue?: string | number, placeholder?: string, config?: Omit<ModalFuncProps, 'content' | 'title' | 'icon' | 'onOk'>) {
58
39
  const isNumber = typeof initialValue === 'number';
59
40
  return new Promise((resolve) => {
60
41
  const ref = React.createRef()
61
- let element:any = isNumber ? <InputNumber placeholder={placeholder}/> : <Input placeholder={placeholder}/>;
62
- const content:any = <div>
63
- <div style={{marginBottom: 4}}>{message}</div>
42
+ let element: any = isNumber ? <InputNumber placeholder={placeholder}/> : <Input placeholder={placeholder}/>;
43
+ const content: any = <div>
44
+ <div style={{marginBottom: 4}}>{msg}</div>
64
45
  <Form ref={ref}>
65
46
  <Form.Item name='inputValue' initialValue={initialValue}>
66
47
  {element}
67
48
  </Form.Item>
68
49
  </Form>
69
50
  </div>;
70
- this.modalApi.confirm({
51
+ Modal.confirm({
71
52
  icon: null,
72
53
  title: '提示',
73
- content:content,
54
+ content,
74
55
  okText: '确定',
75
56
  cancelText: '取消',
76
57
  onOk: () => {
@@ -86,83 +67,24 @@ export class MessageUtils {
86
67
  })
87
68
  }
88
69
 
89
- // --- Antd message 封装 (全局通知/Loading) ---
90
-
91
- /**
92
- * 成功消息
93
- */
94
- static success(content: String, duration: number = 3) {
95
- if(!this.messageApi){
96
- alert(content)
97
- return
98
- }
99
- this.messageApi.success(content, duration);
70
+ static success(content: string, duration: number = 3) {
71
+ message.success(content, duration);
100
72
  }
101
73
 
102
- /**
103
- * 错误消息
104
- */
105
- static error(content: String, duration: number = 3) {
106
- if(!this.messageApi){
107
- alert(content)
108
- return
109
- }
110
- this.messageApi.error(content, duration);
74
+ static error(content: string, duration: number = 3) {
75
+ message.error(content, duration);
111
76
  }
112
77
 
113
- /**
114
- * 警告消息
115
- */
116
- static warning(content: String, duration: number = 3) {
117
- if(!this.messageApi){
118
- alert(content)
119
- return
120
- }
121
- this.messageApi.warning(content, duration);
78
+ static warning(content: string, duration: number = 3) {
79
+ message.warning(content, duration);
122
80
  }
123
81
 
124
- /**
125
- * 通用消息
126
- */
127
82
  static info(content: React.ReactNode, duration: number = 3) {
128
- if(!this.messageApi){
129
- alert(content)
130
- return
131
- }
132
- this.messageApi.info(content, duration);
83
+ message.info(content, duration);
133
84
  }
134
85
 
135
- /**
136
- * 弹出 Loading 提示
137
- */
138
86
  static loading(content: string = '正在加载...', duration?: number) {
139
- duration = duration === undefined ? 0 : duration;
140
- return this.messageApi.loading(content, duration);
87
+ duration = duration === undefined ? 0 : duration;
88
+ return message.loading(content, duration);
141
89
  }
142
-
143
- static config(messageApi: MessageInstance, modalApi: HookAPI) {
144
- this.messageApi = messageApi;
145
- this.modalApi = modalApi;
146
- }
147
-
148
- private static modalApi:HookAPI = null;
149
- private static messageApi:MessageInstance = null;
150
- }
151
-
152
- /**
153
- * antd6 推荐使用这个hooks,这里统一设置, 供公共layout使用
154
- * @constructor
155
- */
156
- export function MessageHolder(props){
157
- const [modalApi, modalContextHolder] = Modal.useModal();
158
- const [messageApi, messageContextHolder] = message.useMessage();
159
-
160
- React.useEffect(()=>{
161
- Logger.getLogger("MessageHolder").debug('Rendered')
162
- MessageUtils.config(messageApi,modalApi);
163
- props.onFinish()
164
- },[])
165
- return <>
166
- {modalContextHolder} {messageContextHolder}
167
- </>
168
- }
90
+ }
@@ -6,6 +6,7 @@ import {MessageUtils} from "../MessageUtils";
6
6
 
7
7
 
8
8
  const axiosInstance = axios.create({
9
+ baseURL: (typeof SERVLET_CONTEXT !== 'undefined' && SERVLET_CONTEXT) || '',
9
10
  withCredentials: true,
10
11
  headers: {
11
12
  'Content-Type': 'application/json'
@@ -35,7 +36,7 @@ export class HttpUtils {
35
36
  config.url = url.startsWith('admin') ? '/' + url : url;
36
37
 
37
38
  return new Promise((resolve, reject) => {
38
- axios(config).then((response: AxiosResponse) => {
39
+ axiosInstance(config).then((response: AxiosResponse) => {
39
40
  const body = response.data;
40
41
  // 假设后端响应结构为 { success: boolean | null, message: string, data: any, code: number }
41
42
  let {success, message, data} = body;
@@ -89,6 +89,14 @@ export class SysUtils {
89
89
  public static getDictInfo(): DictInfo {
90
90
  return StorageUtils.get(DICT_INFO_KEY);
91
91
  }
92
+
93
+ /**
94
+ * 拼接 servlet context-path,例如 contextPath('/admin/auth/login') → '/open-admin/admin/auth/login'
95
+ */
96
+ public static contextPath(path: string): string {
97
+ const base = (typeof SERVLET_CONTEXT !== 'undefined' && SERVLET_CONTEXT) || '';
98
+ return base + path;
99
+ }
92
100
  }
93
101
 
94
102
  // 导出常量(保持不变,但通常将常量放在类内部作为 static readonly 属性更符合 class 模式,
@@ -1,22 +1,7 @@
1
- // @ts-ignore
2
1
  import React from "react";
3
2
 
4
3
  declare type PageRenderProps = {
5
-
6
- /**
7
- * 路径 如 /flowable/task/form
8
- */
9
- pathname: string;
10
- /***
11
- * 搜索参数 如 /?id=1
12
- */
13
- search?:string;
14
-
15
- /***
16
- * 是否把location信息透传到真正页面
17
- */
18
- passLocation?: boolean
4
+ pathname: string;
19
5
  };
20
6
 
21
- export class PageRender extends React.Component<PageRenderProps, any> {
22
- }
7
+ export declare function PageRender(props: PageRenderProps): React.JSX.Element;
@@ -1,90 +1,28 @@
1
1
  import {matchRoutes, useAppData} from "umi";
2
2
  import React from "react";
3
3
  import {Result} from "antd";
4
- import {UrlUtils} from "../framework";
5
4
 
6
5
  /**
7
6
  * 通过指定 pathname 渲染页面
8
- * @param props
9
- * 为了规范,接收参数何router保持一致,
10
- * pathname: 路径 如 /flowable/task/form
11
- * search:搜索参数 如 /?id=1
12
- *
13
- * passLocation: 是否把location信息透传到真正页面
14
- *
15
- * @returns {React.JSX.Element|*}
16
- * @constructor
7
+ * @param {object} props
8
+ * @param {string} props.pathname - 路径 如 /flowable/task/form
17
9
  */
18
-
19
- let APP_DATA_CACHE = null
20
-
21
-
22
- /**
23
- * 写函数组件主要为了使用hooks
24
- * @param props
25
- * @returns {Element}
26
- * @constructor
27
- */
28
- export function PageRender(props) {
29
- const {pathname, search, passLocation} = props
30
-
31
- let appData = useAppData()
32
- if(Object.keys(appData).length === 0){
33
- appData = APP_DATA_CACHE
34
- }else {
35
- APP_DATA_CACHE = appData;
36
- }
37
-
38
- return <_PageRender appData={appData} pathname={pathname} search={search}
39
- passLocation={passLocation}/>
40
- }
41
-
42
- class _PageRender extends React.Component {
43
-
44
- render() {
45
- if (this.props.passLocation) {
46
- return this.passLocationRender()
10
+ export function PageRender({pathname}) {
11
+ const appData = useAppData()
12
+ const matchArr = matchRoutes(appData.clientRoutes, pathname)
13
+
14
+ if (matchArr != null) {
15
+ const matchResult = matchArr[matchArr.length - 1].route
16
+ if (matchResult && matchResult.element) {
17
+ return matchResult.element
47
18
  }
48
- return this.defaultRender()
49
19
  }
50
20
 
51
- passLocationRender = () => {
52
- const {pathname, search, appData} = this.props
53
-
54
- const map = appData.routeComponents
55
- const key = pathname.substring(1); // 移除第一个斜杠
56
- const componentType = map[key] || map[key + '/index']
57
- if (componentType) {
58
- const params =search ? UrlUtils.getParams(search): {}
59
- const location = {pathname, search, params}
60
- return React.createElement(componentType, {location});
61
- }
62
- };
63
-
64
-
65
- defaultRender = () => {
66
- const {pathname, appData} = this.props
67
- const matchArr = matchRoutes(appData.clientRoutes, pathname)
68
-
69
- if (matchArr != null) {
70
- if (pathname === '/') {
71
- // 匹配结果为1,表示未定义index.jsx ,导致死循环
72
- if (matchArr.length === 1) { // 如果项目中没有定义index.jsx
73
- return <Result icon={null} title='未定义首页'></Result>
74
- }
75
- }
76
- // 取最匹配的那个
77
- const mathResult = matchArr[matchArr.length - 1].route
78
- if(mathResult){
79
- return mathResult.element;
80
- }
81
- }
82
-
83
- // 如果实在找不到页面组件,则404
84
- return <Result
21
+ return (
22
+ <Result
85
23
  status={404}
86
24
  title='页面不存在!'
87
25
  subTitle={<div>路由地址:{pathname}</div>}
88
26
  />
89
- };
90
- }
27
+ )
28
+ }