diff --git a/ApplicationLibrary/Views/Connections/ConnectionListView.swift b/ApplicationLibrary/Views/Connections/ConnectionListView.swift index b0a33a5..204f199 100644 --- a/ApplicationLibrary/Views/Connections/ConnectionListView.swift +++ b/ApplicationLibrary/Views/Connections/ConnectionListView.swift @@ -8,7 +8,6 @@ public struct ConnectionListView: View { @State private var isLoading = true @StateObject private var commandClient = CommandClient(.connections) @State private var connections: [Connection] = [] - @State private var selection: ConnectionListPage = .active @State private var searchText = "" @State private var alert: Alert? diff --git a/ApplicationLibrary/Views/Connections/ConnectionView.swift b/ApplicationLibrary/Views/Connections/ConnectionView.swift index 137c289..9eae68d 100644 --- a/ApplicationLibrary/Views/Connections/ConnectionView.swift +++ b/ApplicationLibrary/Views/Connections/ConnectionView.swift @@ -67,7 +67,7 @@ public struct ConnectionView: View { Spacer() VStack(alignment: .trailing) { Text(connection.inboundType + "/" + connection.inbound) - Text(connection.chain.reversed().joined(separator: "/")) + Text(connection.chain[0]) } } } @@ -111,7 +111,7 @@ public struct ConnectionView: View { private nonisolated func closeConnection() async { do { - try LibboxNewStandaloneCommandClient()!.closeConnection(connection.id) + try await LibboxNewStandaloneCommandClient()!.closeConnection(connection.id) } catch { await MainActor.run { alert = Alert(error) diff --git a/ApplicationLibrary/Views/Dashboard/ActiveDashboardView.swift b/ApplicationLibrary/Views/Dashboard/ActiveDashboardView.swift index 6c93062..913abcf 100644 --- a/ApplicationLibrary/Views/Dashboard/ActiveDashboardView.swift +++ b/ApplicationLibrary/Views/Dashboard/ActiveDashboardView.swift @@ -51,7 +51,7 @@ public struct ActiveDashboardView: View { #if os(iOS) || os(tvOS) if ApplicationLibrary.inPreview || profile.status.isConnectedStrict { Picker("Page", selection: $selection) { - ForEach(DashboardPage.allCases) { page in + ForEach(DashboardPage.enabledCases()) { page in page.label } } @@ -61,7 +61,7 @@ public struct ActiveDashboardView: View { .navigationBarTitleDisplayMode(.inline) #endif TabView(selection: $selection) { - ForEach(DashboardPage.enabledCases) { page in + ForEach(DashboardPage.enabledCases()) { page in page.contentView($profileList, $selectedProfileID, $systemProxyAvailable, $systemProxyEnabled) .tag(page) } diff --git a/ApplicationLibrary/Views/Dashboard/DashboardPage.swift b/ApplicationLibrary/Views/Dashboard/DashboardPage.swift index 3e61fcc..90cc5c8 100644 --- a/ApplicationLibrary/Views/Dashboard/DashboardPage.swift +++ b/ApplicationLibrary/Views/Dashboard/DashboardPage.swift @@ -13,18 +13,18 @@ public enum DashboardPage: Int, CaseIterable, Identifiable { } public extension DashboardPage { - #if !tvOS - static var enabledCases: [DashboardPage] = [ - .overview, - .groups, - .connections, - ] - #else - static var enabledCases: [DashboardPage] = [ + static func enabledCases() -> [DashboardPage] { + var cases: [DashboardPage] = [ .overview, .groups, ] - #endif + #if !tvOS + if Variant.isBeta { + cases.append(.connections) + } + #endif + return cases + } } public extension DashboardPage { diff --git a/Library/Network/CommandClient.swift b/Library/Network/CommandClient.swift index c13942b..9848eab 100644 --- a/Library/Network/CommandClient.swift +++ b/Library/Network/CommandClient.swift @@ -22,7 +22,7 @@ public class CommandClient: ObservableObject { @Published public var clashModeList: [String] @Published public var clashMode: String - @Published public var connectionStateFilter = ConnectionStateFilter.all + @Published public var connectionStateFilter = ConnectionStateFilter.active @Published public var connectionSort = ConnectionSort.byDate @Published public var connections: [LibboxConnection]? public var rawConnections: LibboxConnections? diff --git a/Library/Shared/Variant.swift b/Library/Shared/Variant.swift index a894d12..669e4bb 100644 --- a/Library/Shared/Variant.swift +++ b/Library/Shared/Variant.swift @@ -1,4 +1,5 @@ import Foundation +import Libbox public enum Variant { #if os(macOS) @@ -14,4 +15,6 @@ public enum Variant { #elseif os(tvOS) public static let applicationName = "SFT" #endif + + public static var isBeta = LibboxVersion().contains("-") } diff --git a/MacLibrary/SidebarView.swift b/MacLibrary/SidebarView.swift index 9a54d6a..8711ee0 100644 --- a/MacLibrary/SidebarView.swift +++ b/MacLibrary/SidebarView.swift @@ -35,7 +35,9 @@ public struct SidebarView: View { .tint(.textColor) .tag(NavigationPage.dashboard) NavigationPage.groups.label.tag(NavigationPage.groups) - NavigationPage.connections.label.tag(NavigationPage.connections) + if Variant.isBeta { + NavigationPage.connections.label.tag(NavigationPage.connections) + } } Divider() ForEach(NavigationPage.macosDefaultPages, id: \.self) { it in diff --git a/SFM.System/Application.swift b/SFM.System/Application.swift index 49bb577..74c9a6f 100644 --- a/SFM.System/Application.swift +++ b/SFM.System/Application.swift @@ -4,7 +4,7 @@ import SwiftUI @main struct Application: App { - @NSApplicationDelegateAdaptor private var appDelegate: IndependentApplicationDelegate + @NSApplicationDelegateAdaptor private var appDelegate: StandaloneApplicationDelegate var body: some Scene { MacApplication() diff --git a/SFM.System/IndependentApplicationDelegate.swift b/SFM.System/StandaloneApplicationDelegate.swift similarity index 88% rename from SFM.System/IndependentApplicationDelegate.swift rename to SFM.System/StandaloneApplicationDelegate.swift index 401e6bd..bbf9303 100644 --- a/SFM.System/IndependentApplicationDelegate.swift +++ b/SFM.System/StandaloneApplicationDelegate.swift @@ -3,9 +3,10 @@ import Foundation import Library import MacLibrary -class IndependentApplicationDelegate: ApplicationDelegate { +class StandaloneApplicationDelegate: ApplicationDelegate { public func applicationWillFinishLaunching(_: Notification) { Variant.useSystemExtension = true + Variant.isBeta = false Task { await setupSystemExtension() } diff --git a/sing-box.xcodeproj/project.pbxproj b/sing-box.xcodeproj/project.pbxproj index 5fc820e..8381fd7 100644 --- a/sing-box.xcodeproj/project.pbxproj +++ b/sing-box.xcodeproj/project.pbxproj @@ -23,7 +23,7 @@ 3A251C122A52D09700651082 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 3AAB5E7A2A4C1446009757F1 /* Assets.xcassets */; }; 3A27D9002A89BE230031EBCC /* CommandClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3A27D8FF2A89BE230031EBCC /* CommandClient.swift */; }; 3A27D9022A89C6870031EBCC /* ExtensionEnvironments.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3A27D9012A89C6870031EBCC /* ExtensionEnvironments.swift */; }; - 3A2EAEED2A6F4CBB00D00DE3 /* IndependentApplicationDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3A2EAEEC2A6F4CBB00D00DE3 /* IndependentApplicationDelegate.swift */; }; + 3A2EAEED2A6F4CBB00D00DE3 /* StandaloneApplicationDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3A2EAEEC2A6F4CBB00D00DE3 /* StandaloneApplicationDelegate.swift */; }; 3A2F29EB2C998A5D007E024C /* Export.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3A2F29EA2C998A5D007E024C /* Export.plist */; }; 3A334ED02C0F621E00E9C577 /* ConnectionDetailsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3A334ECF2C0F621E00E9C577 /* ConnectionDetailsView.swift */; }; 3A3AA7FC2A4EFDAE002F78AB /* Library.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3AEC211D2A459B4700A63465 /* Library.framework */; }; @@ -482,7 +482,7 @@ 3A2223592A6E212A00C50B23 /* SystemExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SystemExtension.swift; sourceTree = ""; }; 3A27D8FF2A89BE230031EBCC /* CommandClient.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CommandClient.swift; sourceTree = ""; }; 3A27D9012A89C6870031EBCC /* ExtensionEnvironments.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExtensionEnvironments.swift; sourceTree = ""; }; - 3A2EAEEC2A6F4CBB00D00DE3 /* IndependentApplicationDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IndependentApplicationDelegate.swift; sourceTree = ""; }; + 3A2EAEEC2A6F4CBB00D00DE3 /* StandaloneApplicationDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StandaloneApplicationDelegate.swift; sourceTree = ""; }; 3A334ECF2C0F621E00E9C577 /* ConnectionDetailsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConnectionDetailsView.swift; sourceTree = ""; }; 3A2F29EA2C998A5D007E024C /* Export.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Export.plist; sourceTree = ""; }; 3A334ECF2C0F621E00E9C577 /* ConnectionDetailsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConnectionDetailsView.swift; sourceTree = ""; }; @@ -1055,7 +1055,7 @@ 3AEECC062A6DF9CA006A0E0C /* Application.swift */, 3AEECC502A6E0074006A0E0C /* SFM.entitlements */, 3A2223532A6E1B6700C50B23 /* Info.plist */, - 3A2EAEEC2A6F4CBB00D00DE3 /* IndependentApplicationDelegate.swift */, + 3A2EAEEC2A6F4CBB00D00DE3 /* StandaloneApplicationDelegate.swift */, 3AABFD462A9CCC58005A24A4 /* Upload.plist */, ); path = SFM.System; @@ -1741,7 +1741,7 @@ buildActionMask = 2147483647; files = ( 3AEECC072A6DF9CA006A0E0C /* Application.swift in Sources */, - 3A2EAEED2A6F4CBB00D00DE3 /* IndependentApplicationDelegate.swift in Sources */, + 3A2EAEED2A6F4CBB00D00DE3 /* StandaloneApplicationDelegate.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; };