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.
Files changed (125) hide show
  1. package/.dockerignore +21 -0
  2. package/.editorconfig +11 -0
  3. package/.eslintrc.cjs +14 -0
  4. package/.eslintrc.json +7 -0
  5. package/.prettierrc.js +3 -0
  6. package/.tpl.env +22 -0
  7. package/README.md +260 -0
  8. package/bin/build.sh +28 -0
  9. package/bin/deploy.sh +8 -0
  10. package/bin/dev.sh +10 -0
  11. package/bin/docker/.env +4 -0
  12. package/bin/docker/dev-docker-compose.yml +43 -0
  13. package/bin/docker/dev.Dockerfile +24 -0
  14. package/bin/docker/prod-docker-compose.yml +17 -0
  15. package/bin/docker/prod.Dockerfile +29 -0
  16. package/bin/fdb2.js +142 -0
  17. package/data/connections.demo.json +32 -0
  18. package/env.d.ts +1 -0
  19. package/nw-build.js +120 -0
  20. package/nw-dev.js +65 -0
  21. package/package.json +114 -0
  22. package/public/favicon.ico +0 -0
  23. package/public/index.html +9 -0
  24. package/public/modules/header.tpl +14 -0
  25. package/public/modules/initial_state.tpl +55 -0
  26. package/server/index.ts +677 -0
  27. package/server/model/connection.entity.ts +66 -0
  28. package/server/model/database.entity.ts +246 -0
  29. package/server/service/connection.service.ts +334 -0
  30. package/server/service/database/base.service.ts +363 -0
  31. package/server/service/database/database.service.ts +510 -0
  32. package/server/service/database/index.ts +7 -0
  33. package/server/service/database/mssql.service.ts +723 -0
  34. package/server/service/database/mysql.service.ts +761 -0
  35. package/server/service/database/oracle.service.ts +839 -0
  36. package/server/service/database/postgres.service.ts +744 -0
  37. package/server/service/database/sqlite.service.ts +559 -0
  38. package/server/service/session.service.ts +158 -0
  39. package/server.js +128 -0
  40. package/src/adapter/ajax.ts +135 -0
  41. package/src/assets/base.css +1 -0
  42. package/src/assets/database.css +950 -0
  43. package/src/assets/images/collapse.png +0 -0
  44. package/src/assets/images/no-login.png +0 -0
  45. package/src/assets/images/svg/illustrations/illustration-1.svg +1 -0
  46. package/src/assets/images/svg/illustrations/illustration-2.svg +2 -0
  47. package/src/assets/images/svg/illustrations/illustration-3.svg +50 -0
  48. package/src/assets/images/svg/illustrations/illustration-4.svg +1 -0
  49. package/src/assets/images/svg/illustrations/illustration-5.svg +73 -0
  50. package/src/assets/images/svg/illustrations/illustration-6.svg +89 -0
  51. package/src/assets/images/svg/illustrations/illustration-7.svg +39 -0
  52. package/src/assets/images/svg/illustrations/illustration-8.svg +1 -0
  53. package/src/assets/images/svg/separators/curve-2.svg +3 -0
  54. package/src/assets/images/svg/separators/curve.svg +3 -0
  55. package/src/assets/images/svg/separators/line.svg +3 -0
  56. package/src/assets/images/theme/light/screen-1-1000x800.jpg +0 -0
  57. package/src/assets/images/theme/light/screen-2-1000x800.jpg +0 -0
  58. package/src/assets/login/bg.jpg +0 -0
  59. package/src/assets/login/bg.png +0 -0
  60. package/src/assets/login/left.jpg +0 -0
  61. package/src/assets/logo.svg +73 -0
  62. package/src/assets/logo.webp +0 -0
  63. package/src/assets/main.css +1 -0
  64. package/src/base/config.ts +20 -0
  65. package/src/base/detect.ts +134 -0
  66. package/src/base/entity.ts +92 -0
  67. package/src/base/eventBus.ts +37 -0
  68. package/src/base//345/237/272/347/241/200/345/261/202.md +7 -0
  69. package/src/components/connection-editor/index.vue +590 -0
  70. package/src/components/dataGrid/index.vue +105 -0
  71. package/src/components/dataGrid/pagination.vue +106 -0
  72. package/src/components/loading/index.vue +43 -0
  73. package/src/components/modal/index.ts +181 -0
  74. package/src/components/modal/index.vue +560 -0
  75. package/src/components/toast/index.ts +44 -0
  76. package/src/components/toast/toast.vue +58 -0
  77. package/src/components/user/name.vue +104 -0
  78. package/src/components/user/selector.vue +416 -0
  79. package/src/domain/SysConfig.ts +74 -0
  80. package/src/platform/App.vue +8 -0
  81. package/src/platform/database/components/connection-detail.vue +1154 -0
  82. package/src/platform/database/components/data-editor.vue +478 -0
  83. package/src/platform/database/components/data-import-export.vue +1602 -0
  84. package/src/platform/database/components/database-detail.vue +1173 -0
  85. package/src/platform/database/components/database-monitor.vue +1086 -0
  86. package/src/platform/database/components/db-tools.vue +577 -0
  87. package/src/platform/database/components/query-history.vue +1349 -0
  88. package/src/platform/database/components/sql-executor.vue +738 -0
  89. package/src/platform/database/components/sql-query-editor.vue +1046 -0
  90. package/src/platform/database/components/table-detail.vue +1376 -0
  91. package/src/platform/database/components/table-editor.vue +690 -0
  92. package/src/platform/database/explorer.vue +1840 -0
  93. package/src/platform/database/index.vue +1193 -0
  94. package/src/platform/database/layout.vue +367 -0
  95. package/src/platform/database/router.ts +37 -0
  96. package/src/platform/database/styles/common.scss +602 -0
  97. package/src/platform/database/types/common.ts +445 -0
  98. package/src/platform/database/utils/export.ts +232 -0
  99. package/src/platform/database/utils/helpers.ts +437 -0
  100. package/src/platform/index.ts +33 -0
  101. package/src/platform/router.ts +41 -0
  102. package/src/service/base.ts +128 -0
  103. package/src/service/database.ts +500 -0
  104. package/src/service/login.ts +121 -0
  105. package/src/shims-vue.d.ts +7 -0
  106. package/src/stores/connection.ts +266 -0
  107. package/src/stores/session.ts +87 -0
  108. package/src/typings/database-types.ts +413 -0
  109. package/src/typings/database.ts +364 -0
  110. package/src/typings/global.d.ts +58 -0
  111. package/src/typings/pinia.d.ts +8 -0
  112. package/src/utils/clipboard.ts +30 -0
  113. package/src/utils/database-types.ts +243 -0
  114. package/src/utils/modal.ts +124 -0
  115. package/src/utils/request.ts +55 -0
  116. package/src/utils/sleep.ts +4 -0
  117. package/src/utils/toast.ts +73 -0
  118. package/src/utils/util.ts +171 -0
  119. package/src/utils/xlsx.ts +228 -0
  120. package/tsconfig.json +33 -0
  121. package/tsconfig.server.json +19 -0
  122. package/view/index.html +9 -0
  123. package/view/modules/header.tpl +14 -0
  124. package/view/modules/initial_state.tpl +20 -0
  125. package/vite.config.ts +384 -0
