♻️ refactor(全局): 统一错误消息中文化,补充 godoc 与测试,修复横向滚动和 Vite 代理

错误消息中文化:
- 19 个驱动实现文件中 connection not open / table name required 等英文消息替换为中文
- methods_file.go / methods_db.go / methods_driver.go 英文消息中文化
- 前端 App/Sidebar/DataGrid/ConnectionModal/DriverManagerModal 同步替换 "Cancelled" → "已取消"

文档与测试:
- database.go Database/BatchApplier 接口、types.go 12 个类型、driver_support.go 导出函数补充中文 godoc
- 新增 logger_test.go(ErrorChain 5 个用例)和 methods_db_conn_test.go(连接管理 7 个用例)

Bug 修复:
- DataGrid: 将 liveTargets 空检查移至非虚拟路径,修复外部横向滚动条拖动时内容不跟随
- vite.config.ts: server.host 指定 127.0.0.1,修复 IPv6 回环被拦截导致 Wails 代理 502

基础设施:
- .gitignore 新增 .gemini/ 规则,tmpclaude-* 改为 **/tmpclaude-* 覆盖子目录
This commit is contained in:
杨国锋
2026-03-17 21:44:50 +08:00
parent c62f4b7d3c
commit 064cdc34be
34 changed files with 478 additions and 267 deletions

View File

@@ -117,7 +117,7 @@ func (s *SqlServerDB) Close() error {
func (s *SqlServerDB) Ping() error {
if s.conn == nil {
return fmt.Errorf("connection not open")
return fmt.Errorf("连接未打开")
}
timeout := s.pingTimeout
if timeout <= 0 {
@@ -130,7 +130,7 @@ func (s *SqlServerDB) Ping() error {
func (s *SqlServerDB) QueryContext(ctx context.Context, query string) ([]map[string]interface{}, []string, error) {
if s.conn == nil {
return nil, nil, fmt.Errorf("connection not open")
return nil, nil, fmt.Errorf("连接未打开")
}
rows, err := s.conn.QueryContext(ctx, query)
@@ -144,7 +144,7 @@ func (s *SqlServerDB) QueryContext(ctx context.Context, query string) ([]map[str
func (s *SqlServerDB) Query(query string) ([]map[string]interface{}, []string, error) {
if s.conn == nil {
return nil, nil, fmt.Errorf("connection not open")
return nil, nil, fmt.Errorf("连接未打开")
}
rows, err := s.conn.Query(query)
@@ -157,7 +157,7 @@ func (s *SqlServerDB) Query(query string) ([]map[string]interface{}, []string, e
func (s *SqlServerDB) ExecContext(ctx context.Context, query string) (int64, error) {
if s.conn == nil {
return 0, fmt.Errorf("connection not open")
return 0, fmt.Errorf("连接未打开")
}
res, err := s.conn.ExecContext(ctx, query)
if err != nil {
@@ -168,7 +168,7 @@ func (s *SqlServerDB) ExecContext(ctx context.Context, query string) (int64, err
func (s *SqlServerDB) Exec(query string) (int64, error) {
if s.conn == nil {
return 0, fmt.Errorf("connection not open")
return 0, fmt.Errorf("连接未打开")
}
res, err := s.conn.Exec(query)
if err != nil {
@@ -236,7 +236,7 @@ func (s *SqlServerDB) GetColumns(dbName, tableName string) ([]connection.ColumnD
}
if table == "" {
return nil, fmt.Errorf("table name required")
return nil, fmt.Errorf("表名不能为空")
}
esc := func(s string) string { return strings.ReplaceAll(s, "'", "''") }
@@ -344,7 +344,7 @@ func (s *SqlServerDB) GetIndexes(dbName, tableName string) ([]connection.IndexDe
}
if table == "" {
return nil, fmt.Errorf("table name required")
return nil, fmt.Errorf("表名不能为空")
}
esc := func(s string) string { return strings.ReplaceAll(s, "'", "''") }
@@ -425,7 +425,7 @@ func (s *SqlServerDB) GetForeignKeys(dbName, tableName string) ([]connection.For
}
if table == "" {
return nil, fmt.Errorf("table name required")
return nil, fmt.Errorf("表名不能为空")
}
esc := func(s string) string { return strings.ReplaceAll(s, "'", "''") }
@@ -483,7 +483,7 @@ func (s *SqlServerDB) GetTriggers(dbName, tableName string) ([]connection.Trigge
}
if table == "" {
return nil, fmt.Errorf("table name required")
return nil, fmt.Errorf("表名不能为空")
}
esc := func(s string) string { return strings.ReplaceAll(s, "'", "''") }
@@ -530,7 +530,7 @@ ORDER BY tr.name`,
func (s *SqlServerDB) ApplyChanges(tableName string, changes connection.ChangeSet) error {
if s.conn == nil {
return fmt.Errorf("connection not open")
return fmt.Errorf("连接未打开")
}
tx, err := s.conn.Begin()
@@ -573,7 +573,7 @@ func (s *SqlServerDB) ApplyChanges(tableName string, changes connection.ChangeSe
}
query := fmt.Sprintf("DELETE FROM %s WHERE %s", qualifiedTable, strings.Join(wheres, " AND "))
if _, err := tx.Exec(query, args...); err != nil {
return fmt.Errorf("delete error: %v", err)
return fmt.Errorf("删除失败:%v", err)
}
}
@@ -601,12 +601,12 @@ func (s *SqlServerDB) ApplyChanges(tableName string, changes connection.ChangeSe
}
if len(wheres) == 0 {
return fmt.Errorf("update requires keys")
return fmt.Errorf("更新操作需要主键条件")
}
query := fmt.Sprintf("UPDATE %s SET %s WHERE %s", qualifiedTable, strings.Join(sets, ", "), strings.Join(wheres, " AND "))
if _, err := tx.Exec(query, args...); err != nil {
return fmt.Errorf("update error: %v", err)
return fmt.Errorf("更新失败:%v", err)
}
}
@@ -630,7 +630,7 @@ func (s *SqlServerDB) ApplyChanges(tableName string, changes connection.ChangeSe
query := fmt.Sprintf("INSERT INTO %s (%s) VALUES (%s)", qualifiedTable, strings.Join(cols, ", "), strings.Join(placeholders, ", "))
if _, err := tx.Exec(query, args...); err != nil {
return fmt.Errorf("insert error: %v", err)
return fmt.Errorf("插入失败:%v", err)
}
}