From 04fadb4f8fed18e6d23725e3b99f1b79347729ec Mon Sep 17 00:00:00 2001 From: William Date: Tue, 30 Jun 2026 08:48:34 +0600 Subject: [PATCH] =?UTF-8?q?refactor:=20=E5=8E=9F=E7=94=9F=20Mac=20?= =?UTF-8?q?=E5=BA=94=E7=94=A8=E7=9B=B4=E6=8E=A5=E4=BD=BF=E7=94=A8=E5=86=85?= =?UTF-8?q?=E7=BD=AE=E4=B8=8B=E8=BD=BD=EF=BC=8C=E7=A7=BB=E9=99=A4=E6=B5=8F?= =?UTF-8?q?=E8=A7=88=E5=99=A8/=E4=B8=8B=E8=BD=BD=E5=B7=A5=E5=85=B7?= =?UTF-8?q?=E9=80=89=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../VODManager/Views/DownloadPanelView.swift | 88 +------------------ 1 file changed, 3 insertions(+), 85 deletions(-) diff --git a/apps/macos/VODManager/Sources/VODManager/Views/DownloadPanelView.swift b/apps/macos/VODManager/Sources/VODManager/Views/DownloadPanelView.swift index 00706b3..ecd5d42 100644 --- a/apps/macos/VODManager/Sources/VODManager/Views/DownloadPanelView.swift +++ b/apps/macos/VODManager/Sources/VODManager/Views/DownloadPanelView.swift @@ -8,7 +8,6 @@ struct DownloadPanelView: View { @State private var selectedDefinitions: [String: String] = [:] @State private var downloadDirectory: URL? @State private var isDownloading = false - @State private var showToolsHelp = false var body: some View { VStack(alignment: .leading, spacing: 16) { @@ -51,20 +50,14 @@ struct DownloadPanelView: View { } HStack { - Button("使用下载工具") { - showToolsHelp = true - } - .disabled(isDownloading) - Spacer() - Button("取消") { dismiss() } .disabled(isDownloading) - Button("浏览器下载") { - Task { await startBrowserDownloads() } + Button("开始下载") { + Task { await startDownloads() } } .disabled(downloadDirectory == nil || isDownloading) .buttonStyle(.borderedProminent) @@ -81,9 +74,6 @@ struct DownloadPanelView: View { } selectedDefinitions = defs } - .sheet(isPresented: $showToolsHelp) { - DownloadToolsHelpView(items: items, selectedDefinitions: selectedDefinitions) - } } private func selectDirectory() { @@ -97,7 +87,7 @@ struct DownloadPanelView: View { } } - private func startBrowserDownloads() async { + private func startDownloads() async { guard let directory = downloadDirectory else { return } isDownloading = true @@ -127,75 +117,3 @@ struct DownloadPanelView: View { return String(format: "%.2f %@", size, units[i]) } } - -struct DownloadToolsHelpView: View { - let items: [(video: VideoItem, playInfos: [PlayInfo])] - let selectedDefinitions: [String: String] - @Environment(\.dismiss) private var dismiss - - var selectedURLs: [String] { - items.compactMap { item -> String? in - guard let definition = selectedDefinitions[item.video.videoId] else { return nil } - return item.playInfos.first(where: { $0.definition == definition })?.playURL - } - } - - var wgetCommand: String { - selectedURLs.map { "wget \"\($0)\"" }.joined(separator: "\n") - } - - var aria2Command: String { - selectedURLs.map { "aria2c \"\($0)\"" }.joined(separator: "\n") - } - - var body: some View { - VStack(alignment: .leading, spacing: 16) { - Text("使用下载工具") - .font(.title2) - - Text("浏览器对批量下载限制较多,推荐使用 aria2 或 wget 等命令行工具。先点击下方按钮复制全部链接,再粘贴到终端执行。") - .foregroundStyle(.secondary) - - HStack { - Button("复制全部链接") { - let pasteboard = NSPasteboard.general - pasteboard.clearContents() - pasteboard.setString(selectedURLs.joined(separator: "\n"), forType: .string) - } - Spacer() - Button("关闭") { - dismiss() - } - } - - Text("aria2 示例(推荐)") - .font(.headline) - Text("aria2 支持断点续传、多线程下载,适合大文件。") - .font(.caption) - .foregroundStyle(.secondary) - ScrollView { - Text(aria2Command) - .font(.system(.caption, design: .monospaced)) - .padding(8) - .frame(maxWidth: .infinity, alignment: .leading) - .background(Color(.textBackgroundColor)) - .cornerRadius(6) - } - .frame(maxHeight: 120) - - Text("wget 示例") - .font(.headline) - ScrollView { - Text(wgetCommand) - .font(.system(.caption, design: .monospaced)) - .padding(8) - .frame(maxWidth: .infinity, alignment: .leading) - .background(Color(.textBackgroundColor)) - .cornerRadius(6) - } - .frame(maxHeight: 120) - } - .padding() - .frame(minWidth: 500, minHeight: 400) - } -}