refactor: remove showFile API for Docker compatibility
Docker 容器内无法调用宿主机文件管理器,移除 showFile 接口: - 移除后端 showFile 路由和处理函数 - 移除前端 showFile 调用和"打开文件位置"按钮 - 移除 opening 状态和 FolderSVG 组件 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -22,7 +22,6 @@ func API() *http.ServeMux {
|
||||
router.HandleFunc("/createTask", createTask)
|
||||
router.HandleFunc("/getActiveTask", getActiveTask)
|
||||
router.HandleFunc("/getTaskList", getTaskList)
|
||||
router.HandleFunc("/showFile", showFile)
|
||||
router.HandleFunc("/getFields", getFields)
|
||||
router.HandleFunc("/saveFields", saveFields)
|
||||
router.HandleFunc("/logout", logout)
|
||||
|
||||
@@ -4,8 +4,6 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"os/exec"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
@@ -139,39 +137,6 @@ func getTaskList(w http.ResponseWriter, r *http.Request) {
|
||||
util.Res{Success: true, Message: "获取成功", Data: tasks}.Write(w)
|
||||
}
|
||||
|
||||
// showFile 调用 Explorer 查看文件位置
|
||||
func showFile(w http.ResponseWriter, r *http.Request) {
|
||||
if err := r.ParseForm(); err != nil {
|
||||
util.Res{Success: false, Message: "参数错误"}.Write(w)
|
||||
return
|
||||
}
|
||||
filePath := r.FormValue("filePath")
|
||||
|
||||
var cmd *exec.Cmd
|
||||
|
||||
// 根据操作系统选择命令
|
||||
switch runtime.GOOS {
|
||||
case "windows":
|
||||
// Windows 使用 explorer
|
||||
cmd = exec.Command("explorer", "/select,", filePath)
|
||||
case "darwin":
|
||||
// macOS 使用 open
|
||||
cmd = exec.Command("open", "-R", filePath)
|
||||
case "linux":
|
||||
// Linux 使用 xdg-open
|
||||
cmd = exec.Command("xdg-open", filePath)
|
||||
default:
|
||||
util.Res{Success: false, Message: "不支持的操作系统"}.Write(w)
|
||||
return
|
||||
}
|
||||
err := cmd.Start()
|
||||
if err != nil {
|
||||
util.Res{Success: false, Message: err.Error()}.Write(w)
|
||||
return
|
||||
}
|
||||
util.Res{Success: true, Message: "操作成功"}.Write(w)
|
||||
}
|
||||
|
||||
func deleteTask(w http.ResponseWriter, r *http.Request) {
|
||||
// 支持单个删除(GET 参数 id)和批量删除(POST 参数 ids)
|
||||
var taskIDs []int
|
||||
|
||||
Reference in New Issue
Block a user