feat: 百宝箱添加自定义下载功能UI,MyButton新增disabled属性 .gitignore 屏蔽下划线开头文件#209
Open
wunanc wants to merge 2 commits into
Open
feat: 百宝箱添加自定义下载功能UI,MyButton新增disabled属性 .gitignore 屏蔽下划线开头文件#209wunanc wants to merge 2 commits into
wunanc wants to merge 2 commits into
Conversation
Author
|
这更改真是太好了! |
AnemoFlower
requested changes
Jun 21, 2026
AnemoFlower
left a comment
Member
There was a problem hiding this comment.
此 PR 实际上并没有添加“下载功能”,只是为 MyButton 新增了 disabled 属性。
| private let disabled: Bool | ||
| private let action: () -> Void | ||
|
|
||
| private var color: Color { hovered ? type.hoverColor : type.color } |
Member
There was a problem hiding this comment.
不可点击样式与 PCL 不一致。
Suggested change
| private var color: Color { hovered ? type.hoverColor : type.color } | |
| private var color: Color { | |
| if disabled { | |
| return .colorGray4 | |
| } | |
| return hovered ? type.hoverColor : type.color | |
| } |
Comment on lines
51
to
54
| .contentShape(RoundedRectangle(cornerRadius: 4)) | ||
| .allowsHitTesting(!disabled) | ||
| .opacity(disabled ? 0.5 : 1.0) | ||
| .onHover { hovered = $0 } |
Member
There was a problem hiding this comment.
Suggested change
| .contentShape(RoundedRectangle(cornerRadius: 4)) | |
| .allowsHitTesting(!disabled) | |
| .opacity(disabled ? 0.5 : 1.0) | |
| .onHover { hovered = $0 } | |
| .animation(.easeInOut(duration: 0.2), value: disabled) | |
| .contentShape(RoundedRectangle(cornerRadius: 4)) | |
| .allowsHitTesting(!disabled) | |
| .onHover { | |
| if !disabled { | |
| hovered = $0 | |
| } | |
| } |
Comment on lines
+68
to
+106
| MyCard("下载自定义文件", foldable: false) { | ||
| MyText("使用 PCL 的多线程下载引擎下载任意文件。请注意,部分网站(例如百度网盘)可能会报错(403)已禁止,无法正常下载。") | ||
| .frame(maxWidth: .infinity, alignment: .leading) | ||
| HStack(spacing: 10) { | ||
| MyText("下载链接") | ||
| MyTextField(text: $downloadURL, placeholder: "输入文件直链地址") | ||
| .onChange(of: downloadURL) { newValue in | ||
| fileName = "" | ||
| if let lastComponent = newValue.split(separator: "/").last, | ||
| !lastComponent.isEmpty { | ||
| fileName = String(lastComponent) | ||
| } | ||
| } | ||
| } | ||
| .padding(.top, 8) | ||
| HStack(spacing: 10) { | ||
| MyText("保存到") | ||
| .frame(width: 56, alignment: .leading) | ||
| MyTextField(text: $savePath, placeholder: "文件保存路径") | ||
| MyButton("选择") { | ||
| selectSavePath() | ||
| } | ||
| .frame(width: 60) | ||
| } | ||
| .padding(.top, 8) | ||
| HStack(spacing: 10) { | ||
| MyText("文件名") | ||
| .frame(width: 56, alignment: .leading) | ||
| MyTextField(text: $fileName, placeholder: "文件下载之后的名字(包含后缀)") | ||
| } | ||
| .padding(.top, 8) | ||
| HStack(spacing: 20) { | ||
| MyButton("开始下载", disabled: downloadURL.isEmpty || savePath.isEmpty || fileName.isEmpty) {} | ||
| .frame(width: 160) | ||
| MyButton("打开文件夹", disabled: savePath.isEmpty) {} | ||
| .frame(width: 160) | ||
| } | ||
| .frame(height: 50) | ||
| } |
Member
There was a problem hiding this comment.
部分间距和控件与 PCL 不一致。
Suggested change
| MyCard("下载自定义文件", foldable: false) { | |
| MyText("使用 PCL 的多线程下载引擎下载任意文件。请注意,部分网站(例如百度网盘)可能会报错(403)已禁止,无法正常下载。") | |
| .frame(maxWidth: .infinity, alignment: .leading) | |
| HStack(spacing: 10) { | |
| MyText("下载链接") | |
| MyTextField(text: $downloadURL, placeholder: "输入文件直链地址") | |
| .onChange(of: downloadURL) { newValue in | |
| fileName = "" | |
| if let lastComponent = newValue.split(separator: "/").last, | |
| !lastComponent.isEmpty { | |
| fileName = String(lastComponent) | |
| } | |
| } | |
| } | |
| .padding(.top, 8) | |
| HStack(spacing: 10) { | |
| MyText("保存到") | |
| .frame(width: 56, alignment: .leading) | |
| MyTextField(text: $savePath, placeholder: "文件保存路径") | |
| MyButton("选择") { | |
| selectSavePath() | |
| } | |
| .frame(width: 60) | |
| } | |
| .padding(.top, 8) | |
| HStack(spacing: 10) { | |
| MyText("文件名") | |
| .frame(width: 56, alignment: .leading) | |
| MyTextField(text: $fileName, placeholder: "文件下载之后的名字(包含后缀)") | |
| } | |
| .padding(.top, 8) | |
| HStack(spacing: 20) { | |
| MyButton("开始下载", disabled: downloadURL.isEmpty || savePath.isEmpty || fileName.isEmpty) {} | |
| .frame(width: 160) | |
| MyButton("打开文件夹", disabled: savePath.isEmpty) {} | |
| .frame(width: 160) | |
| } | |
| .frame(height: 50) | |
| } | |
| MyCard("下载自定义文件", foldable: false) { | |
| MyText("使用 PCL.Mac 的多线程下载引擎下载任意文件。请注意,部分网站(例如百度网盘)可能会报错(403)已禁止,无法正常下载。") | |
| .frame(maxWidth: .infinity, alignment: .leading) | |
| VStack(spacing: 8) { | |
| HStack(spacing: 10) { | |
| MyText("下载链接") | |
| MyTextField(text: $downloadURL, placeholder: "输入文件直链地址") | |
| .onChange(of: downloadURL) { newValue in | |
| fileName = "" | |
| if let lastComponent = newValue.split(separator: "/").last, | |
| !lastComponent.isEmpty { | |
| fileName = String(lastComponent) | |
| } | |
| } | |
| } | |
| HStack(spacing: 10) { | |
| MyText("保存到") | |
| .frame(width: 56, alignment: .leading) | |
| MyTextField(text: $savePath, placeholder: "文件保存路径") | |
| MyText("选择") | |
| .contentShape(.rect) | |
| .onTapGesture { | |
| selectSavePath() | |
| } | |
| } | |
| HStack(spacing: 10) { | |
| MyText("文件名") | |
| .frame(width: 56, alignment: .leading) | |
| MyTextField(text: $fileName, placeholder: "文件下载之后的名字(包含后缀)") | |
| } | |
| HStack(spacing: 20) { | |
| MyButton("开始下载", disabled: downloadURL.isEmpty || savePath.isEmpty || fileName.isEmpty) {} | |
| .frame(width: 160) | |
| MyButton("打开文件夹", disabled: savePath.isEmpty) {} | |
| .frame(width: 160) | |
| } | |
| .frame(height: 50) | |
| .padding(.top, 10) | |
| } | |
| } |
| panel.message = "选择文件下载后保存的文件夹" | ||
| let response = panel.runModal() | ||
| if response == .OK, let url = panel.url { | ||
| savePath = url.path |
Member
There was a problem hiding this comment.
Suggested change
| savePath = url.path | |
| savePath = url.path |
Comment on lines
+100
to
+103
| MyButton("开始下载", disabled: downloadURL.isEmpty || savePath.isEmpty || fileName.isEmpty) {} | ||
| .frame(width: 160) | ||
| MyButton("打开文件夹", disabled: savePath.isEmpty) {} | ||
| .frame(width: 160) |
| } | ||
| } | ||
| MyCard("下载自定义文件", foldable: false) { | ||
| MyText("使用 PCL 的多线程下载引擎下载任意文件。请注意,部分网站(例如百度网盘)可能会报错(403)已禁止,无法正常下载。") |
Member
There was a problem hiding this comment.
PCL.Mac 暂时还没有类似 PCL 的大文件分片下载器,此处文本需要修改。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.