@pisell/core 1.0.1 → 1.0.3
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/es/app/app.d.ts +15 -54
- package/es/app/app.js +33 -48
- package/es/app/const.js +3 -3
- package/es/app/index.d.ts +1 -1
- package/es/app/index.js +9 -11
- package/es/applicationManager/application.d.ts +2 -2
- package/es/applicationManager/application.js +9 -12
- package/es/applicationManager/index.js +4 -4
- package/es/config.js +5 -5
- package/es/data/index.d.ts +8 -29
- package/es/data/index.js +16 -8
- package/es/history/config.js +5 -5
- package/es/history/index.d.ts +1 -1
- package/es/history/index.js +4 -4
- package/es/hooks/useDelayedValue/index.js +1 -1
- package/es/hooks/useLowCode/index.js +5 -5
- package/es/hooks/useStore/index.d.ts +2 -2
- package/es/index.d.ts +0 -2
- package/es/index.js +2 -2
- package/es/indexDB/index.d.ts +3 -1
- package/es/indexDB/index.js +28 -22
- package/es/locales/index.d.ts +30 -89
- package/es/locales/index.js +202 -243
- package/es/locales/type.d.ts +3 -3
- package/es/logger/feishu.js +2 -2
- package/es/logger/index.d.ts +1 -1
- package/es/logger/index.js +31 -23
- package/es/menuManager/hooks.d.ts +10 -1
- package/es/menuManager/hooks.js +4 -6
- package/es/menuManager/index.d.ts +1 -1
- package/es/menuManager/index.js +3 -3
- package/es/models/global.js +8 -7
- package/es/models/index.d.ts +6 -6
- package/es/models/index.js +1 -2
- package/es/pubsub/index.d.ts +1 -1
- package/es/pubsub/index.js +3 -3
- package/es/request/cache.d.ts +1 -1
- package/es/request/cache.js +7 -6
- package/es/request/config.js +7 -7
- package/es/request/index.js +12 -11
- package/es/request/pisell2Request.d.ts +1 -1
- package/es/request/pisell2Request.js +5 -5
- package/es/request/type.d.ts +1 -0
- package/es/request/utils.js +5 -3
- package/es/routes/index.d.ts +2 -2
- package/es/routes/index.js +11 -17
- package/es/socket/components/SocketMonitorPage.js +255 -462
- package/es/socket/events.js +3 -3
- package/es/socket/heartbeat.js +6 -7
- package/es/socket/index.js +7 -7
- package/es/socket/monitor.d.ts +1 -1
- package/es/socket/monitor.js +24 -15
- package/es/socket/reconnect.js +9 -9
- package/es/socket/socket.js +11 -13
- package/es/socket/types.d.ts +2 -1
- package/es/socket/types.js +23 -7
- package/es/storage/index.d.ts +17 -42
- package/es/storage/index.js +55 -61
- package/es/tasks/index.d.ts +1 -1
- package/es/tasks/index.js +46 -22
- package/es/tasks/type.d.ts +4 -4
- package/es/tasks/useTasks.d.ts +2 -1
- package/es/tasks/useTasks.js +1 -1
- package/es/variables/VariablesProvider.js +3 -5
- package/es/variables/config.js +5 -5
- package/es/variables/index.d.ts +3 -3
- package/lib/app/app.d.ts +15 -54
- package/lib/app/app.js +7 -10
- package/lib/app/index.d.ts +1 -1
- package/lib/applicationManager/application.d.ts +2 -2
- package/lib/data/index.d.ts +8 -29
- package/lib/data/index.js +8 -22
- package/lib/history/index.d.ts +1 -1
- package/lib/hooks/useStore/index.d.ts +2 -2
- package/lib/index.d.ts +0 -2
- package/lib/index.js +1 -7
- package/lib/indexDB/index.d.ts +3 -1
- package/lib/indexDB/index.js +8 -18
- package/lib/locales/index.d.ts +30 -89
- package/lib/locales/index.js +111 -124
- package/lib/locales/type.d.ts +3 -3
- package/lib/logger/index.d.ts +1 -1
- package/lib/menuManager/hooks.d.ts +10 -1
- package/lib/menuManager/index.d.ts +1 -1
- package/lib/models/index.d.ts +6 -6
- package/lib/models/index.js +1 -2
- package/lib/pubsub/index.d.ts +1 -1
- package/lib/request/cache.d.ts +1 -1
- package/lib/request/config.js +2 -12
- package/lib/request/index.js +5 -1
- package/lib/request/pisell2Request.d.ts +1 -1
- package/lib/request/type.d.ts +1 -0
- package/lib/request/utils.js +2 -0
- package/lib/routes/index.d.ts +2 -2
- package/lib/socket/monitor.d.ts +1 -1
- package/lib/socket/types.d.ts +2 -1
- package/lib/storage/index.d.ts +17 -42
- package/lib/storage/index.js +35 -38
- package/lib/tasks/index.d.ts +1 -1
- package/lib/tasks/type.d.ts +4 -4
- package/lib/tasks/useTasks.d.ts +2 -1
- package/lib/variables/VariablesProvider.js +1 -1
- package/lib/variables/index.d.ts +3 -3
- package/package.json +11 -4
- package/es/locales/config.d.ts +0 -24
- package/es/locales/config.js +0 -59
- package/es/models/tasks.d.ts +0 -31
- package/es/models/tasks.js +0 -331
- package/es/models/tasksUtils.d.ts +0 -65
- package/es/models/tasksUtils.js +0 -179
- package/es/storage/config.d.ts +0 -3
- package/es/storage/config.js +0 -16
- package/es/storage/type.d.ts +0 -5
- package/es/storage/type.js +0 -1
- package/lib/locales/config.d.ts +0 -24
- package/lib/locales/config.js +0 -66
- package/lib/models/tasks.d.ts +0 -31
- package/lib/models/tasks.js +0 -199
- package/lib/models/tasksUtils.d.ts +0 -65
- package/lib/models/tasksUtils.js +0 -160
- package/lib/storage/config.d.ts +0 -3
- package/lib/storage/config.js +0 -38
- package/lib/storage/type.d.ts +0 -5
- package/lib/storage/type.js +0 -17
package/lib/locales/index.js
CHANGED
|
@@ -29,143 +29,130 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
29
29
|
// src/locales/index.ts
|
|
30
30
|
var locales_exports = {};
|
|
31
31
|
__export(locales_exports, {
|
|
32
|
-
|
|
33
|
-
default: () => locales_default,
|
|
34
|
-
getCurrentTexts: () => getCurrentTexts,
|
|
35
|
-
getLibraryByData: () => getLibraryByData,
|
|
36
|
-
getLocale: () => getLocale,
|
|
37
|
-
getText: () => getText,
|
|
38
|
-
isCN: () => isCN,
|
|
39
|
-
loadLibrary: () => loadLibrary,
|
|
40
|
-
loadLibraryByItems: () => loadLibraryByItems,
|
|
41
|
-
loadLibraryByUrl: () => loadLibraryByUrl,
|
|
42
|
-
setLocale: () => setLocale,
|
|
43
|
-
translation: () => translation
|
|
32
|
+
Locales: () => Locales
|
|
44
33
|
});
|
|
45
34
|
module.exports = __toCommonJS(locales_exports);
|
|
46
|
-
var import_config = require("./config");
|
|
47
35
|
var import_lodash = __toESM(require("lodash"));
|
|
48
36
|
var import_utils = require("@pisell/utils");
|
|
49
|
-
var
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
var
|
|
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
|
-
|
|
37
|
+
var import_en = __toESM(require("./en"));
|
|
38
|
+
var import_zh_CN = __toESM(require("./zh-CN"));
|
|
39
|
+
var import_zh_HK = __toESM(require("./zh-HK"));
|
|
40
|
+
var import_original = __toESM(require("./original"));
|
|
41
|
+
var Locales = class {
|
|
42
|
+
constructor(app, options) {
|
|
43
|
+
// 当前语言 本地语言 > 英文语言包
|
|
44
|
+
this.locale = import_en.default.locale;
|
|
45
|
+
// 语言包
|
|
46
|
+
this.library = [import_original.default, import_en.default, import_zh_CN.default, import_zh_HK.default].reduce((pre, cur) => {
|
|
47
|
+
pre[cur.locale] = cur;
|
|
48
|
+
return pre;
|
|
49
|
+
}, {});
|
|
50
|
+
this.loadLibraryByUrl = async (urls) => {
|
|
51
|
+
try {
|
|
52
|
+
let fetchList = urls.map((item) => {
|
|
53
|
+
if (typeof item === "string") {
|
|
54
|
+
return fetch(item);
|
|
55
|
+
}
|
|
56
|
+
if (typeof item === "function") {
|
|
57
|
+
return item();
|
|
58
|
+
}
|
|
59
|
+
if (typeof item === "object" && item !== null && "locale" in item) {
|
|
60
|
+
return Promise.resolve(item);
|
|
61
|
+
}
|
|
62
|
+
return item;
|
|
63
|
+
});
|
|
64
|
+
let res = await Promise.all(fetchList);
|
|
65
|
+
let library = { ...this.library };
|
|
66
|
+
for (const item of res) {
|
|
67
|
+
const _item = item instanceof Response ? await item.json() : item;
|
|
68
|
+
library = {
|
|
69
|
+
...library,
|
|
70
|
+
[_item.locale]: import_lodash.default.mergeWith(library[_item.locale] || {}, _item)
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
this.library = library;
|
|
74
|
+
return library;
|
|
75
|
+
} catch (err) {
|
|
76
|
+
console.log(err);
|
|
77
|
+
throw err;
|
|
79
78
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
79
|
+
};
|
|
80
|
+
this.app = app;
|
|
81
|
+
this.locale = (options == null ? void 0 : options.locale) || this.app.storage.getStorage("locale") || import_en.default.locale;
|
|
82
|
+
this.library = (options == null ? void 0 : options.library) || [import_original.default, import_en.default, import_zh_CN.default, import_zh_HK.default].reduce((pre, cur) => {
|
|
83
|
+
pre[cur.locale] = cur;
|
|
84
|
+
return pre;
|
|
85
|
+
}, {});
|
|
86
|
+
}
|
|
87
|
+
getLocale() {
|
|
88
|
+
return this.locale;
|
|
89
|
+
}
|
|
90
|
+
getCurrentTexts(locale) {
|
|
91
|
+
return this.library[locale || this.locale].translations;
|
|
92
|
+
}
|
|
93
|
+
setLocale(locale, reload = false) {
|
|
94
|
+
this.locale = locale;
|
|
95
|
+
if (reload) {
|
|
96
|
+
window.location.reload();
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
getText(id, locale) {
|
|
101
|
+
var _a;
|
|
102
|
+
return ((_a = this.getCurrentTexts(locale)) == null ? void 0 : _a[id]) || id;
|
|
103
|
+
}
|
|
104
|
+
isCN() {
|
|
105
|
+
let locale = this.getLocale();
|
|
106
|
+
return locale === "zh-CN" || locale === "zh-HK";
|
|
107
|
+
}
|
|
108
|
+
loadLibraryByItems(libraryList) {
|
|
109
|
+
let library = { ...this.library };
|
|
110
|
+
libraryList.forEach((item) => {
|
|
89
111
|
library = {
|
|
90
112
|
...library,
|
|
91
|
-
[
|
|
113
|
+
[item.locale]: import_lodash.default.mergeWith(library[item.locale] || {}, item)
|
|
92
114
|
};
|
|
115
|
+
});
|
|
116
|
+
this.library = library;
|
|
117
|
+
}
|
|
118
|
+
loadLibrary(urls) {
|
|
119
|
+
return this.loadLibraryByUrl(urls);
|
|
120
|
+
}
|
|
121
|
+
translation(text, locale) {
|
|
122
|
+
if (!text) {
|
|
123
|
+
return "";
|
|
124
|
+
}
|
|
125
|
+
if ((0, import_utils.isString)(text) || (0, import_utils.isNumber)(text)) {
|
|
126
|
+
return text;
|
|
127
|
+
}
|
|
128
|
+
let primary = locale || this.getLocale();
|
|
129
|
+
if (typeof text === "string") {
|
|
130
|
+
return text;
|
|
93
131
|
}
|
|
94
|
-
|
|
95
|
-
return library;
|
|
96
|
-
} catch (err) {
|
|
97
|
-
console.log(err);
|
|
98
|
-
throw err;
|
|
132
|
+
return text[primary] || text["original"] || text["en"] || text["zh-CN"] || text["zh-HK"];
|
|
99
133
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
};
|
|
108
|
-
});
|
|
109
|
-
(0, import_config.setConfig)({ library });
|
|
110
|
-
};
|
|
111
|
-
var loadLibrary = async (urls) => {
|
|
112
|
-
return loadLibraryByUrl(urls);
|
|
113
|
-
};
|
|
114
|
-
var translation = (text, locale) => {
|
|
115
|
-
if (!text) {
|
|
116
|
-
return "";
|
|
134
|
+
getLibraryByData(data) {
|
|
135
|
+
return data.reduce((pre, next) => {
|
|
136
|
+
return {
|
|
137
|
+
...pre,
|
|
138
|
+
[next.locale]: next
|
|
139
|
+
};
|
|
140
|
+
}, {});
|
|
117
141
|
}
|
|
118
|
-
|
|
119
|
-
|
|
142
|
+
createTextsByLibrary(id, library) {
|
|
143
|
+
const _library = library || this.library;
|
|
144
|
+
return Object.keys(_library).reduce((pre, next) => {
|
|
145
|
+
var _a;
|
|
146
|
+
let _pre = { ...pre };
|
|
147
|
+
let cur = (_a = _library[next].translations) == null ? void 0 : _a[id];
|
|
148
|
+
if (cur) {
|
|
149
|
+
_pre[_library[next].locale] = cur;
|
|
150
|
+
}
|
|
151
|
+
return _pre;
|
|
152
|
+
}, {});
|
|
120
153
|
}
|
|
121
|
-
let primary = locale || getLocale();
|
|
122
|
-
return text[primary] || text["original"] || text["en"] || text["zh-CN"] || text["zh-HK"];
|
|
123
|
-
};
|
|
124
|
-
var getLibraryByData = (data) => {
|
|
125
|
-
return data.reduce((pre, next) => {
|
|
126
|
-
return {
|
|
127
|
-
...pre,
|
|
128
|
-
[next.locale]: next
|
|
129
|
-
};
|
|
130
|
-
}, {});
|
|
131
|
-
};
|
|
132
|
-
var createTextsByLibrary = (id, library) => {
|
|
133
|
-
const _library = library || (0, import_config.getConfig)().library;
|
|
134
|
-
return Object.keys(_library).reduce((pre, next) => {
|
|
135
|
-
var _a;
|
|
136
|
-
let _pre = { ...pre };
|
|
137
|
-
let cur = (_a = _library[next].translations) == null ? void 0 : _a[id];
|
|
138
|
-
if (cur) {
|
|
139
|
-
_pre[_library[next].locale] = cur;
|
|
140
|
-
}
|
|
141
|
-
return _pre;
|
|
142
|
-
}, {});
|
|
143
|
-
};
|
|
144
|
-
var locales_default = {
|
|
145
|
-
getLocale,
|
|
146
|
-
getCurrentTexts,
|
|
147
|
-
setLocale,
|
|
148
|
-
getText,
|
|
149
|
-
isCN,
|
|
150
|
-
getConfig: import_config.getConfig,
|
|
151
|
-
setConfig: import_config.setConfig,
|
|
152
|
-
loadLibraryByUrl,
|
|
153
|
-
translation,
|
|
154
|
-
loadLibraryByItems,
|
|
155
|
-
getLibraryByData,
|
|
156
|
-
createTextsByLibrary
|
|
157
154
|
};
|
|
158
155
|
// Annotate the CommonJS export names for ESM import in node:
|
|
159
156
|
0 && (module.exports = {
|
|
160
|
-
|
|
161
|
-
getCurrentTexts,
|
|
162
|
-
getLibraryByData,
|
|
163
|
-
getLocale,
|
|
164
|
-
getText,
|
|
165
|
-
isCN,
|
|
166
|
-
loadLibrary,
|
|
167
|
-
loadLibraryByItems,
|
|
168
|
-
loadLibraryByUrl,
|
|
169
|
-
setLocale,
|
|
170
|
-
translation
|
|
157
|
+
Locales
|
|
171
158
|
});
|
package/lib/locales/type.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
1
|
+
export type Locale = 'original' | 'en' | 'zh-CN' | 'zh-HK' | string;
|
|
2
|
+
export type MultiLanguage = {
|
|
3
3
|
[key in Locale]: string;
|
|
4
4
|
};
|
|
5
5
|
export interface LibraryItem {
|
|
@@ -16,4 +16,4 @@ export interface LocaleConfig {
|
|
|
16
16
|
[key in Locale]: LibraryItem;
|
|
17
17
|
};
|
|
18
18
|
}
|
|
19
|
-
export
|
|
19
|
+
export type LoadLibraryByUrlParams = (string | Promise<LibraryItem> | (() => Promise<LibraryItem>) | LibraryItem)[];
|
package/lib/logger/index.d.ts
CHANGED
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { MenuItem } from "./index";
|
|
3
3
|
export declare const isHttp: (url: string) => boolean;
|
|
4
|
+
export interface MenuContextType {
|
|
5
|
+
selectedKeys: string[];
|
|
6
|
+
openKeys: string[];
|
|
7
|
+
setOpenKeys: (keys: string[]) => void;
|
|
8
|
+
handleClick: (key: string) => void;
|
|
9
|
+
menuItems: MenuItem[];
|
|
10
|
+
getShowChildren: (children: MenuItem[]) => MenuItem[];
|
|
11
|
+
setMenuItems: (items: MenuItem[]) => void;
|
|
12
|
+
}
|
|
4
13
|
export declare const MenuProvider: React.FC<{
|
|
5
14
|
children: React.ReactNode;
|
|
6
15
|
menus: MenuItem[];
|
|
7
16
|
}>;
|
|
8
|
-
export declare const useMenu: () =>
|
|
17
|
+
export declare const useMenu: () => MenuContextType;
|
package/lib/models/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import hooks from '../hooks';
|
|
2
2
|
import { Provider as StoreProvider } from "react-redux";
|
|
3
|
-
declare const models:
|
|
4
|
-
|
|
3
|
+
declare const models: import("./global").GlobalModal[];
|
|
4
|
+
type ModalsType = (typeof models[number]);
|
|
5
5
|
export interface Store {
|
|
6
6
|
getDataByModel: typeof getDataByModel;
|
|
7
7
|
useStore: typeof hooks.useStore;
|
|
@@ -10,8 +10,8 @@ export interface Store {
|
|
|
10
10
|
dispatch: any;
|
|
11
11
|
getState: any;
|
|
12
12
|
}
|
|
13
|
-
export
|
|
14
|
-
export
|
|
13
|
+
export type ModelsNames = ModalsType['namespace'];
|
|
14
|
+
export type ModelsState = {
|
|
15
15
|
[K in (ModalsType['namespace'])]: Extract<ModalsType, {
|
|
16
16
|
namespace: K;
|
|
17
17
|
}>['state'];
|
|
@@ -25,7 +25,7 @@ export declare type ModelsState = {
|
|
|
25
25
|
* @Author: zhiwei.Wang
|
|
26
26
|
* @Date: 2024-09-03 11:07
|
|
27
27
|
*/
|
|
28
|
-
declare const getDataByModel: <T extends "
|
|
28
|
+
declare const getDataByModel: <T extends "global", D extends keyof ModelsState[T]>(model: string, key?: D) => D extends undefined ? ModelsState[T] : ModelsState[T][D];
|
|
29
29
|
/**
|
|
30
30
|
* @title: 设置数据到store
|
|
31
31
|
* @description:
|
|
@@ -36,7 +36,7 @@ declare const getDataByModel: <T extends "tasks" | "global", D extends keyof Mod
|
|
|
36
36
|
* @Author: zhiwei.Wang
|
|
37
37
|
* @Date: 2024-09-08 15:17
|
|
38
38
|
*/
|
|
39
|
-
declare const setDataByModel: <T extends "
|
|
39
|
+
declare const setDataByModel: <T extends "global", D extends keyof ModelsState[T]>(model: string, key: any, value: any) => void;
|
|
40
40
|
declare const _default: {
|
|
41
41
|
getStore: () => Store;
|
|
42
42
|
StoreProvider: typeof StoreProvider;
|
package/lib/models/index.js
CHANGED
|
@@ -35,9 +35,8 @@ module.exports = __toCommonJS(models_exports);
|
|
|
35
35
|
var import_dva_core = require("dva-core");
|
|
36
36
|
var import_hooks = __toESM(require("../hooks"));
|
|
37
37
|
var import_global = __toESM(require("./global"));
|
|
38
|
-
var import_tasks = __toESM(require("./tasks"));
|
|
39
38
|
var import_react_redux = require("react-redux");
|
|
40
|
-
var models = [import_global.default
|
|
39
|
+
var models = [import_global.default];
|
|
41
40
|
var app = (0, import_dva_core.create)();
|
|
42
41
|
models.forEach((item) => app.model(item));
|
|
43
42
|
var getStore = () => app._store;
|
package/lib/pubsub/index.d.ts
CHANGED
package/lib/request/cache.d.ts
CHANGED
package/lib/request/config.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
1
|
var __defProp = Object.defineProperty;
|
|
3
2
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
5
|
var __export = (target, all) => {
|
|
8
6
|
for (var name in all)
|
|
@@ -16,14 +14,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
14
|
}
|
|
17
15
|
return to;
|
|
18
16
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
-
mod
|
|
26
|
-
));
|
|
27
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
18
|
|
|
29
19
|
// src/request/config.ts
|
|
@@ -34,11 +24,11 @@ __export(config_exports, {
|
|
|
34
24
|
});
|
|
35
25
|
module.exports = __toCommonJS(config_exports);
|
|
36
26
|
var import_constants = require("./constants");
|
|
37
|
-
var import_storage =
|
|
27
|
+
var import_storage = require("../storage");
|
|
38
28
|
var import_lodash = require("lodash");
|
|
39
29
|
var defaultConfig = {
|
|
40
30
|
axiosConfig: import_constants.axiosConfig,
|
|
41
|
-
storage: import_storage.
|
|
31
|
+
storage: new import_storage.Storage(),
|
|
42
32
|
requestCallbacks: {
|
|
43
33
|
200: (resData) => {
|
|
44
34
|
const { res, props, resolve, reject, err } = resData;
|
package/lib/request/index.js
CHANGED
|
@@ -48,7 +48,11 @@ var import_axios = __toESM(require("axios"));
|
|
|
48
48
|
var import_config = require("./config");
|
|
49
49
|
__reExport(request_exports, require("./type"), module.exports);
|
|
50
50
|
var axiosInstance = import_axios.default.create(import_constants.axiosConfig);
|
|
51
|
-
|
|
51
|
+
console.log("config1111");
|
|
52
|
+
axiosInstance.interceptors.request.use((config) => {
|
|
53
|
+
console.log("config11", config);
|
|
54
|
+
return config;
|
|
55
|
+
}, import_utils.interceptorsRequestError);
|
|
52
56
|
axiosInstance.interceptors.response.use(import_utils.interceptorsResponse, import_utils.interceptorsResponseError);
|
|
53
57
|
var createRequest = (props) => {
|
|
54
58
|
const { data, config, method } = props;
|
package/lib/request/type.d.ts
CHANGED
package/lib/request/utils.js
CHANGED
|
@@ -78,6 +78,7 @@ var interceptorsResponseError = (response) => {
|
|
|
78
78
|
return (_b = (_a = (0, import_config.getConfig)()).interceptorsResponseError) == null ? void 0 : _b.call(_a, response);
|
|
79
79
|
};
|
|
80
80
|
var requestCallback = (resData) => {
|
|
81
|
+
var _a;
|
|
81
82
|
const { res, props, resolve, reject, err } = resData;
|
|
82
83
|
try {
|
|
83
84
|
const { config } = props;
|
|
@@ -87,6 +88,7 @@ var requestCallback = (resData) => {
|
|
|
87
88
|
if ((res == null ? void 0 : res.code) === 200) {
|
|
88
89
|
if (config == null ? void 0 : config.cache) {
|
|
89
90
|
(0, import_cache.setCacheData)(props.url, props.data, res, config == null ? void 0 : config.cache);
|
|
91
|
+
(_a = config == null ? void 0 : config.cacheUpdateChange) == null ? void 0 : _a.call(config, res);
|
|
90
92
|
}
|
|
91
93
|
}
|
|
92
94
|
return codeFn(resData);
|
package/lib/routes/index.d.ts
CHANGED
|
@@ -20,9 +20,9 @@ export declare class RouterManager {
|
|
|
20
20
|
get(name: string): RouteType;
|
|
21
21
|
has(name: string): boolean;
|
|
22
22
|
remove(name: string): void;
|
|
23
|
-
renderComponent(item: RouteType, children?: React.ReactNode):
|
|
23
|
+
renderComponent(item: RouteType, children?: React.ReactNode): string | number | boolean | Iterable<React.ReactNode> | React.JSX.Element | null | undefined;
|
|
24
24
|
getPageByRoute(route: string): ApplicationInterface | undefined;
|
|
25
25
|
getRouterComponent({ fallback }: {
|
|
26
26
|
fallback?: React.ReactNode;
|
|
27
|
-
}): JSX.Element[];
|
|
27
|
+
}): React.JSX.Element[];
|
|
28
28
|
}
|
package/lib/socket/monitor.d.ts
CHANGED
package/lib/socket/types.d.ts
CHANGED
|
@@ -45,6 +45,7 @@ export interface SocketMessage<T = any> {
|
|
|
45
45
|
data?: T;
|
|
46
46
|
/** 消息ID */
|
|
47
47
|
id?: string;
|
|
48
|
+
event?: any;
|
|
48
49
|
}
|
|
49
50
|
/**
|
|
50
51
|
* 心跳配置选项
|
|
@@ -75,7 +76,7 @@ export interface ReconnectOptions {
|
|
|
75
76
|
/**
|
|
76
77
|
* 事件处理函数类型
|
|
77
78
|
*/
|
|
78
|
-
export
|
|
79
|
+
export type EventHandler = (...args: any[]) => void;
|
|
79
80
|
/**
|
|
80
81
|
* 事件处理函数映射
|
|
81
82
|
*/
|
package/lib/storage/index.d.ts
CHANGED
|
@@ -1,42 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
* @description:
|
|
19
|
-
* @param {string} key
|
|
20
|
-
* @return {*}
|
|
21
|
-
* @Author: zhiwei.Wang
|
|
22
|
-
* @Date: 2024-09-08 14:53
|
|
23
|
-
*/
|
|
24
|
-
export declare const getStorage: (key: string) => string | null;
|
|
25
|
-
/**
|
|
26
|
-
* @title: 删除数据 --storage
|
|
27
|
-
* @description:
|
|
28
|
-
* @param {string} key
|
|
29
|
-
* @return {*}
|
|
30
|
-
* @Author: zhiwei.Wang
|
|
31
|
-
* @Date: 2024-09-08 14:53
|
|
32
|
-
*/
|
|
33
|
-
export declare const removeStorage: (key: string) => void;
|
|
34
|
-
declare const _default: {
|
|
35
|
-
setStorage: (key: string, value: string) => void;
|
|
36
|
-
getStorage: (key: string) => string | null;
|
|
37
|
-
removeStorage: (key: string) => void;
|
|
38
|
-
createKey: (key: string) => string;
|
|
39
|
-
setConfig: (newConfig: Partial<import("./type").StorageConfig>) => void;
|
|
40
|
-
getConfig: () => import("./type").StorageConfig;
|
|
41
|
-
};
|
|
42
|
-
export default _default;
|
|
1
|
+
import App from '../app';
|
|
2
|
+
export interface StorageOptions {
|
|
3
|
+
storageKey?: string;
|
|
4
|
+
removeStorageAfter?: (key: string) => void;
|
|
5
|
+
setStorageAfter?: (key: string, value: string) => void;
|
|
6
|
+
}
|
|
7
|
+
export declare class Storage {
|
|
8
|
+
private storageKey;
|
|
9
|
+
private app?;
|
|
10
|
+
private options;
|
|
11
|
+
constructor(app?: App, options?: StorageOptions);
|
|
12
|
+
createKey(key: string): string;
|
|
13
|
+
setStorage(key: string, value: string): void;
|
|
14
|
+
getStorage(key: string): string | null;
|
|
15
|
+
removeStorage(key: string): void;
|
|
16
|
+
clear(): void;
|
|
17
|
+
}
|
package/lib/storage/index.js
CHANGED
|
@@ -19,48 +19,45 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
19
19
|
// src/storage/index.ts
|
|
20
20
|
var storage_exports = {};
|
|
21
21
|
__export(storage_exports, {
|
|
22
|
-
|
|
23
|
-
default: () => storage_default,
|
|
24
|
-
getStorage: () => getStorage,
|
|
25
|
-
removeStorage: () => removeStorage,
|
|
26
|
-
setStorage: () => setStorage
|
|
22
|
+
Storage: () => Storage
|
|
27
23
|
});
|
|
28
24
|
module.exports = __toCommonJS(storage_exports);
|
|
29
|
-
var
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
25
|
+
var Storage = class {
|
|
26
|
+
constructor(app, options) {
|
|
27
|
+
this.storageKey = "CapacitorStorage.native_";
|
|
28
|
+
this.options = {};
|
|
29
|
+
this.app = app;
|
|
30
|
+
if (options) {
|
|
31
|
+
this.options = options;
|
|
32
|
+
}
|
|
33
|
+
if (options == null ? void 0 : options.storageKey) {
|
|
34
|
+
this.storageKey = options.storageKey;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
createKey(key) {
|
|
38
|
+
if (key.indexOf(this.storageKey) !== -1) {
|
|
39
|
+
return key;
|
|
40
|
+
}
|
|
41
|
+
return this.storageKey + key;
|
|
42
|
+
}
|
|
43
|
+
setStorage(key, value) {
|
|
44
|
+
var _a, _b;
|
|
45
|
+
localStorage.setItem(this.createKey(key), value);
|
|
46
|
+
(_b = (_a = this.options) == null ? void 0 : _a.setStorageAfter) == null ? void 0 : _b.call(_a, key, value);
|
|
47
|
+
}
|
|
48
|
+
getStorage(key) {
|
|
49
|
+
return localStorage.getItem(this.createKey(key));
|
|
50
|
+
}
|
|
51
|
+
removeStorage(key) {
|
|
52
|
+
var _a, _b;
|
|
53
|
+
localStorage.removeItem(this.createKey(key));
|
|
54
|
+
(_b = (_a = this.options) == null ? void 0 : _a.removeStorageAfter) == null ? void 0 : _b.call(_a, key);
|
|
55
|
+
}
|
|
56
|
+
clear() {
|
|
57
|
+
localStorage.clear();
|
|
36
58
|
}
|
|
37
|
-
return getStorageKey() + key;
|
|
38
|
-
};
|
|
39
|
-
var setStorage = (key, value) => {
|
|
40
|
-
var _a, _b;
|
|
41
|
-
localStorage.setItem(createKey(key), value);
|
|
42
|
-
(_b = (_a = (0, import_config.getConfig)()).setStorageAfter) == null ? void 0 : _b.call(_a, key, value);
|
|
43
|
-
};
|
|
44
|
-
var getStorage = (key) => {
|
|
45
|
-
return localStorage.getItem(createKey(key));
|
|
46
|
-
};
|
|
47
|
-
var removeStorage = (key) => {
|
|
48
|
-
var _a, _b;
|
|
49
|
-
localStorage.removeItem(createKey(key));
|
|
50
|
-
(_b = (_a = (0, import_config.getConfig)()).removeStorageAfter) == null ? void 0 : _b.call(_a, key);
|
|
51
|
-
};
|
|
52
|
-
var storage_default = {
|
|
53
|
-
setStorage,
|
|
54
|
-
getStorage,
|
|
55
|
-
removeStorage,
|
|
56
|
-
createKey,
|
|
57
|
-
setConfig: import_config.setConfig,
|
|
58
|
-
getConfig: import_config.getConfig
|
|
59
59
|
};
|
|
60
60
|
// Annotate the CommonJS export names for ESM import in node:
|
|
61
61
|
0 && (module.exports = {
|
|
62
|
-
|
|
63
|
-
getStorage,
|
|
64
|
-
removeStorage,
|
|
65
|
-
setStorage
|
|
62
|
+
Storage
|
|
66
63
|
});
|