@jiangood/open-admin 3.0.14 → 3.1.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.
- package/package.json +15 -2
- package/src/framework/biz/OrgTree.tsx +10 -6
- package/src/framework/biz/PermActions.tsx +5 -3
- package/src/framework/biz/RoleTree.tsx +10 -6
- package/src/framework/biz/index.tsx +1 -0
- package/src/framework/components/ContextMenu/index.tsx +17 -1
- package/src/framework/components/DownloadModal/index.tsx +40 -33
- package/src/framework/components/FormModal/index.tsx +10 -8
- package/src/framework/components/NamedIcon/index.tsx +2 -2
- package/src/framework/components/OrgSwitcher/index.tsx +6 -7
- package/src/framework/components/PageLoading/index.tsx +3 -3
- package/src/framework/components/ProTable/index.tsx +28 -25
- package/src/framework/components/ValueType/index.tsx +1 -1
- package/src/framework/config/themeConfig.ts +5 -5
- package/src/framework/fields/BaseRemoteSelect/index.tsx +23 -21
- package/src/framework/fields/FieldBoolean/index.tsx +6 -6
- package/src/framework/fields/FieldDate/index.tsx +10 -10
- package/src/framework/fields/FieldDateRange/index.tsx +20 -20
- package/src/framework/fields/FieldDictSelect/index.tsx +2 -2
- package/src/framework/fields/FieldEditor/index.tsx +1 -1
- package/src/framework/fields/FieldNumberRange/index.tsx +16 -17
- package/src/framework/fields/FieldPercent/index.tsx +2 -2
- package/src/framework/fields/FieldRemoteSelect/index.tsx +4 -4
- package/src/framework/fields/FieldRemoteTree/index.tsx +1 -1
- package/src/framework/fields/FieldRemoteTreeCascader/index.tsx +1 -1
- package/src/framework/fields/FieldRemoteTreeSelect/index.tsx +1 -1
- package/src/framework/fields/FieldSysOrgTree/index.tsx +1 -1
- package/src/framework/fields/FieldSysOrgTreeSelect/index.tsx +1 -1
- package/src/framework/fields/FieldTable/index.tsx +15 -13
- package/src/framework/fields/FieldTableSelect/index.tsx +5 -5
- package/src/framework/fields/FieldUploadFile/index.tsx +3 -3
- package/src/framework/fields/FieldUploadImage/index.tsx +31 -29
- package/src/framework/fields/types.ts +0 -2
- package/src/framework/router/PageFrame.tsx +1 -1
- package/src/framework/router/matcher.ts +2 -2
- package/src/framework/utils/ArrayUtils.ts +2 -2
- package/src/framework/utils/DateUtils.ts +1 -1
- package/src/framework/utils/{system/DictUtils.ts → DictUtils.ts} +1 -1
- package/src/framework/utils/EventBus.ts +7 -7
- package/src/framework/utils/HttpClient.ts +283 -0
- package/src/framework/utils/{system/PageUtils.ts → PageUtils.ts} +4 -4
- package/src/framework/utils/{system/PermUtils.ts → PermUtils.ts} +3 -3
- package/src/framework/utils/StringUtils.ts +10 -8
- package/src/framework/utils/TreeUtils.ts +3 -3
- package/src/framework/utils/UrlUtils.ts +3 -2
- package/src/framework/utils/index.ts +4 -1
- package/src/framework/views/ViewApproveStatus/index.tsx +1 -2
- package/src/framework/views/ViewBoolean/index.tsx +4 -1
- package/src/framework/views/ViewFile/index.tsx +4 -4
- package/src/framework/views/ViewImage/index.tsx +2 -2
- package/src/framework/views/ViewPassword/index.tsx +3 -2
- package/src/framework/views/ViewText/index.tsx +12 -3
- package/src/framework/views/types.ts +2 -4
- package/src/layouts/admin/AdminTabs.jsx +9 -0
- package/src/layouts/admin/AdminTabs.less +2 -2
- package/src/layouts/admin/HeaderRight.jsx +8 -7
- package/src/layouts/admin/TabLayout.jsx +2 -2
- package/src/layouts/admin/index.jsx +15 -11
- package/src/layouts/admin/index.less +16 -1
- package/src/layouts/index.tsx +24 -18
- package/src/pages/404.jsx +1 -1
- package/src/pages/article/$code.jsx +4 -4
- package/src/pages/index.jsx +1 -1
- package/src/pages/public/login.jsx +34 -27
- package/src/pages/public/test.jsx +1 -1
- package/src/pages/standalone/forceUpdatePwd.jsx +9 -7
- package/src/pages/system/article/index.jsx +9 -8
- package/src/pages/system/dict/index.jsx +19 -16
- package/src/pages/system/file/index.jsx +9 -9
- package/src/pages/system/job/index.jsx +17 -17
- package/src/pages/system/log/index.jsx +5 -7
- package/src/pages/system/org/index.jsx +31 -18
- package/src/pages/system/role/index.jsx +13 -12
- package/src/pages/system/role/rolePerm.jsx +25 -21
- package/src/pages/system/user/index.jsx +35 -33
- package/src/pages/system/user/userPerm.jsx +12 -12
- package/src/pages/userCenter/index.jsx +11 -9
- package/src/pages/userCenter/permView.jsx +7 -7
- package/src/framework/utils/system/HttpUtils.ts +0 -97
- package/src/framework/utils/system/index.ts +0 -4
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import axios from "axios";
|
|
2
|
-
import type {AxiosRequestConfig} from "axios";
|
|
3
|
-
import qs from 'qs';
|
|
4
|
-
import {PageUtils} from "./PageUtils";
|
|
5
|
-
import {message as messageApi} from "antd";
|
|
6
|
-
import {EventBus} from "../EventBus";
|
|
7
|
-
|
|
8
|
-
interface RequestOptions extends AxiosRequestConfig {
|
|
9
|
-
showError?: boolean;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
const axiosInstance = axios.create({
|
|
13
|
-
baseURL: import.meta.env.VITE_SERVER_SERVLET_CONTEXT_PATH,
|
|
14
|
-
withCredentials: true,
|
|
15
|
-
headers: { 'Content-Type': 'application/json' },
|
|
16
|
-
paramsSerializer: (params: Record<string, unknown>) => qs.stringify(params, {indices: false})
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
export class HttpUtils {
|
|
20
|
-
static coreRequest<T = any>(config: RequestOptions, transformData = true): Promise<T> {
|
|
21
|
-
const url = config.url as string;
|
|
22
|
-
config.url = url.startsWith('admin') ? '/' + url : url;
|
|
23
|
-
|
|
24
|
-
// FormData 请求交由浏览器自动生成带 boundary 的 multipart Content-Type,
|
|
25
|
-
// 否则手动指定 Content-Type 会缺失 boundary 导致后端解析失败
|
|
26
|
-
if (typeof FormData !== 'undefined' && config.data instanceof FormData) {
|
|
27
|
-
config.headers = {...config.headers, 'Content-Type': undefined};
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
return new Promise<T>((resolve, reject) => {
|
|
31
|
-
axiosInstance(config).then((response) => {
|
|
32
|
-
const body = response.data;
|
|
33
|
-
let {success, message, data} = body;
|
|
34
|
-
if (success == undefined) {
|
|
35
|
-
resolve(response as unknown as T);
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
if (!success) {
|
|
39
|
-
console.error(`[HttpUtils] 请求失败: ${url}`, {code: body.code, message, data: body});
|
|
40
|
-
if (config.showError !== false) {
|
|
41
|
-
messageApi.error(message || '操作失败');
|
|
42
|
-
}
|
|
43
|
-
reject(message || '操作失败');
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
if (message) {
|
|
47
|
-
messageApi.success(message);
|
|
48
|
-
}
|
|
49
|
-
resolve((transformData ? data : response) as T);
|
|
50
|
-
}).catch((e) => {
|
|
51
|
-
console.error(`[HttpUtils] 请求异常: ${url}`, e);
|
|
52
|
-
if (axios.isAxiosError(e) && e.response?.status === 401) {
|
|
53
|
-
EventBus.emit('loginExpired');
|
|
54
|
-
reject('登录过期');
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
const msg = HttpUtils.extractErrorMessage(e);
|
|
58
|
-
if (config.showError !== false) {
|
|
59
|
-
messageApi.error(msg);
|
|
60
|
-
}
|
|
61
|
-
reject(msg);
|
|
62
|
-
});
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
static extractErrorMessage(e: unknown, defaultMsg = '操作失败'): string {
|
|
67
|
-
if (axios.isAxiosError(e)) {
|
|
68
|
-
const responseData = e.response?.data;
|
|
69
|
-
const status = e.response?.status;
|
|
70
|
-
if (status === 504) return '504 请求后端服务失败';
|
|
71
|
-
if (responseData && responseData.message) return responseData.message;
|
|
72
|
-
if (e.message) return e.message;
|
|
73
|
-
return defaultMsg;
|
|
74
|
-
}
|
|
75
|
-
if (e instanceof Error) return e.message || defaultMsg;
|
|
76
|
-
return defaultMsg;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
static get<T = any>(url: string, params: any = null, options: Partial<RequestOptions> = {}): Promise<T> {
|
|
80
|
-
return HttpUtils.coreRequest<T>({...options, url, method: 'GET', params});
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
static post<T = any>(url: string, data: any = null, params: any = null, options: Partial<RequestOptions> = {}): Promise<T> {
|
|
84
|
-
return HttpUtils.coreRequest<T>({...options, url, method: 'POST', data, params});
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
static postForm<T = any>(url: string, data: any, options: Partial<RequestOptions> = {}): Promise<T> {
|
|
88
|
-
return HttpUtils.coreRequest<T>({
|
|
89
|
-
...options,
|
|
90
|
-
url,
|
|
91
|
-
method: 'POST',
|
|
92
|
-
data: qs.stringify(data),
|
|
93
|
-
headers: {'Content-Type': 'application/x-www-form-urlencoded'}
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
}
|