diff --git a/ShadowsocksX-NG2/App/Resources/Localizable.xcstrings b/ShadowsocksX-NG2/App/Resources/Localizable.xcstrings index 0841e39d..5f785878 100644 --- a/ShadowsocksX-NG2/App/Resources/Localizable.xcstrings +++ b/ShadowsocksX-NG2/App/Resources/Localizable.xcstrings @@ -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": { diff --git a/ShadowsocksX-NG2/App/UI/Servers/ServersView.swift b/ShadowsocksX-NG2/App/UI/Servers/ServersView.swift index b2fce522..d712f539 100644 --- a/ShadowsocksX-NG2/App/UI/Servers/ServersView.swift +++ b/ShadowsocksX-NG2/App/UI/Servers/ServersView.swift @@ -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 {