fix(servers): show subscription creation in subscription toolbar

This commit is contained in:
Qiu Yuzhou
2026-10-14 23:30:40 +08:00
parent 9bccdf460a
commit a8fedace16
2 changed files with 38 additions and 1 deletions
@@ -1,6 +1,28 @@
{
"sourceLanguage": "zh-Hans",
"strings": {
"添加订阅": {
"extractionState": "manual",
"localizations": {
"en": {
"stringUnit": {
"state": "translated",
"value": "Add Subscription"
}
}
}
},
"用工具栏的「添加订阅」按钮添加 HTTPS 订阅地址(SIP-008 JSON)": {
"extractionState": "manual",
"localizations": {
"en": {
"stringUnit": {
"state": "translated",
"value": "Use Add Subscription in the toolbar to add an HTTPS subscription URL (SIP-008 JSON)."
}
}
}
},
"位置": {
"extractionState": "manual",
"localizations": {
@@ -29,6 +29,7 @@ struct ServersView: View {
@State private var renameTarget: NodeID?
@State private var newGroupParent: NodeID?
@State private var isPresentingNewGroup = false
@State private var isPresentingAddSubscription = false
@State private var serverFormOperation: ServerFormSheet.Operation?
@State private var subscriptionEditTarget: SubscriptionSummary?
@State private var deleteTarget: DeleteTarget?
@@ -75,6 +76,9 @@ struct ServersView: View {
.sheet(item: $subscriptionEditTarget) { summary in
EditSubscriptionURLSheet(workflow: workflow, errors: errors, summary: summary)
}
.sheet(isPresented: $isPresentingAddSubscription) {
AddSubscriptionSheet(workflow: workflow, errors: errors)
}
.presentingErrors(errors)
.confirmationDialog(
deleteTitle,
@@ -205,7 +209,9 @@ struct ServersView: View {
if rows.isEmpty {
ContentUnavailableView(
"暂无服务器", systemImage: "server.rack",
description: Text("用工具栏的「新建服务器」按钮手动录入,或用「导入」菜单导入")
description: section == .subscription
? Text("用工具栏的「添加订阅」按钮添加 HTTPS 订阅地址(SIP-008 JSON)")
: Text("用工具栏的「新建服务器」按钮手动录入,或用「导入」菜单导入")
)
.allowsHitTesting(false)
}
@@ -324,6 +330,8 @@ extension ServersView {
.labelStyle(.iconOnly)
.help("排序")
}
}
if section == .manual {
ToolbarItem(placement: .primaryAction) {
Button {
presentNewServer(in: workflow.importTargetParent(for: selection))
@@ -340,6 +348,13 @@ extension ServersView {
}
.help("新建分组")
}
} else if section == .subscription {
ToolbarItem(placement: .primaryAction) {
Button("添加订阅", systemImage: "plus") {
isPresentingAddSubscription = true
}
.help("添加订阅")
}
}
ToolbarItem(placement: .primaryAction) {
Button {