@freelog/tools-lib 0.1.153 → 0.1.155
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/dist/i18n/I18nNext.d.ts +3 -0
- package/dist/service-API/activities.d.ts +1 -0
- package/dist/service-API/resources.d.ts +2 -1
- package/dist/tools-lib.cjs.development.js +100 -82
- 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 +100 -82
- package/dist/tools-lib.esm.js.map +1 -1
- package/dist/utils/linkTo.d.ts +16 -8
- package/package.json +2 -1
- package/src/i18n/I18nNext.ts +162 -155
- package/src/service-API/activities.ts +1 -0
- package/src/service-API/collections.ts +80 -80
- package/src/service-API/resources.ts +2 -1
- package/src/utils/hooks.ts +17 -17
- package/src/utils/index.ts +22 -22
- package/src/utils/linkTo.ts +457 -439
- package/src/utils/regexp.ts +60 -60
- package/src/utils/tools.ts +2 -2
package/dist/utils/linkTo.d.ts
CHANGED
|
@@ -40,25 +40,33 @@ interface ResourceInfoParamsType {
|
|
|
40
40
|
resourceID: string;
|
|
41
41
|
}
|
|
42
42
|
export declare function resourceInfo({ resourceID }: ResourceInfoParamsType): TReturnType;
|
|
43
|
-
interface
|
|
43
|
+
interface ResourcePolicyParamsType {
|
|
44
44
|
resourceID: string;
|
|
45
45
|
}
|
|
46
|
-
export declare function
|
|
47
|
-
interface
|
|
46
|
+
export declare function resourcePolicy({ resourceID }: ResourcePolicyParamsType): TReturnType;
|
|
47
|
+
interface ResourceContractParamsType {
|
|
48
48
|
resourceID: string;
|
|
49
49
|
}
|
|
50
|
-
export declare function
|
|
51
|
-
interface
|
|
50
|
+
export declare function resourceContract({ resourceID }: ResourceContractParamsType): TReturnType;
|
|
51
|
+
interface ResourceDependencyParamsType {
|
|
52
|
+
resourceID: string;
|
|
53
|
+
}
|
|
54
|
+
export declare function resourceDependency({ resourceID }: ResourceDependencyParamsType): TReturnType;
|
|
55
|
+
interface ResourceVersionCreatorParamsType {
|
|
52
56
|
resourceID: string;
|
|
53
|
-
version: string;
|
|
54
57
|
}
|
|
55
|
-
export declare function
|
|
58
|
+
export declare function resourceVersionCreator({ resourceID }: ResourceVersionCreatorParamsType): TReturnType;
|
|
59
|
+
interface ResourceVersionInfoParamsType {
|
|
60
|
+
resourceID: string;
|
|
61
|
+
version?: string;
|
|
62
|
+
}
|
|
63
|
+
export declare function resourceVersionInfo({ resourceID, version }: ResourceVersionInfoParamsType): TReturnType;
|
|
56
64
|
interface NodeCreatorParamsType {
|
|
57
65
|
}
|
|
58
66
|
export declare function nodeCreator({}?: NodeCreatorParamsType): TReturnType;
|
|
59
67
|
interface NodeManagementParamsType {
|
|
60
68
|
nodeID: number;
|
|
61
|
-
showPage?: 'exhibit' | 'theme' | '
|
|
69
|
+
showPage?: 'exhibit' | 'theme' | 'contract' | 'setting';
|
|
62
70
|
}
|
|
63
71
|
export declare function nodeManagement({ nodeID, showPage, ...params }: NodeManagementParamsType): TReturnType;
|
|
64
72
|
interface ExhibitManagementParamsType {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@freelog/tools-lib",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.155",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
@@ -59,6 +59,7 @@
|
|
|
59
59
|
"@freelog/resource-policy-lang": "1.1.26",
|
|
60
60
|
"axios": "^0.21.1",
|
|
61
61
|
"crypto-js": "^4.0.0",
|
|
62
|
+
"html-react-parser": "^4.2.0",
|
|
62
63
|
"i18next": "^21.8.10",
|
|
63
64
|
"js-cookie": "^3.0.1",
|
|
64
65
|
"moment": "^2.29.1",
|
package/src/i18n/I18nNext.ts
CHANGED
|
@@ -1,155 +1,162 @@
|
|
|
1
|
-
import i18next, {Resource} from 'i18next';
|
|
2
|
-
import axios from "axios";
|
|
3
|
-
import Cookies from 'js-cookie';
|
|
4
|
-
import FUtil from '../utils';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
private
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
this.ready
|
|
29
|
-
|
|
30
|
-
this.
|
|
31
|
-
this.
|
|
32
|
-
this.
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
.
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
const
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
zh_CN
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
1
|
+
import i18next, {Resource} from 'i18next';
|
|
2
|
+
import axios from "axios";
|
|
3
|
+
import Cookies from 'js-cookie';
|
|
4
|
+
import FUtil from '../utils';
|
|
5
|
+
// import * as React from 'react';
|
|
6
|
+
import htmlReactParser from 'html-react-parser';
|
|
7
|
+
|
|
8
|
+
type LanguageKeyType = 'zh_CN' | 'en_US';
|
|
9
|
+
|
|
10
|
+
const ossJsonUrl: string = 'https://freelog-i18n.oss-cn-shenzhen.aliyuncs.com/configs/i18n.json';
|
|
11
|
+
const ossJsonUrl_Test: string = 'https://freelog-i18n.oss-cn-shenzhen.aliyuncs.com/configs-test/i18n.json';
|
|
12
|
+
const localStorage_i18nextLng_key: string = 'locale';
|
|
13
|
+
const localStorage_i18nextResources_key: string = 'i18nextResources';
|
|
14
|
+
|
|
15
|
+
const allLanguage = [
|
|
16
|
+
{value: 'en_US', label: 'English'},
|
|
17
|
+
{value: 'zh_CN', label: '简体中文'},
|
|
18
|
+
];
|
|
19
|
+
|
|
20
|
+
class I18nNext {
|
|
21
|
+
|
|
22
|
+
private _loadingData: 'NotStart' | 'Start' | 'End' = 'NotStart';
|
|
23
|
+
private _taskQueue: Function[] = [];
|
|
24
|
+
// private _currentLanguage: LanguageKeyType = window.localStorage.getItem(localStorage_i18nextLng_key) as null || 'zh_CN';
|
|
25
|
+
private _currentLanguage: LanguageKeyType = Cookies.get(localStorage_i18nextLng_key) as undefined || 'zh_CN';
|
|
26
|
+
|
|
27
|
+
constructor() {
|
|
28
|
+
this.ready();
|
|
29
|
+
|
|
30
|
+
this.ready = this.ready.bind(this);
|
|
31
|
+
this.t = this.t.bind(this);
|
|
32
|
+
this.changeLanguage = this.changeLanguage.bind(this);
|
|
33
|
+
this.getAllLanguage = this.getAllLanguage.bind(this);
|
|
34
|
+
this.getCurrentLanguage = this.getCurrentLanguage.bind(this);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
async ready(this: I18nNext): Promise<void> {
|
|
38
|
+
const exc = () => {
|
|
39
|
+
while (this._taskQueue.length > 0) {
|
|
40
|
+
const task = this._taskQueue.shift();
|
|
41
|
+
task && task();
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
const handleTasks = async () => {
|
|
45
|
+
// console.log(this._loadingData, 'this._loadingData90iowejflksdfjlsdk');
|
|
46
|
+
if (this._loadingData === 'End') {
|
|
47
|
+
exc();
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
if (this._loadingData === 'Start') {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// NO_START
|
|
55
|
+
this._loadingData = 'Start';
|
|
56
|
+
|
|
57
|
+
await this._handleData();
|
|
58
|
+
// console.log('######');
|
|
59
|
+
exc();
|
|
60
|
+
};
|
|
61
|
+
const promise = new Promise<void>((resolve) => {
|
|
62
|
+
this._taskQueue.push(resolve);
|
|
63
|
+
});
|
|
64
|
+
handleTasks();
|
|
65
|
+
return promise;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
t(this: I18nNext, key: string, options?: { [key: string]: any }): string {
|
|
69
|
+
return i18next.t(key.trim(), options);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
tJSXElement(this: I18nNext, key: string, options?: { [key: string]: any }): string | JSX.Element | JSX.Element[] {
|
|
73
|
+
return htmlReactParser(i18next.t(key.trim(), options));
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
changeLanguage(this: I18nNext, lng: LanguageKeyType): void {
|
|
78
|
+
// return i18next.changeLanguage(lng);
|
|
79
|
+
// window.localStorage.setItem(localStorage_i18nextLng_key, lng)
|
|
80
|
+
Cookies.set(localStorage_i18nextLng_key, lng, {
|
|
81
|
+
expires: 36525,
|
|
82
|
+
domain: FUtil.Format.completeUrlByDomain('').replace(/http(s)?:\/\//, ''),
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
getAllLanguage(this: I18nNext): typeof allLanguage {
|
|
87
|
+
return allLanguage;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
getCurrentLanguage(this: I18nNext): LanguageKeyType {
|
|
91
|
+
return this._currentLanguage;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
private async _handleData(this: I18nNext): Promise<void> {
|
|
95
|
+
|
|
96
|
+
const lng: string = this._currentLanguage;
|
|
97
|
+
const resource: string | null = window.localStorage.getItem(localStorage_i18nextResources_key);
|
|
98
|
+
// const resource: string | undefined = Cookies.get(decodeURIComponent(localStorage_i18nextResources_key));
|
|
99
|
+
let i18nextResources: Resource | null = resource ? JSON.parse(resource) : null;
|
|
100
|
+
|
|
101
|
+
if (!i18nextResources) {
|
|
102
|
+
// console.log('######892io3jlkl')
|
|
103
|
+
i18nextResources = await this._fetchData();
|
|
104
|
+
} else {
|
|
105
|
+
this._fetchData();
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
await i18next
|
|
109
|
+
.init({
|
|
110
|
+
// the translations
|
|
111
|
+
// (tip move them in a JSON file and import them,
|
|
112
|
+
// or even better, manage them via a UI: https://react.i18next.com/guides/multiple-translation-files#manage-your-translations-with-a-management-gui)
|
|
113
|
+
resources: i18nextResources,
|
|
114
|
+
lng: lng, // if you're using a language detector, do not define the lng option
|
|
115
|
+
fallbackLng: 'zh_CN',
|
|
116
|
+
|
|
117
|
+
interpolation: {
|
|
118
|
+
escapeValue: false, // react already safes from xss => https://www.i18next.com/translation-function/interpolation#unescape
|
|
119
|
+
prefix: '{',
|
|
120
|
+
suffix: '}',
|
|
121
|
+
},
|
|
122
|
+
});
|
|
123
|
+
this._loadingData = 'End';
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
private async _fetchData(this: I18nNext): Promise<Resource> {
|
|
127
|
+
const url: string = window.location.origin.includes('.freelog.com') ? ossJsonUrl : ossJsonUrl_Test;
|
|
128
|
+
const res: any = await axios.get(url + '?timestamp=' + Date.now(), {
|
|
129
|
+
withCredentials: false,
|
|
130
|
+
});
|
|
131
|
+
// console.log(res, 'data09oiw3qjelsfkdfjlsdkfjl');
|
|
132
|
+
|
|
133
|
+
const en_US: { [key: string]: string } = {};
|
|
134
|
+
const zh_CN: { [key: string]: string } = {};
|
|
135
|
+
|
|
136
|
+
for (const [key, value] of Object.entries(res)) {
|
|
137
|
+
// console.log(key, value, 'key, value90iowsldfjlsdkj');
|
|
138
|
+
en_US[key] = (value as any)['en_US'];
|
|
139
|
+
zh_CN[key] = (value as any)['zh_CN'];
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
const result: Resource = {
|
|
143
|
+
en_US: {
|
|
144
|
+
translation: en_US,
|
|
145
|
+
},
|
|
146
|
+
zh_CN: {
|
|
147
|
+
translation: zh_CN,
|
|
148
|
+
},
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
// console.log(result, 'result093sdolkfjlsdkjl');
|
|
152
|
+
window.localStorage.setItem(localStorage_i18nextResources_key, JSON.stringify(result));
|
|
153
|
+
// Cookies.set(localStorage_i18nextResources_key, encodeURIComponent(JSON.stringify(result)), {
|
|
154
|
+
// expires: 36525,
|
|
155
|
+
// domain: FUtil.Format.completeUrlByDomain('').replace(/http(s)?:\/\//, ''),
|
|
156
|
+
// });
|
|
157
|
+
|
|
158
|
+
return result;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
export default I18nNext;
|
|
@@ -137,6 +137,7 @@ export function getRewardRecordInfo(params: GetRewardRecordInfoParamsType) {
|
|
|
137
137
|
// 推送任务消息埋点
|
|
138
138
|
interface PushMessageTaskParamsType {
|
|
139
139
|
taskConfigCode: string;
|
|
140
|
+
meta?: any;
|
|
140
141
|
}
|
|
141
142
|
|
|
142
143
|
export function pushMessageTask(params: PushMessageTaskParamsType) {
|
|
@@ -1,80 +1,80 @@
|
|
|
1
|
-
import FUtil from '../utils';
|
|
2
|
-
|
|
3
|
-
// 收藏资源
|
|
4
|
-
interface CollectResourceParamsType {
|
|
5
|
-
resourceId: string;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export function collectResource(params: CollectResourceParamsType) {
|
|
9
|
-
// return FUtil.Axios.post('/v2/collections/resources', params);
|
|
10
|
-
return FUtil.Request({
|
|
11
|
-
method: 'POST',
|
|
12
|
-
url: `/v2/collections/resources`,
|
|
13
|
-
data: params,
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
// 查看收藏的资源列表
|
|
18
|
-
interface CollectionResourcesParamsType {
|
|
19
|
-
skip?: number;
|
|
20
|
-
limit?: number;
|
|
21
|
-
keywords?: string;
|
|
22
|
-
resourceType?: string;
|
|
23
|
-
resourceTypeCode?: string;
|
|
24
|
-
resourceTypeCategory?: 1 | 2;
|
|
25
|
-
omitResourceType?: string;
|
|
26
|
-
resourceStatus?: 0 | 1 | 2 | 4;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export function collectionResources(params: CollectionResourcesParamsType) {
|
|
30
|
-
return FUtil.Request({
|
|
31
|
-
method: 'GET',
|
|
32
|
-
url: `/v2/collections/resources`,
|
|
33
|
-
params: params,
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
// 删除收藏的资源
|
|
39
|
-
interface DeleteCollectResourceParamsType {
|
|
40
|
-
resourceId: string;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export function deleteCollectResource({resourceId}: DeleteCollectResourceParamsType) {
|
|
44
|
-
// return FUtil.Axios.delete(`/v2/collections/resources/${resourceId}`);
|
|
45
|
-
return FUtil.Request({
|
|
46
|
-
method: 'DELETE',
|
|
47
|
-
url: `/v2/collections/resources/${resourceId}`,
|
|
48
|
-
// params: params,
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
// 批量查询资源是否收藏
|
|
53
|
-
interface IsCollectedParamsType {
|
|
54
|
-
resourceIds: string;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export function isCollected(params: IsCollectedParamsType) {
|
|
58
|
-
// return FUtil.Axios.get('/v2/collections/resources/isCollected', {
|
|
59
|
-
// params
|
|
60
|
-
// });
|
|
61
|
-
return FUtil.Request({
|
|
62
|
-
method: 'GET',
|
|
63
|
-
url: `/v2/collections/resources/isCollected`,
|
|
64
|
-
params: params,
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
// 查询资源总收藏数量
|
|
69
|
-
interface CollectedCountParamsType {
|
|
70
|
-
resourceId: string;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
export function collectedCount({resourceId}: CollectedCountParamsType) {
|
|
74
|
-
// return FUtil.Axios.get(`/v2/collections/resources/${resourceId}/count`);
|
|
75
|
-
return FUtil.Request({
|
|
76
|
-
method: 'GET',
|
|
77
|
-
url: `/v2/collections/resources/${resourceId}/count`,
|
|
78
|
-
// params: params,
|
|
79
|
-
});
|
|
80
|
-
}
|
|
1
|
+
import FUtil from '../utils';
|
|
2
|
+
|
|
3
|
+
// 收藏资源
|
|
4
|
+
interface CollectResourceParamsType {
|
|
5
|
+
resourceId: string;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export function collectResource(params: CollectResourceParamsType) {
|
|
9
|
+
// return FUtil.Axios.post('/v2/collections/resources', params);
|
|
10
|
+
return FUtil.Request({
|
|
11
|
+
method: 'POST',
|
|
12
|
+
url: `/v2/collections/resources`,
|
|
13
|
+
data: params,
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// 查看收藏的资源列表
|
|
18
|
+
interface CollectionResourcesParamsType {
|
|
19
|
+
skip?: number;
|
|
20
|
+
limit?: number;
|
|
21
|
+
keywords?: string;
|
|
22
|
+
resourceType?: string;
|
|
23
|
+
resourceTypeCode?: string;
|
|
24
|
+
resourceTypeCategory?: 1 | 2;
|
|
25
|
+
omitResourceType?: string;
|
|
26
|
+
resourceStatus?: 0 | 1 | 2 | 4;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function collectionResources(params: CollectionResourcesParamsType) {
|
|
30
|
+
return FUtil.Request({
|
|
31
|
+
method: 'GET',
|
|
32
|
+
url: `/v2/collections/resources`,
|
|
33
|
+
params: params,
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// 删除收藏的资源
|
|
39
|
+
interface DeleteCollectResourceParamsType {
|
|
40
|
+
resourceId: string;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function deleteCollectResource({resourceId}: DeleteCollectResourceParamsType) {
|
|
44
|
+
// return FUtil.Axios.delete(`/v2/collections/resources/${resourceId}`);
|
|
45
|
+
return FUtil.Request({
|
|
46
|
+
method: 'DELETE',
|
|
47
|
+
url: `/v2/collections/resources/${resourceId}`,
|
|
48
|
+
// params: params,
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// 批量查询资源是否收藏
|
|
53
|
+
interface IsCollectedParamsType {
|
|
54
|
+
resourceIds: string;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export function isCollected(params: IsCollectedParamsType) {
|
|
58
|
+
// return FUtil.Axios.get('/v2/collections/resources/isCollected', {
|
|
59
|
+
// params
|
|
60
|
+
// });
|
|
61
|
+
return FUtil.Request({
|
|
62
|
+
method: 'GET',
|
|
63
|
+
url: `/v2/collections/resources/isCollected`,
|
|
64
|
+
params: params,
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// 查询资源总收藏数量
|
|
69
|
+
interface CollectedCountParamsType {
|
|
70
|
+
resourceId: string;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export function collectedCount({resourceId}: CollectedCountParamsType) {
|
|
74
|
+
// return FUtil.Axios.get(`/v2/collections/resources/${resourceId}/count`);
|
|
75
|
+
return FUtil.Request({
|
|
76
|
+
method: 'GET',
|
|
77
|
+
url: `/v2/collections/resources/${resourceId}/count`,
|
|
78
|
+
// params: params,
|
|
79
|
+
});
|
|
80
|
+
}
|
|
@@ -54,6 +54,7 @@ export function create(params: CreateParamsType) {
|
|
|
54
54
|
interface UpdateParamsType {
|
|
55
55
|
resourceId: string;
|
|
56
56
|
status?: 0 | 1;
|
|
57
|
+
resourceTitle?: string;
|
|
57
58
|
intro?: string;
|
|
58
59
|
tags?: string[];
|
|
59
60
|
coverImages?: string[];
|
|
@@ -216,7 +217,7 @@ interface CreateVersionParamsType {
|
|
|
216
217
|
policyId: string;
|
|
217
218
|
}[];
|
|
218
219
|
}[];
|
|
219
|
-
inputAttrs
|
|
220
|
+
inputAttrs?: {
|
|
220
221
|
key: string;
|
|
221
222
|
value: string;
|
|
222
223
|
}[];
|
package/src/utils/hooks.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
|
|
3
|
-
export function useGetState<T>(initVal: T): [T, (newVal: T) => void, () => T] {
|
|
4
|
-
const [state, setState] = React.useState<T>(initVal);
|
|
5
|
-
const ref = React.useRef<T>(initVal);
|
|
6
|
-
|
|
7
|
-
function setStateCopy(newVal: T): void {
|
|
8
|
-
ref.current = newVal;
|
|
9
|
-
setState(newVal);
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
function getState(): T {
|
|
13
|
-
return ref.current;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
return [state, setStateCopy, getState];
|
|
17
|
-
}
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
export function useGetState<T>(initVal: T): [T, (newVal: T) => void, () => T] {
|
|
4
|
+
const [state, setState] = React.useState<T>(initVal);
|
|
5
|
+
const ref = React.useRef<T>(initVal);
|
|
6
|
+
|
|
7
|
+
function setStateCopy(newVal: T): void {
|
|
8
|
+
ref.current = newVal;
|
|
9
|
+
setState(newVal);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function getState(): T {
|
|
13
|
+
return ref.current;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return [state, setStateCopy, getState];
|
|
17
|
+
}
|
package/src/utils/index.ts
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
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 * as Hook from './hooks';
|
|
8
|
-
// import I18n from '../i18n';
|
|
9
|
-
|
|
10
|
-
const FUtil = {
|
|
11
|
-
Format,
|
|
12
|
-
Regexp,
|
|
13
|
-
LinkTo,
|
|
14
|
-
Predefined,
|
|
15
|
-
Axios,
|
|
16
|
-
Request: request,
|
|
17
|
-
Tool,
|
|
18
|
-
Hook,
|
|
19
|
-
// i18n: new I18n(),
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
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 * as Hook from './hooks';
|
|
8
|
+
// import I18n from '../i18n';
|
|
9
|
+
|
|
10
|
+
const FUtil = {
|
|
11
|
+
Format,
|
|
12
|
+
Regexp,
|
|
13
|
+
LinkTo,
|
|
14
|
+
Predefined,
|
|
15
|
+
Axios,
|
|
16
|
+
Request: request,
|
|
17
|
+
Tool,
|
|
18
|
+
Hook,
|
|
19
|
+
// i18n: new I18n(),
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export default FUtil;
|