Skip to content

Commit b607475

Browse files
authored
Merge pull request #107 from codingapi/dev
Dev
2 parents 47f3f6c + 9f2770c commit b607475

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+168
-1203
lines changed

admin-ui/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
"@ant-design/icons": "^5.4.0",
77
"@ant-design/pro-components": "^2.8.7",
88
"@babel/standalone": "^7.25.6",
9-
"@codingapi/flow-pc": "^0.0.24",
10-
"@codingapi/form-pc": "^0.0.24",
11-
"@codingapi/ui-framework": "^0.0.24",
9+
"@codingapi/flow-pc": "^0.0.36",
10+
"@codingapi/form-pc": "^0.0.36",
11+
"@codingapi/ui-framework": "^0.0.36",
1212
"@dnd-kit/core": "^6.2.0",
1313
"@dnd-kit/sortable": "^9.0.0",
1414
"@handsontable/react-wrapper": "^15.0.0",

admin-ui/src/api/account.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import {get, post} from "@/api/index";
1+
import {httpClient} from "@/api/index";
22

33
export async function login(body: Account.LoginRequest) {
4-
return post('/user/login', body);
4+
return httpClient.post('/user/login', body);
55
}
66

77
export async function captcha() {
8-
return get('/open/captcha');
8+
return httpClient.get('/open/captcha');
99
}
1010

1111

admin-ui/src/api/flow.ts

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {get, page, post} from "@/api/index";
1+
import {httpClient} from "@/api/index";
22

33

44
// 流程设计
@@ -12,79 +12,79 @@ export async function list(
1212
type: string
1313
}[]
1414
) {
15-
return page('/api/query/flowWork/list', params, sort, filter, match);
15+
return httpClient.page('/api/query/flowWork/list', params, sort, filter, match);
1616
}
1717

1818

1919
export async function save(body: any) {
20-
return post('/api/cmd/flowWork/save', body);
20+
return httpClient.post('/api/cmd/flowWork/save', body);
2121
}
2222

2323
export async function copy(id: any) {
24-
return post('/api/cmd/flowWork/copy', {id});
24+
return httpClient.post('/api/cmd/flowWork/copy', {id});
2525
}
2626

2727
export async function remove(id: any) {
28-
return post('/api/cmd/flowWork/delete', {id});
28+
return httpClient.post('/api/cmd/flowWork/delete', {id});
2929
}
3030

3131
export async function changeState(id: any) {
32-
return post('/api/cmd/flowWork/changeState', {id});
32+
return httpClient.post('/api/cmd/flowWork/changeState', {id});
3333
}
3434

3535
export async function schema(body: any) {
36-
return post('/api/cmd/flowWork/schema', body);
36+
return httpClient.post('/api/cmd/flowWork/schema', body);
3737
}
3838

3939
// 流程控制
4040

4141
export async function startFlow(body:any) {
42-
return post('/api/cmd/flowRecord/startFlow', body);
42+
return httpClient.post('/api/cmd/flowRecord/startFlow', body);
4343
}
4444

4545
export async function getFlowStep(body:any) {
46-
return post('/api/cmd/flowRecord/getFlowStep', body);
46+
return httpClient.post('/api/cmd/flowRecord/getFlowStep', body);
4747
}
4848

4949
export async function removeFlow(body:any) {
50-
return post('/api/cmd/flowRecord/remove', body);
50+
return httpClient.post('/api/cmd/flowRecord/remove', body);
5151
}
5252

5353

5454
export async function detail(id?:any,workCode?:any) {
55-
return get('/api/query/flowRecord/detail', {id,workCode});
55+
return httpClient.get('/api/query/flowRecord/detail', {id,workCode});
5656
}
5757

5858
export async function saveFlow(body:any) {
59-
return post('/api/cmd/flowRecord/save', body);
59+
return httpClient.post('/api/cmd/flowRecord/save', body);
6060
}
6161

6262
export async function submitFlow(body:any) {
63-
return post('/api/cmd/flowRecord/submitFlow', body);
63+
return httpClient.post('/api/cmd/flowRecord/submitFlow', body);
6464
}
6565

6666
export async function trySubmitFlow(body:any) {
67-
return post('/api/cmd/flowRecord/trySubmitFlow', body);
67+
return httpClient.post('/api/cmd/flowRecord/trySubmitFlow', body);
6868
}
6969

7070
export async function custom(body:any) {
71-
return post('/api/cmd/flowRecord/custom', body);
71+
return httpClient.post('/api/cmd/flowRecord/custom', body);
7272
}
7373

