fdb2 1.0.0
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/.dockerignore +21 -0
- package/.editorconfig +11 -0
- package/.eslintrc.cjs +14 -0
- package/.eslintrc.json +7 -0
- package/.prettierrc.js +3 -0
- package/.tpl.env +22 -0
- package/README.md +260 -0
- package/bin/build.sh +28 -0
- package/bin/deploy.sh +8 -0
- package/bin/dev.sh +10 -0
- package/bin/docker/.env +4 -0
- package/bin/docker/dev-docker-compose.yml +43 -0
- package/bin/docker/dev.Dockerfile +24 -0
- package/bin/docker/prod-docker-compose.yml +17 -0
- package/bin/docker/prod.Dockerfile +29 -0
- package/bin/fdb2.js +142 -0
- package/data/connections.demo.json +32 -0
- package/env.d.ts +1 -0
- package/nw-build.js +120 -0
- package/nw-dev.js +65 -0
- package/package.json +114 -0
- package/public/favicon.ico +0 -0
- package/public/index.html +9 -0
- package/public/modules/header.tpl +14 -0
- package/public/modules/initial_state.tpl +55 -0
- package/server/index.ts +677 -0
- package/server/model/connection.entity.ts +66 -0
- package/server/model/database.entity.ts +246 -0
- package/server/service/connection.service.ts +334 -0
- package/server/service/database/base.service.ts +363 -0
- package/server/service/database/database.service.ts +510 -0
- package/server/service/database/index.ts +7 -0
- package/server/service/database/mssql.service.ts +723 -0
- package/server/service/database/mysql.service.ts +761 -0
- package/server/service/database/oracle.service.ts +839 -0
- package/server/service/database/postgres.service.ts +744 -0
- package/server/service/database/sqlite.service.ts +559 -0
- package/server/service/session.service.ts +158 -0
- package/server.js +128 -0
- package/src/adapter/ajax.ts +135 -0
- package/src/assets/base.css +1 -0
- package/src/assets/database.css +950 -0
- package/src/assets/images/collapse.png +0 -0
- package/src/assets/images/no-login.png +0 -0
- package/src/assets/images/svg/illustrations/illustration-1.svg +1 -0
- package/src/assets/images/svg/illustrations/illustration-2.svg +2 -0
- package/src/assets/images/svg/illustrations/illustration-3.svg +50 -0
- package/src/assets/images/svg/illustrations/illustration-4.svg +1 -0
- package/src/assets/images/svg/illustrations/illustration-5.svg +73 -0
- package/src/assets/images/svg/illustrations/illustration-6.svg +89 -0
- package/src/assets/images/svg/illustrations/illustration-7.svg +39 -0
- package/src/assets/images/svg/illustrations/illustration-8.svg +1 -0
- package/src/assets/images/svg/separators/curve-2.svg +3 -0
- package/src/assets/images/svg/separators/curve.svg +3 -0
- package/src/assets/images/svg/separators/line.svg +3 -0
- package/src/assets/images/theme/light/screen-1-1000x800.jpg +0 -0
- package/src/assets/images/theme/light/screen-2-1000x800.jpg +0 -0
- package/src/assets/login/bg.jpg +0 -0
- package/src/assets/login/bg.png +0 -0
- package/src/assets/login/left.jpg +0 -0
- package/src/assets/logo.svg +73 -0
- package/src/assets/logo.webp +0 -0
- package/src/assets/main.css +1 -0
- package/src/base/config.ts +20 -0
- package/src/base/detect.ts +134 -0
- package/src/base/entity.ts +92 -0
- package/src/base/eventBus.ts +37 -0
- package/src/base//345/237/272/347/241/200/345/261/202.md +7 -0
- package/src/components/connection-editor/index.vue +590 -0
- package/src/components/dataGrid/index.vue +105 -0
- package/src/components/dataGrid/pagination.vue +106 -0
- package/src/components/loading/index.vue +43 -0
- package/src/components/modal/index.ts +181 -0
- package/src/components/modal/index.vue +560 -0
- package/src/components/toast/index.ts +44 -0
- package/src/components/toast/toast.vue +58 -0
- package/src/components/user/name.vue +104 -0
- package/src/components/user/selector.vue +416 -0
- package/src/domain/SysConfig.ts +74 -0
- package/src/platform/App.vue +8 -0
- package/src/platform/database/components/connection-detail.vue +1154 -0
- package/src/platform/database/components/data-editor.vue +478 -0
- package/src/platform/database/components/data-import-export.vue +1602 -0
- package/src/platform/database/components/database-detail.vue +1173 -0
- package/src/platform/database/components/database-monitor.vue +1086 -0
- package/src/platform/database/components/db-tools.vue +577 -0
- package/src/platform/database/components/query-history.vue +1349 -0
- package/src/platform/database/components/sql-executor.vue +738 -0
- package/src/platform/database/components/sql-query-editor.vue +1046 -0
- package/src/platform/database/components/table-detail.vue +1376 -0
- package/src/platform/database/components/table-editor.vue +690 -0
- package/src/platform/database/explorer.vue +1840 -0
- package/src/platform/database/index.vue +1193 -0
- package/src/platform/database/layout.vue +367 -0
- package/src/platform/database/router.ts +37 -0
- package/src/platform/database/styles/common.scss +602 -0
- package/src/platform/database/types/common.ts +445 -0
- package/src/platform/database/utils/export.ts +232 -0
- package/src/platform/database/utils/helpers.ts +437 -0
- package/src/platform/index.ts +33 -0
- package/src/platform/router.ts +41 -0
- package/src/service/base.ts +128 -0
- package/src/service/database.ts +500 -0
- package/src/service/login.ts +121 -0
- package/src/shims-vue.d.ts +7 -0
- package/src/stores/connection.ts +266 -0
- package/src/stores/session.ts +87 -0
- package/src/typings/database-types.ts +413 -0
- package/src/typings/database.ts +364 -0
- package/src/typings/global.d.ts +58 -0
- package/src/typings/pinia.d.ts +8 -0
- package/src/utils/clipboard.ts +30 -0
- package/src/utils/database-types.ts +243 -0
- package/src/utils/modal.ts +124 -0
- package/src/utils/request.ts +55 -0
- package/src/utils/sleep.ts +4 -0
- package/src/utils/toast.ts +73 -0
- package/src/utils/util.ts +171 -0
- package/src/utils/xlsx.ts +228 -0
- package/tsconfig.json +33 -0
- package/tsconfig.server.json +19 -0
- package/view/index.html +9 -0
- package/view/modules/header.tpl +14 -0
- package/view/modules/initial_state.tpl +20 -0
- package/vite.config.ts +384 -0
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<!-- Generator: Adobe Illustrator 27.5.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
|
3
|
+
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
|
4
|
+
viewBox="0 0 2200 2200" style="enable-background:new 0 0 2200 2200;" xml:space="preserve">
|
|
5
|
+
<g id="Objects">
|
|
6
|
+
<g>
|
|
7
|
+
<linearGradient id="SVGID_1_" gradientUnits="userSpaceOnUse" x1="1100" y1="129.7386" x2="1100" y2="1986.1602">
|
|
8
|
+
<stop offset="0" style="stop-color:#04D8EA"/>
|
|
9
|
+
<stop offset="1" style="stop-color:#123AD0"/>
|
|
10
|
+
</linearGradient>
|
|
11
|
+
<path style="fill:url(#SVGID_1_);" d="M1100,1971.015c-188.469,0-365.829-24.542-499.409-69.104
|
|
12
|
+
c-137.851-45.986-213.768-108.898-213.768-177.147v-299.266c0-6.904,5.597-12.502,12.502-12.502
|
|
13
|
+
c6.905,0,12.502,5.598,12.502,12.502v299.266c0,55.809,71.686,111.732,196.677,153.429
|
|
14
|
+
c131.096,43.734,305.646,67.819,491.497,67.819s360.401-24.085,491.497-67.819c124.991-41.697,196.678-97.62,196.678-153.429
|
|
15
|
+
v-299.266c0-6.904,5.597-12.502,12.502-12.502s12.502,5.598,12.502,12.502v299.266c0,68.249-75.918,131.161-213.768,177.147
|
|
16
|
+
C1465.829,1946.473,1288.469,1971.015,1100,1971.015z"/>
|
|
17
|
+
|
|
18
|
+
<linearGradient id="SVGID_00000103986466880628412640000005085555427086651027_" gradientUnits="userSpaceOnUse" x1="1100" y1="157.2316" x2="1100" y2="2013.6531">
|
|
19
|
+
<stop offset="0" style="stop-color:#04D8EA"/>
|
|
20
|
+
<stop offset="1" style="stop-color:#123AD0"/>
|
|
21
|
+
</linearGradient>
|
|
22
|
+
<path style="fill:url(#SVGID_00000103986466880628412640000005085555427086651027_);" d="M1100,1554.507
|
|
23
|
+
c-188.469,0-365.829-24.542-499.409-69.104c-137.85-45.987-213.768-108.9-213.768-177.148v-299.266
|
|
24
|
+
c0-6.905,5.597-12.502,12.502-12.502c6.905,0,12.502,5.597,12.502,12.502v299.266c0,55.809,71.686,111.732,196.677,153.429
|
|
25
|
+
c131.096,43.735,305.646,67.82,491.497,67.82c185.85,0,360.401-24.085,491.497-67.82
|
|
26
|
+
c124.991-41.697,196.678-97.62,196.678-153.429v-299.266c0-6.905,5.597-12.502,12.502-12.502s12.502,5.597,12.502,12.502v299.266
|
|
27
|
+
c0,68.249-75.917,131.161-213.768,177.148C1465.828,1529.965,1288.469,1554.507,1100,1554.507z"/>
|
|
28
|
+
|
|
29
|
+
<linearGradient id="SVGID_00000031886458925340796210000012289672888456263298_" gradientUnits="userSpaceOnUse" x1="1100" y1="184.7246" x2="1100" y2="2041.1461">
|
|
30
|
+
<stop offset="0" style="stop-color:#04D8EA"/>
|
|
31
|
+
<stop offset="1" style="stop-color:#123AD0"/>
|
|
32
|
+
</linearGradient>
|
|
33
|
+
<path style="fill:url(#SVGID_00000031886458925340796210000012289672888456263298_);" d="M1100,1137.997
|
|
34
|
+
c-188.469,0-365.829-24.542-499.409-69.104c-137.85-45.987-213.768-108.9-213.768-177.148V592.48
|
|
35
|
+
c0-6.905,5.597-12.502,12.502-12.502c6.905,0,12.502,5.597,12.502,12.502v299.266c0,55.809,71.686,111.732,196.677,153.429
|
|
36
|
+
c131.096,43.734,305.646,67.819,491.497,67.819s360.401-24.085,491.497-67.819c124.991-41.697,196.678-97.62,196.678-153.429
|
|
37
|
+
V592.48c0-6.905,5.597-12.502,12.502-12.502s12.502,5.597,12.502,12.502v299.266c0,68.248-75.917,131.161-213.768,177.148
|
|
38
|
+
C1465.829,1113.456,1288.469,1137.997,1100,1137.997z"/>
|
|
39
|
+
|
|
40
|
+
<linearGradient id="SVGID_00000163766843213231212890000002270524868808310195_" gradientUnits="userSpaceOnUse" x1="1100" y1="243.7521" x2="1100" y2="1985.2223">
|
|
41
|
+
<stop offset="0" style="stop-color:#04D8EA"/>
|
|
42
|
+
<stop offset="1" style="stop-color:#123AD0"/>
|
|
43
|
+
</linearGradient>
|
|
44
|
+
<path style="fill:url(#SVGID_00000163766843213231212890000002270524868808310195_);" d="M1100,721.476
|
|
45
|
+
c-188.467,0-365.827-24.541-499.409-69.103C462.74,606.388,386.823,543.48,386.823,475.237
|
|
46
|
+
c0-68.248,75.918-131.161,213.768-177.148c133.58-44.563,310.941-69.104,499.409-69.104s365.829,24.542,499.409,69.104
|
|
47
|
+
c137.851,45.987,213.768,108.9,213.768,177.148c0,68.242-75.918,131.15-213.768,177.136
|
|
48
|
+
C1465.827,696.935,1288.467,721.476,1100,721.476z M1100,253.989c-185.85,0-360.401,24.085-491.497,67.819
|
|
49
|
+
c-124.991,41.697-196.677,97.62-196.677,153.429c0,55.803,71.686,111.722,196.677,153.418
|
|
50
|
+
c131.098,43.733,305.648,67.818,491.497,67.818c185.848,0,360.399-24.085,491.497-67.818
|
|
51
|
+
c124.991-41.695,196.678-97.615,196.678-153.418c0-55.809-71.687-111.732-196.678-153.429
|
|
52
|
+
C1460.401,278.074,1285.85,253.989,1100,253.989z"/>
|
|
53
|
+
|
|
54
|
+
<linearGradient id="SVGID_00000132810544753024625480000015798895142198034064_" gradientUnits="userSpaceOnUse" x1="563.2605" y1="243.7521" x2="563.2605" y2="1985.2223">
|
|
55
|
+
<stop offset="0" style="stop-color:#04D8EA"/>
|
|
56
|
+
<stop offset="1" style="stop-color:#123AD0"/>
|
|
57
|
+
</linearGradient>
|
|
58
|
+
<circle style="fill:url(#SVGID_00000132810544753024625480000015798895142198034064_);" cx="563.26" cy="819.38" r="28.589"/>
|
|
59
|
+
|
|
60
|
+
<linearGradient id="SVGID_00000089546958102350120530000006844826025430641287_" gradientUnits="userSpaceOnUse" x1="563.2605" y1="243.7521" x2="563.2605" y2="1985.2223">
|
|
61
|
+
<stop offset="0" style="stop-color:#04D8EA"/>
|
|
62
|
+
<stop offset="1" style="stop-color:#123AD0"/>
|
|
63
|
+
</linearGradient>
|
|
64
|
+
<circle style="fill:url(#SVGID_00000089546958102350120530000006844826025430641287_);" cx="563.26" cy="1243.191" r="28.589"/>
|
|
65
|
+
|
|
66
|
+
<linearGradient id="SVGID_00000031914378609623124750000000956243823947244183_" gradientUnits="userSpaceOnUse" x1="563.2605" y1="243.7521" x2="563.2605" y2="1985.2223">
|
|
67
|
+
<stop offset="0" style="stop-color:#04D8EA"/>
|
|
68
|
+
<stop offset="1" style="stop-color:#123AD0"/>
|
|
69
|
+
</linearGradient>
|
|
70
|
+
<circle style="fill:url(#SVGID_00000031914378609623124750000000956243823947244183_);" cx="563.26" cy="1667.002" r="28.589"/>
|
|
71
|
+
</g>
|
|
72
|
+
</g>
|
|
73
|
+
</svg>
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@import './base.css';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// 基础配置
|
|
2
|
+
|
|
3
|
+
const state = window.__INITIAL_STATE__ || {};
|
|
4
|
+
|
|
5
|
+
const config = state.config || {};
|
|
6
|
+
|
|
7
|
+
const prefix = config.prefix || '';
|
|
8
|
+
const apiUrl = config.apiUrl || '';
|
|
9
|
+
|
|
10
|
+
export default {
|
|
11
|
+
...config,
|
|
12
|
+
state,
|
|
13
|
+
prefix,
|
|
14
|
+
apiUrl,
|
|
15
|
+
// api的根URL
|
|
16
|
+
baseURL: `${location.origin}` + prefix,
|
|
17
|
+
// xhr的超时时间
|
|
18
|
+
timeout: 3e4,
|
|
19
|
+
logUrl: prefix + '/api/monitor/log',
|
|
20
|
+
};
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
|
|
2
|
+
// @ts-ignore // 在nwjs中
|
|
3
|
+
export const isNWjs = typeof process !== 'undefined' && process.__nwjs !== undefined;
|
|
4
|
+
// @ts-ignore 扩展进程
|
|
5
|
+
export const isVSCode = typeof acquireVsCodeApi !== 'undefined' || (typeof process !== 'undefined' && process.env.VSCODE_PID);
|
|
6
|
+
// @ts-ignore 判断是否是 Chrome 扩展环境
|
|
7
|
+
export const isChromeExtension = !isNWjs && !isVSCode && (()=>{try{return typeof chrome !== 'undefined' && Boolean(chrome?.runtime) && Boolean(chrome?.runtime?.id)}catch(e){return false}})();
|
|
8
|
+
// @ts-ignore 检查是否是 Electron
|
|
9
|
+
export const isElectron = typeof process === 'object' && process.versions?.electron !== undefined;
|
|
10
|
+
export const isBrowser = typeof window !== 'undefined' && !isNWjs && !isVSCode && !isChromeExtension && !isElectron;
|
|
11
|
+
// 在iframe中
|
|
12
|
+
export const isInIframe = isBrowser && window.top !== window;
|
|
13
|
+
// 探测运行环境并标记各个全局环境变量
|
|
14
|
+
const UA = isBrowser? navigator.userAgent: '';
|
|
15
|
+
|
|
16
|
+
// 平台
|
|
17
|
+
export enum PLATFORM {
|
|
18
|
+
UNKNOWN = 'unknown',
|
|
19
|
+
WEB = 'web',
|
|
20
|
+
PCWEIXIN = 'pcweixin',
|
|
21
|
+
WEIXIN = 'weixin',
|
|
22
|
+
WEWORK = 'wework',// 企业微信
|
|
23
|
+
MQQ = 'mqq',
|
|
24
|
+
// 微信小程序
|
|
25
|
+
MINA = 'mina',
|
|
26
|
+
// 嵌入iframe中
|
|
27
|
+
IFRAME = 'iframe',
|
|
28
|
+
}
|
|
29
|
+
export const IS_WINDOWS = /WindowsWechat/i.test(UA);
|
|
30
|
+
export const IS_MOBILE = /Mobile/i.test(UA);
|
|
31
|
+
// 系统
|
|
32
|
+
export enum SYSTEM {
|
|
33
|
+
UNKNOWN = 'unknown',
|
|
34
|
+
ANDROID = 'android',
|
|
35
|
+
IOS = 'ios',
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const VER_MQQ = UA.match(/QQ\/([\d.]+)/i) && UA.match(/QQ\/([\d.]+)/i)?.[1];
|
|
39
|
+
export const IS_MQQ = Boolean(VER_MQQ);
|
|
40
|
+
// 微信版本号可能分4段,影响业务代码里使用semver比较版本号(会报错),如果业务需要4段版本号可以自己从ua里取
|
|
41
|
+
const VER_WEIXIN =
|
|
42
|
+
UA.match(/MicroMessenger\/([\d.]+)/i) &&
|
|
43
|
+
UA.match(/MicroMessenger\/([\d.]+)/i)?.[1]?.split('.').slice(0, 3).join('.');
|
|
44
|
+
export const IS_WEIXIN = Boolean(VER_WEIXIN);
|
|
45
|
+
|
|
46
|
+
// 是否是开发者工具
|
|
47
|
+
export const IS_WECHATTOOLS = /wechatdevtools\//i.test(UA);
|
|
48
|
+
// @ts-ignore
|
|
49
|
+
export const IS_WKWEBVIEW = isBrowser && window.__wxjs_is_wkwebview;
|
|
50
|
+
export const IS_PCWEIXIN = /(Windows|Mac)Wechat/i.test(UA);
|
|
51
|
+
// 是否是企业微信
|
|
52
|
+
export const IS_WXWORK = /wxwork\//i.test(UA);
|
|
53
|
+
// @ts-ignore
|
|
54
|
+
const VER_MINA = isBrowser && (window.__wxjs_environment === 'miniprogram' || /miniProgram/i.test(UA));
|
|
55
|
+
export const IS_MINA = Boolean(VER_MINA);
|
|
56
|
+
|
|
57
|
+
let platformVersion = '0.0.0';
|
|
58
|
+
let platformID = PLATFORM.WEB;
|
|
59
|
+
let platformName = '';
|
|
60
|
+
if (IS_MQQ) {
|
|
61
|
+
platformID = PLATFORM.MQQ;
|
|
62
|
+
platformVersion = VER_MQQ as string;
|
|
63
|
+
platformName = '手机QQ';
|
|
64
|
+
} else if (IS_MINA) {
|
|
65
|
+
platformID = PLATFORM.MINA;
|
|
66
|
+
platformVersion = VER_WEIXIN || '0.0.0';
|
|
67
|
+
platformName = '微信小程序';
|
|
68
|
+
} else if (IS_PCWEIXIN) {
|
|
69
|
+
platformID = PLATFORM.PCWEIXIN;
|
|
70
|
+
platformVersion = VER_WEIXIN as string;
|
|
71
|
+
platformName = '微信';
|
|
72
|
+
} else if (IS_WEIXIN) {
|
|
73
|
+
platformID = PLATFORM.WEIXIN;
|
|
74
|
+
platformVersion = VER_WEIXIN || '0.0.0';
|
|
75
|
+
platformName = '微信';
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const os: { version: string; android: boolean; ios: boolean; iphone: boolean; ipad: boolean; x5: boolean } = {
|
|
79
|
+
version: '0.0.0',
|
|
80
|
+
android: false,
|
|
81
|
+
ios: false,
|
|
82
|
+
iphone: false,
|
|
83
|
+
ipad: false,
|
|
84
|
+
x5: false,
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
const webkit = UA.match(/Web[kK]it[/]{0,1}([\d.]+)/),
|
|
88
|
+
android = UA.match(/(Android);?[\s/]+([\d.]+)?/),
|
|
89
|
+
osx = !!UA.match(/\(Macintosh; Intel /),
|
|
90
|
+
ipad = UA.match(/(iPad).*OS\s([\d_]+)/),
|
|
91
|
+
ipod = UA.match(/(iPod)(.*OS\s([\d_]+))?/),
|
|
92
|
+
iphone = !ipad && UA.match(/(iPhone\sOS)\s([\d_]+)/),
|
|
93
|
+
webos = UA.match(/(webOS|hpwOS)[\s/]([\d.]+)/),
|
|
94
|
+
win = /Win\d{2}|Windows/.test(navigator.platform),
|
|
95
|
+
blackberry = UA.match(/(BlackBerry).*Version\/([\d.]+)/),
|
|
96
|
+
bb10 = UA.match(/(BB10).*Version\/([\d.]+)/),
|
|
97
|
+
playbook = UA.match(/PlayBook/),
|
|
98
|
+
chrome = UA.match(/Chrome\/([\d.]+)/) || UA.match(/CriOS\/([\d.]+)/),
|
|
99
|
+
x5 = UA.match(/MQQBrowser\/([\d.]+)/i),
|
|
100
|
+
ie = UA.match(/MSIE\s([\d.]+)/) || UA.match(/Trident\/[\d](?=[^?]+).*rv:([0-9.].)/),
|
|
101
|
+
webview = !chrome && UA.match(/(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari)/),
|
|
102
|
+
safari = webview || UA.match(/Version\/([\d.]+)([^S](Safari)|[^M]*(Mobile)[^S]*(Safari))/);
|
|
103
|
+
|
|
104
|
+
if (android) {
|
|
105
|
+
(os.android = true), (os.version = android[2] as string);
|
|
106
|
+
}
|
|
107
|
+
if (iphone && !ipod) {
|
|
108
|
+
(os.ios = os.iphone = true), (os.version = iphone[2]?.replace(/_/g, '.') as string);
|
|
109
|
+
}
|
|
110
|
+
if (ipad) {
|
|
111
|
+
(os.ios = os.ipad = true), (os.version = ipad[2]?.replace(/_/g, '.') as string);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
if (x5) {
|
|
115
|
+
(os.x5 = true), (os.version = x5[1] as string);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
let system = SYSTEM.UNKNOWN;
|
|
119
|
+
if (os.ios) {
|
|
120
|
+
system = SYSTEM.IOS;
|
|
121
|
+
} else if (os.android) {
|
|
122
|
+
system = SYSTEM.ANDROID;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
let IS_IPHONEX = false;
|
|
126
|
+
if (os.ios) {
|
|
127
|
+
if (screen.height == 812 && screen.width == 375) {
|
|
128
|
+
IS_IPHONEX = true;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
export { platformID as platform, platformVersion, platformName };
|
|
132
|
+
export { os };
|
|
133
|
+
export { system };
|
|
134
|
+
export { IS_IPHONEX };
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import EventEmitter from '@fefeding/eventemitter';
|
|
2
|
+
/**
|
|
3
|
+
* @public
|
|
4
|
+
* An interface to define a callback function with any number and type of parameters, and any return.
|
|
5
|
+
*/
|
|
6
|
+
export interface CallBack {
|
|
7
|
+
(...args: any[]): any;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @public
|
|
13
|
+
* @param newValue - The new state value.
|
|
14
|
+
* @param oldValue - The previous state value.
|
|
15
|
+
* @param key - The key which the state value was updated.
|
|
16
|
+
*/
|
|
17
|
+
export interface WatchCallBack {
|
|
18
|
+
(
|
|
19
|
+
newValue: Record<string, any>,
|
|
20
|
+
oldVaule: Record<string, any>,
|
|
21
|
+
key: string
|
|
22
|
+
): void;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// 菜单项类型
|
|
26
|
+
export type MenuItem = {
|
|
27
|
+
id: string,
|
|
28
|
+
name: string,
|
|
29
|
+
icon?: string,
|
|
30
|
+
path?: string;
|
|
31
|
+
/**
|
|
32
|
+
* 是否展开
|
|
33
|
+
*/
|
|
34
|
+
expanded?: boolean,
|
|
35
|
+
children?: Array<MenuItem>;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* @public
|
|
40
|
+
* Entity class with watchable state.
|
|
41
|
+
*/
|
|
42
|
+
export default class Entity<T> extends EventEmitter {
|
|
43
|
+
/**
|
|
44
|
+
* 状态
|
|
45
|
+
* @public
|
|
46
|
+
*/
|
|
47
|
+
state: T;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* @public
|
|
51
|
+
* @param data - initialization data.
|
|
52
|
+
*/
|
|
53
|
+
constructor(data?:T) {
|
|
54
|
+
super();
|
|
55
|
+
this.state = new Proxy(data || {}, {
|
|
56
|
+
set: (oTarget: any, sKey, vValue) => {
|
|
57
|
+
if (oTarget[sKey] !== vValue) {
|
|
58
|
+
const oldValue = { ...oTarget };
|
|
59
|
+
oTarget[sKey] = vValue;
|
|
60
|
+
// 这里不传入this.state, 避免在update回调那里再修改state,造成死循环
|
|
61
|
+
this.emit('update', { ...oTarget }, oldValue, sKey);
|
|
62
|
+
// if (typeof sKey === 'string') {
|
|
63
|
+
// this.emit(`update:${sKey}`, oTarget[sKey], oldValue[sKey]);
|
|
64
|
+
// }
|
|
65
|
+
}
|
|
66
|
+
return true;
|
|
67
|
+
},
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* @public
|
|
72
|
+
* @param cb - Callback function to execute on state updates.
|
|
73
|
+
* return Callback to lift the watch state.
|
|
74
|
+
*/
|
|
75
|
+
watch(cb: WatchCallBack): CallBack {
|
|
76
|
+
this.on('update', cb);
|
|
77
|
+
return () => this.off('update', cb);
|
|
78
|
+
}
|
|
79
|
+
// 目前看,根据key监听暂时用不到
|
|
80
|
+
// watch(cb: WatchCallBack): CallBack;
|
|
81
|
+
// watch(key: string, cb: WatchCallBack): CallBack;
|
|
82
|
+
// watch(keyOrCb: string | WatchCallBack, cb?: WatchCallBack): CallBack {
|
|
83
|
+
// if (typeof keyOrCb === 'string' && cb) {
|
|
84
|
+
// this.on(`update:${keyOrCb}`, cb);
|
|
85
|
+
// return () => this.off('update', cb);
|
|
86
|
+
// } else if (typeof keyOrCb === 'function') {
|
|
87
|
+
// this.on('update', keyOrCb);
|
|
88
|
+
// return () => this.off('update', keyOrCb);
|
|
89
|
+
// }
|
|
90
|
+
// return () => {};
|
|
91
|
+
// }
|
|
92
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
import EventEmitter from '@fefeding/eventemitter';
|
|
4
|
+
|
|
5
|
+
export const AUTHTIMEOUT = 'AUTHTIMEOUT';
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
const GlobalEventBus = new EventEmitter();
|
|
9
|
+
const GlobalEventBusCache = new Map<string|symbol, any>();
|
|
10
|
+
// 订阅
|
|
11
|
+
export function subscribe(name: string|symbol, callback: any) {
|
|
12
|
+
const id = typeof name === 'symbol' ? name : Symbol(name);
|
|
13
|
+
GlobalEventBusCache.set(id, {
|
|
14
|
+
name,
|
|
15
|
+
callback
|
|
16
|
+
});
|
|
17
|
+
GlobalEventBus.on(name, callback);
|
|
18
|
+
|
|
19
|
+
return id;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// 取消订阅
|
|
23
|
+
export function unsubscribe(eventId: string|symbol) {
|
|
24
|
+
const event = GlobalEventBusCache.get(eventId);
|
|
25
|
+
if(event) {
|
|
26
|
+
GlobalEventBus.off(event.name, event.callback);
|
|
27
|
+
GlobalEventBusCache.delete(eventId);
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// 发布事件
|
|
34
|
+
export function publish(name: string|symbol, data?: any) {
|
|
35
|
+
return GlobalEventBus.emit(name, data);
|
|
36
|
+
}
|
|
37
|
+
|