@freelog/tools-lib 0.1.132 → 0.1.135
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 +20 -20
- package/README.md +103 -103
- package/dist/service-API/policies.d.ts +1 -1
- package/dist/service-API/recombinations/index.d.ts +4 -1
- package/dist/tools-lib.cjs.development.js +214 -197
- package/dist/tools-lib.cjs.development.js.map +1 -1
- package/dist/tools-lib.cjs.production.min.js +1 -1
- package/dist/tools-lib.cjs.production.min.js.map +1 -1
- package/dist/tools-lib.esm.js +214 -197
- package/dist/tools-lib.esm.js.map +1 -1
- package/dist/utils/format.d.ts +0 -4
- package/package.json +1 -1
- package/src/i18n/I18nNext.ts +154 -154
- package/src/i18n/index.ts +7 -7
- package/src/index.ts +9 -9
- package/src/service-API/activities.ts +231 -231
- package/src/service-API/captcha.ts +30 -30
- package/src/service-API/collections.ts +81 -81
- package/src/service-API/contracts.ts +101 -101
- package/src/service-API/events.ts +18 -18
- package/src/service-API/i18n.ts +35 -35
- package/src/service-API/index.ts +39 -39
- package/src/service-API/informalNodes.ts +238 -238
- package/src/service-API/nodes.ts +65 -65
- package/src/service-API/policies.ts +75 -72
- package/src/service-API/presentables.ts +287 -287
- package/src/service-API/recombinations/index.ts +92 -69
- package/src/service-API/resources.ts +532 -532
- package/src/service-API/statistics.ts +20 -20
- package/src/service-API/storages.ts +358 -358
- package/src/service-API/testQualifications.ts +109 -109
- package/src/service-API/tools/index.ts +10 -10
- package/src/service-API/transactions.ts +109 -109
- package/src/service-API/user.ts +270 -270
- package/src/utils/axios.ts +145 -145
- package/src/utils/format.ts +98 -98
- package/src/utils/index.ts +20 -20
- package/src/utils/linkTo.ts +399 -399
- package/src/utils/predefined.ts +37 -37
- package/src/utils/regexp.ts +52 -52
- package/src/utils/tools.ts +85 -85
package/src/utils/axios.ts
CHANGED
|
@@ -1,145 +1,145 @@
|
|
|
1
|
-
import axios, {AxiosRequestConfig} from 'axios';
|
|
2
|
-
import NProgress from 'nprogress';
|
|
3
|
-
import "nprogress/nprogress.css";
|
|
4
|
-
import {completeUrlByDomain} from "./format";
|
|
5
|
-
import * as LinkTo from './linkTo';
|
|
6
|
-
// import {CommonReturn, RequestParamsType} from "../service-API/tools";
|
|
7
|
-
import FServiceAPI from "../service-API";
|
|
8
|
-
// import from '../service-API';
|
|
9
|
-
|
|
10
|
-
const codeMessage: any = {
|
|
11
|
-
200: '服务器成功返回请求的数据。',
|
|
12
|
-
201: '新建或修改数据成功。',
|
|
13
|
-
202: '一个请求已经进入后台排队(异步任务)。',
|
|
14
|
-
204: '删除数据成功。',
|
|
15
|
-
400: '发出的请求有错误,服务器没有进行新建或修改数据的操作。',
|
|
16
|
-
401: '用户没有权限(令牌、用户名、密码错误)。',
|
|
17
|
-
403: '用户得到授权,但是访问是被禁止的。',
|
|
18
|
-
404: '发出的请求针对的是不存在的记录,服务器没有进行操作。',
|
|
19
|
-
406: '请求的格式不可得。',
|
|
20
|
-
410: '请求的资源被永久删除,且不会再得到的。',
|
|
21
|
-
422: '当创建一个对象时,发生一个验证错误。',
|
|
22
|
-
500: '服务器发生错误,请检查服务器。',
|
|
23
|
-
502: '网关错误。',
|
|
24
|
-
503: '服务不可用,服务器暂时过载或维护。',
|
|
25
|
-
504: '网关超时。',
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
// export let apiHost: string = '';
|
|
29
|
-
if (window.location.hostname.includes('.com')) {
|
|
30
|
-
// apiHost = `${window.location.protocol}//qi.${(window.location.host.match(/(?<=\.).*/) || [''])[0]}`;
|
|
31
|
-
// apiHost = window.location.origin.replace('console', 'qi');
|
|
32
|
-
axios.defaults.withCredentials = true;
|
|
33
|
-
axios.defaults.baseURL = completeUrlByDomain('qi');
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* 异常处理程序
|
|
38
|
-
*/
|
|
39
|
-
// const errorHandler = (error: { response: Response }): Response => {
|
|
40
|
-
// const {response} = error;
|
|
41
|
-
// if (response && response.status) {
|
|
42
|
-
// const errorText = codeMessage[response.status] || response.statusText;
|
|
43
|
-
// const {status, url} = response;
|
|
44
|
-
//
|
|
45
|
-
// // notification.error({
|
|
46
|
-
// // message: `请求错误 ${status}: ${url}`,
|
|
47
|
-
// // description: errorText,
|
|
48
|
-
// // });
|
|
49
|
-
// } else if (!response) {
|
|
50
|
-
// // notification.error({
|
|
51
|
-
// // description: '您的网络发生异常,无法连接服务器',
|
|
52
|
-
// // message: '网络异常',
|
|
53
|
-
// // });
|
|
54
|
-
// }
|
|
55
|
-
// return response;
|
|
56
|
-
// };
|
|
57
|
-
//
|
|
58
|
-
// // Add a request interceptor
|
|
59
|
-
axios.interceptors.request.use(function (config) {
|
|
60
|
-
// Do something before request is sent
|
|
61
|
-
NProgress.start();
|
|
62
|
-
return config;
|
|
63
|
-
}, function (error) {
|
|
64
|
-
// Do something with request error
|
|
65
|
-
NProgress.done();
|
|
66
|
-
return Promise.reject(error);
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* 配置request请求时的默认参数
|
|
71
|
-
*/
|
|
72
|
-
axios.interceptors.response.use(function (response) {
|
|
73
|
-
// Do something with response data
|
|
74
|
-
// console.log(response, 'response!!!!!!');
|
|
75
|
-
NProgress.done();
|
|
76
|
-
if (response.status !== 200) {
|
|
77
|
-
|
|
78
|
-
const error = {
|
|
79
|
-
description: codeMessage[response.status],
|
|
80
|
-
message: response.status,
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
// notification.error(error);
|
|
84
|
-
throw new Error(JSON.stringify(error));
|
|
85
|
-
}
|
|
86
|
-
const {data, headers} = response;
|
|
87
|
-
if (headers['content-disposition']?.includes('attachment;')) {
|
|
88
|
-
// downloadFile(response);
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
// console.log(data, 'data2390jasdflkf');
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
// if ((data.errcode === undefined
|
|
96
|
-
// ? (data.errCode !== 0 && data.errCode !== 2)
|
|
97
|
-
// : (data.errcode !== 0 && data.errcode !== 2))
|
|
98
|
-
// || data.ret !== 0) {
|
|
99
|
-
//
|
|
100
|
-
// // notification.error({
|
|
101
|
-
// // message: data.msg,
|
|
102
|
-
// // });
|
|
103
|
-
// throw new Error(JSON.stringify(data));
|
|
104
|
-
// }
|
|
105
|
-
return data;
|
|
106
|
-
}, function (error) {
|
|
107
|
-
// Do something with response error
|
|
108
|
-
NProgress.done();
|
|
109
|
-
return Promise.reject(error);
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
export default axios;
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
export async function request(config: AxiosRequestConfig, {
|
|
116
|
-
// export async function request(config: any, {
|
|
117
|
-
noRedirect = false,
|
|
118
|
-
noErrorAlert = false,
|
|
119
|
-
// }: RequestParamsType = {}): Promise<CommonReturn & { data: any } | void> {
|
|
120
|
-
}: any = {}): Promise<any> {
|
|
121
|
-
const result: any = await axios.request(config);
|
|
122
|
-
// console.log(result, 'response');
|
|
123
|
-
// const {data} = response;
|
|
124
|
-
// console.log(result, 'result90iowjksdfjlsdkj')
|
|
125
|
-
if (result.ret === 0 && result.errCode === 30 && !noRedirect) {
|
|
126
|
-
await FServiceAPI.User.logout();
|
|
127
|
-
window.location.replace(`${completeUrlByDomain('user')}${LinkTo.login({goTo: window.location.href})}`);
|
|
128
|
-
}
|
|
129
|
-
if (result.ret === 4 && result.errCode === 10 && !noRedirect) {
|
|
130
|
-
window.location.replace(`${completeUrlByDomain('user')}${LinkTo.userFreeze({goTo: window.location.href})}`);
|
|
131
|
-
}
|
|
132
|
-
if ((result.errcode !== 0 || result.errCode !== 0) && !noErrorAlert) {
|
|
133
|
-
// window.alert(result.msg);
|
|
134
|
-
// return;
|
|
135
|
-
}
|
|
136
|
-
return result;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
// export function downloadFile(res: AxiosResponse) {
|
|
140
|
-
// const {data, headers} = res;
|
|
141
|
-
// // const fileName = headers['content-disposition'].replace(/attachment; filename="(.*)"/, '$1');
|
|
142
|
-
// const fileName = headers['content-disposition'].replace(/attachment; filename="(.*)"/, '$1');
|
|
143
|
-
// const blob = new Blob([data], {});
|
|
144
|
-
// FileSaver.saveAs(blob, fileName);
|
|
145
|
-
// }
|
|
1
|
+
import axios, {AxiosRequestConfig} from 'axios';
|
|
2
|
+
import NProgress from 'nprogress';
|
|
3
|
+
import "nprogress/nprogress.css";
|
|
4
|
+
import {completeUrlByDomain} from "./format";
|
|
5
|
+
import * as LinkTo from './linkTo';
|
|
6
|
+
// import {CommonReturn, RequestParamsType} from "../service-API/tools";
|
|
7
|
+
import FServiceAPI from "../service-API";
|
|
8
|
+
// import from '../service-API';
|
|
9
|
+
|
|
10
|
+
const codeMessage: any = {
|
|
11
|
+
200: '服务器成功返回请求的数据。',
|
|
12
|
+
201: '新建或修改数据成功。',
|
|
13
|
+
202: '一个请求已经进入后台排队(异步任务)。',
|
|
14
|
+
204: '删除数据成功。',
|
|
15
|
+
400: '发出的请求有错误,服务器没有进行新建或修改数据的操作。',
|
|
16
|
+
401: '用户没有权限(令牌、用户名、密码错误)。',
|
|
17
|
+
403: '用户得到授权,但是访问是被禁止的。',
|
|
18
|
+
404: '发出的请求针对的是不存在的记录,服务器没有进行操作。',
|
|
19
|
+
406: '请求的格式不可得。',
|
|
20
|
+
410: '请求的资源被永久删除,且不会再得到的。',
|
|
21
|
+
422: '当创建一个对象时,发生一个验证错误。',
|
|
22
|
+
500: '服务器发生错误,请检查服务器。',
|
|
23
|
+
502: '网关错误。',
|
|
24
|
+
503: '服务不可用,服务器暂时过载或维护。',
|
|
25
|
+
504: '网关超时。',
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
// export let apiHost: string = '';
|
|
29
|
+
if (window.location.hostname.includes('.com')) {
|
|
30
|
+
// apiHost = `${window.location.protocol}//qi.${(window.location.host.match(/(?<=\.).*/) || [''])[0]}`;
|
|
31
|
+
// apiHost = window.location.origin.replace('console', 'qi');
|
|
32
|
+
axios.defaults.withCredentials = true;
|
|
33
|
+
axios.defaults.baseURL = completeUrlByDomain('qi');
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* 异常处理程序
|
|
38
|
+
*/
|
|
39
|
+
// const errorHandler = (error: { response: Response }): Response => {
|
|
40
|
+
// const {response} = error;
|
|
41
|
+
// if (response && response.status) {
|
|
42
|
+
// const errorText = codeMessage[response.status] || response.statusText;
|
|
43
|
+
// const {status, url} = response;
|
|
44
|
+
//
|
|
45
|
+
// // notification.error({
|
|
46
|
+
// // message: `请求错误 ${status}: ${url}`,
|
|
47
|
+
// // description: errorText,
|
|
48
|
+
// // });
|
|
49
|
+
// } else if (!response) {
|
|
50
|
+
// // notification.error({
|
|
51
|
+
// // description: '您的网络发生异常,无法连接服务器',
|
|
52
|
+
// // message: '网络异常',
|
|
53
|
+
// // });
|
|
54
|
+
// }
|
|
55
|
+
// return response;
|
|
56
|
+
// };
|
|
57
|
+
//
|
|
58
|
+
// // Add a request interceptor
|
|
59
|
+
axios.interceptors.request.use(function (config) {
|
|
60
|
+
// Do something before request is sent
|
|
61
|
+
NProgress.start();
|
|
62
|
+
return config;
|
|
63
|
+
}, function (error) {
|
|
64
|
+
// Do something with request error
|
|
65
|
+
NProgress.done();
|
|
66
|
+
return Promise.reject(error);
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* 配置request请求时的默认参数
|
|
71
|
+
*/
|
|
72
|
+
axios.interceptors.response.use(function (response) {
|
|
73
|
+
// Do something with response data
|
|
74
|
+
// console.log(response, 'response!!!!!!');
|
|
75
|
+
NProgress.done();
|
|
76
|
+
if (response.status !== 200) {
|
|
77
|
+
|
|
78
|
+
const error = {
|
|
79
|
+
description: codeMessage[response.status],
|
|
80
|
+
message: response.status,
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
// notification.error(error);
|
|
84
|
+
throw new Error(JSON.stringify(error));
|
|
85
|
+
}
|
|
86
|
+
const {data, headers} = response;
|
|
87
|
+
if (headers['content-disposition']?.includes('attachment;')) {
|
|
88
|
+
// downloadFile(response);
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// console.log(data, 'data2390jasdflkf');
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
// if ((data.errcode === undefined
|
|
96
|
+
// ? (data.errCode !== 0 && data.errCode !== 2)
|
|
97
|
+
// : (data.errcode !== 0 && data.errcode !== 2))
|
|
98
|
+
// || data.ret !== 0) {
|
|
99
|
+
//
|
|
100
|
+
// // notification.error({
|
|
101
|
+
// // message: data.msg,
|
|
102
|
+
// // });
|
|
103
|
+
// throw new Error(JSON.stringify(data));
|
|
104
|
+
// }
|
|
105
|
+
return data;
|
|
106
|
+
}, function (error) {
|
|
107
|
+
// Do something with response error
|
|
108
|
+
NProgress.done();
|
|
109
|
+
return Promise.reject(error);
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
export default axios;
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
export async function request(config: AxiosRequestConfig, {
|
|
116
|
+
// export async function request(config: any, {
|
|
117
|
+
noRedirect = false,
|
|
118
|
+
noErrorAlert = false,
|
|
119
|
+
// }: RequestParamsType = {}): Promise<CommonReturn & { data: any } | void> {
|
|
120
|
+
}: any = {}): Promise<any> {
|
|
121
|
+
const result: any = await axios.request(config);
|
|
122
|
+
// console.log(result, 'response');
|
|
123
|
+
// const {data} = response;
|
|
124
|
+
// console.log(result, 'result90iowjksdfjlsdkj')
|
|
125
|
+
if (result.ret === 0 && result.errCode === 30 && !noRedirect) {
|
|
126
|
+
await FServiceAPI.User.logout();
|
|
127
|
+
window.location.replace(`${completeUrlByDomain('user')}${LinkTo.login({goTo: window.location.href})}`);
|
|
128
|
+
}
|
|
129
|
+
if (result.ret === 4 && result.errCode === 10 && !noRedirect) {
|
|
130
|
+
window.location.replace(`${completeUrlByDomain('user')}${LinkTo.userFreeze({goTo: window.location.href})}`);
|
|
131
|
+
}
|
|
132
|
+
if ((result.errcode !== 0 || result.errCode !== 0) && !noErrorAlert) {
|
|
133
|
+
// window.alert(result.msg);
|
|
134
|
+
// return;
|
|
135
|
+
}
|
|
136
|
+
return result;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// export function downloadFile(res: AxiosResponse) {
|
|
140
|
+
// const {data, headers} = res;
|
|
141
|
+
// // const fileName = headers['content-disposition'].replace(/attachment; filename="(.*)"/, '$1');
|
|
142
|
+
// const fileName = headers['content-disposition'].replace(/attachment; filename="(.*)"/, '$1');
|
|
143
|
+
// const blob = new Blob([data], {});
|
|
144
|
+
// FileSaver.saveAs(blob, fileName);
|
|
145
|
+
// }
|
package/src/utils/format.ts
CHANGED
|
@@ -1,98 +1,98 @@
|
|
|
1
|
-
import moment from 'moment';
|
|
2
|
-
import {report} from '@freelog/resource-policy-lang/dist';
|
|
3
|
-
import {ContractEntity} from '@freelog/resource-policy-lang/dist/tools/ContractTool';
|
|
4
|
-
|
|
5
|
-
const {compile} = require('@freelog/resource-policy-lang');
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* 将对应的字节数,转换为易读单位数量
|
|
9
|
-
* @param bytes
|
|
10
|
-
* @return {string}
|
|
11
|
-
*/
|
|
12
|
-
export function humanizeSize(bytes: number): string {
|
|
13
|
-
// console.log('dddhumanizeSizesdfsd');
|
|
14
|
-
if (bytes <= 0) {
|
|
15
|
-
return '0 B';
|
|
16
|
-
}
|
|
17
|
-
const unitArr = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
|
|
18
|
-
const index = Math.floor(Math.log(bytes) / Math.log(1024));
|
|
19
|
-
const size = Math.round((bytes / Math.pow(1024, index)) * 100) / 100; //保留的小数位数
|
|
20
|
-
return size + ' ' + unitArr[index];
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* 格式化日期时间
|
|
25
|
-
*/
|
|
26
|
-
export function formatDateTime(date: string, showTime: boolean = false) {
|
|
27
|
-
return moment(date).format('YYYY/MM/DD' + (showTime ? ' HH:mm' : ''));
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* 根据传入的子域名拼合成完整的适合的url
|
|
32
|
-
* @param domain 要组合的三级域名
|
|
33
|
-
*/
|
|
34
|
-
export function completeUrlByDomain(domain: string): string {
|
|
35
|
-
let origin: string = `http://${domain}.testfreelog.com`;
|
|
36
|
-
|
|
37
|
-
if (window.location.origin.includes('.freelog.com')) {
|
|
38
|
-
origin = `https://${domain}.freelog.com`;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
return origin;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* 根据策略代码和标的物类型,生成对应的翻译
|
|
46
|
-
* @param code 策略代码
|
|
47
|
-
* @param targetType 标的物类型
|
|
48
|
-
*/
|
|
49
|
-
export async function policyCodeTranslationToText(code: string, targetType: string): Promise<{
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}> {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* 将资源类型关键字数组,转换成标准展示文字
|
|
94
|
-
* @param arr 关键字数组
|
|
95
|
-
*/
|
|
96
|
-
export function resourceTypeKeyArrToResourceType(arr: string[]): string {
|
|
97
|
-
return arr.join(' / ');
|
|
98
|
-
}
|
|
1
|
+
import moment from 'moment';
|
|
2
|
+
// import {report} from '@freelog/resource-policy-lang/dist';
|
|
3
|
+
// import {ContractEntity} from '@freelog/resource-policy-lang/dist/tools/ContractTool';
|
|
4
|
+
|
|
5
|
+
// const {compile} = require('@freelog/resource-policy-lang');
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* 将对应的字节数,转换为易读单位数量
|
|
9
|
+
* @param bytes
|
|
10
|
+
* @return {string}
|
|
11
|
+
*/
|
|
12
|
+
export function humanizeSize(bytes: number): string {
|
|
13
|
+
// console.log('dddhumanizeSizesdfsd');
|
|
14
|
+
if (bytes <= 0) {
|
|
15
|
+
return '0 B';
|
|
16
|
+
}
|
|
17
|
+
const unitArr = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
|
|
18
|
+
const index = Math.floor(Math.log(bytes) / Math.log(1024));
|
|
19
|
+
const size = Math.round((bytes / Math.pow(1024, index)) * 100) / 100; //保留的小数位数
|
|
20
|
+
return size + ' ' + unitArr[index];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* 格式化日期时间
|
|
25
|
+
*/
|
|
26
|
+
export function formatDateTime(date: string, showTime: boolean = false) {
|
|
27
|
+
return moment(date).format('YYYY/MM/DD' + (showTime ? ' HH:mm' : ''));
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* 根据传入的子域名拼合成完整的适合的url
|
|
32
|
+
* @param domain 要组合的三级域名
|
|
33
|
+
*/
|
|
34
|
+
export function completeUrlByDomain(domain: string): string {
|
|
35
|
+
let origin: string = `http://${domain}.testfreelog.com`;
|
|
36
|
+
|
|
37
|
+
if (window.location.origin.includes('.freelog.com')) {
|
|
38
|
+
origin = `https://${domain}.freelog.com`;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return origin;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* 根据策略代码和标的物类型,生成对应的翻译
|
|
46
|
+
* @param code 策略代码
|
|
47
|
+
* @param targetType 标的物类型
|
|
48
|
+
*/
|
|
49
|
+
// export async function policyCodeTranslationToText(code: string, targetType: string): Promise<{
|
|
50
|
+
// error: string[] | null;
|
|
51
|
+
// text?: string;
|
|
52
|
+
// }> {
|
|
53
|
+
// try {
|
|
54
|
+
// const result = await compile(
|
|
55
|
+
// code,
|
|
56
|
+
// targetType,
|
|
57
|
+
// completeUrlByDomain('qi'),
|
|
58
|
+
// window.location.origin.endsWith('.freelog.com') ? 'prod' : 'dev',
|
|
59
|
+
// );
|
|
60
|
+
// const contract: ContractEntity = {
|
|
61
|
+
// audiences: result.state_machine.audiences,
|
|
62
|
+
// fsmStates: Object.entries<any>(result.state_machine.states)
|
|
63
|
+
// .map((st) => {
|
|
64
|
+
// return {
|
|
65
|
+
// name: st[0],
|
|
66
|
+
// serviceStates: st[1].serviceStates,
|
|
67
|
+
// events: st[1].transitions.map((ts: any) => {
|
|
68
|
+
//
|
|
69
|
+
// return {
|
|
70
|
+
// id: ts.code,
|
|
71
|
+
// name: ts.name,
|
|
72
|
+
// args: ts.args,
|
|
73
|
+
// state: ts.toState,
|
|
74
|
+
// };
|
|
75
|
+
// }),
|
|
76
|
+
// };
|
|
77
|
+
// }),
|
|
78
|
+
// };
|
|
79
|
+
// const rrr = report(contract);
|
|
80
|
+
// return {
|
|
81
|
+
// error: null,
|
|
82
|
+
// text: rrr.audienceInfos[0].content + rrr.content,
|
|
83
|
+
// };
|
|
84
|
+
// } catch (err) {
|
|
85
|
+
// return {
|
|
86
|
+
// error: [err.message],
|
|
87
|
+
// };
|
|
88
|
+
// }
|
|
89
|
+
// }
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* 将资源类型关键字数组,转换成标准展示文字
|
|
94
|
+
* @param arr 关键字数组
|
|
95
|
+
*/
|
|
96
|
+
export function resourceTypeKeyArrToResourceType(arr: string[]): string {
|
|
97
|
+
return arr.join(' / ');
|
|
98
|
+
}
|
package/src/utils/index.ts
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import * as Format from './format';
|
|
2
|
-
import * as Regexp from './regexp';
|
|
3
|
-
import * as LinkTo from './linkTo';
|
|
4
|
-
import * as Predefined from './predefined';
|
|
5
|
-
import Axios, {request} from './axios';
|
|
6
|
-
import * as Tool from './tools';
|
|
7
|
-
// import I18n from '../i18n';
|
|
8
|
-
|
|
9
|
-
const FUtil = {
|
|
10
|
-
Format,
|
|
11
|
-
Regexp,
|
|
12
|
-
LinkTo,
|
|
13
|
-
Predefined,
|
|
14
|
-
Axios,
|
|
15
|
-
Request: request,
|
|
16
|
-
Tool,
|
|
17
|
-
// i18n: new I18n(),
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export default FUtil;
|
|
1
|
+
import * as Format from './format';
|
|
2
|
+
import * as Regexp from './regexp';
|
|
3
|
+
import * as LinkTo from './linkTo';
|
|
4
|
+
import * as Predefined from './predefined';
|
|
5
|
+
import Axios, {request} from './axios';
|
|
6
|
+
import * as Tool from './tools';
|
|
7
|
+
// import I18n from '../i18n';
|
|
8
|
+
|
|
9
|
+
const FUtil = {
|
|
10
|
+
Format,
|
|
11
|
+
Regexp,
|
|
12
|
+
LinkTo,
|
|
13
|
+
Predefined,
|
|
14
|
+
Axios,
|
|
15
|
+
Request: request,
|
|
16
|
+
Tool,
|
|
17
|
+
// i18n: new I18n(),
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export default FUtil;
|