优化:文件操作精确更新,避免占用问题
后端改进:
- API 返回 FileOperationResult 结构体(类型安全)
- 所有操作返回文件信息,支持精确更新
- 删除过度抽象的接口和全局函数包装器(桌面程序不需要)
前端改进:
- 精确更新文件列表(避免整目录刷新)
- 分离 add/remove/update 三个独立函数
- 重命名前智能关闭文件/文件夹,解决占用问题
- 优化错误提示,用户友好提示
技术细节:
- 定义 FileOperationResult 结构体替代 map[string]interface{}
- 前端 API 返回类型从 void 改为 any
- 保留运行时状态(如 is_favorite)
- 智能识别文件占用错误并给出解决建议
This commit is contained in:
8
app.go
8
app.go
@@ -270,17 +270,17 @@ func (a *App) ListDir(path string) ([]map[string]interface{}, error) {
|
||||
}
|
||||
|
||||
// CreateDir 创建目录
|
||||
func (a *App) CreateDir(path string) error {
|
||||
func (a *App) CreateDir(path string) (*filesystem.FileOperationResult, error) {
|
||||
return a.filesystem.CreateDir(path)
|
||||
}
|
||||
|
||||
// CreateFile 创建文件
|
||||
func (a *App) CreateFile(path string) error {
|
||||
func (a *App) CreateFile(path string) (*filesystem.FileOperationResult, error) {
|
||||
return a.filesystem.CreateFile(path)
|
||||
}
|
||||
|
||||
// DeletePath 删除文件或目录
|
||||
func (a *App) DeletePath(path string) error {
|
||||
func (a *App) DeletePath(path string) (*filesystem.FileOperationResult, error) {
|
||||
return a.filesystem.DeletePath(path)
|
||||
}
|
||||
|
||||
@@ -291,7 +291,7 @@ type RenamePathRequest struct {
|
||||
}
|
||||
|
||||
// RenamePath 重命名文件或目录
|
||||
func (a *App) RenamePath(req RenamePathRequest) error {
|
||||
func (a *App) RenamePath(req RenamePathRequest) (*filesystem.FileOperationResult, error) {
|
||||
return a.filesystem.RenamePath(req.OldPath, req.NewPath)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user