fdb2 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -43,9 +43,9 @@ export class SQLiteService extends BaseDatabaseService {
43
43
  return result.map((row: any) => ({
44
44
  name: row.name,
45
45
  type: row.type,
46
- rowCount: 0, // SQLite需要额外查询
47
- dataSize: 0,
48
- indexSize: 0
46
+ rowCount: undefined,
47
+ dataSize: undefined,
48
+ indexSize: undefined
49
49
  }));
50
50
  }
51
51
 
package/server.js CHANGED
@@ -4,6 +4,28 @@ const express = require('express');
4
4
  const path = require('path');
5
5
  const fs = require('fs');
6
6
 
7
+ // 预加载 sqlite3 模块,确保原生绑定文件能够正确加载
8
+ // 并将其缓存到全局模块缓存中,以便 dist/server/index.js 可以使用
9
+ try {
10
+ const sqlite3 = require('sqlite3');
11
+ console.log('SQLite3 module preloaded successfully');
12
+
13
+ // 将 sqlite3 模块添加到全局 require.cache 中
14
+ const Module = require('module');
15
+ const sqlite3Path = require.resolve('sqlite3');
16
+
17
+ // 修改模块解析函数,确保 sqlite3 从正确的路径加载
18
+ const originalResolveFilename = Module._resolveFilename;
19
+ Module._resolveFilename = function(request, parent) {
20
+ if (request === 'sqlite3') {
21
+ return sqlite3Path;
22
+ }
23
+ return originalResolveFilename.call(this, request, parent);
24
+ };
25
+ } catch (error) {
26
+ console.error('Warning: Failed to preload sqlite3 module:', error.message);
27
+ }
28
+
7
29
  // 日志文件路径 - 使用绝对路径
8
30
  const logFilePath = path.resolve(__dirname, 'server.log');
9
31
 
@@ -96,7 +118,7 @@ for (let i = 0; i < process.argv.length; i++) {
96
118
  }
97
119
 
98
120
  // 启动服务器
