@pisell/core 1.0.13 → 1.0.15
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 +87 -0
- package/es/app/const.d.ts +4 -0
- package/es/app/index.d.ts +14 -0
- package/es/applicationManager/application.d.ts +50 -0
- package/es/applicationManager/index.d.ts +13 -0
- package/es/aws/index.d.ts +16 -0
- package/es/cmd/const.d.ts +11 -0
- package/es/cmd/index.d.ts +13 -0
- package/es/cmd/type.d.ts +5 -0
- package/es/config.d.ts +3 -0
- package/es/cookie/index.d.ts +13 -0
- package/es/data/index.d.ts +8 -0
- package/es/history/config.d.ts +24 -0
- package/es/history/index.d.ts +20 -0
- package/es/history/type.d.ts +2 -0
- package/es/hooks/index.d.ts +12 -0
- package/es/hooks/useDelayedValue/index.d.ts +2 -0
- package/es/hooks/useDispatch/index.d.ts +2 -0
- package/es/hooks/useLowCode/index.d.ts +13 -0
- package/es/hooks/useStore/index.d.ts +6 -0
- package/es/index.d.ts +6 -0
- package/es/indexDB/index.d.ts +248 -0
- package/es/indexDB/index.js +453 -70
- package/es/locales/en.d.ts +3 -0
- package/es/locales/index.d.ts +39 -0
- package/es/locales/original.d.ts +3 -0
- package/es/locales/type.d.ts +19 -0
- package/es/locales/zh-CN.d.ts +3 -0
- package/es/locales/zh-HK.d.ts +3 -0
- package/es/logger/feishu.d.ts +11 -0
- package/es/menuManager/hooks.d.ts +17 -0
- package/es/menuManager/index.d.ts +28 -0
- package/es/models/global.d.ts +32 -0
- package/es/models/index.d.ts +45 -0
- package/es/models/type.d.ts +2 -0
- package/es/plugin/index.d.ts +0 -0
- package/es/pubsub/example.d.ts +5 -0
- package/es/pubsub/index.d.ts +63 -0
- package/es/request/cache.d.ts +46 -0
- package/es/request/cancelToken.d.ts +38 -0
- package/es/request/config.d.ts +3 -0
- package/es/request/constants.d.ts +2 -0
- package/es/request/index.d.ts +24 -0
- package/es/request/pisell2Request.d.ts +6 -0
- package/es/request/type.d.ts +41 -0
- package/es/request/utils.d.ts +46 -0
- package/es/routes/config.d.ts +7 -0
- package/es/routes/index.d.ts +28 -0
- package/es/socket/components/SocketMonitorPage.d.ts +6 -0
- package/es/socket/components/index.d.ts +2 -0
- package/es/socket/constants.d.ts +33 -0
- package/es/socket/events.d.ts +31 -0
- package/es/socket/heartbeat.d.ts +66 -0
- package/es/socket/index.d.ts +61 -0
- package/es/socket/monitor.d.ts +169 -0
- package/es/socket/reconnect.d.ts +61 -0
- package/es/socket/socket.d.ts +130 -0
- package/es/socket/types.d.ts +84 -0
- package/es/storage/index.d.ts +17 -0
- package/es/tasks/index.d.ts +83 -0
- package/es/tasks/type.d.ts +62 -0
- package/es/tasks/useTasks.d.ts +5 -0
- package/es/type.d.ts +2 -0
- package/es/variables/VariablesProvider.d.ts +7 -0
- package/es/variables/config.d.ts +3 -0
- package/es/variables/index.d.ts +6 -0
- package/es/variables/type.d.ts +2 -0
- package/es/website/index.d.ts +6 -0
- package/lib/app/app.d.ts +87 -0
- package/lib/app/const.d.ts +4 -0
- package/lib/app/index.d.ts +14 -0
- package/lib/applicationManager/application.d.ts +50 -0
- package/lib/applicationManager/index.d.ts +13 -0
- package/lib/aws/index.d.ts +16 -0
- package/lib/cmd/const.d.ts +11 -0
- package/lib/cmd/index.d.ts +13 -0
- package/lib/cmd/type.d.ts +5 -0
- package/lib/config.d.ts +3 -0
- package/lib/cookie/index.d.ts +13 -0
- package/lib/data/index.d.ts +8 -0
- package/lib/history/config.d.ts +24 -0
- package/lib/history/index.d.ts +20 -0
- package/lib/history/type.d.ts +2 -0
- package/lib/hooks/index.d.ts +12 -0
- package/lib/hooks/useDelayedValue/index.d.ts +2 -0
- package/lib/hooks/useDispatch/index.d.ts +2 -0
- package/lib/hooks/useLowCode/index.d.ts +13 -0
- package/lib/hooks/useStore/index.d.ts +6 -0
- package/lib/index.d.ts +6 -0
- package/lib/indexDB/index.d.ts +248 -0
- package/lib/indexDB/index.js +159 -0
- package/lib/locales/en.d.ts +3 -0
- package/lib/locales/index.d.ts +39 -0
- package/lib/locales/original.d.ts +3 -0
- package/lib/locales/type.d.ts +19 -0
- package/lib/locales/zh-CN.d.ts +3 -0
- package/lib/locales/zh-HK.d.ts +3 -0
- package/lib/logger/feishu.d.ts +11 -0
- package/lib/menuManager/hooks.d.ts +17 -0
- package/lib/menuManager/index.d.ts +28 -0
- package/lib/models/global.d.ts +32 -0
- package/lib/models/index.d.ts +45 -0
- package/lib/models/type.d.ts +2 -0
- package/lib/plugin/index.d.ts +0 -0
- package/lib/pubsub/example.d.ts +5 -0
- package/lib/pubsub/index.d.ts +63 -0
- package/lib/request/cache.d.ts +46 -0
- package/lib/request/cancelToken.d.ts +38 -0
- package/lib/request/config.d.ts +3 -0
- package/lib/request/constants.d.ts +2 -0
- package/lib/request/index.d.ts +24 -0
- package/lib/request/pisell2Request.d.ts +6 -0
- package/lib/request/type.d.ts +41 -0
- package/lib/request/utils.d.ts +46 -0
- package/lib/routes/config.d.ts +7 -0
- package/lib/routes/index.d.ts +28 -0
- package/lib/socket/components/SocketMonitorPage.d.ts +6 -0
- package/lib/socket/components/index.d.ts +2 -0
- package/lib/socket/constants.d.ts +33 -0
- package/lib/socket/events.d.ts +31 -0
- package/lib/socket/heartbeat.d.ts +66 -0
- package/lib/socket/index.d.ts +61 -0
- package/lib/socket/monitor.d.ts +169 -0
- package/lib/socket/reconnect.d.ts +61 -0
- package/lib/socket/socket.d.ts +130 -0
- package/lib/socket/types.d.ts +84 -0
- package/lib/storage/index.d.ts +17 -0
- package/lib/tasks/index.d.ts +83 -0
- package/lib/tasks/type.d.ts +62 -0
- package/lib/tasks/useTasks.d.ts +5 -0
- package/lib/type.d.ts +2 -0
- package/lib/variables/VariablesProvider.d.ts +7 -0
- package/lib/variables/config.d.ts +3 -0
- package/lib/variables/index.d.ts +6 -0
- package/lib/variables/type.d.ts +2 -0
- package/lib/website/index.d.ts +6 -0
- package/package.json +8 -8
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Locale, LibraryItem, LoadLibraryByUrlParams } from "./type";
|
|
2
|
+
import App from "../app";
|
|
3
|
+
export interface LocalesOptions {
|
|
4
|
+
locale?: Locale;
|
|
5
|
+
library?: {
|
|
6
|
+
[key in Locale]: LibraryItem;
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
export declare class Locales {
|
|
10
|
+
private app;
|
|
11
|
+
locale: string;
|
|
12
|
+
library: {
|
|
13
|
+
[key in Locale]: LibraryItem;
|
|
14
|
+
};
|
|
15
|
+
constructor(app: App, options?: LocalesOptions);
|
|
16
|
+
getLocale: () => string;
|
|
17
|
+
getCurrentTexts: (locale?: Locale) => {
|
|
18
|
+
[key: string]: string;
|
|
19
|
+
};
|
|
20
|
+
setLocale: (locale: Locale, reload?: boolean) => void;
|
|
21
|
+
getText: (id: string, locale?: Locale) => string;
|
|
22
|
+
isCN: () => boolean;
|
|
23
|
+
loadLibraryByUrl: (urls: LoadLibraryByUrlParams) => Promise<{
|
|
24
|
+
[x: string]: LibraryItem;
|
|
25
|
+
}>;
|
|
26
|
+
loadLibraryByItems(libraryList: LibraryItem[]): void;
|
|
27
|
+
loadLibrary: (urls: LoadLibraryByUrlParams) => Promise<{
|
|
28
|
+
[x: string]: LibraryItem;
|
|
29
|
+
}>;
|
|
30
|
+
translation: (text: string | {
|
|
31
|
+
[key: string]: string;
|
|
32
|
+
}, locale?: Locale) => string | number;
|
|
33
|
+
getLibraryByData: (data: LibraryItem[]) => LibraryItem;
|
|
34
|
+
createTextsByLibrary: (id: string, library?: {
|
|
35
|
+
[x: string]: LibraryItem;
|
|
36
|
+
} | undefined) => {
|
|
37
|
+
[x: string]: string;
|
|
38
|
+
};
|
|
39
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export declare type Locale = 'original' | 'en' | 'zh-CN' | 'zh-HK' | string;
|
|
2
|
+
export declare type MultiLanguage = {
|
|
3
|
+
[key in Locale]: string;
|
|
4
|
+
};
|
|
5
|
+
export interface LibraryItem {
|
|
6
|
+
locale: Locale;
|
|
7
|
+
name: string;
|
|
8
|
+
translations: {
|
|
9
|
+
[key: string]: string;
|
|
10
|
+
};
|
|
11
|
+
[key: string]: any;
|
|
12
|
+
}
|
|
13
|
+
export interface LocaleConfig {
|
|
14
|
+
locale: Locale;
|
|
15
|
+
library: {
|
|
16
|
+
[key in Locale]: LibraryItem;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
export declare type LoadLibraryByUrlParams = (string | Promise<LibraryItem> | (() => Promise<LibraryItem>) | LibraryItem)[];
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
interface contentItem {
|
|
2
|
+
key: string;
|
|
3
|
+
value: string;
|
|
4
|
+
}
|
|
5
|
+
interface sendWebhookProps {
|
|
6
|
+
title: string;
|
|
7
|
+
content: contentItem[];
|
|
8
|
+
webhook: string;
|
|
9
|
+
}
|
|
10
|
+
export declare const sendWarningLog: ({ title, content, webhook }: sendWebhookProps) => Promise<any>;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { MenuItem } from "./index";
|
|
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
|
+
}
|
|
13
|
+
export declare const MenuProvider: React.FC<{
|
|
14
|
+
children: React.ReactNode;
|
|
15
|
+
menus: MenuItem[];
|
|
16
|
+
}>;
|
|
17
|
+
export declare const useMenu: () => MenuContextType;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import App from '../app';
|
|
3
|
+
export interface MenuItem {
|
|
4
|
+
key: string;
|
|
5
|
+
label: string;
|
|
6
|
+
path: string;
|
|
7
|
+
children?: MenuItem[];
|
|
8
|
+
icon?: string | React.ReactNode;
|
|
9
|
+
hide?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare class MenuManager {
|
|
12
|
+
private menuItems;
|
|
13
|
+
private menuMaps;
|
|
14
|
+
private app;
|
|
15
|
+
useMenu: () => import("./hooks").MenuContextType;
|
|
16
|
+
MenuProvider: React.FC<{
|
|
17
|
+
children: React.ReactNode;
|
|
18
|
+
menus: MenuItem[];
|
|
19
|
+
}>;
|
|
20
|
+
constructor(items: MenuItem[], app: App);
|
|
21
|
+
set(items: MenuItem[]): void;
|
|
22
|
+
getMenus(): MenuItem[];
|
|
23
|
+
getMenuMaps(): void;
|
|
24
|
+
findMenuItemByPath(items: MenuItem[], path: string): MenuItem | null;
|
|
25
|
+
findParent(items: MenuItem[], key: string, parent?: MenuItem | null): MenuItem | null;
|
|
26
|
+
getShowChildren(items: MenuItem[]): MenuItem[];
|
|
27
|
+
findMenuItemByKey(items: MenuItem[], key: string): MenuItem | null;
|
|
28
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Effect, Subscription } from 'dva';
|
|
2
|
+
import { Reducer } from 'redux';
|
|
3
|
+
export interface GlobalModal {
|
|
4
|
+
namespace: 'global';
|
|
5
|
+
state: {
|
|
6
|
+
isLogin: boolean;
|
|
7
|
+
account: any;
|
|
8
|
+
core: any;
|
|
9
|
+
isInstallAPP: boolean;
|
|
10
|
+
app: {
|
|
11
|
+
status: {
|
|
12
|
+
login: boolean;
|
|
13
|
+
storage: boolean;
|
|
14
|
+
network: boolean;
|
|
15
|
+
materials: boolean;
|
|
16
|
+
pisell2: boolean;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
effects: {
|
|
21
|
+
init: Effect;
|
|
22
|
+
};
|
|
23
|
+
reducers: {
|
|
24
|
+
saveGlobalState: Reducer<any>;
|
|
25
|
+
setInit: Reducer<any>;
|
|
26
|
+
};
|
|
27
|
+
subscriptions: {
|
|
28
|
+
_init: Subscription;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
declare const modal: GlobalModal;
|
|
32
|
+
export default modal;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import hooks from '../hooks';
|
|
2
|
+
import { Provider as StoreProvider } from "react-redux";
|
|
3
|
+
declare const models: import("./global").GlobalModal[];
|
|
4
|
+
declare type ModalsType = (typeof models[number]);
|
|
5
|
+
export interface Store {
|
|
6
|
+
getDataByModel: typeof getDataByModel;
|
|
7
|
+
useStore: typeof hooks.useStore;
|
|
8
|
+
useDispatch: typeof hooks.useDispatch;
|
|
9
|
+
setDataByModel: typeof setDataByModel;
|
|
10
|
+
dispatch: any;
|
|
11
|
+
getState: any;
|
|
12
|
+
}
|
|
13
|
+
export declare type ModelsNames = ModalsType['namespace'];
|
|
14
|
+
export declare type ModelsState = {
|
|
15
|
+
[K in (ModalsType['namespace'])]: Extract<ModalsType, {
|
|
16
|
+
namespace: K;
|
|
17
|
+
}>['state'];
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* @title: 从store内获取数据
|
|
21
|
+
* @description:
|
|
22
|
+
* @param {string} model
|
|
23
|
+
* @param {string} key
|
|
24
|
+
* @return {*}
|
|
25
|
+
* @Author: zhiwei.Wang
|
|
26
|
+
* @Date: 2024-09-03 11:07
|
|
27
|
+
*/
|
|
28
|
+
declare const getDataByModel: <T extends "global", D extends keyof ModelsState[T]>(model: string, key?: D | undefined) => D extends undefined ? ModelsState[T] : ModelsState[T][D];
|
|
29
|
+
/**
|
|
30
|
+
* @title: 设置数据到store
|
|
31
|
+
* @description:
|
|
32
|
+
* @param {string} model
|
|
33
|
+
* @param {string} key
|
|
34
|
+
* @param {string} value
|
|
35
|
+
* @return {*}
|
|
36
|
+
* @Author: zhiwei.Wang
|
|
37
|
+
* @Date: 2024-09-08 15:17
|
|
38
|
+
*/
|
|
39
|
+
declare const setDataByModel: <T extends "global", D extends keyof ModelsState[T]>(model: string, key: any, value: any) => void;
|
|
40
|
+
declare const _default: {
|
|
41
|
+
getStore: () => Store;
|
|
42
|
+
StoreProvider: typeof StoreProvider;
|
|
43
|
+
setConfig: (models: any[]) => void;
|
|
44
|
+
};
|
|
45
|
+
export default _default;
|
|
File without changes
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 发布订阅模块
|
|
3
|
+
* 用于组件/服务间的事件通信
|
|
4
|
+
*/
|
|
5
|
+
declare type EventCallback = (...args: any[]) => void;
|
|
6
|
+
interface EventSubscription {
|
|
7
|
+
unsubscribe: () => void;
|
|
8
|
+
}
|
|
9
|
+
declare class PubSub {
|
|
10
|
+
private events;
|
|
11
|
+
/**
|
|
12
|
+
* 订阅事件
|
|
13
|
+
* @param event 事件名称
|
|
14
|
+
* @param callback 回调函数
|
|
15
|
+
* @returns 订阅对象,可用于取消订阅
|
|
16
|
+
*/
|
|
17
|
+
subscribe(event: string, callback: EventCallback): EventSubscription;
|
|
18
|
+
/**
|
|
19
|
+
* 取消订阅事件
|
|
20
|
+
* @param event 事件名称
|
|
21
|
+
* @param callback 回调函数
|
|
22
|
+
* @returns 是否成功取消订阅
|
|
23
|
+
*/
|
|
24
|
+
unsubscribe(event: string, callback: EventCallback): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* 发布事件
|
|
27
|
+
* @param event 事件名称
|
|
28
|
+
* @param args 事件参数
|
|
29
|
+
*/
|
|
30
|
+
publish(event: string, ...args: any[]): void;
|
|
31
|
+
/**
|
|
32
|
+
* 移除某个事件的所有订阅
|
|
33
|
+
* @param event 事件名称
|
|
34
|
+
* @returns 是否成功移除
|
|
35
|
+
*/
|
|
36
|
+
clearEvent(event: string): boolean;
|
|
37
|
+
/**
|
|
38
|
+
* 移除所有事件订阅
|
|
39
|
+
*/
|
|
40
|
+
clearAllEvents(): void;
|
|
41
|
+
/**
|
|
42
|
+
* 获取事件的订阅数量
|
|
43
|
+
* @param event 事件名称
|
|
44
|
+
* @returns 订阅数量
|
|
45
|
+
*/
|
|
46
|
+
getSubscriberCount(event: string): number;
|
|
47
|
+
/**
|
|
48
|
+
* 检查事件是否有订阅者
|
|
49
|
+
* @param event 事件名称
|
|
50
|
+
* @returns 是否有订阅者
|
|
51
|
+
*/
|
|
52
|
+
hasSubscribers(event: string): boolean;
|
|
53
|
+
/**
|
|
54
|
+
* 一次性订阅事件,事件触发后自动取消订阅
|
|
55
|
+
* @param event 事件名称
|
|
56
|
+
* @param callback 回调函数
|
|
57
|
+
* @returns 订阅对象,可用于取消订阅
|
|
58
|
+
*/
|
|
59
|
+
once(event: string, callback: EventCallback): EventSubscription;
|
|
60
|
+
}
|
|
61
|
+
declare const pubsub: PubSub;
|
|
62
|
+
export default pubsub;
|
|
63
|
+
export { PubSub, type EventCallback, type EventSubscription };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { CacheProps } from './type';
|
|
2
|
+
export declare type CacheType = 'memory' | 'storage' | 'indexDB';
|
|
3
|
+
/**
|
|
4
|
+
* @title: 设置缓存
|
|
5
|
+
* @description:
|
|
6
|
+
* @return {*}
|
|
7
|
+
* @Author: zhiwei.Wang
|
|
8
|
+
*/
|
|
9
|
+
export declare const setCache: (key: string, data: any, cache: CacheProps) => Promise<void>;
|
|
10
|
+
/**
|
|
11
|
+
* @title: 删除缓存数据
|
|
12
|
+
* @description:
|
|
13
|
+
* @return {*}
|
|
14
|
+
* @Author: zhiwei.Wang
|
|
15
|
+
*/
|
|
16
|
+
export declare const removeCache: (key: string, cache: CacheProps) => void;
|
|
17
|
+
/**
|
|
18
|
+
* @title: 获取数据
|
|
19
|
+
* @description:
|
|
20
|
+
* @param {any} url
|
|
21
|
+
* @param {any} data
|
|
22
|
+
* @return {*}
|
|
23
|
+
* @Author: zhiwei.Wang
|
|
24
|
+
*/
|
|
25
|
+
export declare const getCacheData: (url: string, data: any, cache: CacheProps) => Promise<any>;
|
|
26
|
+
/**
|
|
27
|
+
* @title: 设置缓存
|
|
28
|
+
* @description:
|
|
29
|
+
* @param {any} url 路径
|
|
30
|
+
* @param {any} data 参数
|
|
31
|
+
* @param {any} res 数据
|
|
32
|
+
* @return {*}
|
|
33
|
+
* @Author: zhiwei.Wang
|
|
34
|
+
*/
|
|
35
|
+
export declare const setCacheData: (url: string, data: any, res: any, cache: CacheProps) => any | null;
|
|
36
|
+
/**
|
|
37
|
+
* @title: 缓存函数包装器
|
|
38
|
+
* @description:
|
|
39
|
+
* @param {any} url
|
|
40
|
+
* @param {any} data
|
|
41
|
+
* @param {any} config
|
|
42
|
+
* @param {any} fn
|
|
43
|
+
* @return {*}
|
|
44
|
+
* @Author: zhiwei.Wang
|
|
45
|
+
*/
|
|
46
|
+
export declare const cacheFn: (props: any, fn: any) => Promise<any>;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @Title: 请求列表
|
|
3
|
+
* @Describe:
|
|
4
|
+
* @Author: Wzw
|
|
5
|
+
*/
|
|
6
|
+
export declare let requestList: {
|
|
7
|
+
[key: string]: AbortController;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* @Title: 创建一个控制器
|
|
11
|
+
* @Describe:
|
|
12
|
+
* @Author: Wzw
|
|
13
|
+
* @param {string} key
|
|
14
|
+
*/
|
|
15
|
+
export declare const createController: (key: string) => AbortController;
|
|
16
|
+
/**
|
|
17
|
+
* @Title: 储存请求
|
|
18
|
+
* @Describe:
|
|
19
|
+
* @Author: Wzw
|
|
20
|
+
* @param {AbortController} controller
|
|
21
|
+
* @param {string} key
|
|
22
|
+
*/
|
|
23
|
+
export declare const setRequestList: (controller: AbortController, key: string) => void;
|
|
24
|
+
/**
|
|
25
|
+
* @Title: 取消请求
|
|
26
|
+
* @Describe:
|
|
27
|
+
* @Author: Wzw
|
|
28
|
+
* @param {string} key
|
|
29
|
+
*/
|
|
30
|
+
export declare const abortRequest: (key: string) => void;
|
|
31
|
+
/**
|
|
32
|
+
* @Title: 创建signal
|
|
33
|
+
* @Describe:
|
|
34
|
+
* @Author: Wzw
|
|
35
|
+
* @param {string} isAbort
|
|
36
|
+
* @param {string} url
|
|
37
|
+
*/
|
|
38
|
+
export declare const createSignal: (isAbort: boolean, url: string) => AbortSignal | null;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { RequestWrapperProps, RequestConfig } from "./type";
|
|
2
|
+
export declare const createRequest: (props: RequestWrapperProps) => Promise<unknown>;
|
|
3
|
+
/**
|
|
4
|
+
* 请求
|
|
5
|
+
* @param props
|
|
6
|
+
* @returns
|
|
7
|
+
*/
|
|
8
|
+
export declare const request: (props: RequestWrapperProps) => Promise<any>;
|
|
9
|
+
export declare const get: (url: RequestWrapperProps["url"], data: RequestWrapperProps["data"], config: RequestWrapperProps["config"]) => Promise<any>;
|
|
10
|
+
export declare const post: (url: RequestWrapperProps["url"], data: RequestWrapperProps["data"], config: RequestWrapperProps["config"]) => Promise<any>;
|
|
11
|
+
export declare const put: (url: RequestWrapperProps["url"], data: RequestWrapperProps["data"], config: RequestWrapperProps["config"]) => Promise<any>;
|
|
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"]) => Promise<any>;
|
|
14
|
+
export * from "./type";
|
|
15
|
+
declare const _default: {
|
|
16
|
+
get: (url: string, data: any, config: import("./type").RequestSetting | undefined) => Promise<any>;
|
|
17
|
+
post: (url: string, data: any, config: import("./type").RequestSetting | undefined) => Promise<any>;
|
|
18
|
+
put: (url: string, data: any, config: import("./type").RequestSetting | undefined) => Promise<any>;
|
|
19
|
+
remove: (url: string, data: any, config: import("./type").RequestSetting | undefined) => Promise<any>;
|
|
20
|
+
custom: (url: string, config: import("./type").RequestSetting | undefined) => Promise<any>;
|
|
21
|
+
setConfig: (newConfig: Partial<RequestConfig>) => void;
|
|
22
|
+
getConfig: () => RequestConfig;
|
|
23
|
+
};
|
|
24
|
+
export default _default;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
declare type RequestMethod = any;
|
|
2
|
+
declare const pisell2Get: RequestMethod;
|
|
3
|
+
declare const pisell2Post: RequestMethod;
|
|
4
|
+
declare const pisell2Put: RequestMethod;
|
|
5
|
+
declare const pisell2Remove: RequestMethod;
|
|
6
|
+
export { pisell2Get as get, pisell2Post as post, pisell2Put as put, pisell2Remove as remove, };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { CreateAxiosDefaults } from "axios";
|
|
2
|
+
import { CacheType } from './cache';
|
|
3
|
+
export interface RequestConfig {
|
|
4
|
+
interceptorsRequest?: ((value: any) => any | Promise<any>) | null;
|
|
5
|
+
interceptorsRequestError?: ((error: any) => any) | null;
|
|
6
|
+
interceptorsResponse?: any;
|
|
7
|
+
interceptorsResponseError?: ((error: any) => any) | null;
|
|
8
|
+
axiosConfig?: CreateAxiosDefaults;
|
|
9
|
+
storage?: any;
|
|
10
|
+
getToken?: () => string | null;
|
|
11
|
+
setToken?: (token: string) => void;
|
|
12
|
+
getLocale?: () => string | null;
|
|
13
|
+
getUrl?: (config: any) => string;
|
|
14
|
+
requestCallbacks?: {
|
|
15
|
+
200?: (data: any) => void;
|
|
16
|
+
401?: (data: any) => void;
|
|
17
|
+
403?: (data: any) => void;
|
|
18
|
+
other?: (data: any) => void;
|
|
19
|
+
[key: string]: any;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
export interface CacheProps {
|
|
23
|
+
key?: string;
|
|
24
|
+
type?: CacheType;
|
|
25
|
+
updateCache?: boolean;
|
|
26
|
+
cacheUpdateChange?: (data: any) => void;
|
|
27
|
+
}
|
|
28
|
+
export interface RequestSetting {
|
|
29
|
+
abort?: boolean;
|
|
30
|
+
headers?: any;
|
|
31
|
+
cache?: CacheProps;
|
|
32
|
+
signal?: any;
|
|
33
|
+
token?: string;
|
|
34
|
+
[key: string]: any;
|
|
35
|
+
}
|
|
36
|
+
export interface RequestWrapperProps {
|
|
37
|
+
url: string;
|
|
38
|
+
method: 'get' | 'post' | 'remove' | 'put';
|
|
39
|
+
data?: any;
|
|
40
|
+
config?: RequestSetting;
|
|
41
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { InternalAxiosRequestConfig } from "axios";
|
|
2
|
+
import { RequestSetting, RequestConfig, RequestWrapperProps } from "./type";
|
|
3
|
+
export declare const getRequestHeaders: (config: InternalAxiosRequestConfig<RequestSetting> & Record<string, any>) => Record<string, string | null>;
|
|
4
|
+
/**
|
|
5
|
+
* @title: 请求前拦截
|
|
6
|
+
* @description:
|
|
7
|
+
* @param {any} config
|
|
8
|
+
* @return {*}
|
|
9
|
+
* @Author: zhiwei.Wang
|
|
10
|
+
* @Date: 2024-07-04 10:51
|
|
11
|
+
*/
|
|
12
|
+
export declare const interceptorsRequest: (config: InternalAxiosRequestConfig<RequestSetting> & Record<string, any>) => Promise<InternalAxiosRequestConfig<RequestSetting> & Record<string, any>>;
|
|
13
|
+
/**
|
|
14
|
+
* @title: 请求前error
|
|
15
|
+
* @description:
|
|
16
|
+
* @param {any} err
|
|
17
|
+
* @return {*}
|
|
18
|
+
* @Author: zhiwei.Wang
|
|
19
|
+
* @Date: 2024-07-04 10:51
|
|
20
|
+
*/
|
|
21
|
+
export declare const interceptorsRequestError: (err: RequestConfig["interceptorsRequestError"]) => any;
|
|
22
|
+
/**
|
|
23
|
+
* @title: 请求后拦截
|
|
24
|
+
* @description:
|
|
25
|
+
* @param {any} response
|
|
26
|
+
* @return {*}
|
|
27
|
+
* @Author: zhiwei.Wang
|
|
28
|
+
* @Date: 2024-07-04 10:51
|
|
29
|
+
*/
|
|
30
|
+
export declare const interceptorsResponse: (response: RequestConfig["interceptorsResponse"]) => any;
|
|
31
|
+
/**
|
|
32
|
+
* @title: 请求后错误拦截
|
|
33
|
+
* @description:
|
|
34
|
+
* @param {any} response
|
|
35
|
+
* @return {*}
|
|
36
|
+
* @Author: zhiwei.Wang
|
|
37
|
+
* @Date: 2024-07-04 10:51
|
|
38
|
+
*/
|
|
39
|
+
export declare const interceptorsResponseError: (response: RequestConfig["interceptorsResponseError"]) => any;
|
|
40
|
+
export declare const requestCallback: (resData: {
|
|
41
|
+
res?: any;
|
|
42
|
+
props: RequestWrapperProps;
|
|
43
|
+
resolve: (value: unknown) => void;
|
|
44
|
+
reject: () => void;
|
|
45
|
+
err?: any;
|
|
46
|
+
}) => void;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import App from '../app';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import type { ApplicationInterface } from '../applicationManager/application';
|
|
4
|
+
export interface RouterOptions {
|
|
5
|
+
routes?: Record<string, RouteType>;
|
|
6
|
+
basename?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface RouteType extends ApplicationInterface {
|
|
9
|
+
}
|
|
10
|
+
export declare class RouterManager {
|
|
11
|
+
routes: Record<string, RouteType>;
|
|
12
|
+
options: RouterOptions;
|
|
13
|
+
app: App;
|
|
14
|
+
constructor(options: RouterOptions | undefined, app: App);
|
|
15
|
+
init(): void;
|
|
16
|
+
getRoutes(): Record<string, RouteType>;
|
|
17
|
+
getBasename(): string | undefined;
|
|
18
|
+
setBasename(basename: string): void;
|
|
19
|
+
add(name: string, route: any): void;
|
|
20
|
+
get(name: string): RouteType;
|
|
21
|
+
has(name: string): boolean;
|
|
22
|
+
remove(name: string): void;
|
|
23
|
+
renderComponent(item: RouteType, children?: React.ReactNode): string | number | boolean | React.ReactFragment | JSX.Element | null | undefined;
|
|
24
|
+
getPageByRoute(route: string): ApplicationInterface | undefined;
|
|
25
|
+
getRouterComponent({ fallback }: {
|
|
26
|
+
fallback?: React.ReactNode;
|
|
27
|
+
}): JSX.Element[];
|
|
28
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Socket模块常量
|
|
3
|
+
*/
|
|
4
|
+
/** 默认配置选项 */
|
|
5
|
+
export declare const DEFAULT_SOCKET_OPTIONS: {
|
|
6
|
+
autoConnect: boolean;
|
|
7
|
+
reconnection: boolean;
|
|
8
|
+
reconnectionAttempts: number;
|
|
9
|
+
reconnectionDelay: number;
|
|
10
|
+
reconnectionDelayMax: number;
|
|
11
|
+
heartbeat: boolean;
|
|
12
|
+
heartbeatInterval: number;
|
|
13
|
+
heartbeatTimeout: number;
|
|
14
|
+
timeout: number;
|
|
15
|
+
};
|
|
16
|
+
/** 默认心跳消息 */
|
|
17
|
+
export declare const DEFAULT_HEARTBEAT_MESSAGE: {
|
|
18
|
+
type: string;
|
|
19
|
+
};
|
|
20
|
+
/** 默认心跳响应事件 */
|
|
21
|
+
export declare const DEFAULT_HEARTBEAT_RESPONSE = "pong";
|
|
22
|
+
/** 最小心跳间隔(毫秒) */
|
|
23
|
+
export declare const MIN_HEARTBEAT_INTERVAL = 1000;
|
|
24
|
+
/** 最小重连延迟(毫秒) */
|
|
25
|
+
export declare const MIN_RECONNECTION_DELAY = 500;
|
|
26
|
+
/** 连接状态码映射 */
|
|
27
|
+
export declare const WS_STATUS_MAP: {
|
|
28
|
+
0: string;
|
|
29
|
+
1: string;
|
|
30
|
+
2: string;
|
|
31
|
+
3: string;
|
|
32
|
+
4: string;
|
|
33
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Socket标准事件类型
|
|
3
|
+
*/
|
|
4
|
+
export declare enum SocketEvents {
|
|
5
|
+
/** 连接成功事件 */
|
|
6
|
+
CONNECT = "connect",
|
|
7
|
+
/** 连接断开事件 */
|
|
8
|
+
DISCONNECT = "disconnect",
|
|
9
|
+
/** 连接错误事件 */
|
|
10
|
+
ERROR = "error",
|
|
11
|
+
/** 接收消息事件 */
|
|
12
|
+
MESSAGE = "message",
|
|
13
|
+
/** 发送消息事件 */
|
|
14
|
+
SEND = "send",
|
|
15
|
+
/** 重连中事件 */
|
|
16
|
+
RECONNECTING = "reconnecting",
|
|
17
|
+
/** 重连尝试事件 */
|
|
18
|
+
RECONNECT_ATTEMPT = "reconnect_attempt",
|
|
19
|
+
/** 重连成功事件 */
|
|
20
|
+
RECONNECT = "reconnect",
|
|
21
|
+
/** 重连失败事件 */
|
|
22
|
+
RECONNECT_ERROR = "reconnect_error",
|
|
23
|
+
/** 重连次数超限 */
|
|
24
|
+
RECONNECT_FAILED = "reconnect_failed",
|
|
25
|
+
/** 心跳发送事件 */
|
|
26
|
+
HEARTBEAT = "heartbeat",
|
|
27
|
+
/** 心跳响应事件 */
|
|
28
|
+
HEARTBEAT_RESPONSE = "heartbeat_response",
|
|
29
|
+
/** 心跳超时事件 */
|
|
30
|
+
HEARTBEAT_TIMEOUT = "heartbeat_timeout"
|
|
31
|
+
}
|