mirror of
https://github.com/Syngnat/GoNavi.git
synced 2026-05-24 01:40:08 +08:00
✨ feat(data-grid): 增强数据表编辑与展示体验
- 新增变更预览能力,支持在提交前查看删除、更新和新增对应的 SQL 语句 - 增加表格密度配置,统一控制默认列宽、行高、字号与单元格内边距 - 优化 DataGrid 编辑状态展示,区分新增、修改和删除行列的视觉反馈 - 调整导出入口与 Wails 前端绑定,补齐变更预览相关调用与测试覆盖
This commit is contained in:
@@ -1012,6 +1012,35 @@ func (a *App) ApplyChanges(config connection.ConnectionConfig, dbName, tableName
|
||||
return connection.QueryResult{Success: false, Message: "当前数据库类型不支持批量提交"}
|
||||
}
|
||||
|
||||
// ChangePreview 变更预览结果
|
||||
type ChangePreview struct {
|
||||
Deletes []string `json:"deletes"`
|
||||
Updates []string `json:"updates"`
|
||||
Inserts []string `json:"inserts"`
|
||||
}
|
||||
|
||||
func (a *App) PreviewChanges(config connection.ConnectionConfig, dbName, tableName string, changes connection.ChangeSet) connection.QueryResult {
|
||||
runConfig := normalizeRunConfig(config, dbName)
|
||||
|
||||
dbInst, err := a.getDatabase(runConfig)
|
||||
if err != nil {
|
||||
return connection.QueryResult{Success: false, Message: err.Error()}
|
||||
}
|
||||
|
||||
var cp ChangePreview
|
||||
// 优先使用驱动的 PreviewChanges(若实现了 ChangePreviewer 接口)
|
||||
if previewer, ok := dbInst.(db.ChangePreviewer); ok {
|
||||
deletes, updates, inserts := previewer.PreviewChanges(tableName, changes)
|
||||
cp = ChangePreview{Deletes: deletes, Updates: updates, Inserts: inserts}
|
||||
} else {
|
||||
// 回退到通用生成,使用 quoteIdentByType 处理标识符转义
|
||||
quoter := func(s string) string { return quoteIdentByType(runConfig.Type, s) }
|
||||
deletes, updates, inserts := db.GenerateChangePreview(tableName, changes, quoter)
|
||||
cp = ChangePreview{Deletes: deletes, Updates: updates, Inserts: inserts}
|
||||
}
|
||||
return connection.QueryResult{Success: true, Data: cp}
|
||||
}
|
||||
|
||||
func (a *App) ExportTable(config connection.ConnectionConfig, dbName string, tableName string, format string) connection.QueryResult {
|
||||
filename, err := runtime.SaveFileDialog(a.ctx, runtime.SaveDialogOptions{
|
||||
Title: fmt.Sprintf("Export %s", tableName),
|
||||
|
||||
Reference in New Issue
Block a user