@pisell/core 1.0.0 → 1.0.2
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 +83 -0
- package/es/app/app.js +151 -0
- package/es/app/const.d.ts +4 -0
- package/es/app/const.js +6 -0
- package/es/app/index.d.ts +14 -0
- package/es/app/index.js +52 -0
- package/es/applicationManager/application.d.ts +50 -0
- package/es/applicationManager/application.js +223 -0
- package/es/applicationManager/index.d.ts +13 -0
- package/es/applicationManager/index.js +190 -0
- package/es/config.d.ts +3 -3
- package/es/config.js +5 -5
- package/es/cookie/index.d.ts +13 -0
- package/es/cookie/index.js +47 -0
- package/es/css/global.less +73 -0
- package/es/css/index.less +31 -0
- package/es/css/variables.css +84 -0
- package/es/data/index.d.ts +8 -0
- package/es/data/index.js +16 -0
- package/es/{locales → history}/config.d.ts +5 -5
- package/es/history/config.js +43 -0
- package/es/history/index.d.ts +20 -0
- package/es/history/index.js +41 -0
- package/es/history/type.d.ts +2 -0
- package/es/hooks/index.d.ts +12 -0
- package/es/hooks/index.js +13 -0
- package/es/hooks/useDelayedValue/index.d.ts +2 -0
- package/es/hooks/useDelayedValue/index.js +26 -0
- package/es/hooks/useDispatch/index.d.ts +2 -0
- package/es/hooks/useDispatch/index.js +2 -0
- package/es/hooks/useLowCode/index.d.ts +13 -0
- package/es/hooks/useLowCode/index.js +74 -0
- package/es/hooks/useStore/index.d.ts +6 -0
- package/es/hooks/useStore/index.js +11 -0
- package/es/index.d.ts +1 -2
- package/es/index.js +9 -2
- package/es/indexDB/index.d.ts +178 -0
- package/es/indexDB/index.js +542 -0
- package/es/locales/en.d.ts +2 -1
- package/es/locales/en.js +5 -1
- package/es/locales/index.d.ts +37 -53
- package/es/locales/index.js +213 -70
- package/es/locales/original.d.ts +3 -0
- package/es/locales/original.js +7 -0
- package/es/locales/type.d.ts +15 -5
- package/es/locales/zh-CN.d.ts +2 -1
- package/es/locales/zh-CN.js +5 -1
- package/es/locales/zh-HK.d.ts +2 -1
- package/es/locales/zh-HK.js +5 -1
- package/es/logger/feishu.d.ts +11 -0
- package/es/logger/feishu.js +50 -0
- package/es/logger/index.d.ts +122 -0
- package/es/logger/index.js +539 -0
- package/es/menuManager/hooks.d.ts +17 -0
- package/es/menuManager/hooks.js +136 -0
- package/es/menuManager/index.d.ts +28 -0
- package/es/menuManager/index.js +142 -0
- package/es/models/global.d.ts +32 -0
- package/es/models/global.js +66 -0
- package/es/models/index.d.ts +45 -0
- package/es/models/index.js +65 -0
- package/es/models/type.d.ts +2 -0
- package/es/models/type.js +1 -0
- package/es/plugin/index.d.ts +0 -0
- package/es/plugin/index.js +0 -0
- package/es/pubsub/example.d.ts +5 -0
- package/es/pubsub/example.js +92 -0
- package/es/pubsub/index.d.ts +63 -0
- package/es/pubsub/index.js +144 -0
- package/es/request/cache.d.ts +46 -0
- package/es/request/cache.js +311 -0
- package/es/request/cancelToken.d.ts +38 -0
- package/es/request/cancelToken.js +59 -0
- package/es/request/config.d.ts +3 -0
- package/es/request/config.js +58 -0
- package/es/request/constants.d.ts +2 -0
- package/es/request/constants.js +6 -0
- package/es/request/index.d.ts +24 -0
- package/es/request/index.js +176 -0
- package/es/request/pisell2Request.d.ts +6 -0
- package/es/request/pisell2Request.js +62 -0
- package/es/request/type.d.ts +41 -0
- package/es/request/type.js +1 -0
- package/es/request/utils.d.ts +46 -0
- package/es/request/utils.js +147 -0
- package/es/routes/config.d.ts +7 -0
- package/es/routes/config.js +17 -0
- package/es/routes/index.d.ts +28 -0
- package/es/routes/index.js +148 -0
- package/es/socket/components/SocketMonitorPage.d.ts +6 -0
- package/es/socket/components/SocketMonitorPage.js +485 -0
- package/es/socket/components/index.d.ts +2 -0
- package/es/socket/components/index.js +2 -0
- package/es/socket/constants.d.ts +33 -0
- package/es/socket/constants.js +39 -0
- package/es/socket/events.d.ts +31 -0
- package/es/socket/events.js +19 -0
- package/es/socket/heartbeat.d.ts +66 -0
- package/es/socket/heartbeat.js +184 -0
- package/es/socket/index.d.ts +61 -0
- package/es/socket/index.js +246 -0
- package/es/socket/monitor.d.ts +169 -0
- package/es/socket/monitor.js +447 -0
- package/es/socket/reconnect.d.ts +61 -0
- package/es/socket/reconnect.js +199 -0
- package/es/socket/socket.d.ts +129 -0
- package/es/socket/socket.js +595 -0
- package/es/socket/types.d.ts +85 -0
- package/es/socket/types.js +35 -0
- package/es/storage/index.d.ts +17 -0
- package/es/storage/index.js +56 -0
- package/es/tasks/index.d.ts +77 -0
- package/es/tasks/index.js +743 -0
- package/es/tasks/type.d.ts +62 -0
- package/es/tasks/type.js +1 -0
- package/es/tasks/useTasks.d.ts +5 -0
- package/es/tasks/useTasks.js +25 -0
- package/es/type.d.ts +1 -1
- package/es/variables/VariablesProvider.d.ts +7 -0
- package/es/variables/VariablesProvider.js +12 -0
- package/es/variables/config.d.ts +3 -0
- package/es/variables/config.js +16 -0
- package/es/variables/index.d.ts +6 -0
- package/es/variables/index.js +5 -0
- package/es/variables/type.d.ts +2 -0
- package/es/variables/type.js +1 -0
- package/es/website/index.d.ts +6 -0
- package/es/website/index.js +65 -0
- package/lib/app/app.d.ts +83 -0
- package/lib/app/app.js +125 -0
- package/lib/app/const.d.ts +4 -0
- package/lib/app/const.js +33 -0
- package/lib/app/index.d.ts +14 -0
- package/lib/app/index.js +76 -0
- package/lib/applicationManager/application.d.ts +50 -0
- package/lib/applicationManager/application.js +110 -0
- package/lib/applicationManager/index.d.ts +13 -0
- package/lib/applicationManager/index.js +76 -0
- package/lib/config.d.ts +3 -3
- package/lib/cookie/index.d.ts +13 -0
- package/lib/cookie/index.js +64 -0
- package/lib/css/global.less +73 -0
- package/lib/css/index.less +31 -0
- package/lib/css/variables.css +84 -0
- package/lib/data/index.d.ts +8 -0
- package/lib/data/index.js +35 -0
- package/lib/{locales → history}/config.d.ts +5 -5
- package/lib/history/config.js +41 -0
- package/lib/history/index.d.ts +20 -0
- package/lib/history/index.js +58 -0
- package/lib/history/type.d.ts +2 -0
- package/lib/history/type.js +17 -0
- package/lib/hooks/index.d.ts +12 -0
- package/lib/{date → hooks}/index.js +14 -20
- package/lib/hooks/useDelayedValue/index.d.ts +2 -0
- package/lib/hooks/useDelayedValue/index.js +36 -0
- package/lib/hooks/useDispatch/index.d.ts +2 -0
- package/lib/hooks/useDispatch/index.js +26 -0
- package/lib/hooks/useLowCode/index.d.ts +13 -0
- package/lib/hooks/useLowCode/index.js +75 -0
- package/lib/hooks/useStore/index.d.ts +6 -0
- package/lib/hooks/useStore/index.js +33 -0
- package/lib/index.d.ts +1 -2
- package/lib/index.js +3 -22
- package/lib/indexDB/index.d.ts +178 -0
- package/lib/indexDB/index.js +277 -0
- package/lib/locales/en.d.ts +2 -1
- package/lib/locales/en.js +5 -1
- package/lib/locales/index.d.ts +37 -53
- package/lib/locales/index.js +130 -41
- package/lib/locales/original.d.ts +3 -0
- package/lib/locales/original.js +31 -0
- package/lib/locales/type.d.ts +15 -5
- package/lib/locales/zh-CN.d.ts +2 -1
- package/lib/locales/zh-CN.js +5 -1
- package/lib/locales/zh-HK.d.ts +2 -1
- package/lib/locales/zh-HK.js +5 -1
- package/lib/logger/feishu.d.ts +11 -0
- package/lib/logger/feishu.js +52 -0
- package/lib/logger/index.d.ts +122 -0
- package/lib/logger/index.js +288 -0
- package/lib/menuManager/hooks.d.ts +17 -0
- package/lib/menuManager/hooks.js +135 -0
- package/lib/menuManager/index.d.ts +28 -0
- package/lib/menuManager/index.js +110 -0
- package/lib/models/global.d.ts +32 -0
- package/lib/models/global.js +62 -0
- package/lib/models/index.d.ts +45 -0
- package/lib/models/index.js +69 -0
- package/lib/models/type.d.ts +2 -0
- package/lib/models/type.js +17 -0
- package/lib/plugin/index.d.ts +0 -0
- package/lib/plugin/index.js +0 -0
- package/lib/pubsub/example.d.ts +5 -0
- package/lib/pubsub/example.js +61 -0
- package/lib/pubsub/index.d.ts +63 -0
- package/lib/pubsub/index.js +129 -0
- package/lib/request/cache.d.ts +46 -0
- package/lib/request/cache.js +159 -0
- package/lib/request/cancelToken.d.ts +38 -0
- package/lib/request/cancelToken.js +59 -0
- package/lib/request/config.d.ts +3 -0
- package/lib/request/config.js +64 -0
- package/lib/request/constants.d.ts +2 -0
- package/lib/request/constants.js +34 -0
- package/lib/request/index.d.ts +24 -0
- package/lib/request/index.js +147 -0
- package/lib/request/pisell2Request.d.ts +6 -0
- package/lib/request/pisell2Request.js +75 -0
- package/lib/request/type.d.ts +41 -0
- package/lib/request/type.js +17 -0
- package/lib/request/utils.d.ts +46 -0
- package/lib/request/utils.js +113 -0
- package/lib/routes/config.d.ts +7 -0
- package/lib/routes/config.js +50 -0
- package/lib/routes/index.d.ts +28 -0
- package/lib/routes/index.js +118 -0
- package/lib/socket/components/SocketMonitorPage.d.ts +6 -0
- package/lib/socket/components/SocketMonitorPage.js +346 -0
- package/lib/socket/components/index.d.ts +2 -0
- package/lib/socket/components/index.js +39 -0
- package/lib/socket/constants.d.ts +33 -0
- package/lib/socket/constants.js +62 -0
- package/lib/socket/events.d.ts +31 -0
- package/lib/socket/events.js +44 -0
- package/lib/socket/heartbeat.d.ts +66 -0
- package/lib/socket/heartbeat.js +152 -0
- package/lib/socket/index.d.ts +61 -0
- package/lib/socket/index.js +200 -0
- package/lib/socket/monitor.d.ts +169 -0
- package/lib/socket/monitor.js +346 -0
- package/lib/socket/reconnect.d.ts +61 -0
- package/lib/socket/reconnect.js +153 -0
- package/lib/socket/socket.d.ts +129 -0
- package/lib/socket/socket.js +410 -0
- package/lib/socket/types.d.ts +85 -0
- package/lib/socket/types.js +36 -0
- package/lib/storage/index.d.ts +17 -0
- package/lib/storage/index.js +63 -0
- package/lib/tasks/index.d.ts +77 -0
- package/lib/tasks/index.js +438 -0
- package/lib/tasks/type.d.ts +62 -0
- package/lib/{date → tasks}/type.js +1 -1
- package/lib/tasks/useTasks.d.ts +5 -0
- package/lib/tasks/useTasks.js +37 -0
- package/lib/type.d.ts +1 -1
- package/lib/variables/VariablesProvider.d.ts +7 -0
- package/lib/{locales/config.js → variables/VariablesProvider.js} +17 -29
- package/lib/variables/config.d.ts +3 -0
- package/lib/{date → variables}/config.js +2 -7
- package/lib/variables/index.d.ts +6 -0
- package/lib/variables/index.js +29 -0
- package/lib/variables/type.d.ts +2 -0
- package/lib/variables/type.js +17 -0
- package/lib/website/index.d.ts +6 -0
- package/lib/website/index.js +75 -0
- package/package.json +22 -5
- package/es/date/config.d.ts +0 -3
- package/es/date/config.js +0 -21
- package/es/date/index.d.ts +0 -7
- package/es/date/index.js +0 -22
- package/es/date/type.d.ts +0 -7
- package/es/locales/config.js +0 -57
- package/lib/date/config.d.ts +0 -3
- package/lib/date/index.d.ts +0 -7
- package/lib/date/type.d.ts +0 -7
- /package/es/{date → history}/type.js +0 -0
package/es/app/app.d.ts
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { RouterManager } from '../routes';
|
|
2
|
+
import { ApplicationManager } from '../applicationManager';
|
|
3
|
+
import { History, HistoryOptions } from '../history';
|
|
4
|
+
import { Data } from '../data';
|
|
5
|
+
import { Locales, LocalesOptions } from '../locales';
|
|
6
|
+
import { Storage, StorageOptions } from '../storage';
|
|
7
|
+
import { MenuManager } from '../menuManager';
|
|
8
|
+
import LoggerManager, { LoggerOptions } from '../logger';
|
|
9
|
+
import { TasksManager } from '../tasks';
|
|
10
|
+
import IndexDBManager, { DBOptions } from '../indexDB';
|
|
11
|
+
declare global {
|
|
12
|
+
interface Window {
|
|
13
|
+
app: App;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
export interface AppOptions {
|
|
17
|
+
logger?: LoggerOptions;
|
|
18
|
+
db?: DBOptions;
|
|
19
|
+
constants?: any;
|
|
20
|
+
history?: HistoryOptions;
|
|
21
|
+
storage?: StorageOptions;
|
|
22
|
+
locales?: LocalesOptions;
|
|
23
|
+
}
|
|
24
|
+
declare class App {
|
|
25
|
+
private static instance;
|
|
26
|
+
private plugins;
|
|
27
|
+
globalData: any;
|
|
28
|
+
router: RouterManager;
|
|
29
|
+
applicationManager: ApplicationManager;
|
|
30
|
+
history: History;
|
|
31
|
+
data: Data;
|
|
32
|
+
hooks: import("../hooks").HooksExport;
|
|
33
|
+
locales: Locales;
|
|
34
|
+
models: {
|
|
35
|
+
getStore: () => import("../models").Store;
|
|
36
|
+
StoreProvider: typeof import("react-redux").Provider;
|
|
37
|
+
setConfig: (models: any[]) => void;
|
|
38
|
+
};
|
|
39
|
+
request: {
|
|
40
|
+
get: (url: string, data: any, config: import("@").RequestSetting | undefined) => Promise<any>;
|
|
41
|
+
post: (url: string, data: any, config: import("@").RequestSetting | undefined) => Promise<any>;
|
|
42
|
+
put: (url: string, data: any, config: import("@").RequestSetting | undefined) => Promise<any>;
|
|
43
|
+
remove: (url: string, data: any, config: import("@").RequestSetting | undefined) => Promise<any>;
|
|
44
|
+
custom: (url: string, config: import("@").RequestSetting | undefined) => Promise<any>;
|
|
45
|
+
setConfig: (newConfig: Partial<import("@").RequestConfig>) => void;
|
|
46
|
+
getConfig: () => import("@").RequestConfig;
|
|
47
|
+
};
|
|
48
|
+
storage: Storage;
|
|
49
|
+
menuManager: MenuManager;
|
|
50
|
+
cookie: {
|
|
51
|
+
setCookie: (name: string, value: string, domain?: string | undefined) => void;
|
|
52
|
+
getCookie: (name: string) => string | null;
|
|
53
|
+
deleteCookie: (name: string, domain?: string | undefined) => void;
|
|
54
|
+
checkCookie: (name: string) => boolean;
|
|
55
|
+
updateCookie: (name: string, value: string, domain?: string | undefined) => void;
|
|
56
|
+
};
|
|
57
|
+
website: {
|
|
58
|
+
setTitle: (title: string) => void;
|
|
59
|
+
setIcon: (paramsIcon: string) => void;
|
|
60
|
+
setAppleWebAppTitle: (title: string) => void;
|
|
61
|
+
};
|
|
62
|
+
logger: LoggerManager;
|
|
63
|
+
pubsub: import("../pubsub").PubSub;
|
|
64
|
+
tasksManager: TasksManager;
|
|
65
|
+
dbManager: IndexDBManager | null;
|
|
66
|
+
constants: {
|
|
67
|
+
channel: string;
|
|
68
|
+
[key: string]: string;
|
|
69
|
+
};
|
|
70
|
+
private constructor();
|
|
71
|
+
static getInstance(options?: AppOptions): App;
|
|
72
|
+
setGlobalData(globalData: any): void;
|
|
73
|
+
usePlugin(name: string, plugin: any): void;
|
|
74
|
+
usePlugins(plugins: {
|
|
75
|
+
name: string;
|
|
76
|
+
plugin: any;
|
|
77
|
+
}[]): void;
|
|
78
|
+
getPlugin(name: string): any;
|
|
79
|
+
getGlobalData(): any;
|
|
80
|
+
install(): void;
|
|
81
|
+
unInstall(): void;
|
|
82
|
+
}
|
|
83
|
+
export default App;
|
package/es/app/app.js
ADDED
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
5
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
6
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
7
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
8
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
9
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
10
|
+
import { RouterManager } from "../routes";
|
|
11
|
+
import { ApplicationManager } from "../applicationManager";
|
|
12
|
+
import { History } from "../history";
|
|
13
|
+
import { Data } from "../data";
|
|
14
|
+
import hooks from "../hooks";
|
|
15
|
+
import { Locales } from "../locales";
|
|
16
|
+
import models from "../models";
|
|
17
|
+
import request from "../request";
|
|
18
|
+
import { Storage } from "../storage";
|
|
19
|
+
import { MenuManager } from "../menuManager";
|
|
20
|
+
import cookie from "../cookie";
|
|
21
|
+
import website from "../website";
|
|
22
|
+
import LoggerManager from "../logger";
|
|
23
|
+
import { TasksManager } from "../tasks";
|
|
24
|
+
import IndexDBManager from "../indexDB";
|
|
25
|
+
import pubsub from "../pubsub";
|
|
26
|
+
import { APPEvent } from "./const";
|
|
27
|
+
var App = /*#__PURE__*/function () {
|
|
28
|
+
function App(options) {
|
|
29
|
+
_classCallCheck(this, App);
|
|
30
|
+
// 插件管理
|
|
31
|
+
_defineProperty(this, "plugins", void 0);
|
|
32
|
+
// 全局数据
|
|
33
|
+
_defineProperty(this, "globalData", void 0);
|
|
34
|
+
// 路由管理
|
|
35
|
+
_defineProperty(this, "router", void 0);
|
|
36
|
+
// 应用管理
|
|
37
|
+
_defineProperty(this, "applicationManager", void 0);
|
|
38
|
+
// History
|
|
39
|
+
_defineProperty(this, "history", void 0);
|
|
40
|
+
// 数据存储
|
|
41
|
+
_defineProperty(this, "data", void 0);
|
|
42
|
+
// hooks
|
|
43
|
+
_defineProperty(this, "hooks", hooks);
|
|
44
|
+
// 多语言
|
|
45
|
+
_defineProperty(this, "locales", void 0);
|
|
46
|
+
// dva
|
|
47
|
+
_defineProperty(this, "models", models);
|
|
48
|
+
// 请求
|
|
49
|
+
_defineProperty(this, "request", request);
|
|
50
|
+
// 存储
|
|
51
|
+
_defineProperty(this, "storage", void 0);
|
|
52
|
+
// 菜单管理
|
|
53
|
+
_defineProperty(this, "menuManager", void 0);
|
|
54
|
+
// cookie
|
|
55
|
+
_defineProperty(this, "cookie", cookie);
|
|
56
|
+
// 网站信息
|
|
57
|
+
_defineProperty(this, "website", website);
|
|
58
|
+
// 日志
|
|
59
|
+
_defineProperty(this, "logger", void 0);
|
|
60
|
+
// 发布订阅
|
|
61
|
+
_defineProperty(this, "pubsub", pubsub);
|
|
62
|
+
// 任务管理
|
|
63
|
+
_defineProperty(this, "tasksManager", void 0);
|
|
64
|
+
_defineProperty(this, "dbManager", null);
|
|
65
|
+
_defineProperty(this, "constants", {
|
|
66
|
+
channel: ""
|
|
67
|
+
});
|
|
68
|
+
this.plugins = new Map();
|
|
69
|
+
this.globalData = {};
|
|
70
|
+
this.router = new RouterManager({}, this);
|
|
71
|
+
this.menuManager = new MenuManager([], this);
|
|
72
|
+
this.applicationManager = new ApplicationManager([], this);
|
|
73
|
+
this.history = new History(this, options === null || options === void 0 ? void 0 : options.history);
|
|
74
|
+
this.storage = new Storage(this, options === null || options === void 0 ? void 0 : options.storage);
|
|
75
|
+
this.data = new Data(this);
|
|
76
|
+
this.locales = new Locales(this, options === null || options === void 0 ? void 0 : options.locales);
|
|
77
|
+
if (options !== null && options !== void 0 && options.db) {
|
|
78
|
+
this.dbManager = new IndexDBManager(this, options === null || options === void 0 ? void 0 : options.db);
|
|
79
|
+
}
|
|
80
|
+
this.logger = new LoggerManager(this, options === null || options === void 0 ? void 0 : options.logger);
|
|
81
|
+
this.tasksManager = new TasksManager(this);
|
|
82
|
+
if (options !== null && options !== void 0 && options.constants) {
|
|
83
|
+
this.constants = options.constants || {};
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// 单例模式
|
|
88
|
+
_createClass(App, [{
|
|
89
|
+
key: "setGlobalData",
|
|
90
|
+
value:
|
|
91
|
+
// 初始化配置
|
|
92
|
+
function setGlobalData(globalData) {
|
|
93
|
+
this.globalData = _objectSpread(_objectSpread({}, this.globalData), globalData);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// 注册插件
|
|
97
|
+
}, {
|
|
98
|
+
key: "usePlugin",
|
|
99
|
+
value: function usePlugin(name, plugin) {
|
|
100
|
+
this.plugins.set(name, plugin);
|
|
101
|
+
}
|
|
102
|
+
// 注册插件列表
|
|
103
|
+
}, {
|
|
104
|
+
key: "usePlugins",
|
|
105
|
+
value: function usePlugins(plugins) {
|
|
106
|
+
var _this = this;
|
|
107
|
+
plugins.forEach(function (_ref) {
|
|
108
|
+
var name = _ref.name,
|
|
109
|
+
plugin = _ref.plugin;
|
|
110
|
+
_this.plugins.set(name, plugin);
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// 获取应用
|
|
115
|
+
}, {
|
|
116
|
+
key: "getPlugin",
|
|
117
|
+
value: function getPlugin(name) {
|
|
118
|
+
return this.plugins.get(name);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// 获取配置
|
|
122
|
+
}, {
|
|
123
|
+
key: "getGlobalData",
|
|
124
|
+
value: function getGlobalData() {
|
|
125
|
+
return this.globalData;
|
|
126
|
+
}
|
|
127
|
+
}, {
|
|
128
|
+
key: "install",
|
|
129
|
+
value: function install() {
|
|
130
|
+
this.pubsub.publish(APPEvent.APP_INSTALL, this);
|
|
131
|
+
}
|
|
132
|
+
}, {
|
|
133
|
+
key: "unInstall",
|
|
134
|
+
value: function unInstall() {
|
|
135
|
+
this.pubsub.publish(APPEvent.APP_UNINSTALL, this);
|
|
136
|
+
}
|
|
137
|
+
}], [{
|
|
138
|
+
key: "getInstance",
|
|
139
|
+
value: function getInstance(options) {
|
|
140
|
+
if (!App.instance) {
|
|
141
|
+
App.instance = new App(options);
|
|
142
|
+
window.app = App.instance;
|
|
143
|
+
}
|
|
144
|
+
return App.instance;
|
|
145
|
+
}
|
|
146
|
+
}]);
|
|
147
|
+
return App;
|
|
148
|
+
}();
|
|
149
|
+
// 实例
|
|
150
|
+
_defineProperty(App, "instance", void 0);
|
|
151
|
+
export default App;
|
package/es/app/const.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import App, { AppOptions } from "./app";
|
|
3
|
+
type AppContextType = {
|
|
4
|
+
globalData: any;
|
|
5
|
+
setGlobalData: React.Dispatch<React.SetStateAction<any>>;
|
|
6
|
+
app: App;
|
|
7
|
+
};
|
|
8
|
+
export declare const AppProvider: React.FC<{
|
|
9
|
+
children: React.ReactNode;
|
|
10
|
+
options: AppOptions;
|
|
11
|
+
}>;
|
|
12
|
+
export declare const useApp: () => AppContextType;
|
|
13
|
+
export declare const getApp: typeof App.getInstance;
|
|
14
|
+
export default App;
|
package/es/app/index.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
8
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
9
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
10
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
11
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
12
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
13
|
+
import React, { createContext, useContext, useEffect, useRef, useState } from "react";
|
|
14
|
+
import App from "./app";
|
|
15
|
+
var AppContext = /*#__PURE__*/createContext(undefined);
|
|
16
|
+
export var AppProvider = function AppProvider(_ref) {
|
|
17
|
+
var children = _ref.children,
|
|
18
|
+
options = _ref.options;
|
|
19
|
+
var _useState = useState({}),
|
|
20
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
21
|
+
globalData = _useState2[0],
|
|
22
|
+
setGlobalData = _useState2[1];
|
|
23
|
+
var app = useRef(App.getInstance(options));
|
|
24
|
+
useEffect(function () {
|
|
25
|
+
app.current.install();
|
|
26
|
+
return function () {
|
|
27
|
+
app.current.unInstall();
|
|
28
|
+
};
|
|
29
|
+
}, []);
|
|
30
|
+
var _setGlobalData = function _setGlobalData(data) {
|
|
31
|
+
setGlobalData(function (prev) {
|
|
32
|
+
return _objectSpread(_objectSpread({}, prev), data);
|
|
33
|
+
});
|
|
34
|
+
app.current.setGlobalData(data);
|
|
35
|
+
};
|
|
36
|
+
return /*#__PURE__*/React.createElement(AppContext.Provider, {
|
|
37
|
+
value: {
|
|
38
|
+
globalData: globalData,
|
|
39
|
+
setGlobalData: _setGlobalData,
|
|
40
|
+
app: app.current
|
|
41
|
+
}
|
|
42
|
+
}, children);
|
|
43
|
+
};
|
|
44
|
+
export var useApp = function useApp() {
|
|
45
|
+
var context = useContext(AppContext);
|
|
46
|
+
if (!context) {
|
|
47
|
+
throw new Error();
|
|
48
|
+
}
|
|
49
|
+
return context;
|
|
50
|
+
};
|
|
51
|
+
export var getApp = App.getInstance;
|
|
52
|
+
export default App;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import App from "../app";
|
|
2
|
+
import { LoadLibraryByUrlParams } from "../locales/type";
|
|
3
|
+
import { MenuItem } from "../menuManager/index";
|
|
4
|
+
export type ApplicationInterface = {
|
|
5
|
+
page_type: "low_code" | "code";
|
|
6
|
+
page_id: number | string;
|
|
7
|
+
page_code: string;
|
|
8
|
+
page_version?: string;
|
|
9
|
+
page_name: string;
|
|
10
|
+
router: string;
|
|
11
|
+
category: "page" | "component" | "function";
|
|
12
|
+
Component?: any;
|
|
13
|
+
children?: any;
|
|
14
|
+
layout?: string;
|
|
15
|
+
originalUrl?: string;
|
|
16
|
+
};
|
|
17
|
+
export type ApplicationData = {
|
|
18
|
+
app_id: number;
|
|
19
|
+
app_name: string;
|
|
20
|
+
app_type: "system" | "custom";
|
|
21
|
+
interfaces: ApplicationInterface[];
|
|
22
|
+
functions?: any[];
|
|
23
|
+
menu?: {
|
|
24
|
+
[key: string]: MenuItem[];
|
|
25
|
+
};
|
|
26
|
+
locales?: LoadLibraryByUrlParams;
|
|
27
|
+
[key: string]: any;
|
|
28
|
+
};
|
|
29
|
+
export declare class Application {
|
|
30
|
+
options: ApplicationData;
|
|
31
|
+
name: ApplicationData["app_name"];
|
|
32
|
+
interfaces: Map<ApplicationInterface["page_name"], ApplicationInterface>;
|
|
33
|
+
components: Map<string, any>;
|
|
34
|
+
functions: Map<string, any>;
|
|
35
|
+
app: App;
|
|
36
|
+
constructor(options: ApplicationData, app: App);
|
|
37
|
+
afterAdd(application: Application): Promise<void>;
|
|
38
|
+
beforeLoad(): Promise<void>;
|
|
39
|
+
load(): Promise<void>;
|
|
40
|
+
initInterfaces(interfaces: ApplicationData["interfaces"]): void;
|
|
41
|
+
initFunctions(functions: ApplicationData["functions"]): void;
|
|
42
|
+
loadInterface(interfaceItem: ApplicationInterface): Promise<ApplicationInterface>;
|
|
43
|
+
setInterface(code: string, interfaceItem: ApplicationInterface): void;
|
|
44
|
+
setComponent(code: string, component: ApplicationInterface): void;
|
|
45
|
+
setFunction(code: string, functionItem: ApplicationInterface): void;
|
|
46
|
+
getInterface(code: string): ApplicationInterface | undefined;
|
|
47
|
+
getComponent(code: string): any;
|
|
48
|
+
getFunction(code: string): any;
|
|
49
|
+
runFunction(code: string, params?: any, ...args: any): any;
|
|
50
|
+
}
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
5
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
6
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
7
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
8
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
9
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
10
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
11
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
12
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
13
|
+
export var Application = /*#__PURE__*/function () {
|
|
14
|
+
function Application(options, app) {
|
|
15
|
+
_classCallCheck(this, Application);
|
|
16
|
+
_defineProperty(this, "options", void 0);
|
|
17
|
+
_defineProperty(this, "name", void 0);
|
|
18
|
+
// 应用内的interface
|
|
19
|
+
_defineProperty(this, "interfaces", new Map());
|
|
20
|
+
// 应用内的组件
|
|
21
|
+
_defineProperty(this, "components", new Map());
|
|
22
|
+
// 应用内的函数, 比如跳转登录页面的方法
|
|
23
|
+
_defineProperty(this, "functions", new Map());
|
|
24
|
+
_defineProperty(this, "app", void 0);
|
|
25
|
+
this.options = options;
|
|
26
|
+
this.name = options.app_name;
|
|
27
|
+
this.app = app;
|
|
28
|
+
this.initInterfaces(options.interfaces);
|
|
29
|
+
this.initFunctions(options.functions);
|
|
30
|
+
}
|
|
31
|
+
_createClass(Application, [{
|
|
32
|
+
key: "afterAdd",
|
|
33
|
+
value: function () {
|
|
34
|
+
var _afterAdd = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(application) {
|
|
35
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
36
|
+
while (1) switch (_context.prev = _context.next) {
|
|
37
|
+
case 0:
|
|
38
|
+
if (application.options.locales) {
|
|
39
|
+
this.app.locales.loadLibraryByUrl(application.options.locales);
|
|
40
|
+
}
|
|
41
|
+
case 1:
|
|
42
|
+
case "end":
|
|
43
|
+
return _context.stop();
|
|
44
|
+
}
|
|
45
|
+
}, _callee, this);
|
|
46
|
+
}));
|
|
47
|
+
function afterAdd(_x) {
|
|
48
|
+
return _afterAdd.apply(this, arguments);
|
|
49
|
+
}
|
|
50
|
+
return afterAdd;
|
|
51
|
+
}()
|
|
52
|
+
}, {
|
|
53
|
+
key: "beforeLoad",
|
|
54
|
+
value: function () {
|
|
55
|
+
var _beforeLoad = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
56
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
57
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
58
|
+
case 0:
|
|
59
|
+
case "end":
|
|
60
|
+
return _context2.stop();
|
|
61
|
+
}
|
|
62
|
+
}, _callee2);
|
|
63
|
+
}));
|
|
64
|
+
function beforeLoad() {
|
|
65
|
+
return _beforeLoad.apply(this, arguments);
|
|
66
|
+
}
|
|
67
|
+
return beforeLoad;
|
|
68
|
+
}()
|
|
69
|
+
}, {
|
|
70
|
+
key: "load",
|
|
71
|
+
value: function () {
|
|
72
|
+
var _load = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
73
|
+
var _this = this;
|
|
74
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
75
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
76
|
+
case 0:
|
|
77
|
+
// 将interface 生成路由
|
|
78
|
+
this.interfaces.forEach(function (item, key) {
|
|
79
|
+
_this.app.router.add(item.router, item);
|
|
80
|
+
});
|
|
81
|
+
case 1:
|
|
82
|
+
case "end":
|
|
83
|
+
return _context3.stop();
|
|
84
|
+
}
|
|
85
|
+
}, _callee3, this);
|
|
86
|
+
}));
|
|
87
|
+
function load() {
|
|
88
|
+
return _load.apply(this, arguments);
|
|
89
|
+
}
|
|
90
|
+
return load;
|
|
91
|
+
}()
|
|
92
|
+
}, {
|
|
93
|
+
key: "initInterfaces",
|
|
94
|
+
value: function initInterfaces(interfaces) {
|
|
95
|
+
var _this2 = this;
|
|
96
|
+
interfaces.forEach( /*#__PURE__*/function () {
|
|
97
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(interfaceItem) {
|
|
98
|
+
var _interface;
|
|
99
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
100
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
101
|
+
case 0:
|
|
102
|
+
_context4.next = 2;
|
|
103
|
+
return _this2.loadInterface(interfaceItem);
|
|
104
|
+
case 2:
|
|
105
|
+
_interface = _context4.sent;
|
|
106
|
+
if (interfaceItem.category === "page") {
|
|
107
|
+
_this2.setInterface(interfaceItem.page_code, _interface);
|
|
108
|
+
}
|
|
109
|
+
if (interfaceItem.category === "component") {
|
|
110
|
+
_this2.setComponent(interfaceItem.page_code, _interface);
|
|
111
|
+
}
|
|
112
|
+
if (interfaceItem.category === "function") {
|
|
113
|
+
_this2.setFunction(interfaceItem.page_code, _interface);
|
|
114
|
+
}
|
|
115
|
+
case 6:
|
|
116
|
+
case "end":
|
|
117
|
+
return _context4.stop();
|
|
118
|
+
}
|
|
119
|
+
}, _callee4);
|
|
120
|
+
}));
|
|
121
|
+
return function (_x2) {
|
|
122
|
+
return _ref.apply(this, arguments);
|
|
123
|
+
};
|
|
124
|
+
}());
|
|
125
|
+
}
|
|
126
|
+
}, {
|
|
127
|
+
key: "initFunctions",
|
|
128
|
+
value: function initFunctions(functions) {
|
|
129
|
+
var _this3 = this;
|
|
130
|
+
(functions || []).forEach( /*#__PURE__*/function () {
|
|
131
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(functionItem) {
|
|
132
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
133
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
134
|
+
case 0:
|
|
135
|
+
_this3.setFunction(functionItem.function_code, functionItem);
|
|
136
|
+
case 1:
|
|
137
|
+
case "end":
|
|
138
|
+
return _context5.stop();
|
|
139
|
+
}
|
|
140
|
+
}, _callee5);
|
|
141
|
+
}));
|
|
142
|
+
return function (_x3) {
|
|
143
|
+
return _ref2.apply(this, arguments);
|
|
144
|
+
};
|
|
145
|
+
}());
|
|
146
|
+
}
|
|
147
|
+
}, {
|
|
148
|
+
key: "loadInterface",
|
|
149
|
+
value: function () {
|
|
150
|
+
var _loadInterface = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(interfaceItem) {
|
|
151
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
152
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
153
|
+
case 0:
|
|
154
|
+
if (!interfaceItem.Component) {
|
|
155
|
+
_context6.next = 2;
|
|
156
|
+
break;
|
|
157
|
+
}
|
|
158
|
+
return _context6.abrupt("return", interfaceItem);
|
|
159
|
+
case 2:
|
|
160
|
+
if (interfaceItem.page_type === "low_code") {
|
|
161
|
+
// TODO: load low code interface
|
|
162
|
+
}
|
|
163
|
+
if (interfaceItem.page_type === "code") {
|
|
164
|
+
// TODO: load code interface
|
|
165
|
+
}
|
|
166
|
+
return _context6.abrupt("return", interfaceItem);
|
|
167
|
+
case 5:
|
|
168
|
+
case "end":
|
|
169
|
+
return _context6.stop();
|
|
170
|
+
}
|
|
171
|
+
}, _callee6);
|
|
172
|
+
}));
|
|
173
|
+
function loadInterface(_x4) {
|
|
174
|
+
return _loadInterface.apply(this, arguments);
|
|
175
|
+
}
|
|
176
|
+
return loadInterface;
|
|
177
|
+
}()
|
|
178
|
+
}, {
|
|
179
|
+
key: "setInterface",
|
|
180
|
+
value: function setInterface(code, interfaceItem) {
|
|
181
|
+
this.interfaces.set(code, interfaceItem);
|
|
182
|
+
}
|
|
183
|
+
}, {
|
|
184
|
+
key: "setComponent",
|
|
185
|
+
value: function setComponent(code, component) {
|
|
186
|
+
this.components.set(code, component);
|
|
187
|
+
}
|
|
188
|
+
}, {
|
|
189
|
+
key: "setFunction",
|
|
190
|
+
value: function setFunction(code, functionItem) {
|
|
191
|
+
this.functions.set(code, functionItem);
|
|
192
|
+
}
|
|
193
|
+
}, {
|
|
194
|
+
key: "getInterface",
|
|
195
|
+
value: function getInterface(code) {
|
|
196
|
+
return this.interfaces.get(code);
|
|
197
|
+
}
|
|
198
|
+
}, {
|
|
199
|
+
key: "getComponent",
|
|
200
|
+
value: function getComponent(code) {
|
|
201
|
+
return this.components.get(code);
|
|
202
|
+
}
|
|
203
|
+
}, {
|
|
204
|
+
key: "getFunction",
|
|
205
|
+
value: function getFunction(code) {
|
|
206
|
+
return this.functions.get(code);
|
|
207
|
+
}
|
|
208
|
+
}, {
|
|
209
|
+
key: "runFunction",
|
|
210
|
+
value: function runFunction(code, params) {
|
|
211
|
+
var _this$getFunction;
|
|
212
|
+
// 合并参数
|
|
213
|
+
var _params = _objectSpread({
|
|
214
|
+
app: this.app
|
|
215
|
+
}, params);
|
|
216
|
+
for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
|
217
|
+
args[_key - 2] = arguments[_key];
|
|
218
|
+
}
|
|
219
|
+
return (_this$getFunction = this.getFunction(code)) === null || _this$getFunction === void 0 ? void 0 : _this$getFunction.code.apply(_this$getFunction, [_params].concat(args));
|
|
220
|
+
}
|
|
221
|
+
}]);
|
|
222
|
+
return Application;
|
|
223
|
+
}();
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import APP from "../app";
|
|
2
|
+
import { Application, ApplicationData } from "./application";
|
|
3
|
+
export declare class ApplicationManager {
|
|
4
|
+
applicationList: Application[];
|
|
5
|
+
protected app: APP;
|
|
6
|
+
applications: Map<string, Application>;
|
|
7
|
+
constructor(applicationList: Application[], app: APP);
|
|
8
|
+
init(applicationList: Application[] | ApplicationData[]): Promise<unknown>;
|
|
9
|
+
add(application: Application): Promise<void>;
|
|
10
|
+
get(appName: Application["name"]): Application | undefined;
|
|
11
|
+
remove(appName: Application["name"]): void;
|
|
12
|
+
load(): Promise<void>;
|
|
13
|
+
}
|