99
- const PORT = portFromArgs || process.env.PORT || 9300;
121
+ const PORT = portFromArgs || process.env.PORT || 9800;
100
122
  app.listen(PORT, () => {
101
123
 
102
124
  // 将 PID 写入 PID 文件
package/server.pid ADDED
@@ -0,0 +1 @@
1
+ 7684
@@ -127,19 +127,19 @@
127
127
  </div>
128
128
  </div>
129
129
  <div class="card-body">
130
- <div class="table-stats">
131
- <div class="stat">
132
- <span class="stat-label">行数</span>
133
- <span class="stat-value">{{ formatNumber(table.rowCount || 0) }}</span>
130
+ <div class="table-stats">
131
+ <div class="stat" v-if="table.rowCount !== undefined">
132
+ <span class="stat-label">行数</span>
133
+ <span class="stat-value">{{ formatNumber(table.rowCount) }}</span>
134
+ </div>
135
+ <div class="stat" v-if="table.dataSize !== undefined">
136
+ <span class="stat-label">大小</span>
137
+ <span class="stat-value">{{ formatSize(table.dataSize) }}</span>
138
+ </div>
134
139
  </div>
135
- <div class="stat">
136
- <span class="stat-label">大小</span>
137
- <span class="stat-value">{{ formatSize(table.dataSize || 0) }}</span>
140
+ <div class="table-comment" v-if="table.comment">
141
+ {{ table.comment }}
138
142
  </div>
139
- </div>
140
- <div class="table-comment" v-if="table.comment">
141
- {{ table.comment }}
142
- </div>
143
143
  <div class="table-actions">
144
144
  <button class="btn btn-sm btn-outline-primary" @click.stop="editTable(table)">
145
145
  <i class="bi bi-pencil"></i>
@@ -19,8 +19,8 @@
19
19
  </div>
20
20
  </div>
21
21
  <div class="table-stats">
22
- <div class="stat-item">
23
- <div class="stat-value">{{ formatNumber(table?.rowCount || 0) }}</div>
22
+ <div class="stat-item" v-if="table?.rowCount !== undefined">
23
+ <div class="stat-value">{{ formatNumber(table?.rowCount) }}</div>
24
24
  <div class="stat-label">行数据</div>
25
25
  </div>
26
26
  <div class="stat-item">
@@ -31,8 +31,8 @@
31
31
  <div class="stat-value">{{ tableStructure?.indexes?.length || 0 }}</div>
32
32
  <div class="stat-label">索引</div>
33
33
  </div>
34
- <div class="stat-item">
35
- <div class="stat-value">{{ formatSize(table?.dataSize || 0) }}</div>
34
+ <div class="stat-item" v-if="table?.dataSize !== undefined">
35
+ <div class="stat-value">{{ formatSize(table?.dataSize) }}</div>
36
36
  <div class="stat-label">大小</div>
37
37
  </div>
38
38
  </div>
@@ -10,7 +10,7 @@ export type QueryType = 'SELECT' | 'INSERT' | 'UPDATE' | 'DELETE' | 'CREATE' | '
10
10
  export type QueryStatus = 'success' | 'failed' | 'running';
11
11
 
12
12
  // 数据库类型
13
- export type DatabaseType = 'mysql' | 'postgres' | 'sqlite' | 'mssql' | 'oracle' | 'mongodb';
13
+ export type DatabaseType = 'mysql' | 'postgres' | 'sqlite' | 'mssql' | 'oracle' | 'mongodb' | 'cockroachdb' | 'sap';
14
14
 
15
15
  // 导入模式
16
16
  export type ImportMode = 'insert' | 'replace' | 'update' | 'append';
package/vite.config.ts CHANGED
@@ -282,7 +282,7 @@ const config = defineConfig({
282
282
  base: urlPrefix,
283
283
  server: {
284
284
  host: '0.0.0.0',
285
- port: +`${process.env.VITE_PORT}` || 9300,
285
+ port: +`${process.env.VITE_PORT}` || 9800,
286
286
  cors: true,
287
287
  },
288
288
  });
package/bin/docker/.env DELETED
@@ -1,4 +0,0 @@
1
- MYSQL_DATABASE=mydatabase
2
- MYSQL_USER=myuser
3
- MYSQL_PASSWORD=mypassword
4
- MYSQL_ROOT_PASSWORD=myrootpassword
@@ -1,32 +0,0 @@
1
- [
2
- {
3
- "id": "demo-mysql-1",
4
- "name": "本地MySQL测试",
5
- "type": "mysql",
6
- "host": "localhost",
7
- "port": 3306,
8
- "database": "test",
9
- "username": "root",
10
- "password": "",
11
- "options": {
12
- "charset": "utf8mb4",
13
- "timezone": "+08:00"
14
- },
15
- "enabled": true,
16
- "createdAt": "2024-01-01T00:00:00.000Z",
17
- "updatedAt": "2024-01-01T00:00:00.000Z"
18
- },
19
- {
20
- "id": "demo-sqlite-1",
21
- "name": "SQLite演示数据库",
22
- "type": "sqlite",
23
- "database": "./data/demo.db",
24
- "options": {
25
- "synchronize": false,
26
- "logging": false
27
- },
28
- "enabled": true,
29
- "createdAt": "2024-01-01T00:00:00.000Z",
30
- "updatedAt": "2024-01-01T00:00:00.000Z"
31
- }
32
- ]
package/nw-build.js DELETED
@@ -1,120 +0,0 @@
1
- const nwbuilder = require('nw-builder');
2
- const { resolve, join } = require('path');
3
- const { copyFileSync, existsSync, rmSync, readdirSync } = require('fs');
4
-
5
- // 解析命令行参数
6
- const args = process.argv.slice(2);
7
- const targetPlatform = args.find(arg => arg.startsWith('--platform='))?.split('=')[1];
8
-
9
- async function build() {
10
- try {
11
- console.log('开始构建 NW.js 应用...');
12
-
13
- // 首先构建 Vue 应用
14
- console.log('1. 构建 Vue 应用...');
15
- const { execSync } = require('child_process');
16
- execSync('npm run build', { stdio: 'inherit' });
17
-
18
- console.log('2. 复制 package.json 到 dist 目录...');
19
- const srcPackageJson = join(__dirname, 'package.json');
20
- const destPackageJson = join(__dirname, 'dist', 'package.json');
21
- if (existsSync(srcPackageJson)) {
22
- copyFileSync(srcPackageJson, destPackageJson);
23
- console.log('package.json 复制成功');
24
- } else {
25
- throw new Error('未找到 package.json 文件');
26
- }
27
-
28
- console.log('3. 安装 npm 依赖到 dist 目录...');
29
- // 使用绝对路径执行 npm install 命令
30
- const distPath = resolve(__dirname, 'dist');
31
- console.log('Dist 路径:', distPath);
32
-
33
- // 执行 npm install 命令
34
- execSync('pnpm install --only=production', {
35
- stdio: 'inherit',
36
- cwd: distPath
37
- });
38
-
39
- // 检查 node_modules 目录是否创建成功
40
- const nodeModulesPath = join(distPath, 'node_modules');
41
- if (existsSync(nodeModulesPath)) {
42
- console.log('npm 依赖安装成功');
43
- console.log('node_modules 目录大小:', readdirSync(nodeModulesPath).length, '个包');
44
- } else {
45
- throw new Error('npm install 失败,node_modules 目录未创建');
46
- }
47
-
48
- console.log('4. 配置 NW.js 构建参数...');
49
-
50
- // 根据命令行参数或当前操作系统确定要构建的平台
51
- let platform;
52
- if (targetPlatform) {
53
- platform = targetPlatform;
54
- console.log(`使用命令行指定的平台: ${platform}`);
55
- } else {
56
- platform = process.platform === 'darwin' ? 'osx' :
57
- process.platform === 'linux' ? 'linux' : 'win';
58
- console.log(`使用当前操作系统平台: ${platform}`);
59
- }
60
-
61
- // 为每个平台使用不同的输出目录
62
- const outDir = resolve(__dirname, `nw-build-${platform}`);
63
- console.log(`输出目录: ${outDir}`);
64
-
65
- console.log(`\n正在构建 ${platform} 平台...`);
66
-
67
- const buildOptions = {
68
- mode: 'build',
69
- srcDir: distPath,
70
- version: '0.78.1',
71
- flavor: 'normal',
72
- platform: platform,
73
- arch: 'x64',
74
- outDir: outDir,
75
- cacheDir: resolve(__dirname, 'nw-cache'),
76
- zip: false,
77
- downloadUrl: 'https://dl.nwjs.io',
78
- logLevel: 'info',
79
- glob: false,
80
- app: {
81
- icon: resolve(__dirname, 'public', 'favicon.ico')
82
- }
83
- };
84
-
85
- // macOS 平台需要额外的配置
86
- if (platform === 'osx') {
87
- buildOptions.app.LSApplicationCategoryType = 'public.app-category.productivity';
88
- buildOptions.app.NSHumanReadableCopyright = 'Copyright © 2025';
89
- buildOptions.app.NSLocalNetworkUsageDescription = '需要网络访问以连接数据库';
90
- buildOptions.app.CFBundleIdentifier = 'com.fdb.database';
91
- buildOptions.app.CFBundleName = '数据库管理工具';
92
- buildOptions.app.CFBundleDisplayName = '数据库管理工具';
93
- buildOptions.app.CFBundleShortVersionString = '1.0.0';
94
- buildOptions.app.CFBundleVersion = '1.0.0';
95
- }
96
-
97
- await nwbuilder.default(buildOptions);
98
-
99
- console.log(`✅ ${platform} 平台构建完成`);
100
-
101
- console.log('\n5. 打包完成!');
102
- console.log(`应用已生成在: ${outDir}`);
103
-
104
- // 验证打包后的应用程序
105
- const packagedNodeModulesPath = join(outDir, platform, 'x64', 'package.nw', 'node_modules');
106
- if (existsSync(packagedNodeModulesPath)) {
107
- console.log(`✅ ${platform} 应用程序已包含 node_modules 目录`);
108
- console.log(`✅ ${platform} 依赖包数量:`, readdirSync(packagedNodeModulesPath).length, '个');
109
- } else {
110
- console.warn(`⚠️ ${platform} 应用程序不包含 node_modules 目录`);
111
- }
112
-
113
- } catch (error) {
114
- console.error('构建过程中出错:', error);
115
- process.exit(1);
116
- }
117
- }
118
-
119
- // 开始构建
120
- build();
package/nw-dev.js DELETED
@@ -1,65 +0,0 @@
1
- const { exec } = require('child_process');
2
- const { createServer } = require('http');
3
- const { join, resolve } = require('path');
4
-
5
- // 启动 Vite 开发服务器
6
- const viteProcess = exec('npm run dev', (error, stdout, stderr) => {
7
- if (error) {
8
- console.error(`执行 npm run dev 时出错: ${error}`);
9
- return;
10
- }
11
- console.log(`stdout: ${stdout}`);
12
- console.error(`stderr: ${stderr}`);
13
- });
14
-
15
- viteProcess.stdout.on('data', (data) => {
16
- console.log(data);
17
- // 当 Vite 服务器启动成功后,启动 NW.js
18
- if (data.includes('ready')) {
19
- setTimeout(() => {
20
- console.log('starting NW.js...', 'npx nw . --url=http://localhost:9300');
21
- const nwProcess = exec('npx nw . --url=http://localhost:9300', (error, stdout, stderr) => {
22
- if (error) {
23
- console.error(`启动 NW.js 时出错: ${error}`);
24
- return;
25
- }
26
- console.log(`stdout: ${stdout}`);
27
- console.error(`stderr: ${stderr}`);
28
- });
29
-
30
- nwProcess.stdout.on('data', (data) => {
31
- console.log(data);
32
- });
33
-
34
- nwProcess.stderr.on('data', (data) => {
35
- console.error(data);
36
- });
37
-
38
- nwProcess.on('close', (code) => {
39
- console.log(`NW.js 进程退出,代码: ${code}`);
40
- viteProcess.kill();
41
- });
42
-
43
- // 处理退出信号
44
- process.on('SIGINT', () => {
45
- nwProcess.kill();
46
- viteProcess.kill();
47
- process.exit();
48
- });
49
-
50
- process.on('SIGTERM', () => {
51
- nwProcess.kill();
52
- viteProcess.kill();
53
- process.exit();
54
- });
55
- }, 2000);
56
- }
57
- });
58
-
59
- viteProcess.stderr.on('data', (data) => {
60
- console.error(data);
61
- });
62
-
63
- viteProcess.on('close', (code) => {
64
- console.log(`Vite 进程退出,代码: ${code}`);
65
- });
@@ -1,7 +0,0 @@
1
- # 基础层
2
-
3
- 这里不要依赖领域层或者应用层的内容,也不能直接依赖外部库
4
-
5
- ##
6
-
7
- config.ts: 基础配置,表示系统间的差异;