7474
export async function recall(body:any) {
75-
return post('/api/cmd/flowRecord/recall', body);
75+
return httpClient.post('/api/cmd/flowRecord/recall', body);
7676
}
7777

7878
export async function postponed(body:any) {
79-
return post('/api/cmd/flowRecord/postponed', body);
79+
return httpClient.post('/api/cmd/flowRecord/postponed', body);
8080
}
8181

8282
export async function transfer(body:any) {
83-
return post('/api/cmd/flowRecord/transfer', body);
83+
return httpClient.post('/api/cmd/flowRecord/transfer', body);
8484
}
8585

8686
export async function urge(body:any) {
87-
return post('/api/cmd/flowRecord/urge', body);
87+
return httpClient.post('/api/cmd/flowRecord/urge', body);
8888
}
8989

9090

@@ -97,7 +97,7 @@ export async function flowRecordList(params: any,
9797
key: string,
9898
type: string
9999
}[]) {
100-
return page('/api/query/flowRecord/list', params, sort, filter, match);
100+
return httpClient.page('/api/query/flowRecord/list', params, sort, filter, match);
101101
}
102102

103103

@@ -108,7 +108,7 @@ export async function findAllByOperatorId(params: any,
108108
key: string,
109109
type: string
110110
}[]) {
111-
return page('/api/query/flowRecord/findAllByOperatorId', params, sort, filter, match);
111+
return httpClient.page('/api/query/flowRecord/findAllByOperatorId', params, sort, filter, match);
112112
}
113113

114114

@@ -119,7 +119,7 @@ export async function findTodoByOperatorId(params: any,
119119
key: string,
120120
type: string
121121
}[]) {
122-
return page('/api/query/flowRecord/findTodoByOperatorId', params, sort, filter, match);
122+
return httpClient.page('/api/query/flowRecord/findTodoByOperatorId', params, sort, filter, match);
123123
}
124124

125125
export async function findDoneByOperatorId(params: any,
@@ -129,7 +129,7 @@ export async function findDoneByOperatorId(params: any,
129129
key: string,
130130
type: string
131131
}[]) {
132-
return page('/api/query/flowRecord/findDoneByOperatorId', params, sort, filter, match);
132+
return httpClient.page('/api/query/flowRecord/findDoneByOperatorId', params, sort, filter, match);
133133
}
134134

135135

@@ -140,7 +140,7 @@ export async function findInitiatedByOperatorId(params: any,
140140
key: string,
141141
type: string
142142
}[]) {
143-
return page('/api/query/flowRecord/findInitiatedByOperatorId', params, sort, filter, match);
143+
return httpClient.page('/api/query/flowRecord/findInitiatedByOperatorId', params, sort, filter, match);
144144
}
145145

146146

@@ -151,7 +151,7 @@ export async function findTimeoutTodoByOperatorId(params: any,
151151
key: string,
152152
type: string
153153
}[]) {
154-
return page('/api/query/flowRecord/findTimeoutTodoByOperatorId', params, sort, filter, match);
154+
return httpClient.page('/api/query/flowRecord/findTimeoutTodoByOperatorId', params, sort, filter, match);
155155
}
156156

157157
export async function findPostponedTodoByOperatorId(params: any,
@@ -161,5 +161,5 @@ export async function findPostponedTodoByOperatorId(params: any,
161161
key: string,
162162
type: string
163163
}[]) {
164-
return page('/api/query/flowRecord/findPostponedTodoByOperatorId', params, sort, filter, match);
164+
return httpClient.page('/api/query/flowRecord/findPostponedTodoByOperatorId', params, sort, filter, match);
165165
}

admin-ui/src/api/index.ts

Lines changed: 7 additions & 120 deletions
Original file line numberDiff line numberDiff line change
@@ -1,124 +1,11 @@
1-
import axios from "axios";
2-
import {sleep, textToBase64} from "@/utils";
31
import {message} from "antd";
2+
import {HttpClient} from "@codingapi/ui-framework";
43

