fdb2 1.0.7 → 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 +764 -226
- 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/server/backups/db_ai_breakout_2026-03-11T08-38-48-677Z.sql +0 -0
|
@@ -1,44 +1,44 @@
|
|
|
1
|
-
import { createApp, getCurrentInstance } from 'vue';
|
|
2
|
-
import BootstrapToast from './toast.vue';
|
|
3
|
-
import { setGlobalToast } from '@/utils/toast';
|
|
4
|
-
|
|
5
|
-
export type ToastType = {
|
|
6
|
-
show: (message: string, title: string, type: string, duration?: number) => void,
|
|
7
|
-
success: (msg: string, title?: string, duration?: number) => void,
|
|
8
|
-
error: (msg: string, title?: string, duration?: number) => void,
|
|
9
|
-
warning: (msg: string, title?: string, duration?: number) => void,
|
|
10
|
-
info: (msg: string, title?: string, duration?: number) => void
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export default {
|
|
14
|
-
install(app: any) {
|
|
15
|
-
// 挂载到DOM
|
|
16
|
-
const toastMount = document.createElement('div');
|
|
17
|
-
document.body.appendChild(toastMount);
|
|
18
|
-
|
|
19
|
-
// 创建Toast实例
|
|
20
|
-
const toastApp = createApp(BootstrapToast);
|
|
21
|
-
const toastInstance = toastApp.mount(toastMount) as any;
|
|
22
|
-
|
|
23
|
-
const toastMethods = {
|
|
24
|
-
show: (message: string, title: string, type: string, duration = 3000) => toastInstance.addToast(title, message, type, duration),
|
|
25
|
-
success: (msg: string, title?: string, duration = 3000) => toastInstance.addToast(title, msg, 'success', duration),
|
|
26
|
-
error: (msg: string, title?: string, duration = 3000) => toastInstance.addToast(title, msg, 'danger', duration),
|
|
27
|
-
warning: (msg: string, title?: string, duration = 3000) => toastInstance.addToast(title, msg, 'warning', duration),
|
|
28
|
-
info: (msg: string, title?: string, duration = 3000) => toastInstance.addToast(title, msg, 'info', duration)
|
|
29
|
-
} as ToastType;
|
|
30
|
-
|
|
31
|
-
// 设置全局toast实例
|
|
32
|
-
setGlobalToast(toastMethods);
|
|
33
|
-
|
|
34
|
-
// 全局注入
|
|
35
|
-
app.config.globalProperties.$toast = toastMethods;
|
|
36
|
-
},
|
|
37
|
-
getToast() {
|
|
38
|
-
const instance = getCurrentInstance();
|
|
39
|
-
if(!instance ) return null;
|
|
40
|
-
// @ts-ignore
|
|
41
|
-
const toast = instance.appContext.config?.globalProperties?.$toast as ToastType;
|
|
42
|
-
return toast;
|
|
43
|
-
}
|
|
1
|
+
import { createApp, getCurrentInstance } from 'vue';
|
|
2
|
+
import BootstrapToast from './toast.vue';
|
|
3
|
+
import { setGlobalToast } from '@/utils/toast';
|
|
4
|
+
|
|
5
|
+
export type ToastType = {
|
|
6
|
+
show: (message: string, title: string, type: string, duration?: number) => void,
|
|
7
|
+
success: (msg: string, title?: string, duration?: number) => void,
|
|
8
|
+
error: (msg: string, title?: string, duration?: number) => void,
|
|
9
|
+
warning: (msg: string, title?: string, duration?: number) => void,
|
|
10
|
+
info: (msg: string, title?: string, duration?: number) => void
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export default {
|
|
14
|
+
install(app: any) {
|
|
15
|
+
// 挂载到DOM
|
|
16
|
+
const toastMount = document.createElement('div');
|
|
17
|
+
document.body.appendChild(toastMount);
|
|
18
|
+
|
|
19
|
+
// 创建Toast实例
|
|
20
|
+
const toastApp = createApp(BootstrapToast);
|
|
21
|
+
const toastInstance = toastApp.mount(toastMount) as any;
|
|
22
|
+
|
|
23
|
+
const toastMethods = {
|
|
24
|
+
show: (message: string, title: string, type: string, duration = 3000) => toastInstance.addToast(title, message, type, duration),
|
|
25
|
+
success: (msg: string, title?: string, duration = 3000) => toastInstance.addToast(title, msg, 'success', duration),
|
|
26
|
+
error: (msg: string, title?: string, duration = 3000) => toastInstance.addToast(title, msg, 'danger', duration),
|
|
27
|
+
warning: (msg: string, title?: string, duration = 3000) => toastInstance.addToast(title, msg, 'warning', duration),
|
|
28
|
+
info: (msg: string, title?: string, duration = 3000) => toastInstance.addToast(title, msg, 'info', duration)
|
|
29
|
+
} as ToastType;
|
|
30
|
+
|
|
31
|
+
// 设置全局toast实例
|
|
32
|
+
setGlobalToast(toastMethods);
|
|
33
|
+
|
|
34
|
+
// 全局注入
|
|
35
|
+
app.config.globalProperties.$toast = toastMethods;
|
|
36
|
+
},
|
|
37
|
+
getToast() {
|
|
38
|
+
const instance = getCurrentInstance();
|
|
39
|
+
if(!instance ) return null;
|
|
40
|
+
// @ts-ignore
|
|
41
|
+
const toast = instance.appContext.config?.globalProperties?.$toast as ToastType;
|
|
42
|
+
return toast;
|
|
43
|
+
}
|
|
44
44
|
};
|
|
@@ -1,58 +1,58 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="toast-container position-fixed top-0 start-50 translate-middle-x p-3">
|
|
3
|
-
<div
|
|
4
|
-
:class="`toast show bg-${toast.type==='error'?'danger': toast.type}-subtle ${toast.removed? 'fade-out': ''}`"
|
|
5
|
-
role="alert"
|
|
6
|
-
v-for="(toast, index) in toasts"
|
|
7
|
-
:key="index"
|
|
8
|
-
>
|
|
9
|
-
<div class="toast-header" v-if="toast.title">
|
|
10
|
-
<strong class="me-auto">{{ toast.title }}</strong>
|
|
11
|
-
<button
|
|
12
|
-
type="button"
|
|
13
|
-
class="btn-close"
|
|
14
|
-
@click="removeToast(index)"
|
|
15
|
-
></button>
|
|
16
|
-
</div>
|
|
17
|
-
<div class="toast-body">{{ toast.message }}</div>
|
|
18
|
-
</div>
|
|
19
|
-
</div>
|
|
20
|
-
</template>
|
|
21
|
-
|
|
22
|
-
<script lang="ts" setup>
|
|
23
|
-
import { reactive } from 'vue';
|
|
24
|
-
|
|
25
|
-
const toasts = reactive<Array<any>>([]);
|
|
26
|
-
const addToast = (title: string, message: string, type: string = 'success', duration = 3000) => {
|
|
27
|
-
const toast = { title, message, type, removed: false };
|
|
28
|
-
toasts.push(toast);
|
|
29
|
-
setTimeout(() => removeToast(toast), duration);
|
|
30
|
-
};
|
|
31
|
-
const removeToast = (toast: any) => {
|
|
32
|
-
const index = toasts.indexOf(toast);
|
|
33
|
-
if(index < 0) return;
|
|
34
|
-
toasts[index].removed = true;
|
|
35
|
-
//console.log('remove toast', toast);
|
|
36
|
-
setTimeout(()=>{
|
|
37
|
-
toasts.splice(index, 1);
|
|
38
|
-
}, 1000);
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
// 暴露方法供全局调用
|
|
42
|
-
defineExpose({ addToast });
|
|
43
|
-
</script>
|
|
44
|
-
|
|
45
|
-
<style scoped>
|
|
46
|
-
/* 覆盖Bootstrap默认样式 */
|
|
47
|
-
.toast-container {
|
|
48
|
-
z-index: 1100;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
.fade-out {
|
|
52
|
-
animation: fadeOut 1s forwards;
|
|
53
|
-
}
|
|
54
|
-
@keyframes fadeOut {
|
|
55
|
-
0% { opacity: 1; transform: translateY(0); }
|
|
56
|
-
100% { opacity: 0; transform: translateY(-120%);}
|
|
57
|
-
}
|
|
1
|
+
<template>
|
|
2
|
+
<div class="toast-container position-fixed top-0 start-50 translate-middle-x p-3">
|
|
3
|
+
<div
|
|
4
|
+
:class="`toast show bg-${toast.type==='error'?'danger': toast.type}-subtle ${toast.removed? 'fade-out': ''}`"
|
|
5
|
+
role="alert"
|
|
6
|
+
v-for="(toast, index) in toasts"
|
|
7
|
+
:key="index"
|
|
8
|
+
>
|
|
9
|
+
<div class="toast-header" v-if="toast.title">
|
|
10
|
+
<strong class="me-auto">{{ toast.title }}</strong>
|
|
11
|
+
<button
|
|
12
|
+
type="button"
|
|
13
|
+
class="btn-close"
|
|
14
|
+
@click="removeToast(index)"
|
|
15
|
+
></button>
|
|
16
|
+
</div>
|
|
17
|
+
<div class="toast-body">{{ toast.message }}</div>
|
|
18
|
+
</div>
|
|
19
|
+
</div>
|
|
20
|
+
</template>
|
|
21
|
+
|
|
22
|
+
<script lang="ts" setup>
|
|
23
|
+
import { reactive } from 'vue';
|
|
24
|
+
|
|
25
|
+
const toasts = reactive<Array<any>>([]);
|
|
26
|
+
const addToast = (title: string, message: string, type: string = 'success', duration = 3000) => {
|
|
27
|
+
const toast = { title, message, type, removed: false };
|
|
28
|
+
toasts.push(toast);
|
|
29
|
+
setTimeout(() => removeToast(toast), duration);
|
|
30
|
+
};
|
|
31
|
+
const removeToast = (toast: any) => {
|
|
32
|
+
const index = toasts.indexOf(toast);
|
|
33
|
+
if(index < 0) return;
|
|
34
|
+
toasts[index].removed = true;
|
|
35
|
+
//console.log('remove toast', toast);
|
|
36
|
+
setTimeout(()=>{
|
|
37
|
+
toasts.splice(index, 1);
|
|
38
|
+
}, 1000);
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
// 暴露方法供全局调用
|
|
42
|
+
defineExpose({ addToast });
|
|
43
|
+
</script>
|
|
44
|
+
|
|
45
|
+
<style scoped>
|
|
46
|
+
/* 覆盖Bootstrap默认样式 */
|
|
47
|
+
.toast-container {
|
|
48
|
+
z-index: 1100;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.fade-out {
|
|
52
|
+
animation: fadeOut 1s forwards;
|
|
53
|
+
}
|
|
54
|
+
@keyframes fadeOut {
|
|
55
|
+
0% { opacity: 1; transform: translateY(0); }
|
|
56
|
+
100% { opacity: 0; transform: translateY(-120%);}
|
|
57
|
+
}
|
|
58
58
|
</style>
|
|
@@ -1,104 +1,104 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<span v-if="loading" class="text-muted">
|
|
3
|
-
<i class="bi bi-hourglass-split"></i> 加载中...
|
|
4
|
-
</span>
|
|
5
|
-
<span v-else-if="error" class="text-danger">
|
|
6
|
-
<i class="bi bi-exclamation-circle"></i> 加载失败
|
|
7
|
-
</span>
|
|
8
|
-
<span v-else-if="userInfo" class="user-info" :title="userInfo.id">
|
|
9
|
-
<span class="user-name">{{ userInfo.name }}</span>
|
|
10
|
-
<span class="user-phone ms-2 text-secondary" v-if="userInfo.mobile">({{ formatPhone(userInfo.mobile) }})</span>
|
|
11
|
-
</span>
|
|
12
|
-
<span v-else class="text-secondary">未知用户</span>
|
|
13
|
-
</template>
|
|
14
|
-
|
|
15
|
-
<script setup lang="ts">
|
|
16
|
-
import { ref, watch, onMounted } from 'vue';
|
|
17
|
-
import * as userServer from '@/service/account'; // 假设用户服务路径
|
|
18
|
-
|
|
19
|
-
// 接收父组件传入的用户ID
|
|
20
|
-
const props = defineProps<{
|
|
21
|
-
userId?: number | null
|
|
22
|
-
}>();
|
|
23
|
-
|
|
24
|
-
// 组件内部状态
|
|
25
|
-
const userInfo = ref<any>(null);
|
|
26
|
-
const loading = ref(false);
|
|
27
|
-
const error = ref(false);
|
|
28
|
-
|
|
29
|
-
// 缓存已查询过的用户信息,避免重复请求
|
|
30
|
-
const userCache = new Map<number, any>();
|
|
31
|
-
|
|
32
|
-
// 格式化手机号(13800138000 -> 138****8000)
|
|
33
|
-
const formatPhone = (phone: string) => {
|
|
34
|
-
// if (phone.length === 11) {
|
|
35
|
-
// return `${phone.slice(0, 3)}****${phone.slice(7)}`;
|
|
36
|
-
// }
|
|
37
|
-
return phone;
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
// 根据用户ID获取用户信息
|
|
41
|
-
const fetchUserInfo = async (userId: number | null | undefined) => {
|
|
42
|
-
// 如果没有用户ID,直接清空显示
|
|
43
|
-
if (!userId || userId <= 0) {
|
|
44
|
-
userInfo.value = null;
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// 检查缓存,如果有直接使用
|
|
49
|
-
if (userCache.has(userId)) {
|
|
50
|
-
userInfo.value = userCache.get(userId) || null;
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
// 发起请求获取用户信息
|
|
55
|
-
loading.value = true;
|
|
56
|
-
error.value = false;
|
|
57
|
-
|
|
58
|
-
try {
|
|
59
|
-
const res = await userServer.getUserDetail(userId);
|
|
60
|
-
if (res.ret === 0 && res.data) {
|
|
61
|
-
const user = res.data;
|
|
62
|
-
userInfo.value = user;
|
|
63
|
-
userCache.set(userId, user); // 存入缓存
|
|
64
|
-
} else {
|
|
65
|
-
throw new Error(res.msg || '获取用户信息失败');
|
|
66
|
-
}
|
|
67
|
-
} catch (err) {
|
|
68
|
-
console.error('获取用户信息失败:', err);
|
|
69
|
-
error.value = true;
|
|
70
|
-
userInfo.value = null;
|
|
71
|
-
} finally {
|
|
72
|
-
loading.value = false;
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
// 当用户ID变化时重新获取信息
|
|
77
|
-
watch(
|
|
78
|
-
() => props.userId,
|
|
79
|
-
(newUserId) => {
|
|
80
|
-
fetchUserInfo(newUserId);
|
|
81
|
-
},
|
|
82
|
-
{ immediate: true } // 组件初始化时立即执行
|
|
83
|
-
);
|
|
84
|
-
|
|
85
|
-
// 组件挂载时执行一次
|
|
86
|
-
onMounted(() => {
|
|
87
|
-
fetchUserInfo(props.userId);
|
|
88
|
-
});
|
|
89
|
-
</script>
|
|
90
|
-
|
|
91
|
-
<style scoped>
|
|
92
|
-
.user-name {
|
|
93
|
-
color: var(--bs-primary);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
.user-name:hover {
|
|
97
|
-
text-decoration: underline;
|
|
98
|
-
cursor: pointer;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
.user-phone {
|
|
102
|
-
font-size: 0.875rem;
|
|
103
|
-
}
|
|
1
|
+
<template>
|
|
2
|
+
<span v-if="loading" class="text-muted">
|
|
3
|
+
<i class="bi bi-hourglass-split"></i> 加载中...
|
|
4
|
+
</span>
|
|
5
|
+
<span v-else-if="error" class="text-danger">
|
|
6
|
+
<i class="bi bi-exclamation-circle"></i> 加载失败
|
|
7
|
+
</span>
|
|
8
|
+
<span v-else-if="userInfo" class="user-info" :title="userInfo.id">
|
|
9
|
+
<span class="user-name">{{ userInfo.name }}</span>
|
|
10
|
+
<span class="user-phone ms-2 text-secondary" v-if="userInfo.mobile">({{ formatPhone(userInfo.mobile) }})</span>
|
|
11
|
+
</span>
|
|
12
|
+
<span v-else class="text-secondary">未知用户</span>
|
|
13
|
+
</template>
|
|
14
|
+
|
|
15
|
+
<script setup lang="ts">
|
|
16
|
+
import { ref, watch, onMounted } from 'vue';
|
|
17
|
+
import * as userServer from '@/service/account'; // 假设用户服务路径
|
|
18
|
+
|
|
19
|
+
// 接收父组件传入的用户ID
|
|
20
|
+
const props = defineProps<{
|
|
21
|
+
userId?: number | null
|
|
22
|
+
}>();
|
|
23
|
+
|
|
24
|
+
// 组件内部状态
|
|
25
|
+
const userInfo = ref<any>(null);
|
|
26
|
+
const loading = ref(false);
|
|
27
|
+
const error = ref(false);
|
|
28
|
+
|
|
29
|
+
// 缓存已查询过的用户信息,避免重复请求
|
|
30
|
+
const userCache = new Map<number, any>();
|
|
31
|
+
|
|
32
|
+
// 格式化手机号(13800138000 -> 138****8000)
|
|
33
|
+
const formatPhone = (phone: string) => {
|
|
34
|
+
// if (phone.length === 11) {
|
|
35
|
+
// return `${phone.slice(0, 3)}****${phone.slice(7)}`;
|
|
36
|
+
// }
|
|
37
|
+
return phone;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
// 根据用户ID获取用户信息
|
|
41
|
+
const fetchUserInfo = async (userId: number | null | undefined) => {
|
|
42
|
+
// 如果没有用户ID,直接清空显示
|
|
43
|
+
if (!userId || userId <= 0) {
|
|
44
|
+
userInfo.value = null;
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// 检查缓存,如果有直接使用
|
|
49
|
+
if (userCache.has(userId)) {
|
|
50
|
+
userInfo.value = userCache.get(userId) || null;
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// 发起请求获取用户信息
|
|
55
|
+
loading.value = true;
|
|
56
|
+
error.value = false;
|
|
57
|
+
|
|
58
|
+
try {
|
|
59
|
+
const res = await userServer.getUserDetail(userId);
|
|
60
|
+
if (res.ret === 0 && res.data) {
|
|
61
|
+
const user = res.data;
|
|
62
|
+
userInfo.value = user;
|
|
63
|
+
userCache.set(userId, user); // 存入缓存
|
|
64
|
+
} else {
|
|
65
|
+
throw new Error(res.msg || '获取用户信息失败');
|
|
66
|
+
}
|
|
67
|
+
} catch (err) {
|
|
68
|
+
console.error('获取用户信息失败:', err);
|
|
69
|
+
error.value = true;
|
|
70
|
+
userInfo.value = null;
|
|
71
|
+
} finally {
|
|
72
|
+
loading.value = false;
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
// 当用户ID变化时重新获取信息
|
|
77
|
+
watch(
|
|
78
|
+
() => props.userId,
|
|
79
|
+
(newUserId) => {
|
|
80
|
+
fetchUserInfo(newUserId);
|
|
81
|
+
},
|
|
82
|
+
{ immediate: true } // 组件初始化时立即执行
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
// 组件挂载时执行一次
|
|
86
|
+
onMounted(() => {
|
|
87
|
+
fetchUserInfo(props.userId);
|
|
88
|
+
});
|
|
89
|
+
</script>
|
|
90
|
+
|
|
91
|
+
<style scoped>
|
|
92
|
+
.user-name {
|
|
93
|
+
color: var(--bs-primary);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.user-name:hover {
|
|
97
|
+
text-decoration: underline;
|
|
98
|
+
cursor: pointer;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
.user-phone {
|
|
102
|
+
font-size: 0.875rem;
|
|
103
|
+
}
|
|
104
104
|
</style>
|