Skip to content

Commit aaf1a6c

Browse files
committed
Merge branch 'meta-dev' into meta
2 parents d1557d2 + a5a7ac8 commit aaf1a6c

File tree

9 files changed

+60
-36
lines changed

9 files changed

+60
-36
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
uses: robinraju/[email protected]
2424
with:
2525
repository: 'MetaCubeX/mihomo'
26-
tag: "v1.19.14"
26+
tag: "v1.19.15"
2727
fileName: "mihomo-darwin-???64-v?.*.*.gz"
2828

2929
# releaseId: "62870807"

ClashX/Dashboard/DashboardViewContoller.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ class DashboardViewContoller: NSViewController {
103103

104104
var items = [NSToolbarItem.Identifier]()
105105
items.append(.toggleSidebar)
106+
items.append(.sidebarTrackingSeparator)
106107

107108
switch item {
108109
case .overview, .config:

ClashX/Dashboard/Views/ContentTabs/Providers/ProvidersView.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
//
66

77
import SwiftUI
8-
import SwiftUIIntrospect
8+
@_spi(Advanced) import SwiftUIIntrospect
99

1010
struct ProvidersView: View {
1111
@ObservedObject var providerStorage = DBProviderStorage()
@@ -86,7 +86,7 @@ struct ProvidersView: View {
8686
}
8787
}
8888
}
89-
.introspect(.table, on: .macOS(.v12, .v13, .v14, .v15)) {
89+
.introspect(.table, on: .macOS(.v12...)) {
9090
$0.refusesFirstResponder = true
9191
$0.doubleAction = nil
9292
}

ClashX/Dashboard/Views/ContentTabs/Proxies/ProxiesView.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
//
66

77
import SwiftUI
8-
import SwiftUIIntrospect
8+
@_spi(Advanced) import SwiftUIIntrospect
99

1010
class ProxiesSearchString: ObservableObject, Identifiable {
1111
let id = UUID().uuidString
@@ -26,7 +26,7 @@ struct ProxiesView: View {
2626
List(proxyStorage.groups.filter({ !$0.hidden }), id: \.id) { group in
2727
ProxyGroupRowView(proxyGroup: group)
2828
}
29-
.introspect(.table, on: .macOS(.v12, .v13, .v14, .v15)) {
29+
.introspect(.table, on: .macOS(.v12...)) {
3030
$0.refusesFirstResponder = true
3131
$0.doubleAction = nil
3232
}

ClashX/Dashboard/Views/SidebarView/SidebarItem.swift

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,35 @@
77
import Cocoa
88
import SwiftUI
99

10-
enum SidebarItem: String {
10+
enum SidebarItem: String, Identifiable, CaseIterable {
11+
var id: String {
12+
self.rawValue
13+
}
14+
1115
case overview = "Overview"
1216
case proxies = "Proxies"
1317
case providers = "Providers"
1418
case rules = "Rules"
1519
case conns = "Conns"
1620
case config = "Config"
1721
case logs = "Logs"
22+
23+
var icon: String {
24+
switch self {
25+
case .overview:
26+
"chart.bar.xaxis"
27+
case .proxies:
28+
"globe.asia.australia"
29+
case .providers:
30+
"link.icloud"
31+
case .rules:
32+
"waveform.and.magnifyingglass"
33+
case .conns:
34+
"app.connected.to.app.below.fill"
35+
case .config:
36+
"slider.horizontal.3"
37+
case .logs:
38+
"wand.and.stars.inverse"
39+
}
40+
}
1841
}

ClashX/Dashboard/Views/SidebarView/SidebarLabel.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,19 @@ import SwiftUI
88

99
struct SidebarLabel: View {
1010
@State var item: SidebarItem
11-
@State var iconName: String
1211

1312
var body: some View {
1413
Label {
1514
Text(item.rawValue)
1615
} icon: {
17-
Image(systemName: iconName)
16+
Image(systemName: item.icon)
1817
.foregroundColor(.accentColor)
1918
}
2019
}
2120
}
2221

2322
struct SidebarLabel_Previews: PreviewProvider {
2423
static var previews: some View {
25-
SidebarLabel(item: .overview, iconName: "chart.bar.xaxis")
24+
SidebarLabel(item: .overview)
2625
}
2726
}

ClashX/Dashboard/Views/SidebarView/SidebarListView.swift

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
//
66

77
import SwiftUI
8-
import SwiftUIIntrospect
8+
@_spi(Advanced) import SwiftUIIntrospect
99

1010
struct SidebarListView: View {
1111

12-
@Binding var selectionName: SidebarItem?
12+
@Binding var selection: SidebarItem?
1313

1414
@State private var reloadID = UUID().uuidString
1515

@@ -18,52 +18,52 @@ struct SidebarListView: View {
1818
List {
1919
NavigationLink(destination: OverviewView(),
2020
tag: SidebarItem.overview,
21-
selection: $selectionName) {
22-
SidebarLabel(item: .overview, iconName: "chart.bar.xaxis")
21+
selection: $selection) {
22+
SidebarLabel(item: .overview)
2323
}
2424

2525
NavigationLink(destination: ProxiesView(),
2626
tag: SidebarItem.proxies,
27-
selection: $selectionName) {
28-
SidebarLabel(item: .proxies, iconName: "globe.asia.australia")
27+
selection: $selection) {
28+
SidebarLabel(item: .proxies)
2929
}
3030

3131
NavigationLink(destination: ProvidersView(),
3232
tag: SidebarItem.providers,
33-
selection: $selectionName) {
34-
SidebarLabel(item: .providers, iconName: "link.icloud")
33+
selection: $selection) {
34+
SidebarLabel(item: .providers)
3535
}
3636

3737
NavigationLink(destination: RulesView(),
3838
tag: SidebarItem.rules,
39-
selection: $selectionName) {
40-
SidebarLabel(item: .rules, iconName: "waveform.and.magnifyingglass")
39+
selection: $selection) {
40+
SidebarLabel(item: .rules)
4141
}
4242

4343
NavigationLink(destination: ConnectionsView(),
4444
tag: SidebarItem.conns,
45-
selection: $selectionName) {
46-
SidebarLabel(item: .conns, iconName: "app.connected.to.app.below.fill")
45+
selection: $selection) {
46+
SidebarLabel(item: .conns)
4747
}
4848

4949
NavigationLink(destination: ConfigView(),
5050
tag: SidebarItem.config,
51-
selection: $selectionName) {
52-
SidebarLabel(item: .config, iconName: "slider.horizontal.3")
51+
selection: $selection) {
52+
SidebarLabel(item: .config)
5353
}
5454

5555
NavigationLink(destination: LogsView(),
5656
tag: SidebarItem.logs,
57-
selection: $selectionName) {
58-
SidebarLabel(item: .logs, iconName: "wand.and.stars.inverse")
57+
selection: $selection) {
58+
SidebarLabel(item: .logs)
5959
}
6060

6161
}
62-
.introspect(.table, on: .macOS(.v12, .v13, .v14, .v15)) {
62+
.introspect(.table, on: .macOS(.v12...)) {
6363
$0.refusesFirstResponder = true
6464

65-
if selectionName == nil {
66-
selectionName = SidebarItem.overview
65+
if selection == nil {
66+
selection = SidebarItem.overview
6767
$0.allowsEmptySelection = false
6868
if $0.selectedRow == -1 {
6969
$0.selectRowIndexes(.init(integer: 0), byExtendingSelection: false)

ClashX/Dashboard/Views/SidebarView/SidebarView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ struct SidebarView: View {
1717

1818
var body: some View {
1919
Group {
20-
SidebarListView(selectionName: $sidebarSelectionName)
20+
SidebarListView(selection: $sidebarSelectionName)
2121
}
2222
.environmentObject(clashApiDatasStorage.overviewData)
2323
.environmentObject(clashApiDatasStorage.logStorage)

ClashX/ViewControllers/ClashWebViewContoller.swift

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,14 @@ import WebKit
1313

1414
enum WebCacheCleaner {
1515
static func clean() {
16-
HTTPCookieStorage.shared.removeCookies(since: Date.distantPast)
17-
Logger.log("[WebCacheCleaner] All cookies deleted")
18-
WKWebsiteDataStore.default().fetchDataRecords(ofTypes: WKWebsiteDataStore.allWebsiteDataTypes()) { records in
19-
records.forEach { record in
20-
WKWebsiteDataStore.default().removeData(ofTypes: record.dataTypes, for: [record], completionHandler: {})
21-
Logger.log("[WebCacheCleaner] Record \(record) deleted")
22-
}
16+
Task { @MainActor in
17+
HTTPCookieStorage.shared.removeCookies(since: Date.distantPast)
18+
Logger.log("[WebCacheCleaner] All cookies deleted")
19+
20+
let types = WKWebsiteDataStore.allWebsiteDataTypes()
21+
let records = await WKWebsiteDataStore.default().dataRecords(ofTypes: types)
22+
await WKWebsiteDataStore.default().removeData(ofTypes: types, for: records)
23+
Logger.log("[WebCacheCleaner] All records deleted")
2324
}
2425
}
2526
}

0 commit comments

Comments
 (0)