5-
const api = axios.create({
6-
timeout: 10000,
7-
headers: {
8-
"Content-Type": "application/json",
4+
export const httpClient = new HttpClient(10000, {
5+
success:(msg:string)=>{
6+
message.success(msg).then();
97
},
10-
});
11-
12-
api.interceptors.request.use((config: any) => {
13-
const token = localStorage.getItem("token");
14-
if (token) {
15-
config.headers = {
16-
Authorization: `${token}`,
17-
} as any;
18-
}
19-
return config;
20-
}, (error: any) => {
21-
return Promise.reject(error);
22-
});
23-
24-
api.interceptors.response.use(async (response: any) => {
25-
const headers = response.headers;
26-
const token = headers['authorization'];
27-
28-
const state = response.status;
29-
if (state === 200) {
30-
if (token) {
31-
console.log('reset token', token);
32-
localStorage.setItem("token", token)
33-
}
34-
35-
if(response.data) {
36-
const success = response.data.success;
37-
if (!success) {
38-
const errMessage = response.data.errMessage;
39-
const errCode = response.data.errCode;
40-
if ("token.expire" === errCode || "token.error" === errCode) {
41-
message.error('登录已过期,请退出再重新打开');
42-
await sleep(1500);
43-
localStorage.clear();
44-
window.location.href = '/#login';
45-
} else {
46-
if ("login.error" === errCode) {
47-
return response;
48-
}
49-
message.error(errMessage)
50-
}
51-
}
52-
}else {
53-
message.error('抱歉,该账户无权限访问');
54-
}
55-
}
56-
return response;
57-
},
58-
(error: any) => {
59-
const response = error.response;
60-
const state = response.data.status;
61-
62-
if(state === 403){
63-
message.error('抱歉,该账户无权限访问').then();
64-
return {
65-
data: {
66-
success: false,
67-
}
68-
}
69-
}
70-
return Promise.reject(error);
71-
}
72-
)
73-
74-
75-
export const get = async (url: string, params?: any) => {
76-
try {
77-
const response = await api.get(url, {
78-
params
79-
});
80-
return response.data;
81-
}catch (e){
82-
return {
83-
success: false,
84-
}
85-
}
86-
}
87-
88-
export const post = async (url: string, data: any) => {
89-
try {
90-
const response = await api.post(url, data);
91-
return response.data;
92-
}catch (e){
93-
return {
94-
success: false,
95-
}
96-
}
97-
}
98-
99-
export const page = async (url: string, params: any, sort: any, filter: any, match: {
100-
key: string,
101-
type: string
102-
}[]) => {
103-
const response = await get(url, {
104-
...params,
105-
sort: textToBase64(sort),
106-
filter: textToBase64(filter),
107-
params: textToBase64(match),
108-
});
109-
110-
if(response.success){
111-
const list = response.data.total > 0 ? response.data.list : [];
112-
return {
113-
data: list,
114-
success: response.success,
115-
total: response.data.total
116-
};
117-
}else{
118-
return {
119-
data: [],
120-
success: response.success,
121-
total: 0
122-
}
8+
error:(msg:string)=>{
9+
message.error(msg).then();
12310
}
124-
}
11+
})

admin-ui/src/api/jar.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import {post} from "@/api/index";
1+
import {httpClient} from "@/api/index";
22

33
export async function upload(body: any) {
4-
return post('/api/jar/upload', body);
4+
return httpClient.post('/api/jar/upload', body);
55
}
66

77
export async function restart() {
8-
return post('/api/jar/restart',{});
8+
return httpClient.post('/api/jar/restart',{});
99
}

admin-ui/src/api/leave.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {page, post} from "@/api/index";
1+
import {httpClient} from "@/api/index";
22

33
export async function list(
44
params: any,
@@ -9,12 +9,12 @@ export async function list(
99
type: string
1010
}[]
1111
) {
12-
return page('/api/query/leave/list', params, sort, filter, match);
12+
return httpClient.page('/api/query/leave/list', params, sort, filter, match);
1313
}
1414

1515

1616

1717
export async function startLeave(body: any) {
18-
return post('/api/cmd/leave/startLeave', body);
18+
return httpClient.post('/api/cmd/leave/startLeave', body);
1919
}
2020

admin-ui/src/api/node.ts

Lines changed: 0 additions & 25 deletions
This file was deleted.

admin-ui/src/api/oss.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import {get, post} from "@/api/index";
1+
import {httpClient} from "@/api/index";
22

33

44
export async function loadFiles(ids: string) {
5-
return get('/api/oss/load', {ids: ids});
5+
return httpClient.get('/api/oss/load', {ids: ids});
66
}
77

88

99
export async function upload(body: any) {
10-
return post('/api/oss/upload', body);
10+
return httpClient.post('/api/oss/upload', body);
1111
}

0 commit comments

Comments
 (0)