@freelog/tools-lib 0.1.151 → 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.
@@ -0,0 +1 @@
1
+ export declare function useGetState<T>(initVal: T): [T, (newVal: T) => void, () => T];
@@ -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;
@@ -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
  }
@@ -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.151",
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
  }
@@ -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;
@@ -21,14 +21,12 @@ interface CollectionResourcesParamsType {
21
21
  keywords?: string;
22
22
  resourceType?: string;
23
23
  resourceTypeCode?: string;
24
+ resourceTypeCategory?: 1 | 2;
24
25
  omitResourceType?: string;
25
26
  resourceStatus?: 0 | 1 | 2 | 4;
26
27
  }
27
28
 
28
29
  export function collectionResources(params: CollectionResourcesParamsType) {
29
- // return FUtil.Axios.get('/v2/collections/resources', {
30
- // params
31
- // });
32
30
  return FUtil.Request({
33
31
  method: 'GET',
34
32
  url: `/v2/collections/resources`,
@@ -1,81 +1,81 @@
1
- import FUtil from '../utils';
2
-
3
- // 创建节点
4
- export interface CreateParamsType {
5
- nodeName: string;
6
- nodeDomain: string;
7
- }
8
-
9
- export function create(params: CreateParamsType) {
10
- // return FUtil.Axios.post('/v2/nodes', params);
11
- return FUtil.Request({
12
- method: 'POST',
13
- url: `/v2/nodes`,
14
- data: params,
15
- });
16
- }
17
-
18
- // 查看节点详情
19
- interface NodeDetailParamsType1 {
20
- nodeId: number;
21
- }
22
-
23
- interface NodeDetailParamsType2 {
24
- nodeName?: string;
25
- nodeDomain?: string;
26
- }
27
-
28
- export function details(params: NodeDetailParamsType1 | NodeDetailParamsType2) {
29
- if ((params as NodeDetailParamsType1).nodeId) {
30
- // return FUtil.Axios.get(`/v2/nodes/${(params as NodeDetailParamsType1).nodeId}`);
31
- return FUtil.Request({
32
- method: 'GET',
33
- url: `/v2/nodes/${(params as NodeDetailParamsType1).nodeId}`,
34
- // params: params,
35
- });
36
- }
37
- // return FUtil.Axios.get(`/v2/nodes/detail`, {
38
- // params,
39
- // });
40
- return FUtil.Request({
41
- method: 'GET',
42
- url: `/v2/nodes/detail`,
43
- params: params,
44
- });
45
- }
46
-
47
- // 查看节点列表
48
- interface NodesParamsType {
49
- skip?: number;
50
- limit?: number;
51
- status?: 0 | 1 | 2; // 0:正常 1:未审核 2:冻结
52
- projection?: string;
53
- }
54
-
55
- export function nodes(params: NodesParamsType) {
56
- return FUtil.Request({
57
- method: 'GET',
58
- url: `/v2/nodes`,
59
- params: params,
60
- });
61
- }
62
-
63
- // 设置节点信息
64
- interface SetNodeInfoParamsType {
65
- nodeId: number;
66
- nodeLogo: string;
67
- nodeTitle: string;
68
- nodeShortDescription: string;
69
- // nodeVisibility: 1 | 2 | 3; // 可见性 1:公开 2:私密 3:暂停
70
- status: 1 | 2 | 8; // 可见性 1:公开 2:私密 3:暂停
71
- nodeSuspendInfo: string;
72
- }
73
-
74
- export function setNodeInfo(params: SetNodeInfoParamsType) {
75
- return FUtil.Request({
76
- method: 'POST',
77
- url: `/v2/nodes/setNodeInfo`,
78
- data: params,
79
- });
80
- }
81
-
1
+ import FUtil from '../utils';
2
+
3
+ // 创建节点
4
+ export interface CreateParamsType {
5
+ nodeName: string;
6
+ nodeDomain: string;
7
+ }
8
+
9
+ export function create(params: CreateParamsType) {
10
+ // return FUtil.Axios.post('/v2/nodes', params);
11
+ return FUtil.Request({
12
+ method: 'POST',
13
+ url: `/v2/nodes`,
14
+ data: params,
15
+ });
16
+ }
17
+
18
+ // 查看节点详情
19
+ interface NodeDetailParamsType1 {
20
+ nodeId: number;
21
+ }
22
+
23
+ interface NodeDetailParamsType2 {
24
+ nodeName?: string;
25
+ nodeDomain?: string;
26
+ }
27
+
28
+ export function details(params: NodeDetailParamsType1 | NodeDetailParamsType2) {
29
+ if ((params as NodeDetailParamsType1).nodeId) {
30
+ // return FUtil.Axios.get(`/v2/nodes/${(params as NodeDetailParamsType1).nodeId}`);
31
+ return FUtil.Request({
32
+ method: 'GET',
33
+ url: `/v2/nodes/${(params as NodeDetailParamsType1).nodeId}`,
34
+ // params: params,
35
+ });
36
+ }
37
+ // return FUtil.Axios.get(`/v2/nodes/detail`, {
38
+ // params,
39
+ // });
40
+ return FUtil.Request({
41
+ method: 'GET',
42
+ url: `/v2/nodes/detail`,
43
+ params: params,
44
+ });
45
+ }
46
+
47
+ // 查看节点列表
48
+ interface NodesParamsType {
49
+ skip?: number;
50
+ limit?: number;
51
+ status?: 0 | 1 | 2; // 0:正常 1:未审核 2:冻结
52
+ projection?: string;
53
+ }
54
+
55
+ export function nodes(params: NodesParamsType) {
56
+ return FUtil.Request({
57
+ method: 'GET',
58
+ url: `/v2/nodes`,
59
+ params: params,
60
+ });
61
+ }
62
+
63
+ // 设置节点信息
64
+ interface SetNodeInfoParamsType {
65
+ nodeId: number;
66
+ nodeLogo: string;
67
+ nodeTitle: string;
68
+ nodeShortDescription: string;
69
+ // nodeVisibility: 1 | 2 | 3; // 可见性 1:公开 2:私密 3:暂停
70
+ status: 1 | 2 | 8; // 可见性 1:公开 2:私密 3:暂停
71
+ nodeSuspendInfo: string;
72
+ }
73
+
74
+ export function setNodeInfo(params: SetNodeInfoParamsType) {
75
+ return FUtil.Request({
76
+ method: 'POST',
77
+ url: `/v2/nodes/setNodeInfo`,
78
+ data: params,
79
+ });
80
+ }
81
+
@@ -3,6 +3,7 @@ import FUtil from '../utils';
3
3
  // 列出运营分类分组排序
4
4
  interface OperationCategoriesParamsType {
5
5
  name?: string;
6
+ status?: number;
6
7
  }
7
8
 
8
9
  export function operationCategories({...params}: OperationCategoriesParamsType = {}) {