@pisell/core 1.0.22 → 1.0.24
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 +4 -2
- package/es/app/app.js +3 -0
- package/es/aws/index.d.ts +1 -1
- package/es/history/index.d.ts +5 -4
- package/es/menuManager/hooks.d.ts +1 -1
- package/es/menuManager/index.d.ts +1 -1
- package/es/models/index.d.ts +2 -1
- package/es/request/cache.d.ts +1 -1
- package/es/request/cache.js +11 -21
- package/es/request/index.d.ts +3 -3
- package/es/request/index.js +13 -1
- package/es/request/type.d.ts +1 -0
- package/es/request/utils.js +1 -1
- package/es/routes/index.d.ts +2 -2
- package/es/tasks/index.d.ts +1 -1
- package/es/tasks/useTasks.d.ts +2 -1
- package/lib/app/app.d.ts +4 -2
- package/lib/app/app.js +3 -0
- package/lib/aws/index.d.ts +1 -1
- package/lib/history/index.d.ts +5 -4
- package/lib/menuManager/hooks.d.ts +1 -1
- package/lib/menuManager/index.d.ts +1 -1
- package/lib/models/index.d.ts +2 -1
- package/lib/request/cache.d.ts +1 -1
- package/lib/request/cache.js +4 -12
- package/lib/request/index.d.ts +3 -3
- package/lib/request/index.js +9 -1
- package/lib/request/type.d.ts +1 -0
- package/lib/request/utils.js +1 -1
- package/lib/routes/index.d.ts +2 -2
- package/lib/tasks/index.d.ts +1 -1
- package/lib/tasks/useTasks.d.ts +2 -1
- package/package.json +7 -7
package/es/app/app.d.ts
CHANGED
|
@@ -22,6 +22,7 @@ export interface AppOptions {
|
|
|
22
22
|
history?: HistoryOptions;
|
|
23
23
|
storage?: StorageOptions;
|
|
24
24
|
locales?: LocalesOptions;
|
|
25
|
+
pisellos?: any;
|
|
25
26
|
}
|
|
26
27
|
declare class App {
|
|
27
28
|
private static instance;
|
|
@@ -35,7 +36,7 @@ declare class App {
|
|
|
35
36
|
locales: Locales;
|
|
36
37
|
models: {
|
|
37
38
|
getStore: () => import("../models").Store;
|
|
38
|
-
StoreProvider:
|
|
39
|
+
StoreProvider: typeof import("react-redux").Provider;
|
|
39
40
|
setConfig: (models: any[]) => void;
|
|
40
41
|
};
|
|
41
42
|
request: {
|
|
@@ -43,7 +44,7 @@ declare class App {
|
|
|
43
44
|
post: (url: string, data: any, config: import("../request").RequestSetting | undefined) => Promise<any>;
|
|
44
45
|
put: (url: string, data: any, config: import("../request").RequestSetting | undefined) => Promise<any>;
|
|
45
46
|
remove: (url: string, data: any, config: import("../request").RequestSetting | undefined) => Promise<any>;
|
|
46
|
-
custom: (url: string, config: import("../request").RequestSetting | undefined) =>
|
|
47
|
+
custom: (url: string, config: import("../request").RequestSetting | undefined) => any;
|
|
47
48
|
setConfig: (newConfig: Partial<import("../request").RequestConfig>) => void;
|
|
48
49
|
getConfig: () => import("../request").RequestConfig;
|
|
49
50
|
};
|
|
@@ -66,6 +67,7 @@ declare class App {
|
|
|
66
67
|
cmd: CMD;
|
|
67
68
|
aws: AWS;
|
|
68
69
|
tasksManager: TasksManager;
|
|
70
|
+
pisellos: any;
|
|
69
71
|
dbManager: IndexDBManager | null;
|
|
70
72
|
constants: {
|
|
71
73
|
channel: string;
|
package/es/app/app.js
CHANGED
|
@@ -67,6 +67,8 @@ var App = /*#__PURE__*/function () {
|
|
|
67
67
|
_defineProperty(this, "aws", void 0);
|
|
68
68
|
// 任务管理
|
|
69
69
|
_defineProperty(this, "tasksManager", void 0);
|
|
70
|
+
// pisellos
|
|
71
|
+
_defineProperty(this, "pisellos", void 0);
|
|
70
72
|
_defineProperty(this, "dbManager", null);
|
|
71
73
|
_defineProperty(this, "constants", {
|
|
72
74
|
channel: ""
|
|
@@ -87,6 +89,7 @@ var App = /*#__PURE__*/function () {
|
|
|
87
89
|
this.tasksManager = new TasksManager(this);
|
|
88
90
|
this.cmd = new CMD(this, options === null || options === void 0 ? void 0 : options.cmd);
|
|
89
91
|
this.aws = new AWS(this, options === null || options === void 0 ? void 0 : options.aws);
|
|
92
|
+
this.pisellos = options === null || options === void 0 ? void 0 : options.pisellos;
|
|
90
93
|
if (options !== null && options !== void 0 && options.constants) {
|
|
91
94
|
this.constants = options.constants || {};
|
|
92
95
|
}
|
package/es/aws/index.d.ts
CHANGED
|
@@ -11,6 +11,6 @@ declare class AWS {
|
|
|
11
11
|
private app;
|
|
12
12
|
private config?;
|
|
13
13
|
constructor(app: App, options?: AWSOptions);
|
|
14
|
-
upload(params: UploadParams): Promise<
|
|
14
|
+
upload(params: UploadParams): Promise<import("@aws-sdk/client-s3").PutObjectCommandOutput | undefined>;
|
|
15
15
|
}
|
|
16
16
|
export default AWS;
|
package/es/history/index.d.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import type { History as HistoryType } from "history";
|
|
2
|
+
import { useHistory, useLocation, useParams } from "react-router-dom";
|
|
2
3
|
import App from "../app";
|
|
3
4
|
export interface HistoryOptions {
|
|
4
5
|
basename?: string;
|
|
5
6
|
}
|
|
6
7
|
export declare class History {
|
|
7
|
-
instance:
|
|
8
|
-
useHistory:
|
|
9
|
-
useLocation:
|
|
10
|
-
useParams:
|
|
8
|
+
instance: HistoryType<unknown>;
|
|
9
|
+
useHistory: typeof useHistory;
|
|
10
|
+
useLocation: typeof useLocation;
|
|
11
|
+
useParams: typeof useParams;
|
|
11
12
|
app: App;
|
|
12
13
|
constructor(app: App, options?: HistoryOptions);
|
|
13
14
|
push: HistoryType["push"];
|
package/es/models/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import hooks from '../hooks';
|
|
2
|
+
import { Provider as StoreProvider } from "react-redux";
|
|
2
3
|
declare const models: import("./global").GlobalModal[];
|
|
3
4
|
declare type ModalsType = (typeof models[number]);
|
|
4
5
|
export interface Store {
|
|
@@ -38,7 +39,7 @@ declare const getDataByModel: <T extends "global", D extends keyof ModelsState[T
|
|
|
38
39
|
declare const setDataByModel: <T extends "global", D extends keyof ModelsState[T]>(model: string, key: any, value: any) => void;
|
|
39
40
|
declare const _default: {
|
|
40
41
|
getStore: () => Store;
|
|
41
|
-
StoreProvider:
|
|
42
|
+
StoreProvider: typeof StoreProvider;
|
|
42
43
|
setConfig: (models: any[]) => void;
|
|
43
44
|
};
|
|
44
45
|
export default _default;
|
package/es/request/cache.d.ts
CHANGED
|
@@ -32,7 +32,7 @@ export declare const getCacheData: (url: string, data: any, cache: CacheProps) =
|
|
|
32
32
|
* @return {*}
|
|
33
33
|
* @Author: zhiwei.Wang
|
|
34
34
|
*/
|
|
35
|
-
export declare const setCacheData: (url: string, data: any, res: any, cache
|
|
35
|
+
export declare const setCacheData: (url: string, data: any, res: any, cache: CacheProps) => any | null;
|
|
36
36
|
/**
|
|
37
37
|
* @title: 缓存函数包装器
|
|
38
38
|
* @description:
|
package/es/request/cache.js
CHANGED
|
@@ -251,10 +251,7 @@ export var getCacheData = /*#__PURE__*/function () {
|
|
|
251
251
|
* @return {*}
|
|
252
252
|
* @Author: zhiwei.Wang
|
|
253
253
|
*/
|
|
254
|
-
export var setCacheData = function setCacheData(url, data, res) {
|
|
255
|
-
var cache = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {
|
|
256
|
-
type: 'memory'
|
|
257
|
-
};
|
|
254
|
+
export var setCacheData = function setCacheData(url, data, res, cache) {
|
|
258
255
|
// 创建缓存key
|
|
259
256
|
var _key = createCacheKey(url, data, cache);
|
|
260
257
|
setCache(_key, res, cache);
|
|
@@ -272,44 +269,37 @@ export var setCacheData = function setCacheData(url, data, res) {
|
|
|
272
269
|
*/
|
|
273
270
|
export var cacheFn = /*#__PURE__*/function () {
|
|
274
271
|
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(props, fn) {
|
|
275
|
-
var url, data, config,
|
|
272
|
+
var url, data, config, _data, _config$cache;
|
|
276
273
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
277
274
|
while (1) switch (_context4.prev = _context4.next) {
|
|
278
275
|
case 0:
|
|
279
276
|
url = props.url, data = props.data, config = props.config;
|
|
280
|
-
if (!(config !== null && config !== void 0 && config.cache
|
|
281
|
-
_context4.next =
|
|
277
|
+
if (!(config !== null && config !== void 0 && config.cache)) {
|
|
278
|
+
_context4.next = 8;
|
|
282
279
|
break;
|
|
283
280
|
}
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
type: 'memory'
|
|
288
|
-
};
|
|
289
|
-
}
|
|
290
|
-
// 获取缓存数据
|
|
291
|
-
_context4.next = 6;
|
|
292
|
-
return getCacheData(url, data, cache);
|
|
293
|
-
case 6:
|
|
281
|
+
_context4.next = 4;
|
|
282
|
+
return getCacheData(url, data, config.cache);
|
|
283
|
+
case 4:
|
|
294
284
|
_data = _context4.sent;
|
|
295
285
|
if (!_data) {
|
|
296
|
-
_context4.next =
|
|
286
|
+
_context4.next = 8;
|
|
297
287
|
break;
|
|
298
288
|
}
|
|
299
289
|
// 如果开启更新缓存执行函数
|
|
300
290
|
if ((_config$cache = config.cache) !== null && _config$cache !== void 0 && _config$cache.updateCache) {
|
|
301
291
|
fn(_objectSpread(_objectSpread({}, props), {}, {
|
|
302
292
|
config: _objectSpread(_objectSpread({}, props.config), {}, {
|
|
303
|
-
cache: _objectSpread(_objectSpread({}, cache), {}, {
|
|
293
|
+
cache: _objectSpread(_objectSpread({}, props.config.cache), {}, {
|
|
304
294
|
updateCache: false
|
|
305
295
|
})
|
|
306
296
|
})
|
|
307
297
|
}));
|
|
308
298
|
}
|
|
309
299
|
return _context4.abrupt("return", _data);
|
|
310
|
-
case
|
|
300
|
+
case 8:
|
|
311
301
|
return _context4.abrupt("return", fn(props));
|
|
312
|
-
case
|
|
302
|
+
case 9:
|
|
313
303
|
case "end":
|
|
314
304
|
return _context4.stop();
|
|
315
305
|
}
|
package/es/request/index.d.ts
CHANGED
|
@@ -5,19 +5,19 @@ export declare const createRequest: (props: RequestWrapperProps) => Promise<unkn
|
|
|
5
5
|
* @param props
|
|
6
6
|
* @returns
|
|
7
7
|
*/
|
|
8
|
-
export declare const request: (props: RequestWrapperProps) =>
|
|
8
|
+
export declare const request: (props: RequestWrapperProps) => any;
|
|
9
9
|
export declare const get: (url: RequestWrapperProps["url"], data: RequestWrapperProps["data"], config: RequestWrapperProps["config"]) => Promise<any>;
|
|
10
10
|
export declare const post: (url: RequestWrapperProps["url"], data: RequestWrapperProps["data"], config: RequestWrapperProps["config"]) => Promise<any>;
|
|
11
11
|
export declare const put: (url: RequestWrapperProps["url"], data: RequestWrapperProps["data"], config: RequestWrapperProps["config"]) => Promise<any>;
|
|
12
12
|
export declare const remove: (url: RequestWrapperProps["url"], data: RequestWrapperProps["data"], config: RequestWrapperProps["config"]) => Promise<any>;
|
|
13
|
-
export declare const custom: (url: RequestWrapperProps["url"], config: RequestWrapperProps["config"]) =>
|
|
13
|
+
export declare const custom: (url: RequestWrapperProps["url"], config: RequestWrapperProps["config"]) => any;
|
|
14
14
|
export * from "./type";
|
|
15
15
|
declare const _default: {
|
|
16
16
|
get: (url: string, data: any, config: import("./type").RequestSetting | undefined) => Promise<any>;
|
|
17
17
|
post: (url: string, data: any, config: import("./type").RequestSetting | undefined) => Promise<any>;
|
|
18
18
|
put: (url: string, data: any, config: import("./type").RequestSetting | undefined) => Promise<any>;
|
|
19
19
|
remove: (url: string, data: any, config: import("./type").RequestSetting | undefined) => Promise<any>;
|
|
20
|
-
custom: (url: string, config: import("./type").RequestSetting | undefined) =>
|
|
20
|
+
custom: (url: string, config: import("./type").RequestSetting | undefined) => any;
|
|
21
21
|
setConfig: (newConfig: Partial<RequestConfig>) => void;
|
|
22
22
|
getConfig: () => RequestConfig;
|
|
23
23
|
};
|
package/es/request/index.js
CHANGED
|
@@ -13,6 +13,7 @@ import { cacheFn } from "./cache";
|
|
|
13
13
|
import { interceptorsRequest, interceptorsResponse, interceptorsRequestError, interceptorsResponseError, requestCallback } from "./utils";
|
|
14
14
|
import axios from "axios";
|
|
15
15
|
import { getConfig, setConfig } from "./config";
|
|
16
|
+
import { getApp } from "../app";
|
|
16
17
|
// 实例
|
|
17
18
|
var axiosInstance = axios.create(axiosConfig);
|
|
18
19
|
|
|
@@ -59,13 +60,24 @@ export var createRequest = function createRequest(props) {
|
|
|
59
60
|
*/
|
|
60
61
|
export var request = function request(props) {
|
|
61
62
|
var config = props.config,
|
|
62
|
-
url = props.url
|
|
63
|
+
url = props.url,
|
|
64
|
+
method = props.method;
|
|
63
65
|
// 请求防抖
|
|
64
66
|
if (config !== null && config !== void 0 && config.abort) {
|
|
65
67
|
var signal = createSignal(config.abort, url);
|
|
66
68
|
config.signal = signal;
|
|
67
69
|
}
|
|
68
70
|
|
|
71
|
+
// 使用os服务层
|
|
72
|
+
if (config !== null && config !== void 0 && config.osServer) {
|
|
73
|
+
var _app$pisellos, _app$pisellos2, _app$pisellos2$hasRou;
|
|
74
|
+
var app = getApp();
|
|
75
|
+
if (app !== null && app !== void 0 && (_app$pisellos = app.pisellos) !== null && _app$pisellos !== void 0 && _app$pisellos.server && (_app$pisellos2 = app.pisellos) !== null && _app$pisellos2 !== void 0 && (_app$pisellos2 = _app$pisellos2.server) !== null && _app$pisellos2 !== void 0 && (_app$pisellos2$hasRou = _app$pisellos2.hasRoute) !== null && _app$pisellos2$hasRou !== void 0 && _app$pisellos2$hasRou.call(_app$pisellos2, method, url)) {
|
|
76
|
+
var _app$pisellos3, _app$pisellos3$handle;
|
|
77
|
+
return (_app$pisellos3 = app.pisellos) === null || _app$pisellos3 === void 0 || (_app$pisellos3 = _app$pisellos3.server) === null || _app$pisellos3 === void 0 || (_app$pisellos3$handle = _app$pisellos3.handleRoute) === null || _app$pisellos3$handle === void 0 ? void 0 : _app$pisellos3$handle.call(_app$pisellos3, method, url, props);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
69
81
|
// 缓存函数
|
|
70
82
|
return cacheFn(props, createRequest);
|
|
71
83
|
};
|
package/es/request/type.d.ts
CHANGED
package/es/request/utils.js
CHANGED
|
@@ -128,7 +128,7 @@ export var requestCallback = function requestCallback(resData) {
|
|
|
128
128
|
if (codeFn) {
|
|
129
129
|
if ((res === null || res === void 0 ? void 0 : res.code) === 200) {
|
|
130
130
|
// 需要缓存的进行缓存数据
|
|
131
|
-
if (config !== null && config !== void 0 && config.
|
|
131
|
+
if (config !== null && config !== void 0 && config.cache) {
|
|
132
132
|
var _config$cacheUpdateCh;
|
|
133
133
|
setCacheData(props.url, props.data, res, config === null || config === void 0 ? void 0 : config.cache);
|
|
134
134
|
config === null || config === void 0 || (_config$cacheUpdateCh = config.cacheUpdateChange) === null || _config$cacheUpdateCh === void 0 || _config$cacheUpdateCh.call(config, res);
|
package/es/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 | React.ReactFragment | JSX.Element | null | undefined;
|
|
24
24
|
getPageByRoute(route: string): ApplicationInterface | undefined;
|
|
25
25
|
getRouterComponent({ fallback }: {
|
|
26
26
|
fallback?: React.ReactNode;
|
|
27
|
-
}):
|
|
27
|
+
}): JSX.Element[];
|
|
28
28
|
}
|
package/es/tasks/index.d.ts
CHANGED
package/es/tasks/useTasks.d.ts
CHANGED
package/lib/app/app.d.ts
CHANGED
|
@@ -22,6 +22,7 @@ export interface AppOptions {
|
|
|
22
22
|
history?: HistoryOptions;
|
|
23
23
|
storage?: StorageOptions;
|
|
24
24
|
locales?: LocalesOptions;
|
|
25
|
+
pisellos?: any;
|
|
25
26
|
}
|
|
26
27
|
declare class App {
|
|
27
28
|
private static instance;
|
|
@@ -35,7 +36,7 @@ declare class App {
|
|
|
35
36
|
locales: Locales;
|
|
36
37
|
models: {
|
|
37
38
|
getStore: () => import("../models").Store;
|
|
38
|
-
StoreProvider:
|
|
39
|
+
StoreProvider: typeof import("react-redux").Provider;
|
|
39
40
|
setConfig: (models: any[]) => void;
|
|
40
41
|
};
|
|
41
42
|
request: {
|
|
@@ -43,7 +44,7 @@ declare class App {
|
|
|
43
44
|
post: (url: string, data: any, config: import("../request").RequestSetting | undefined) => Promise<any>;
|
|
44
45
|
put: (url: string, data: any, config: import("../request").RequestSetting | undefined) => Promise<any>;
|
|
45
46
|
remove: (url: string, data: any, config: import("../request").RequestSetting | undefined) => Promise<any>;
|
|
46
|
-
custom: (url: string, config: import("../request").RequestSetting | undefined) =>
|
|
47
|
+
custom: (url: string, config: import("../request").RequestSetting | undefined) => any;
|
|
47
48
|
setConfig: (newConfig: Partial<import("../request").RequestConfig>) => void;
|
|
48
49
|
getConfig: () => import("../request").RequestConfig;
|
|
49
50
|
};
|
|
@@ -66,6 +67,7 @@ declare class App {
|
|
|
66
67
|
cmd: CMD;
|
|
67
68
|
aws: AWS;
|
|
68
69
|
tasksManager: TasksManager;
|
|
70
|
+
pisellos: any;
|
|
69
71
|
dbManager: IndexDBManager | null;
|
|
70
72
|
constants: {
|
|
71
73
|
channel: string;
|
package/lib/app/app.js
CHANGED
|
@@ -92,6 +92,8 @@ var App = class _App {
|
|
|
92
92
|
aws;
|
|
93
93
|
// 任务管理
|
|
94
94
|
tasksManager;
|
|
95
|
+
// pisellos
|
|
96
|
+
pisellos;
|
|
95
97
|
dbManager = null;
|
|
96
98
|
constants = {
|
|
97
99
|
channel: ""
|
|
@@ -113,6 +115,7 @@ var App = class _App {
|
|
|
113
115
|
this.tasksManager = new import_tasks.TasksManager(this);
|
|
114
116
|
this.cmd = new import_cmd.default(this, options == null ? void 0 : options.cmd);
|
|
115
117
|
this.aws = new import_aws.default(this, options == null ? void 0 : options.aws);
|
|
118
|
+
this.pisellos = options == null ? void 0 : options.pisellos;
|
|
116
119
|
if (options == null ? void 0 : options.constants) {
|
|
117
120
|
this.constants = options.constants || {};
|
|
118
121
|
}
|
package/lib/aws/index.d.ts
CHANGED
|
@@ -11,6 +11,6 @@ declare class AWS {
|
|
|
11
11
|
private app;
|
|
12
12
|
private config?;
|
|
13
13
|
constructor(app: App, options?: AWSOptions);
|
|
14
|
-
upload(params: UploadParams): Promise<
|
|
14
|
+
upload(params: UploadParams): Promise<import("@aws-sdk/client-s3").PutObjectCommandOutput | undefined>;
|
|
15
15
|
}
|
|
16
16
|
export default AWS;
|
package/lib/history/index.d.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import type { History as HistoryType } from "history";
|
|
2
|
+
import { useHistory, useLocation, useParams } from "react-router-dom";
|
|
2
3
|
import App from "../app";
|
|
3
4
|
export interface HistoryOptions {
|
|
4
5
|
basename?: string;
|
|
5
6
|
}
|
|
6
7
|
export declare class History {
|
|
7
|
-
instance:
|
|
8
|
-
useHistory:
|
|
9
|
-
useLocation:
|
|
10
|
-
useParams:
|
|
8
|
+
instance: HistoryType<unknown>;
|
|
9
|
+
useHistory: typeof useHistory;
|
|
10
|
+
useLocation: typeof useLocation;
|
|
11
|
+
useParams: typeof useParams;
|
|
11
12
|
app: App;
|
|
12
13
|
constructor(app: App, options?: HistoryOptions);
|
|
13
14
|
push: HistoryType["push"];
|
package/lib/models/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import hooks from '../hooks';
|
|
2
|
+
import { Provider as StoreProvider } from "react-redux";
|
|
2
3
|
declare const models: import("./global").GlobalModal[];
|
|
3
4
|
declare type ModalsType = (typeof models[number]);
|
|
4
5
|
export interface Store {
|
|
@@ -38,7 +39,7 @@ declare const getDataByModel: <T extends "global", D extends keyof ModelsState[T
|
|
|
38
39
|
declare const setDataByModel: <T extends "global", D extends keyof ModelsState[T]>(model: string, key: any, value: any) => void;
|
|
39
40
|
declare const _default: {
|
|
40
41
|
getStore: () => Store;
|
|
41
|
-
StoreProvider:
|
|
42
|
+
StoreProvider: typeof StoreProvider;
|
|
42
43
|
setConfig: (models: any[]) => void;
|
|
43
44
|
};
|
|
44
45
|
export default _default;
|
package/lib/request/cache.d.ts
CHANGED
|
@@ -32,7 +32,7 @@ export declare const getCacheData: (url: string, data: any, cache: CacheProps) =
|
|
|
32
32
|
* @return {*}
|
|
33
33
|
* @Author: zhiwei.Wang
|
|
34
34
|
*/
|
|
35
|
-
export declare const setCacheData: (url: string, data: any, res: any, cache
|
|
35
|
+
export declare const setCacheData: (url: string, data: any, res: any, cache: CacheProps) => any | null;
|
|
36
36
|
/**
|
|
37
37
|
* @title: 缓存函数包装器
|
|
38
38
|
* @description:
|
package/lib/request/cache.js
CHANGED
|
@@ -122,23 +122,15 @@ var getCacheData = async (url, data, cache) => {
|
|
|
122
122
|
const res = await getCache(_key, cache);
|
|
123
123
|
return res;
|
|
124
124
|
};
|
|
125
|
-
var setCacheData = (url, data, res, cache
|
|
126
|
-
type: "memory"
|
|
127
|
-
}) => {
|
|
125
|
+
var setCacheData = (url, data, res, cache) => {
|
|
128
126
|
let _key = createCacheKey(url, data, cache);
|
|
129
127
|
setCache(_key, res, cache);
|
|
130
128
|
};
|
|
131
129
|
var cacheFn = async (props, fn) => {
|
|
132
130
|
var _a;
|
|
133
131
|
const { url, data, config } = props;
|
|
134
|
-
if (
|
|
135
|
-
let
|
|
136
|
-
if (config.useCache) {
|
|
137
|
-
cache = {
|
|
138
|
-
type: "memory"
|
|
139
|
-
};
|
|
140
|
-
}
|
|
141
|
-
let _data = await getCacheData(url, data, cache);
|
|
132
|
+
if (config == null ? void 0 : config.cache) {
|
|
133
|
+
let _data = await getCacheData(url, data, config.cache);
|
|
142
134
|
if (_data) {
|
|
143
135
|
if ((_a = config.cache) == null ? void 0 : _a.updateCache) {
|
|
144
136
|
fn({
|
|
@@ -146,7 +138,7 @@ var cacheFn = async (props, fn) => {
|
|
|
146
138
|
config: {
|
|
147
139
|
...props.config,
|
|
148
140
|
cache: {
|
|
149
|
-
...cache,
|
|
141
|
+
...props.config.cache,
|
|
150
142
|
updateCache: false
|
|
151
143
|
}
|
|
152
144
|
}
|
package/lib/request/index.d.ts
CHANGED
|
@@ -5,19 +5,19 @@ export declare const createRequest: (props: RequestWrapperProps) => Promise<unkn
|
|
|
5
5
|
* @param props
|
|
6
6
|
* @returns
|
|
7
7
|
*/
|
|
8
|
-
export declare const request: (props: RequestWrapperProps) =>
|
|
8
|
+
export declare const request: (props: RequestWrapperProps) => any;
|
|
9
9
|
export declare const get: (url: RequestWrapperProps["url"], data: RequestWrapperProps["data"], config: RequestWrapperProps["config"]) => Promise<any>;
|
|
10
10
|
export declare const post: (url: RequestWrapperProps["url"], data: RequestWrapperProps["data"], config: RequestWrapperProps["config"]) => Promise<any>;
|
|
11
11
|
export declare const put: (url: RequestWrapperProps["url"], data: RequestWrapperProps["data"], config: RequestWrapperProps["config"]) => Promise<any>;
|
|
12
12
|
export declare const remove: (url: RequestWrapperProps["url"], data: RequestWrapperProps["data"], config: RequestWrapperProps["config"]) => Promise<any>;
|
|
13
|
-
export declare const custom: (url: RequestWrapperProps["url"], config: RequestWrapperProps["config"]) =>
|
|
13
|
+
export declare const custom: (url: RequestWrapperProps["url"], config: RequestWrapperProps["config"]) => any;
|
|
14
14
|
export * from "./type";
|
|
15
15
|
declare const _default: {
|
|
16
16
|
get: (url: string, data: any, config: import("./type").RequestSetting | undefined) => Promise<any>;
|
|
17
17
|
post: (url: string, data: any, config: import("./type").RequestSetting | undefined) => Promise<any>;
|
|
18
18
|
put: (url: string, data: any, config: import("./type").RequestSetting | undefined) => Promise<any>;
|
|
19
19
|
remove: (url: string, data: any, config: import("./type").RequestSetting | undefined) => Promise<any>;
|
|
20
|
-
custom: (url: string, config: import("./type").RequestSetting | undefined) =>
|
|
20
|
+
custom: (url: string, config: import("./type").RequestSetting | undefined) => any;
|
|
21
21
|
setConfig: (newConfig: Partial<RequestConfig>) => void;
|
|
22
22
|
getConfig: () => RequestConfig;
|
|
23
23
|
};
|
package/lib/request/index.js
CHANGED
|
@@ -46,6 +46,7 @@ var import_cache = require("./cache");
|
|
|
46
46
|
var import_utils = require("./utils");
|
|
47
47
|
var import_axios = __toESM(require("axios"));
|
|
48
48
|
var import_config = require("./config");
|
|
49
|
+
var import_app = require("../app");
|
|
49
50
|
__reExport(request_exports, require("./type"), module.exports);
|
|
50
51
|
var axiosInstance = import_axios.default.create(import_constants.axiosConfig);
|
|
51
52
|
axiosInstance.interceptors.request.use(import_utils.interceptorsRequest, import_utils.interceptorsRequestError);
|
|
@@ -74,11 +75,18 @@ var createRequest = (props) => {
|
|
|
74
75
|
});
|
|
75
76
|
};
|
|
76
77
|
var request = (props) => {
|
|
77
|
-
|
|
78
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
79
|
+
const { config, url, method } = props;
|
|
78
80
|
if (config == null ? void 0 : config.abort) {
|
|
79
81
|
let signal = (0, import_cancelToken.createSignal)(config.abort, url);
|
|
80
82
|
config.signal = signal;
|
|
81
83
|
}
|
|
84
|
+
if (config == null ? void 0 : config.osServer) {
|
|
85
|
+
const app = (0, import_app.getApp)();
|
|
86
|
+
if (((_a = app == null ? void 0 : app.pisellos) == null ? void 0 : _a.server) && ((_d = (_c = (_b = app.pisellos) == null ? void 0 : _b.server) == null ? void 0 : _c.hasRoute) == null ? void 0 : _d.call(_c, method, url))) {
|
|
87
|
+
return (_g = (_f = (_e = app.pisellos) == null ? void 0 : _e.server) == null ? void 0 : _f.handleRoute) == null ? void 0 : _g.call(_f, method, url, props);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
82
90
|
return (0, import_cache.cacheFn)(props, createRequest);
|
|
83
91
|
};
|
|
84
92
|
var get = async (url, data, config) => {
|
package/lib/request/type.d.ts
CHANGED
package/lib/request/utils.js
CHANGED
|
@@ -86,7 +86,7 @@ var requestCallback = (resData) => {
|
|
|
86
86
|
const codeFn = requestCallbacks == null ? void 0 : requestCallbacks[res == null ? void 0 : res.code];
|
|
87
87
|
if (codeFn) {
|
|
88
88
|
if ((res == null ? void 0 : res.code) === 200) {
|
|
89
|
-
if (
|
|
89
|
+
if (config == null ? void 0 : config.cache) {
|
|
90
90
|
(0, import_cache.setCacheData)(props.url, props.data, res, config == null ? void 0 : config.cache);
|
|
91
91
|
(_a = config == null ? void 0 : config.cacheUpdateChange) == null ? void 0 : _a.call(config, res);
|
|
92
92
|
}
|
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 | React.ReactFragment | JSX.Element | null | undefined;
|
|
24
24
|
getPageByRoute(route: string): ApplicationInterface | undefined;
|
|
25
25
|
getRouterComponent({ fallback }: {
|
|
26
26
|
fallback?: React.ReactNode;
|
|
27
|
-
}):
|
|
27
|
+
}): JSX.Element[];
|
|
28
28
|
}
|
package/lib/tasks/index.d.ts
CHANGED
package/lib/tasks/useTasks.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pisell/core",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"scripts": {
|
|
5
|
-
"build": "father build",
|
|
6
|
-
"dev": "father dev",
|
|
7
|
-
"build:types": "tsc --project tsconfig.types.json",
|
|
8
|
-
"publish:types": "npm run build:types && cd types && cp ../types-package.json package.json && npm publish"
|
|
9
|
-
},
|
|
3
|
+
"version": "1.0.24",
|
|
10
4
|
"sideEffects": false,
|
|
11
5
|
"main": "./lib/index.js",
|
|
12
6
|
"module": "./es/index.js",
|
|
@@ -44,5 +38,11 @@
|
|
|
44
38
|
],
|
|
45
39
|
"publishConfig": {
|
|
46
40
|
"access": "public"
|
|
41
|
+
},
|
|
42
|
+
"scripts": {
|
|
43
|
+
"build": "father build",
|
|
44
|
+
"dev": "father dev",
|
|
45
|
+
"build:types": "tsc --project tsconfig.types.json",
|
|
46
|
+
"publish:types": "npm run build:types && cd types && cp ../types-package.json package.json && npm publish"
|
|
47
47
|
}
|
|
48
48
|
}
|