@@ -0,0 +1,106 @@
1
+ <template>
2
+ <!-- 分页组件 -->
3
+ <nav aria-label="Page navigation" class="px-3">
4
+ <ul class="pagination">
5
+ <li class="page-item" :class="{ disabled: currentPage === 1 }">
6
+ <a class="page-link" href="#" @click.prevent="prevPage">上一页</a>
7
+ </li>
8
+
9
+ <!-- 生成页码列表 -->
10
+ <li v-for="page in visiblePages"
11
+ :key="page"
12
+ class="page-item"
13
+ :class="{ disabled: page==='...', active: currentPage===page }">
14
+ <a class="page-link"
15
+ href="#"
16
+ @click.prevent="goToPage(page)"
17
+ :tabindex="page==='...'? -1 : 0">
18
+ {{ page }}
19
+ </a>
20
+ </li>
21
+
22
+ <li class="page-item" :class="{ disabled: currentPage === totalPages }">
23
+ <a class="page-link" href="#" @click.prevent="nextPage">下一页</a>
24
+ </li>
25
+ </ul>
26
+ </nav>
27
+ </template>
28
+
29
+ <script setup lang="ts">
30
+ import { computed } from 'vue';
31
+
32
+ const props = defineProps({
33
+ // 总页数
34
+ totalPages: {
35
+ type: Number,
36
+ default: 1
37
+ },
38
+ currentPage: {
39
+ type: Number,
40
+ default: 1,
41
+ },
42
+ });
43
+
44
+ const emits = defineEmits(['pageChanged']);
45
+
46
+ // 可见的页码列表(包括省略号)
47
+ const visiblePages = computed(() => {
48
+ const pages = [] as Array<any>;
49
+ const maxVisiblePages = 5; // 最大可见页码数(不包括省略号)
50
+ const current = props.currentPage;
51
+
52
+ // 总页数较少时,显示所有页码
53
+ if (props.totalPages <= maxVisiblePages) {
54
+ for (let i = 1; i <= props.totalPages; i++) {
55
+ pages.push(i);
56
+ }
57
+ return pages;
58
+ }
59
+
60
+ // 总页数较多时,智能显示部分页码
61
+ if (current <= 3) {
62
+ // 当前页在前3页,显示前5页
63
+ pages.push(1, 2, 3, 4, 5);
64
+ pages.push('...');
65
+ pages.push(props.totalPages);
66
+ } else if (current >= props.totalPages - 2) {
67
+ // 当前页在后3页,显示后5页
68
+ pages.push(1);
69
+ pages.push('...');
70
+ pages.push(props.totalPages - 4, props.totalPages - 3, props.totalPages - 2, props.totalPages - 1, props.totalPages);
71
+ } else {
72
+ // 当前页在中间,显示当前页及其前后2页
73
+ pages.push(1);
74
+ pages.push('...');
75
+ pages.push(current - 2, current - 1, current, current + 1, current + 2);
76
+ pages.push('...');
77
+ pages.push(props.totalPages);
78
+ }
79
+ return pages;
80
+ });
81
+
82
+ // 上一页
83
+ const prevPage = () => {
84
+ if (props.currentPage > 1) {
85
+ emits('pageChanged', props.currentPage - 1);
86
+ }
87
+ };
88
+
89
+ // 下一页
90
+ const nextPage = () => {
91
+ if (props.currentPage < props.totalPages) {
92
+ emits('pageChanged', props.currentPage + 1);
93
+ }
94
+ };
95
+
96
+ // 跳转到指定页
97
+ const goToPage = (page: number|string) => {
98
+ if (typeof page === 'number' && page >= 1 && page <= props.totalPages) {
99
+ emits('pageChanged', page);
100
+ }
101
+ };
102
+ </script>
103
+
104
+ <style scoped>
105
+
106
+ </style>
@@ -0,0 +1,43 @@
1
+ <template>
2
+ <div class="loading-overlay" v-if="isLoading">
3
+ <div class="loading-spinner">
4
+ <div class="spinner-border text-primary" role="status">
5
+ <span class="visually-hidden">Loading...</span>
6
+ </div>
7
+ </div>
8
+ <p v-if="message" class="m-3 text-primary">{{ message }}</p>
9
+ </div>
10
+ </template>
11
+
12
+ <script setup lang="ts">
13
+
14
+ const props = defineProps({
15
+ isLoading: {
16
+ type: Boolean,
17
+ default: false
18
+ },
19
+ message: {
20
+ type: String,
21
+ default: '加载中...'
22
+ }
23
+ })
24
+ </script>
25
+
26
+ <style scoped>
27
+ .loading-overlay {
28
+ position: absolute;
29
+ top: 0;
30
+ left: 0;
31
+ width: 100%;
32
+ height: 100%;
33
+ background-color: rgba(0, 0, 0, 0.3);
34
+ display: flex;
35
+ justify-content: center;
36
+ align-items: center;
37
+ z-index: 1050;
38
+ }
39
+
40
+ .loading-spinner {
41
+ text-align: center;
42
+ }
43
+ </style>
@@ -0,0 +1,181 @@
1
+ import { createApp, getCurrentInstance, nextTick } from 'vue';
2
+ import BootstrapModal from './index.vue';
3
+
4
+ export type ModalType = {
5
+ show: () => void,
6
+ hide: () => void,
7
+ open: () => void,
8
+ close: () => void,
9
+ };
10
+
11
+ // modal方法类型定义
12
+ const modalMethods = {
13
+ alert: {} as (options: ModalOptions | string) => Promise<boolean>,
14
+ confirm: {} as (options: ModalOptions | string) => Promise<boolean>,
15
+ success: {} as (content: string) => Promise<boolean>,
16
+ error: {} as (content: string, details?: any) => Promise<boolean>,
17
+ warning: {} as (content: string) => Promise<boolean>,
18
+ info: {} as (content: string) => Promise<boolean>,
19
+ showModal: {} as (options: ModalOptions) => Promise<boolean>
20
+ };
21
+
22
+ export type ModalTypeWithMethods = ModalType & typeof modalMethods;
23
+
24
+ export type ModalOptions = {
25
+ title?: string;
26
+ content?: string;
27
+ type?: 'success' | 'error' | 'warning' | 'info';
28
+ confirmText?: string;
29
+ cancelText?: string;
30
+ showCancel?: boolean;
31
+ details?: any;
32
+ onConfirm?: () => void;
33
+ onCancel?: () => void;
34
+ };
35
+
36
+ // 全局modal实例
37
+ let globalModalInstance: any = null;
38
+ let modalInstance: ModalTypeWithMethods;
39
+
40
+ export default {
41
+ install(app: any) {
42
+ // 挂载到DOM
43
+ const mount = document.createElement('div');
44
+ document.body.appendChild(mount);
45
+
46
+ // 创建实例
47
+ const modalApp = createApp(BootstrapModal);
48
+ globalModalInstance = modalApp.mount(mount) as any;
49
+
50
+ // 添加事件监听,确保模态框完全隐藏后重置 isModalActive
51
+ if (globalModalInstance && globalModalInstance.$el) {
52
+ const modalElement = globalModalInstance.$el;
53
+ modalElement.addEventListener('hidden.bs.modal', () => {
54
+ isModalActive = false;
55
+ console.log('Modal hidden, isModalActive reset to false');
56
+
57
+ // 处理待显示的modal
58
+ if (pendingModalOptions) {
59
+ const pending = pendingModalOptions;
60
+ pendingModalOptions = null;
61
+ showModal(pending);
62
+ }
63
+ });
64
+ }
65
+
66
+ // 全局注入
67
+ app.config.globalProperties.$modal = modalInstance = {
68
+ show: () => globalModalInstance.show(),
69
+ hide: () => globalModalInstance.hide(),
70
+ open: () => globalModalInstance.show(),
71
+ close: () => globalModalInstance.hide(),
72
+ // 新增方法
73
+ alert(options: ModalOptions | string) {
74
+ const opts = typeof options === 'string'
75
+ ? { content: options, type: 'info' as const, showCancel: false }
76
+ : { ...options, showCancel: false };
77
+ return showModal(opts);
78
+ },
79
+ confirm(options: ModalOptions | string) {
80
+ const opts = typeof options === 'string'
81
+ ? { content: options, type: 'warning' as const }
82
+ : { ...options, showCancel: true };
83
+ return showModal(opts);
84
+ },
85
+ success(content: string) {
86
+ return this.alert({ content, type: 'success' as const, confirmText: '确定' });
87
+ },
88
+ error(content: string, details?: any) {
89
+ return this.alert({ content, type: 'error' as const, confirmText: '确定', details });
90
+ },
91
+ warning(content: string) {
92
+ return this.alert({ content, type: 'warning' as const, confirmText: '确定' });
93
+ },
94
+ info(content: string) {
95
+ return this.alert({ content, type: 'info' as const, confirmText: '确定' });
96
+ },
97
+ } as ModalTypeWithMethods;
98
+ },
99
+ get() {
100
+ const instance = getCurrentInstance();
101
+ if(!instance ) return null;
102
+ // @ts-ignore
103
+ const modal = instance.appContext.config?.globalProperties?.$modal as ModalTypeWithMethods;
104
+ return modal;
105
+ }
106
+ };
107
+
108
+ export const getModalInstance = (): ModalTypeWithMethods => {
109
+ return modalInstance;
110
+ }
111
+
112
+ // 全局modal状态管理
113
+ let isModalActive = false;
114
+ let pendingModalOptions: ModalOptions | null = null;
115
+
116
+ // 导出便捷函数供非Vue环境使用
117
+ export const showModal = (options: ModalOptions) => {
118
+ if (!globalModalInstance) return Promise.resolve(false);
119
+
120
+ return new Promise<boolean>((resolve) => {
121
+ const finalOptions = {
122
+ title: '提示',
123
+ confirmText: '确定',
124
+ cancelText: '取消',
125
+ showCancel: false,
126
+ type: 'info',
127
+ ...options,
128
+ onConfirm: () => {
129
+ options.onConfirm?.();
130
+ globalModalInstance.hide();
131
+ nextTick(() => {
132
+ resolve(true);
133
+ });
134
+ },
135
+ onCancel: () => {
136
+ options.onCancel?.();
137
+ globalModalInstance.hide();
138
+ nextTick(() => {
139
+ resolve(false);
140
+ });
141
+ }
142
+ };
143
+
144
+ // 如果当前有modal正在显示,将新的请求加入队列
145
+ if (isModalActive) {
146
+ console.log('Modal busy, queuing new modal');
147
+ pendingModalOptions = options;
148
+ return;
149
+ }
150
+
151
+ // 显示新的modal
152
+ const showModalInstance = () => {
153
+ globalModalInstance.setOptions?.(finalOptions);
154
+ isModalActive = true;
155
+
156
+ // 使用Promise链确保正确的执行顺序
157
+ return globalModalInstance.show?.() || Promise.resolve();
158
+ };
159
+
160
+ showModalInstance();
161
+ });
162
+ };
163
+
164
+ export const showAlert = (content: string, type: 'success' | 'error' | 'warning' | 'info' = 'info', details?: any) => {
165
+ return showModal({
166
+ content,
167
+ type,
168
+ showCancel: false,
169
+ details
170
+ });
171
+ };
172
+
173
+ export const showConfirm = (content: string, options?: Omit<ModalOptions, 'content' | 'showCancel'>) => {
174
+ return showModal({
175
+ title: '确认',
176
+ content,
177
+ type: 'warning',
178
+ showCancel: true,
179
+ ...options
180
+ });
181
+ };