fdb2 1.0.8 → 1.0.9
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 -21
- package/.editorconfig +11 -11
- package/.eslintrc.cjs +14 -14
- package/.eslintrc.json +7 -7
- package/.prettierrc.js +3 -3
- package/.tpl.env +21 -21
- package/.vscodeignore +45 -45
- package/README.md +312 -312
- package/bin/build.sh +28 -28
- package/bin/deploy.sh +8 -8
- package/bin/dev.sh +10 -10
- package/bin/docker/dev-docker-compose.yml +43 -43
- package/bin/docker/dev.Dockerfile +24 -24
- package/bin/docker/prod-docker-compose.yml +17 -17
- package/bin/docker/prod.Dockerfile +29 -29
- package/bin/fdb2.js +220 -220
- package/dist/package.json +29 -29
- package/dist/pnpm-lock.yaml +1042 -354
- package/dist/public/explorer.css +1464 -1437
- package/dist/public/explorer.js +759 -223
- package/dist/public/index.css +1026 -1026
- package/dist/public/index.js +15 -9
- package/dist/public/layout.css +221 -221
- package/dist/public/layout.js +1 -1
- package/dist/public/vue.js +8 -2
- package/dist/scripts/preinstall.js +112 -112
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +8 -0
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.ts +680 -671
- package/dist/server/model/connection.entity.ts +65 -65
- package/dist/server/model/database.entity.ts +245 -245
- package/dist/server/service/connection.service.d.ts +6 -1
- package/dist/server/service/connection.service.d.ts.map +1 -1
- package/dist/server/service/connection.service.js +15 -0
- package/dist/server/service/connection.service.js.map +1 -1
- package/dist/server/service/connection.service.ts +356 -341
- package/dist/server/service/database/base.service.d.ts +27 -0
- package/dist/server/service/database/base.service.d.ts.map +1 -1
- package/dist/server/service/database/base.service.js +17 -0
- package/dist/server/service/database/base.service.js.map +1 -1
- package/dist/server/service/database/base.service.ts +406 -367
- package/dist/server/service/database/cockroachdb.service.d.ts +16 -0
- package/dist/server/service/database/cockroachdb.service.d.ts.map +1 -1
- package/dist/server/service/database/cockroachdb.service.js +220 -154
- package/dist/server/service/database/cockroachdb.service.js.map +1 -1
- package/dist/server/service/database/cockroachdb.service.ts +871 -782
- package/dist/server/service/database/database.service.d.ts +4 -0
- package/dist/server/service/database/database.service.d.ts.map +1 -1
- package/dist/server/service/database/database.service.js +123 -0
- package/dist/server/service/database/database.service.js.map +1 -1
- package/dist/server/service/database/database.service.ts +775 -638
- package/dist/server/service/database/index.ts +6 -6
- package/dist/server/service/database/mongodb.service.d.ts +16 -0
- package/dist/server/service/database/mongodb.service.d.ts.map +1 -1
- package/dist/server/service/database/mongodb.service.js +35 -0
- package/dist/server/service/database/mongodb.service.js.map +1 -1
- package/dist/server/service/database/mongodb.service.ts +39 -1
- package/dist/server/service/database/mssql.service.d.ts +16 -0
- package/dist/server/service/database/mssql.service.d.ts.map +1 -1
- package/dist/server/service/database/mssql.service.js +168 -96
- package/dist/server/service/database/mssql.service.js.map +1 -1
- package/dist/server/service/database/mssql.service.ts +931 -840
- package/dist/server/service/database/mysql.service.d.ts +16 -0
- package/dist/server/service/database/mysql.service.d.ts.map +1 -1
- package/dist/server/service/database/mysql.service.js +189 -80
- package/dist/server/service/database/mysql.service.js.map +1 -1
- package/dist/server/service/database/mysql.service.ts +1025 -890
- package/dist/server/service/database/oracle.service.d.ts +16 -0
- package/dist/server/service/database/oracle.service.d.ts.map +1 -1
- package/dist/server/service/database/oracle.service.js +182 -120
- package/dist/server/service/database/oracle.service.js.map +1 -1
- package/dist/server/service/database/oracle.service.ts +1035 -959
- package/dist/server/service/database/postgres.service.d.ts +16 -0
- package/dist/server/service/database/postgres.service.d.ts.map +1 -1
- package/dist/server/service/database/postgres.service.js +154 -88
- package/dist/server/service/database/postgres.service.js.map +1 -1
- package/dist/server/service/database/postgres.service.ts +960 -871
- package/dist/server/service/database/sap.service.d.ts +16 -0
- package/dist/server/service/database/sap.service.d.ts.map +1 -1
- package/dist/server/service/database/sap.service.js +66 -0
- package/dist/server/service/database/sap.service.js.map +1 -1
- package/dist/server/service/database/sap.service.ts +89 -0
- package/dist/server/service/database/sqlite.service.d.ts +16 -0
- package/dist/server/service/database/sqlite.service.d.ts.map +1 -1
- package/dist/server/service/database/sqlite.service.js +77 -18
- package/dist/server/service/database/sqlite.service.js.map +1 -1
- package/dist/server/service/database/sqlite.service.ts +787 -708
- package/dist/server/service/session.service.ts +158 -158
- package/dist/view/index.html +38 -38
- package/env.d.ts +1 -1
- package/package.json +1 -1
- package/packages/vscode/.vscodeignore +44 -44
- package/packages/vscode/README.md +62 -62
- package/packages/vscode/out/database-services/cockroachdb.service.js +154 -154
- package/packages/vscode/out/database-services/mssql.service.js +96 -96
- package/packages/vscode/out/database-services/mysql.service.js +80 -80
- package/packages/vscode/out/database-services/oracle.service.js +120 -120
- package/packages/vscode/out/database-services/postgres.service.js +88 -88
- package/packages/vscode/out/database-services/sqlite.service.js +18 -18
- package/packages/vscode/out/provider/WebViewProvider.js +32 -32
- package/packages/vscode/package.json +142 -142
- package/packages/vscode/resources/icon.svg +5 -5
- package/packages/vscode/resources/webview/connection.css +41 -41
- package/packages/vscode/resources/webview/database.css +163 -163
- package/packages/vscode/resources/webview/index.html +9 -9
- package/packages/vscode/resources/webview/modules/header.tpl +13 -13
- package/packages/vscode/resources/webview/modules/initial_state.tpl +54 -54
- package/packages/vscode/resources/webview/query.css +104 -104
- package/packages/vscode/src/database-services/base.service.ts +362 -362
- package/packages/vscode/src/database-services/cockroachdb.service.ts +659 -659
- package/packages/vscode/src/database-services/connection.service.ts +340 -340
- package/packages/vscode/src/database-services/database.service.ts +629 -629
- package/packages/vscode/src/database-services/index.ts +6 -6
- package/packages/vscode/src/database-services/model/connection.entity.ts +65 -65
- package/packages/vscode/src/database-services/model/database.entity.ts +245 -245
- package/packages/vscode/src/database-services/mssql.service.ts +722 -722
- package/packages/vscode/src/database-services/mysql.service.ts +760 -760
- package/packages/vscode/src/database-services/oracle.service.ts +831 -831
- package/packages/vscode/src/database-services/postgres.service.ts +740 -740
- package/packages/vscode/src/database-services/sqlite.service.ts +558 -558
- package/packages/vscode/src/extension.ts +76 -76
- package/packages/vscode/src/provider/DatabaseTreeProvider.ts +167 -167
- package/packages/vscode/src/provider/WebViewProvider.ts +277 -277
- package/packages/vscode/src/service/DatabaseServiceBridge.ts +414 -414
- package/packages/vscode/src/typings/connection.ts +90 -90
- package/packages/vscode/tsconfig.json +21 -21
- package/public/index.html +9 -9
- package/public/modules/header.tpl +13 -13
- package/public/modules/initial_state.tpl +54 -54
- package/scripts/preinstall.js +112 -112
- package/server/index.ts +680 -671
- package/server/model/connection.entity.ts +65 -65
- package/server/model/database.entity.ts +245 -245
- package/server/service/connection.service.ts +356 -341
- package/server/service/database/base.service.ts +406 -367
- package/server/service/database/cockroachdb.service.ts +871 -782
- package/server/service/database/database.service.ts +775 -638
- package/server/service/database/index.ts +6 -6
- package/server/service/database/mongodb.service.ts +39 -1
- package/server/service/database/mssql.service.ts +931 -840
- package/server/service/database/mysql.service.ts +1025 -890
- package/server/service/database/oracle.service.ts +1035 -959
- package/server/service/database/postgres.service.ts +960 -871
- package/server/service/database/sap.service.ts +89 -0
- package/server/service/database/sqlite.service.ts +787 -708
- package/server/service/session.service.ts +158 -158
- package/server/tsconfig.json +20 -20
- package/server.js +149 -149
- package/server.pid +1 -0
- package/src/adapter/ajax.ts +135 -135
- package/src/assets/base.css +1 -1
- package/src/assets/database.css +949 -949
- package/src/assets/images/svg/illustrations/illustration-1.svg +1 -1
- package/src/assets/images/svg/illustrations/illustration-2.svg +2 -2
- package/src/assets/images/svg/illustrations/illustration-3.svg +50 -50
- package/src/assets/images/svg/illustrations/illustration-4.svg +1 -1
- package/src/assets/images/svg/illustrations/illustration-5.svg +73 -73
- package/src/assets/images/svg/illustrations/illustration-6.svg +89 -89
- package/src/assets/images/svg/illustrations/illustration-7.svg +39 -39
- package/src/assets/images/svg/separators/curve-2.svg +3 -3
- package/src/assets/images/svg/separators/curve.svg +3 -3
- package/src/assets/images/svg/separators/line.svg +3 -3
- package/src/assets/logo.svg +73 -73
- package/src/assets/main.css +1 -1
- package/src/base/config.ts +20 -20
- package/src/base/detect.ts +134 -134
- package/src/base/entity.ts +92 -92
- package/src/base/eventBus.ts +36 -36
- package/src/components/connection-editor/index.vue +588 -588
- package/src/components/dataGrid/index.vue +104 -104
- package/src/components/dataGrid/pagination.vue +105 -105
- package/src/components/loading/index.vue +42 -42
- package/src/components/modal/index.ts +180 -180
- package/src/components/modal/index.vue +560 -560
- package/src/components/toast/index.ts +43 -43
- package/src/components/toast/toast.vue +57 -57
- package/src/components/user/name.vue +103 -103
- package/src/components/user/selector.vue +416 -416
- package/src/domain/SysConfig.ts +74 -74
- package/src/platform/App.vue +7 -7
- package/src/platform/database/components/connection-detail.vue +1153 -1154
- package/src/platform/database/components/data-editor.vue +477 -477
- package/src/platform/database/components/database-detail.vue +1173 -1172
- package/src/platform/database/components/database-monitor.vue +1085 -1085
- package/src/platform/database/components/db-tools.vue +1264 -816
- package/src/platform/database/components/query-history.vue +1348 -1348
- package/src/platform/database/components/sql-executor.vue +737 -737
- package/src/platform/database/components/sql-query-editor.vue +1045 -1045
- package/src/platform/database/components/table-detail.vue +1375 -1376
- package/src/platform/database/components/table-editor.vue +916 -916
- package/src/platform/database/explorer.vue +1839 -1839
- package/src/platform/database/index.vue +1192 -1192
- package/src/platform/database/layout.vue +366 -366
- package/src/platform/database/router.ts +36 -36
- package/src/platform/database/styles/common.scss +601 -601
- package/src/platform/database/types/common.ts +444 -444
- package/src/platform/database/utils/export.ts +231 -231
- package/src/platform/database/utils/helpers.ts +436 -436
- package/src/platform/index.ts +32 -32
- package/src/platform/router.ts +40 -40
- package/src/platform/vscode/bridge.ts +121 -121
- package/src/platform/vscode/components/ConnectionPanel.vue +272 -272
- package/src/platform/vscode/components/DatabasePanel.vue +532 -532
- package/src/platform/vscode/components/QueryPanel.vue +371 -371
- package/src/platform/vscode/entry/connection.ts +13 -13
- package/src/platform/vscode/entry/database.ts +13 -13
- package/src/platform/vscode/entry/query.ts +13 -13
- package/src/platform/vscode/index.ts +5 -5
- package/src/service/base.ts +133 -127
- package/src/service/database.ts +505 -495
- package/src/service/login.ts +120 -120
- package/src/shims-vue.d.ts +6 -6
- package/src/stores/connection.ts +266 -266
- package/src/stores/session.ts +87 -87
- package/src/typings/database-types.ts +412 -412
- package/src/typings/database.ts +363 -363
- package/src/typings/global.d.ts +58 -58
- package/src/typings/pinia.d.ts +7 -7
- package/src/utils/clipboard.ts +29 -29
- package/src/utils/database-types.ts +242 -242
- package/src/utils/modal.ts +123 -123
- package/src/utils/request.ts +55 -55
- package/src/utils/sleep.ts +3 -3
- package/src/utils/toast.ts +73 -73
- package/src/utils/util.ts +171 -171
- package/src/utils/xlsx.ts +228 -228
- package/tsconfig.json +33 -33
- package/view/index.html +9 -9
- package/view/modules/header.tpl +13 -13
- package/view/modules/initial_state.tpl +19 -19
- package/vite.config.ts +424 -424
- package/vite.config.vscode.ts +47 -47
- package/fdb2.server.pid +0 -1
- package/server/backups/db_ai_breakout_2026-03-11T08-38-48-677Z.sql +0 -0
package/src/utils/modal.ts
CHANGED
|
@@ -1,124 +1,124 @@
|
|
|
1
|
-
import { getCurrentInstance } from 'vue';
|
|
2
|
-
import { getModalInstance, showAlert, showConfirm, type ModalTypeWithMethods } from '@/components/modal';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* 全局Modal工具类
|
|
6
|
-
* 提供统一的弹窗接口
|
|
7
|
-
*/
|
|
8
|
-
export class ModalHelper {
|
|
9
|
-
/**
|
|
10
|
-
* 获取全局modal实例
|
|
11
|
-
*/
|
|
12
|
-
private getModal(): ModalTypeWithMethods|null {
|
|
13
|
-
const instance = getModalInstance();
|
|
14
|
-
if (!instance) {
|
|
15
|
-
console.warn('ModalHelper: Vue实例不存在,使用默认实现');
|
|
16
|
-
return null;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
// @ts-ignore
|
|
20
|
-
return instance;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* 成功提示
|
|
25
|
-
*/
|
|
26
|
-
success(content: string): Promise<boolean> {
|
|
27
|
-
const modal = this.getModal();
|
|
28
|
-
if (modal?.success) {
|
|
29
|
-
return modal.success(content);
|
|
30
|
-
}
|
|
31
|
-
return showAlert(content, 'success') || Promise.resolve(true);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* 错误提示
|
|
36
|
-
*/
|
|
37
|
-
error(content: string | Error, detail?: any): Promise<boolean> {
|
|
38
|
-
const modal = this.getModal();
|
|
39
|
-
|
|
40
|
-
// 处理错误对象
|
|
41
|
-
let errorMessage: string;
|
|
42
|
-
if (content instanceof Error) {
|
|
43
|
-
errorMessage = content.message;
|
|
44
|
-
console.error('Error details:', {
|
|
45
|
-
name: content.name || detail.name,
|
|
46
|
-
message: content.message || detail.message,
|
|
47
|
-
stack: content.stack || detail.stack,
|
|
48
|
-
});
|
|
49
|
-
} else {
|
|
50
|
-
errorMessage = String(content);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
if (modal?.error) {
|
|
54
|
-
return modal.error(errorMessage, detail);
|
|
55
|
-
}
|
|
56
|
-
return showAlert(errorMessage, 'error', detail) || Promise.resolve(true);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* 警告提示
|
|
63
|
-
*/
|
|
64
|
-
warning(content: string): Promise<boolean> {
|
|
65
|
-
const modal = this.getModal();
|
|
66
|
-
if (modal?.warning) {
|
|
67
|
-
return modal.warning(content);
|
|
68
|
-
}
|
|
69
|
-
return showAlert(content, 'warning') || Promise.resolve(true);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* 信息提示
|
|
74
|
-
*/
|
|
75
|
-
info(content: string): Promise<boolean> {
|
|
76
|
-
const modal = this.getModal();
|
|
77
|
-
if (modal?.info) {
|
|
78
|
-
return modal.info(content);
|
|
79
|
-
}
|
|
80
|
-
return showAlert(content, 'info') || Promise.resolve(true);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* 简单提示(替代alert)
|
|
85
|
-
*/
|
|
86
|
-
alert(content: string): Promise<boolean> {
|
|
87
|
-
const modal = this.getModal();
|
|
88
|
-
if (modal?.alert) {
|
|
89
|
-
return modal.alert(content);
|
|
90
|
-
}
|
|
91
|
-
return showAlert(content, 'info') || Promise.resolve(true);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* 确认对话框(替代confirm)
|
|
96
|
-
*/
|
|
97
|
-
confirm(content: string, options?: {
|
|
98
|
-
title?: string;
|
|
99
|
-
onConfirm?: () => void;
|
|
100
|
-
onCancel?: () => void;
|
|
101
|
-
}): Promise<boolean> {
|
|
102
|
-
const modal = this.getModal();
|
|
103
|
-
if (modal?.confirm) {
|
|
104
|
-
return modal.confirm({
|
|
105
|
-
...options,
|
|
106
|
-
content,
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
return showConfirm(content, options) || Promise.resolve(false);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
// 导出单例实例
|
|
114
|
-
export const modal = new ModalHelper();
|
|
115
|
-
|
|
116
|
-
// 兼容性导出
|
|
117
|
-
export const showToast = modal.info.bind(modal);
|
|
118
|
-
export const showError = modal.error.bind(modal);
|
|
119
|
-
export const showSuccess = modal.success.bind(modal);
|
|
120
|
-
export const showWarning = modal.warning.bind(modal);
|
|
121
|
-
|
|
122
|
-
// 替代原生函数
|
|
123
|
-
export const alert = modal.alert.bind(modal);
|
|
1
|
+
import { getCurrentInstance } from 'vue';
|
|
2
|
+
import { getModalInstance, showAlert, showConfirm, type ModalTypeWithMethods } from '@/components/modal';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* 全局Modal工具类
|
|
6
|
+
* 提供统一的弹窗接口
|
|
7
|
+
*/
|
|
8
|
+
export class ModalHelper {
|
|
9
|
+
/**
|
|
10
|
+
* 获取全局modal实例
|
|
11
|
+
*/
|
|
12
|
+
private getModal(): ModalTypeWithMethods|null {
|
|
13
|
+
const instance = getModalInstance();
|
|
14
|
+
if (!instance) {
|
|
15
|
+
console.warn('ModalHelper: Vue实例不存在,使用默认实现');
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// @ts-ignore
|
|
20
|
+
return instance;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* 成功提示
|
|
25
|
+
*/
|
|
26
|
+
success(content: string): Promise<boolean> {
|
|
27
|
+
const modal = this.getModal();
|
|
28
|
+
if (modal?.success) {
|
|
29
|
+
return modal.success(content);
|
|
30
|
+
}
|
|
31
|
+
return showAlert(content, 'success') || Promise.resolve(true);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* 错误提示
|
|
36
|
+
*/
|
|
37
|
+
error(content: string | Error, detail?: any): Promise<boolean> {
|
|
38
|
+
const modal = this.getModal();
|
|
39
|
+
|
|
40
|
+
// 处理错误对象
|
|
41
|
+
let errorMessage: string;
|
|
42
|
+
if (content instanceof Error) {
|
|
43
|
+
errorMessage = content.message;
|
|
44
|
+
console.error('Error details:', {
|
|
45
|
+
name: content.name || detail.name,
|
|
46
|
+
message: content.message || detail.message,
|
|
47
|
+
stack: content.stack || detail.stack,
|
|
48
|
+
});
|
|
49
|
+
} else {
|
|
50
|
+
errorMessage = String(content);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (modal?.error) {
|
|
54
|
+
return modal.error(errorMessage, detail);
|
|
55
|
+
}
|
|
56
|
+
return showAlert(errorMessage, 'error', detail) || Promise.resolve(true);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* 警告提示
|
|
63
|
+
*/
|
|
64
|
+
warning(content: string): Promise<boolean> {
|
|
65
|
+
const modal = this.getModal();
|
|
66
|
+
if (modal?.warning) {
|
|
67
|
+
return modal.warning(content);
|
|
68
|
+
}
|
|
69
|
+
return showAlert(content, 'warning') || Promise.resolve(true);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* 信息提示
|
|
74
|
+
*/
|
|
75
|
+
info(content: string): Promise<boolean> {
|
|
76
|
+
const modal = this.getModal();
|
|
77
|
+
if (modal?.info) {
|
|
78
|
+
return modal.info(content);
|
|
79
|
+
}
|
|
80
|
+
return showAlert(content, 'info') || Promise.resolve(true);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* 简单提示(替代alert)
|
|
85
|
+
*/
|
|
86
|
+
alert(content: string): Promise<boolean> {
|
|
87
|
+
const modal = this.getModal();
|
|
88
|
+
if (modal?.alert) {
|
|
89
|
+
return modal.alert(content);
|
|
90
|
+
}
|
|
91
|
+
return showAlert(content, 'info') || Promise.resolve(true);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* 确认对话框(替代confirm)
|
|
96
|
+
*/
|
|
97
|
+
confirm(content: string, options?: {
|
|
98
|
+
title?: string;
|
|
99
|
+
onConfirm?: () => void;
|
|
100
|
+
onCancel?: () => void;
|
|
101
|
+
}): Promise<boolean> {
|
|
102
|
+
const modal = this.getModal();
|
|
103
|
+
if (modal?.confirm) {
|
|
104
|
+
return modal.confirm({
|
|
105
|
+
...options,
|
|
106
|
+
content,
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
return showConfirm(content, options) || Promise.resolve(false);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// 导出单例实例
|
|
114
|
+
export const modal = new ModalHelper();
|
|
115
|
+
|
|
116
|
+
// 兼容性导出
|
|
117
|
+
export const showToast = modal.info.bind(modal);
|
|
118
|
+
export const showError = modal.error.bind(modal);
|
|
119
|
+
export const showSuccess = modal.success.bind(modal);
|
|
120
|
+
export const showWarning = modal.warning.bind(modal);
|
|
121
|
+
|
|
122
|
+
// 替代原生函数
|
|
123
|
+
export const alert = modal.alert.bind(modal);
|
|
124
124
|
export const confirm = modal.confirm.bind(modal);
|
package/src/utils/request.ts
CHANGED
|
@@ -1,55 +1,55 @@
|
|
|
1
|
-
|
|
2
|
-
import { useSessionStore } from '@/stores/session';
|
|
3
|
-
import Axios from 'axios';
|
|
4
|
-
import type { AxiosRequestConfig } from 'axios';
|
|
5
|
-
|
|
6
|
-
const axios = Axios.create();
|
|
7
|
-
|
|
8
|
-
export async function request(url: string, data?: any, option?: AxiosRequestConfig) {
|
|
9
|
-
|
|
10
|
-
const session = useSessionStore();
|
|
11
|
-
option = {
|
|
12
|
-
...(option || {})
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
option = {
|
|
16
|
-
method: 'POST',
|
|
17
|
-
withCredentials: true,
|
|
18
|
-
...option,
|
|
19
|
-
headers: {
|
|
20
|
-
...(option.headers || {}),
|
|
21
|
-
'x-auth-token': (session.id || ''),
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
let res;
|
|
25
|
-
if(option.method === 'GET' || option.method === 'get') {
|
|
26
|
-
res = await axios.get(url, {
|
|
27
|
-
...option,
|
|
28
|
-
params: {
|
|
29
|
-
...(option.params||{}),
|
|
30
|
-
...data||{}
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
res = await axios.post(url, data, option);
|
|
36
|
-
}
|
|
37
|
-
return res;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export async function post(url: string, data?: any, option?: AxiosRequestConfig) {
|
|
41
|
-
return request(url, data, {
|
|
42
|
-
method: 'post',
|
|
43
|
-
...option,
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
export async function get(url: string, data?: any, option?: AxiosRequestConfig) {
|
|
50
|
-
return request(url, data, {
|
|
51
|
-
method: 'get',
|
|
52
|
-
...option,
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
|
|
1
|
+
|
|
2
|
+
import { useSessionStore } from '@/stores/session';
|
|
3
|
+
import Axios from 'axios';
|
|
4
|
+
import type { AxiosRequestConfig } from 'axios';
|
|
5
|
+
|
|
6
|
+
const axios = Axios.create();
|
|
7
|
+
|
|
8
|
+
export async function request(url: string, data?: any, option?: AxiosRequestConfig) {
|
|
9
|
+
|
|
10
|
+
const session = useSessionStore();
|
|
11
|
+
option = {
|
|
12
|
+
...(option || {})
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
option = {
|
|
16
|
+
method: 'POST',
|
|
17
|
+
withCredentials: true,
|
|
18
|
+
...option,
|
|
19
|
+
headers: {
|
|
20
|
+
...(option.headers || {}),
|
|
21
|
+
'x-auth-token': (session.id || ''),
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
let res;
|
|
25
|
+
if(option.method === 'GET' || option.method === 'get') {
|
|
26
|
+
res = await axios.get(url, {
|
|
27
|
+
...option,
|
|
28
|
+
params: {
|
|
29
|
+
...(option.params||{}),
|
|
30
|
+
...data||{}
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
res = await axios.post(url, data, option);
|
|
36
|
+
}
|
|
37
|
+
return res;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export async function post(url: string, data?: any, option?: AxiosRequestConfig) {
|
|
41
|
+
return request(url, data, {
|
|
42
|
+
method: 'post',
|
|
43
|
+
...option,
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
export async function get(url: string, data?: any, option?: AxiosRequestConfig) {
|
|
50
|
+
return request(url, data, {
|
|
51
|
+
method: 'get',
|
|
52
|
+
...option,
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
|
package/src/utils/sleep.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// 暂停指定时间后再继续执行,默认暂停1000毫秒
|
|
2
|
-
const sleep = (time = 1000): Promise<void> => new Promise(rs => setTimeout(rs, time));
|
|
3
|
-
|
|
1
|
+
// 暂停指定时间后再继续执行,默认暂停1000毫秒
|
|
2
|
+
const sleep = (time = 1000): Promise<void> => new Promise(rs => setTimeout(rs, time));
|
|
3
|
+
|
|
4
4
|
export default sleep;
|
package/src/utils/toast.ts
CHANGED
|
@@ -1,73 +1,73 @@
|
|
|
1
|
-
import { getCurrentInstance } from 'vue';
|
|
2
|
-
|
|
3
|
-
export type ToastType = {
|
|
4
|
-
show: (title: string, message: string, type: string, duration?: number) => void,
|
|
5
|
-
success: (msg: string, title?: string, duration?: number) => void,
|
|
6
|
-
error: (msg: string, title?: string, duration?: number) => void,
|
|
7
|
-
warning: (msg: string, title?: string, duration?: number) => void,
|
|
8
|
-
info: (msg: string, title?: string, duration?: number) => void
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
let globalToast: ToastType | null = null;
|
|
12
|
-
|
|
13
|
-
export function setGlobalToast(toast: ToastType) {
|
|
14
|
-
globalToast = toast;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export function getGlobalToast(): ToastType | null {
|
|
18
|
-
return globalToast;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export class ToastHelper {
|
|
22
|
-
private getToast(): ToastType | null {
|
|
23
|
-
if (globalToast) {
|
|
24
|
-
return globalToast;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const instance = getCurrentInstance();
|
|
28
|
-
if (!instance) {
|
|
29
|
-
console.warn('ToastHelper: Vue实例不存在,请确保已注册toast插件');
|
|
30
|
-
return null;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const toast = instance.appContext.config?.globalProperties?.$toast as ToastType;
|
|
34
|
-
return toast || null;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
success(message: string, title = '', duration = 3000): void {
|
|
38
|
-
const toast = this.getToast();
|
|
39
|
-
if (toast?.success) {
|
|
40
|
-
toast.success(message, title, duration);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
error(message: string, title = '', duration = 3000): void {
|
|
45
|
-
const toast = this.getToast();
|
|
46
|
-
if (toast?.error) {
|
|
47
|
-
toast.error(message, title, duration);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
warning(message: string, title = '', duration = 3000): void {
|
|
52
|
-
const toast = this.getToast();
|
|
53
|
-
if (toast?.warning) {
|
|
54
|
-
toast.warning(message, title, duration);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
info(message: string, title = '', duration = 3000): void {
|
|
59
|
-
const toast = this.getToast();
|
|
60
|
-
if (toast?.info) {
|
|
61
|
-
toast.info(message, title, duration);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
show(title: string, message: string, type: string, duration = 3000): void {
|
|
66
|
-
const toast = this.getToast();
|
|
67
|
-
if (toast?.show) {
|
|
68
|
-
toast.show(message, title, type, duration);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
export const toast = new ToastHelper();
|
|
1
|
+
import { getCurrentInstance } from 'vue';
|
|
2
|
+
|
|
3
|
+
export type ToastType = {
|
|
4
|
+
show: (title: string, message: string, type: string, duration?: number) => void,
|
|
5
|
+
success: (msg: string, title?: string, duration?: number) => void,
|
|
6
|
+
error: (msg: string, title?: string, duration?: number) => void,
|
|
7
|
+
warning: (msg: string, title?: string, duration?: number) => void,
|
|
8
|
+
info: (msg: string, title?: string, duration?: number) => void
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
let globalToast: ToastType | null = null;
|
|
12
|
+
|
|
13
|
+
export function setGlobalToast(toast: ToastType) {
|
|
14
|
+
globalToast = toast;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function getGlobalToast(): ToastType | null {
|
|
18
|
+
return globalToast;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export class ToastHelper {
|
|
22
|
+
private getToast(): ToastType | null {
|
|
23
|
+
if (globalToast) {
|
|
24
|
+
return globalToast;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const instance = getCurrentInstance();
|
|
28
|
+
if (!instance) {
|
|
29
|
+
console.warn('ToastHelper: Vue实例不存在,请确保已注册toast插件');
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const toast = instance.appContext.config?.globalProperties?.$toast as ToastType;
|
|
34
|
+
return toast || null;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
success(message: string, title = '', duration = 3000): void {
|
|
38
|
+
const toast = this.getToast();
|
|
39
|
+
if (toast?.success) {
|
|
40
|
+
toast.success(message, title, duration);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
error(message: string, title = '', duration = 3000): void {
|
|
45
|
+
const toast = this.getToast();
|
|
46
|
+
if (toast?.error) {
|
|
47
|
+
toast.error(message, title, duration);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
warning(message: string, title = '', duration = 3000): void {
|
|
52
|
+
const toast = this.getToast();
|
|
53
|
+
if (toast?.warning) {
|
|
54
|
+
toast.warning(message, title, duration);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
info(message: string, title = '', duration = 3000): void {
|
|
59
|
+
const toast = this.getToast();
|
|
60
|
+
if (toast?.info) {
|
|
61
|
+
toast.info(message, title, duration);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
show(title: string, message: string, type: string, duration = 3000): void {
|
|
66
|
+
const toast = this.getToast();
|
|
67
|
+
if (toast?.show) {
|
|
68
|
+
toast.show(message, title, type, duration);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export const toast = new ToastHelper();
|