Skip to content

feat: 百宝箱添加自定义下载功能UI,MyButton新增disabled属性 .gitignore 屏蔽下划线开头文件#209

Open
wunanc wants to merge 2 commits into
CylorineStudio:mainfrom
wunanc:main
Open

feat: 百宝箱添加自定义下载功能UI,MyButton新增disabled属性 .gitignore 屏蔽下划线开头文件#209
wunanc wants to merge 2 commits into
CylorineStudio:mainfrom
wunanc:main

Conversation

@wunanc

@wunanc wunanc commented Jun 20, 2026

Copy link
Copy Markdown

No description provided.

@wunanc

wunanc commented Jun 20, 2026

Copy link
Copy Markdown
Author

这更改真是太好了!

@AnemoFlower AnemoFlower left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

此 PR 实际上并没有添加“下载功能”,只是为 MyButton 新增了 disabled 属性。

private let disabled: Bool
private let action: () -> Void

private var color: Color { hovered ? type.hoverColor : type.color }

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不可点击样式与 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 }

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

部分间距和控件与 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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

没有实现“开始下载”和“打开文件夹”的实际逻辑。

}
}
MyCard("下载自定义文件", foldable: false) {
MyText("使用 PCL 的多线程下载引擎下载任意文件。请注意,部分网站(例如百度网盘)可能会报错(403)已禁止,无法正常下载。")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PCL.Mac 暂时还没有类似 PCL 的大文件分片下载器,此处文本需要修改。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants