@freelog/tools-lib 0.1.152 → 0.1.153
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 +1 -1
- package/dist/service-API/collections.d.ts +1 -0
- package/dist/service-API/resources.d.ts +17 -4
- package/dist/tools-lib.cjs.development.js +105 -46
- 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 +105 -46
- package/dist/tools-lib.esm.js.map +1 -1
- package/dist/utils/hooks.d.ts +1 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/linkTo.d.ts +10 -0
- package/dist/utils/regexp.d.ts +2 -0
- package/package.json +4 -2
- package/src/i18n/I18nNext.ts +155 -155
- package/src/service-API/collections.ts +80 -82
- package/src/service-API/resources.ts +644 -622
- package/src/utils/hooks.ts +17 -0
- package/src/utils/index.ts +22 -20
- package/src/utils/linkTo.ts +439 -413
- package/src/utils/regexp.ts +60 -53
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useGetState<T>(initVal: T): [T, (newVal: T) => void, () => T];
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import * as LinkTo from './linkTo';
|
|
|
4
4
|
import * as Predefined from './predefined';
|
|
5
5
|
import { request } from './axios';
|
|
6
6
|
import * as Tool from './tools';
|
|
7
|
+
import * as Hook from './hooks';
|
|
7
8
|
declare const FUtil: {
|
|
8
9
|
Format: typeof Format;
|
|
9
10
|
Regexp: typeof Regexp;
|
|
@@ -12,5 +13,6 @@ declare const FUtil: {
|
|
|
12
13
|
Axios: import("axios").AxiosStatic;
|
|
13
14
|
Request: typeof request;
|
|
14
15
|
Tool: typeof Tool;
|
|
16
|
+
Hook: typeof Hook;
|
|
15
17
|
};
|
|
16
18
|
export default FUtil;
|
package/dist/utils/linkTo.d.ts
CHANGED
|
@@ -119,6 +119,10 @@ interface ResourceFreezeParamsType {
|
|
|
119
119
|
resourceID: string;
|
|
120
120
|
}
|
|
121
121
|
export declare function resourceFreeze({ resourceID }: ResourceFreezeParamsType): string;
|
|
122
|
+
interface GlobalSearchParamsType {
|
|
123
|
+
search: string;
|
|
124
|
+
}
|
|
125
|
+
export declare function globalSearch({ search }: GlobalSearchParamsType): string;
|
|
122
126
|
/************** console End ******************************************************/
|
|
123
127
|
/************** user Start ******************************************************/
|
|
124
128
|
interface LoginParamsType {
|
|
@@ -130,6 +134,12 @@ interface LoginParamsType {
|
|
|
130
134
|
invitationCode?: string;
|
|
131
135
|
}
|
|
132
136
|
export declare function logon({ goTo, ...params }?: LoginParamsType): string;
|
|
137
|
+
interface LoginParamsType {
|
|
138
|
+
goTo?: string;
|
|
139
|
+
identityId?: string;
|
|
140
|
+
returnUrl?: string;
|
|
141
|
+
}
|
|
142
|
+
export declare function bind({ goTo, returnUrl, ...params }?: LoginParamsType): string;
|
|
133
143
|
interface RetrieveUserPasswordParamsType {
|
|
134
144
|
goTo?: string;
|
|
135
145
|
}
|
package/dist/utils/regexp.d.ts
CHANGED
|
@@ -14,3 +14,5 @@ export declare const POSITIVE_INTEGER: RegExp;
|
|
|
14
14
|
export declare const MAX_2_DECIMAL_POSITIVE_NUMBER: RegExp;
|
|
15
15
|
export declare const BUCKET_NAME: RegExp;
|
|
16
16
|
export declare const JS_VARIABLE_NAME: RegExp;
|
|
17
|
+
export declare const DATE: RegExp;
|
|
18
|
+
export declare const DATE_TIME: RegExp;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@freelog/tools-lib",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.153",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
@@ -48,6 +48,7 @@
|
|
|
48
48
|
"@types/js-cookie": "^3.0.2",
|
|
49
49
|
"@types/node": "^18.7.16",
|
|
50
50
|
"@types/nprogress": "^0.2.0",
|
|
51
|
+
"@types/react": "^18.2.17",
|
|
51
52
|
"husky": "^6.0.0",
|
|
52
53
|
"size-limit": "^4.11.0",
|
|
53
54
|
"tsdx": "^0.14.1",
|
|
@@ -61,6 +62,7 @@
|
|
|
61
62
|
"i18next": "^21.8.10",
|
|
62
63
|
"js-cookie": "^3.0.1",
|
|
63
64
|
"moment": "^2.29.1",
|
|
64
|
-
"nprogress": "^0.2.0"
|
|
65
|
+
"nprogress": "^0.2.0",
|
|
66
|
+
"react": "^18.2.0"
|
|
65
67
|
}
|
|
66
68
|
}
|
package/src/i18n/I18nNext.ts
CHANGED
|
@@ -1,155 +1,155 @@
|
|
|
1
|
-
import i18next, {Resource} from 'i18next';
|
|
2
|
-
import axios from "axios";
|
|
3
|
-
import Cookies from 'js-cookie';
|
|
4
|
-
import FUtil from '../utils';
|
|
5
|
-
|
|
6
|
-
type LanguageKeyType = 'zh_CN' | 'en_US';
|
|
7
|
-
|
|
8
|
-
const ossJsonUrl: string = 'https://freelog-i18n.oss-cn-shenzhen.aliyuncs.com/configs/i18n.json';
|
|
9
|
-
const ossJsonUrl_Test: string = 'https://freelog-i18n.oss-cn-shenzhen.aliyuncs.com/configs-test/i18n.json';
|
|
10
|
-
const localStorage_i18nextLng_key: string = 'locale';
|
|
11
|
-
const localStorage_i18nextResources_key: string = 'i18nextResources';
|
|
12
|
-
|
|
13
|
-
const allLanguage = [
|
|
14
|
-
{value: 'en_US', label: 'English'},
|
|
15
|
-
{value: 'zh_CN', label: '简体中文'},
|
|
16
|
-
];
|
|
17
|
-
|
|
18
|
-
class I18nNext {
|
|
19
|
-
|
|
20
|
-
private _loadingData: 'NotStart' | 'Start' | 'End' = 'NotStart';
|
|
21
|
-
private _taskQueue: Function[] = [];
|
|
22
|
-
// private _currentLanguage: LanguageKeyType = window.localStorage.getItem(localStorage_i18nextLng_key) as null || 'zh_CN';
|
|
23
|
-
private _currentLanguage: LanguageKeyType = Cookies.get(localStorage_i18nextLng_key) as undefined || 'zh_CN';
|
|
24
|
-
|
|
25
|
-
constructor() {
|
|
26
|
-
this.ready();
|
|
27
|
-
|
|
28
|
-
this.ready = this.ready.bind(this);
|
|
29
|
-
this.t = this.t.bind(this);
|
|
30
|
-
this.changeLanguage = this.changeLanguage.bind(this);
|
|
31
|
-
this.getAllLanguage = this.getAllLanguage.bind(this);
|
|
32
|
-
this.getCurrentLanguage = this.getCurrentLanguage.bind(this);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
async ready(this: I18nNext) {
|
|
36
|
-
const exc = () => {
|
|
37
|
-
while (this._taskQueue.length > 0) {
|
|
38
|
-
const task = this._taskQueue.shift();
|
|
39
|
-
task && task();
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
const handleTasks = async () => {
|
|
43
|
-
// console.log(this._loadingData, 'this._loadingData90iowejflksdfjlsdk');
|
|
44
|
-
if (this._loadingData === 'End') {
|
|
45
|
-
exc();
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
if (this._loadingData === 'Start') {
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
// NO_START
|
|
53
|
-
this._loadingData = 'Start';
|
|
54
|
-
|
|
55
|
-
await this._handleData();
|
|
56
|
-
// console.log('######');
|
|
57
|
-
exc();
|
|
58
|
-
};
|
|
59
|
-
const promise = new Promise((resolve) => {
|
|
60
|
-
this._taskQueue.push(resolve);
|
|
61
|
-
});
|
|
62
|
-
handleTasks();
|
|
63
|
-
return promise;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
t(this: I18nNext, key: string, options?: { [key: string]: any }) {
|
|
67
|
-
return i18next.t(key.trim(), options);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
changeLanguage(this: I18nNext, lng: LanguageKeyType) {
|
|
71
|
-
// return i18next.changeLanguage(lng);
|
|
72
|
-
// window.localStorage.setItem(localStorage_i18nextLng_key, lng)
|
|
73
|
-
Cookies.set(localStorage_i18nextLng_key, lng, {
|
|
74
|
-
expires: 36525,
|
|
75
|
-
domain: FUtil.Format.completeUrlByDomain('').replace(/http(s)?:\/\//, ''),
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
getAllLanguage(this: I18nNext): typeof allLanguage {
|
|
80
|
-
return allLanguage;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
getCurrentLanguage(this: I18nNext): LanguageKeyType {
|
|
84
|
-
return this._currentLanguage;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
private async _handleData(this: I18nNext) {
|
|
88
|
-
|
|
89
|
-
const lng: string = this._currentLanguage;
|
|
90
|
-
const resource: string | null = window.localStorage.getItem(localStorage_i18nextResources_key);
|
|
91
|
-
// const resource: string | undefined = Cookies.get(decodeURIComponent(localStorage_i18nextResources_key));
|
|
92
|
-
let i18nextResources: Resource | null = resource ? JSON.parse(resource) : null;
|
|
93
|
-
|
|
94
|
-
if (!i18nextResources) {
|
|
95
|
-
// console.log('######892io3jlkl')
|
|
96
|
-
i18nextResources = await this._fetchData();
|
|
97
|
-
} else {
|
|
98
|
-
this._fetchData();
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
await i18next
|
|
102
|
-
.init({
|
|
103
|
-
// the translations
|
|
104
|
-
// (tip move them in a JSON file and import them,
|
|
105
|
-
// or even better, manage them via a UI: https://react.i18next.com/guides/multiple-translation-files#manage-your-translations-with-a-management-gui)
|
|
106
|
-
resources: i18nextResources,
|
|
107
|
-
lng: lng, // if you're using a language detector, do not define the lng option
|
|
108
|
-
fallbackLng: 'zh_CN',
|
|
109
|
-
|
|
110
|
-
interpolation: {
|
|
111
|
-
escapeValue: false, // react already safes from xss => https://www.i18next.com/translation-function/interpolation#unescape
|
|
112
|
-
prefix: '{',
|
|
113
|
-
suffix: '}',
|
|
114
|
-
},
|
|
115
|
-
});
|
|
116
|
-
this._loadingData = 'End';
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
private async _fetchData(this: I18nNext): Promise<Resource> {
|
|
120
|
-
const url: string = window.location.origin.includes('.freelog.com') ? ossJsonUrl : ossJsonUrl_Test;
|
|
121
|
-
const res: any = await axios.get(url + '?timestamp=' + Date.now(), {
|
|
122
|
-
withCredentials: false,
|
|
123
|
-
});
|
|
124
|
-
// console.log(res, 'data09oiw3qjelsfkdfjlsdkfjl');
|
|
125
|
-
|
|
126
|
-
const en_US: { [key: string]: string } = {};
|
|
127
|
-
const zh_CN: { [key: string]: string } = {};
|
|
128
|
-
|
|
129
|
-
for (const [key, value] of Object.entries(res)) {
|
|
130
|
-
// console.log(key, value, 'key, value90iowsldfjlsdkj');
|
|
131
|
-
en_US[key] = (value as any)['en_US'];
|
|
132
|
-
zh_CN[key] = (value as any)['zh_CN'];
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
const result: Resource = {
|
|
136
|
-
en_US: {
|
|
137
|
-
translation: en_US,
|
|
138
|
-
},
|
|
139
|
-
zh_CN: {
|
|
140
|
-
translation: zh_CN,
|
|
141
|
-
},
|
|
142
|
-
};
|
|
143
|
-
|
|
144
|
-
// console.log(result, 'result093sdolkfjlsdkjl');
|
|
145
|
-
window.localStorage.setItem(localStorage_i18nextResources_key, JSON.stringify(result));
|
|
146
|
-
// Cookies.set(localStorage_i18nextResources_key, encodeURIComponent(JSON.stringify(result)), {
|
|
147
|
-
// expires: 36525,
|
|
148
|
-
// domain: FUtil.Format.completeUrlByDomain('').replace(/http(s)?:\/\//, ''),
|
|
149
|
-
// });
|
|
150
|
-
|
|
151
|
-
return result;
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
export default I18nNext;
|
|
1
|
+
import i18next, {Resource} from 'i18next';
|
|
2
|
+
import axios from "axios";
|
|
3
|
+
import Cookies from 'js-cookie';
|
|
4
|
+
import FUtil from '../utils';
|
|
5
|
+
|
|
6
|
+
type LanguageKeyType = 'zh_CN' | 'en_US';
|
|
7
|
+
|
|
8
|
+
const ossJsonUrl: string = 'https://freelog-i18n.oss-cn-shenzhen.aliyuncs.com/configs/i18n.json';
|
|
9
|
+
const ossJsonUrl_Test: string = 'https://freelog-i18n.oss-cn-shenzhen.aliyuncs.com/configs-test/i18n.json';
|
|
10
|
+
const localStorage_i18nextLng_key: string = 'locale';
|
|
11
|
+
const localStorage_i18nextResources_key: string = 'i18nextResources';
|
|
12
|
+
|
|
13
|
+
const allLanguage = [
|
|
14
|
+
{value: 'en_US', label: 'English'},
|
|
15
|
+
{value: 'zh_CN', label: '简体中文'},
|
|
16
|
+
];
|
|
17
|
+
|
|
18
|
+
class I18nNext {
|
|
19
|
+
|
|
20
|
+
private _loadingData: 'NotStart' | 'Start' | 'End' = 'NotStart';
|
|
21
|
+
private _taskQueue: Function[] = [];
|
|
22
|
+
// private _currentLanguage: LanguageKeyType = window.localStorage.getItem(localStorage_i18nextLng_key) as null || 'zh_CN';
|
|
23
|
+
private _currentLanguage: LanguageKeyType = Cookies.get(localStorage_i18nextLng_key) as undefined || 'zh_CN';
|
|
24
|
+
|
|
25
|
+
constructor() {
|
|
26
|
+
this.ready();
|
|
27
|
+
|
|
28
|
+
this.ready = this.ready.bind(this);
|
|
29
|
+
this.t = this.t.bind(this);
|
|
30
|
+
this.changeLanguage = this.changeLanguage.bind(this);
|
|
31
|
+
this.getAllLanguage = this.getAllLanguage.bind(this);
|
|
32
|
+
this.getCurrentLanguage = this.getCurrentLanguage.bind(this);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
async ready(this: I18nNext): Promise<void> {
|
|
36
|
+
const exc = () => {
|
|
37
|
+
while (this._taskQueue.length > 0) {
|
|
38
|
+
const task = this._taskQueue.shift();
|
|
39
|
+
task && task();
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
const handleTasks = async () => {
|
|
43
|
+
// console.log(this._loadingData, 'this._loadingData90iowejflksdfjlsdk');
|
|
44
|
+
if (this._loadingData === 'End') {
|
|
45
|
+
exc();
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
if (this._loadingData === 'Start') {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// NO_START
|
|
53
|
+
this._loadingData = 'Start';
|
|
54
|
+
|
|
55
|
+
await this._handleData();
|
|
56
|
+
// console.log('######');
|
|
57
|
+
exc();
|
|
58
|
+
};
|
|
59
|
+
const promise = new Promise<void>((resolve) => {
|
|
60
|
+
this._taskQueue.push(resolve);
|
|
61
|
+
});
|
|
62
|
+
handleTasks();
|
|
63
|
+
return promise;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
t(this: I18nNext, key: string, options?: { [key: string]: any }): string {
|
|
67
|
+
return i18next.t(key.trim(), options);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
changeLanguage(this: I18nNext, lng: LanguageKeyType): void {
|
|
71
|
+
// return i18next.changeLanguage(lng);
|
|
72
|
+
// window.localStorage.setItem(localStorage_i18nextLng_key, lng)
|
|
73
|
+
Cookies.set(localStorage_i18nextLng_key, lng, {
|
|
74
|
+
expires: 36525,
|
|
75
|
+
domain: FUtil.Format.completeUrlByDomain('').replace(/http(s)?:\/\//, ''),
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
getAllLanguage(this: I18nNext): typeof allLanguage {
|
|
80
|
+
return allLanguage;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
getCurrentLanguage(this: I18nNext): LanguageKeyType {
|
|
84
|
+
return this._currentLanguage;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
private async _handleData(this: I18nNext): Promise<void> {
|
|
88
|
+
|
|
89
|
+
const lng: string = this._currentLanguage;
|
|
90
|
+
const resource: string | null = window.localStorage.getItem(localStorage_i18nextResources_key);
|
|
91
|
+
// const resource: string | undefined = Cookies.get(decodeURIComponent(localStorage_i18nextResources_key));
|
|
92
|
+
let i18nextResources: Resource | null = resource ? JSON.parse(resource) : null;
|
|
93
|
+
|
|
94
|
+
if (!i18nextResources) {
|
|
95
|
+
// console.log('######892io3jlkl')
|
|
96
|
+
i18nextResources = await this._fetchData();
|
|
97
|
+
} else {
|
|
98
|
+
this._fetchData();
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
await i18next
|
|
102
|
+
.init({
|
|
103
|
+
// the translations
|
|
104
|
+
// (tip move them in a JSON file and import them,
|
|
105
|
+
// or even better, manage them via a UI: https://react.i18next.com/guides/multiple-translation-files#manage-your-translations-with-a-management-gui)
|
|
106
|
+
resources: i18nextResources,
|
|
107
|
+
lng: lng, // if you're using a language detector, do not define the lng option
|
|
108
|
+
fallbackLng: 'zh_CN',
|
|
109
|
+
|
|
110
|
+
interpolation: {
|
|
111
|
+
escapeValue: false, // react already safes from xss => https://www.i18next.com/translation-function/interpolation#unescape
|
|
112
|
+
prefix: '{',
|
|
113
|
+
suffix: '}',
|
|
114
|
+
},
|
|
115
|
+
});
|
|
116
|
+
this._loadingData = 'End';
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
private async _fetchData(this: I18nNext): Promise<Resource> {
|
|
120
|
+
const url: string = window.location.origin.includes('.freelog.com') ? ossJsonUrl : ossJsonUrl_Test;
|
|
121
|
+
const res: any = await axios.get(url + '?timestamp=' + Date.now(), {
|
|
122
|
+
withCredentials: false,
|
|
123
|
+
});
|
|
124
|
+
// console.log(res, 'data09oiw3qjelsfkdfjlsdkfjl');
|
|
125
|
+
|
|
126
|
+
const en_US: { [key: string]: string } = {};
|
|
127
|
+
const zh_CN: { [key: string]: string } = {};
|
|
128
|
+
|
|
129
|
+
for (const [key, value] of Object.entries(res)) {
|
|
130
|
+
// console.log(key, value, 'key, value90iowsldfjlsdkj');
|
|
131
|
+
en_US[key] = (value as any)['en_US'];
|
|
132
|
+
zh_CN[key] = (value as any)['zh_CN'];
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
const result: Resource = {
|
|
136
|
+
en_US: {
|
|
137
|
+
translation: en_US,
|
|
138
|
+
},
|
|
139
|
+
zh_CN: {
|
|
140
|
+
translation: zh_CN,
|
|
141
|
+
},
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
// console.log(result, 'result093sdolkfjlsdkjl');
|
|
145
|
+
window.localStorage.setItem(localStorage_i18nextResources_key, JSON.stringify(result));
|
|
146
|
+
// Cookies.set(localStorage_i18nextResources_key, encodeURIComponent(JSON.stringify(result)), {
|
|
147
|
+
// expires: 36525,
|
|
148
|
+
// domain: FUtil.Format.completeUrlByDomain('').replace(/http(s)?:\/\//, ''),
|
|
149
|
+
// });
|
|
150
|
+
|
|
151
|
+
return result;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
export default I18nNext;
|
|
@@ -1,82 +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
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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
|
-
}
|
|
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
|
+
}
|