@freelog/tools-lib 0.1.163 → 0.1.166
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 -0
- package/dist/service-API/index.d.ts +2 -0
- package/dist/service-API/nodes.d.ts +5 -0
- package/dist/service-API/presentables.d.ts +9 -0
- package/dist/service-API/resourceType.d.ts +10 -0
- package/dist/service-API/resources.d.ts +213 -52
- package/dist/service-API/storages.d.ts +6 -0
- package/dist/service-API/user.d.ts +6 -0
- package/dist/tools-lib.cjs.development.js +1228 -1275
- 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 +1228 -1275
- package/dist/tools-lib.esm.js.map +1 -1
- package/dist/utils/linkTo.d.ts +14 -1
- package/package.json +68 -67
- package/src/i18n/I18nNext.ts +156 -162
- package/src/service-API/index.ts +2 -0
- package/src/service-API/nodes.ts +14 -0
- package/src/service-API/presentables.ts +21 -0
- package/src/service-API/resourceType.ts +29 -0
- package/src/service-API/resources.ts +1336 -771
- package/src/service-API/storages.ts +15 -0
- package/src/service-API/user.ts +14 -0
- package/src/utils/linkTo.ts +594 -551
package/dist/utils/linkTo.d.ts
CHANGED
|
@@ -27,6 +27,10 @@ interface ResourceDetailsParamsType {
|
|
|
27
27
|
version?: string;
|
|
28
28
|
}
|
|
29
29
|
export declare function resourceDetails({ resourceID, ...params }: ResourceDetailsParamsType): TReturnType;
|
|
30
|
+
interface CollectionDetailsParamsType {
|
|
31
|
+
collectionID: string;
|
|
32
|
+
}
|
|
33
|
+
export declare function collectionDetails({ collectionID }: CollectionDetailsParamsType): TReturnType;
|
|
30
34
|
interface ResourceCreatorParamsType {
|
|
31
35
|
}
|
|
32
36
|
export declare function resourceCreatorEntry({}?: ResourceCreatorParamsType): TReturnType;
|
|
@@ -104,8 +108,9 @@ export declare function nodeManagement({ nodeID, showPage, ...params }: NodeMana
|
|
|
104
108
|
interface ExhibitManagementParamsType {
|
|
105
109
|
exhibitID: string;
|
|
106
110
|
openAuthDrawer?: boolean;
|
|
111
|
+
showMoreSetting?: boolean;
|
|
107
112
|
}
|
|
108
|
-
export declare function exhibitManagement({ exhibitID,
|
|
113
|
+
export declare function exhibitManagement({ exhibitID, ...params }: ExhibitManagementParamsType): TReturnType;
|
|
109
114
|
interface CollectionExhibitManagementParamsType {
|
|
110
115
|
exhibitID: string;
|
|
111
116
|
openAuthDrawer?: boolean;
|
|
@@ -130,6 +135,10 @@ interface ObjectDetailsParamsType {
|
|
|
130
135
|
objectID: string;
|
|
131
136
|
}
|
|
132
137
|
export declare function objectDetails({ ...params }: ObjectDetailsParamsType): TReturnType;
|
|
138
|
+
interface CollectionCreateSuccessParamsType {
|
|
139
|
+
collectionID: string;
|
|
140
|
+
}
|
|
141
|
+
export declare function collectionCreateSuccess({ collectionID }: CollectionCreateSuccessParamsType): string;
|
|
133
142
|
interface ResourceCreateSuccessParamsType {
|
|
134
143
|
resourceID: string;
|
|
135
144
|
}
|
|
@@ -157,6 +166,10 @@ interface Exception403ParamsType {
|
|
|
157
166
|
from?: string;
|
|
158
167
|
}
|
|
159
168
|
export declare function exception403({ ...params }?: Exception403ParamsType): string;
|
|
169
|
+
interface ExceptionUnableToAccessParamsType {
|
|
170
|
+
from?: string;
|
|
171
|
+
}
|
|
172
|
+
export declare function exceptionUnableToAccess({ ...params }?: ExceptionUnableToAccessParamsType): string;
|
|
160
173
|
interface NodeFreezeParamsType {
|
|
161
174
|
nodeID: number;
|
|
162
175
|
}
|
package/package.json
CHANGED
|
@@ -1,67 +1,68 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@freelog/tools-lib",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"license": "MIT",
|
|
5
|
-
"main": "dist/index.js",
|
|
6
|
-
"typings": "dist/index.d.ts",
|
|
7
|
-
"files": [
|
|
8
|
-
"dist",
|
|
9
|
-
"src"
|
|
10
|
-
],
|
|
11
|
-
"engines": {
|
|
12
|
-
"node": ">=10"
|
|
13
|
-
},
|
|
14
|
-
"scripts": {
|
|
15
|
-
"start": "tsdx watch",
|
|
16
|
-
"build": "tsdx build",
|
|
17
|
-
"test": "tsdx test",
|
|
18
|
-
"lint": "tsdx lint",
|
|
19
|
-
"prepare": "tsdx build",
|
|
20
|
-
"size": "size-limit",
|
|
21
|
-
"analyze": "size-limit --why",
|
|
22
|
-
"publish": "npm publish --access=public"
|
|
23
|
-
|
|
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
|
-
"@types/
|
|
49
|
-
"@types/
|
|
50
|
-
"@types/
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
-
"
|
|
65
|
-
"
|
|
66
|
-
|
|
67
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@freelog/tools-lib",
|
|
3
|
+
"version": "0.1.166",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"typings": "dist/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist",
|
|
9
|
+
"src"
|
|
10
|
+
],
|
|
11
|
+
"engines": {
|
|
12
|
+
"node": ">=10"
|
|
13
|
+
},
|
|
14
|
+
"scripts": {
|
|
15
|
+
"start": "tsdx watch",
|
|
16
|
+
"build": "tsdx build",
|
|
17
|
+
"test": "tsdx test",
|
|
18
|
+
"lint": "tsdx lint",
|
|
19
|
+
"prepare": "tsdx build",
|
|
20
|
+
"size": "size-limit",
|
|
21
|
+
"analyze": "size-limit --why",
|
|
22
|
+
"publish": "npm publish --access=public",
|
|
23
|
+
"resetRegistry": "npm config set registry https://registry.npmjs.org/"
|
|
24
|
+
},
|
|
25
|
+
"husky": {
|
|
26
|
+
"hooks": {}
|
|
27
|
+
},
|
|
28
|
+
"prettier": {
|
|
29
|
+
"printWidth": 80,
|
|
30
|
+
"semi": true,
|
|
31
|
+
"singleQuote": true,
|
|
32
|
+
"trailingComma": "es5"
|
|
33
|
+
},
|
|
34
|
+
"author": "liu-kai-github",
|
|
35
|
+
"module": "dist/tools-lib.esm.js",
|
|
36
|
+
"size-limit": [
|
|
37
|
+
{
|
|
38
|
+
"path": "dist/tools-lib.cjs.production.min.js",
|
|
39
|
+
"limit": "10 KB"
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"path": "dist/tools-lib.esm.js",
|
|
43
|
+
"limit": "10 KB"
|
|
44
|
+
}
|
|
45
|
+
],
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"@size-limit/preset-small-lib": "^4.11.0",
|
|
48
|
+
"@types/js-cookie": "^3.0.2",
|
|
49
|
+
"@types/node": "^18.7.16",
|
|
50
|
+
"@types/nprogress": "^0.2.0",
|
|
51
|
+
"@types/react": "^18.2.17",
|
|
52
|
+
"husky": "^6.0.0",
|
|
53
|
+
"size-limit": "^4.11.0",
|
|
54
|
+
"tsdx": "^0.14.1",
|
|
55
|
+
"tslib": "^2.2.0",
|
|
56
|
+
"typescript": "^4.7.4"
|
|
57
|
+
},
|
|
58
|
+
"dependencies": {
|
|
59
|
+
"@freelog/resource-policy-lang": "1.1.26",
|
|
60
|
+
"axios": "^0.21.1",
|
|
61
|
+
"html-react-parser": "^4.2.0",
|
|
62
|
+
"i18next": "^21.8.10",
|
|
63
|
+
"js-cookie": "^3.0.1",
|
|
64
|
+
"moment": "^2.29.1",
|
|
65
|
+
"nprogress": "^0.2.0",
|
|
66
|
+
"react": "^18.2.0"
|
|
67
|
+
}
|
|
68
|
+
}
|
package/src/i18n/I18nNext.ts
CHANGED
|
@@ -1,162 +1,156 @@
|
|
|
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
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
return result;
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
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
|
+
// 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
|
+
window.localStorage.setItem(localStorage_i18nextResources_key, JSON.stringify(result));
|
|
152
|
+
return result;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
export default I18nNext;
|
package/src/service-API/index.ts
CHANGED
|
@@ -16,6 +16,7 @@ import * as I18n from './i18n';
|
|
|
16
16
|
import * as Policy from './policies';
|
|
17
17
|
import * as recombination from './recombinations';
|
|
18
18
|
import * as Operation from './operation';
|
|
19
|
+
import * as ResourceType from './resourceType';
|
|
19
20
|
|
|
20
21
|
const FServiceAPI = {
|
|
21
22
|
Node,
|
|
@@ -36,6 +37,7 @@ const FServiceAPI = {
|
|
|
36
37
|
Policy,
|
|
37
38
|
recombination,
|
|
38
39
|
Operation,
|
|
40
|
+
ResourceType,
|
|
39
41
|
};
|
|
40
42
|
|
|
41
43
|
export default FServiceAPI;
|
package/src/service-API/nodes.ts
CHANGED
|
@@ -4,6 +4,7 @@ import FUtil from '../utils';
|
|
|
4
4
|
export interface CreateParamsType {
|
|
5
5
|
nodeName: string;
|
|
6
6
|
nodeDomain: string;
|
|
7
|
+
nodeTitle: string;
|
|
7
8
|
}
|
|
8
9
|
|
|
9
10
|
export function create(params: CreateParamsType) {
|
|
@@ -97,3 +98,16 @@ export function setNodeInfo(params: SetNodeInfoParamsType) {
|
|
|
97
98
|
});
|
|
98
99
|
}
|
|
99
100
|
|
|
101
|
+
// 删除节点
|
|
102
|
+
interface DeleteNodeParamsType {
|
|
103
|
+
nodeId: number;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export function deleteNode({nodeId}: DeleteNodeParamsType) {
|
|
107
|
+
return FUtil.Request({
|
|
108
|
+
method: 'DELETE',
|
|
109
|
+
url: `/v2/nodes/${nodeId}`,
|
|
110
|
+
// params: params,
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
|
|
@@ -12,6 +12,7 @@ export interface CreatePresentableParamsType {
|
|
|
12
12
|
}[];
|
|
13
13
|
}[];
|
|
14
14
|
presentableName: string;
|
|
15
|
+
presentableTitle?: string;
|
|
15
16
|
tags?: string[];
|
|
16
17
|
policies?: {
|
|
17
18
|
policyName: string;
|
|
@@ -50,6 +51,7 @@ interface UpdatePresentableParamsType {
|
|
|
50
51
|
policyId: string;
|
|
51
52
|
}[];
|
|
52
53
|
}[];
|
|
54
|
+
autoUpdateStatus?: 0 | 1;
|
|
53
55
|
}
|
|
54
56
|
|
|
55
57
|
export function updatePresentable({presentableId, ...params}: UpdatePresentableParamsType) {
|
|
@@ -131,6 +133,8 @@ interface PresentablesParamsType {
|
|
|
131
133
|
keywords?: string;
|
|
132
134
|
isLoadVersionProperty?: 0 | 1;
|
|
133
135
|
isLoadPolicyInfo?: 0 | 1;
|
|
136
|
+
isLoadResourceDetailInfo?: 0 | 1;
|
|
137
|
+
isLoadVersionUpdateTip?: 0 | 1;
|
|
134
138
|
}
|
|
135
139
|
|
|
136
140
|
export function presentables(params: PresentablesParamsType) {
|
|
@@ -320,3 +324,20 @@ export function batchUpdatePresentableStatus({...params}: BatchUpdatePresentable
|
|
|
320
324
|
data: params,
|
|
321
325
|
});
|
|
322
326
|
}
|
|
327
|
+
|
|
328
|
+
// 忽略展品更新提醒
|
|
329
|
+
interface IgnorePresentableVersionUpdateTipParamsType {
|
|
330
|
+
presentableId: string;
|
|
331
|
+
ignoreVersion: string;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
export function ignorePresentableVersionUpdateTip({
|
|
335
|
+
presentableId,
|
|
336
|
+
...params
|
|
337
|
+
}: IgnorePresentableVersionUpdateTipParamsType) {
|
|
338
|
+
return FUtil.Request({
|
|
339
|
+
method: 'POST',
|
|
340
|
+
url: `/v2/presentables/${presentableId}/ignorePresentableVersionUpdateTip`,
|
|
341
|
+
data: params,
|
|
342
|
+
});
|
|
343
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import FUtil from '../utils';
|
|
2
|
+
// import {CommonReturn} from "./tools";
|
|
3
|
+
|
|
4
|
+
// 根据编号取资源类型
|
|
5
|
+
interface GetInfoByCodeType {
|
|
6
|
+
code: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function getInfoByCode({...params}: GetInfoByCodeType) {
|
|
10
|
+
return FUtil.Request({
|
|
11
|
+
method: 'GET',
|
|
12
|
+
url: `/v2/resources/types/getInfoByCode`,
|
|
13
|
+
params: params,
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// 根据编号取资源类型
|
|
18
|
+
interface GetInfoByCodeOrNameType {
|
|
19
|
+
code?: string;
|
|
20
|
+
name?: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function getInfoByCodeOrName({...params}: GetInfoByCodeOrNameType) {
|
|
24
|
+
return FUtil.Request({
|
|
25
|
+
method: 'GET',
|
|
26
|
+
url: `/v2/resources/types/getInfoByCodeOrName`,
|
|
27
|
+
params: params,
|
|
28
|
+
});
|
|
29
|
+
}
|