Merge branch 'meta-dev' into meta

This commit is contained in:
mrFq1 2024-12-10 16:43:13 +08:00
commit a7871c6871
23 changed files with 191 additions and 27 deletions

View File

@ -23,7 +23,7 @@ jobs:
uses: robinraju/release-downloader@v1.10
with:
repository: 'MetaCubeX/mihomo'
tag: "v1.18.10"
tag: "v1.19.0"
fileName: ".*darwin.*64-v.*.gz"
# releaseId: "62870807"

View File

@ -443,8 +443,8 @@
01BCDAC72C9ECD010028FA94 /* Config */ = {
isa = PBXGroup;
children = (
01BCDAC52C9ECD010028FA94 /* ConfigItemView.swift */,
01BCDAC62C9ECD010028FA94 /* ConfigView.swift */,
01BCDAC52C9ECD010028FA94 /* ConfigItemView.swift */,
);
path = Config;
sourceTree = "<group>";
@ -452,9 +452,9 @@
01BCDACB2C9ECD010028FA94 /* Connections */ = {
isa = PBXGroup;
children = (
01BCDAC82C9ECD010028FA94 /* Connections.swift */,
01BCDAC92C9ECD010028FA94 /* ConnectionsTableView.swift */,
01BCDACA2C9ECD010028FA94 /* ConnectionsView.swift */,
01BCDAC92C9ECD010028FA94 /* ConnectionsTableView.swift */,
01BCDAC82C9ECD010028FA94 /* Connections.swift */,
);
path = Connections;
sourceTree = "<group>";
@ -462,8 +462,8 @@
01BCDACE2C9ECD010028FA94 /* Logs */ = {
isa = PBXGroup;
children = (
01BCDACC2C9ECD010028FA94 /* LogsTableView.swift */,
01BCDACD2C9ECD010028FA94 /* LogsView.swift */,
01BCDACC2C9ECD010028FA94 /* LogsTableView.swift */,
);
path = Logs;
sourceTree = "<group>";
@ -471,8 +471,8 @@
01BCDAD22C9ECD010028FA94 /* Overview */ = {
isa = PBXGroup;
children = (
01BCDACF2C9ECD010028FA94 /* OverviewTopItemView.swift */,
01BCDAD02C9ECD010028FA94 /* OverviewView.swift */,
01BCDACF2C9ECD010028FA94 /* OverviewTopItemView.swift */,
01BCDAD12C9ECD010028FA94 /* TrafficGraphView.swift */,
);
path = Overview;
@ -481,8 +481,8 @@
01BCDADA2C9ECD010028FA94 /* Providers */ = {
isa = PBXGroup;
children = (
01BCDAD42C9ECD010028FA94 /* ProviderRowView.swift */,
01BCDAD52C9ECD010028FA94 /* ProvidersView.swift */,
01BCDAD42C9ECD010028FA94 /* ProviderRowView.swift */,
01BCDAD62C9ECD010028FA94 /* ProxyProviderInfoView.swift */,
01BCDAD72C9ECD010028FA94 /* ProxyProvidersRowView.swift */,
01BCDAD82C9ECD010028FA94 /* RuleProvidersRowView.swift */,
@ -506,8 +506,8 @@
01BCDAE22C9ECD010028FA94 /* Rules */ = {
isa = PBXGroup;
children = (
01BCDAE02C9ECD010028FA94 /* RuleItemView.swift */,
01BCDAE12C9ECD010028FA94 /* RulesView.swift */,
01BCDAE02C9ECD010028FA94 /* RuleItemView.swift */,
);
path = Rules;
sourceTree = "<group>";
@ -515,13 +515,13 @@
01BCDAE32C9ECD010028FA94 /* ContentTabs */ = {
isa = PBXGroup;
children = (
01BCDAC72C9ECD010028FA94 /* Config */,
01BCDACB2C9ECD010028FA94 /* Connections */,
01BCDACE2C9ECD010028FA94 /* Logs */,
01BCDAD22C9ECD010028FA94 /* Overview */,
01BCDADA2C9ECD010028FA94 /* Providers */,
01BCDADF2C9ECD010028FA94 /* Proxies */,
01BCDADA2C9ECD010028FA94 /* Providers */,
01BCDAE22C9ECD010028FA94 /* Rules */,
01BCDACB2C9ECD010028FA94 /* Connections */,
01BCDAC72C9ECD010028FA94 /* Config */,
01BCDACE2C9ECD010028FA94 /* Logs */,
01BCDAD32C9ECD010028FA94 /* ProviderProxiesView.swift */,
);
path = ContentTabs;

View File

@ -72,6 +72,13 @@ class DashboardViewContoller: NSViewController {
.info,
.debug
]
enum LogFilter: String, CaseIterable {
case all = "All"
case rule = "Rule"
case dns = "DNS"
case others = "Others"
}
private var sidebarItemObserver: NSObjectProtocol?
private var searchStringObserver: NSObjectProtocol?
@ -109,6 +116,7 @@ class DashboardViewContoller: NSViewController {
items.append(.stopConnsItem)
items.append(.searchItem)
case .logs:
items.append(.logFilterItem)
items.append(.logLevelItem)
items.append(.searchItem)
}
@ -187,6 +195,7 @@ extension NSToolbarItem.Identifier {
static let hideNamesItem = NSToolbarItem.Identifier("HideNamesItem")
static let stopConnsItem = NSToolbarItem.Identifier("StopConnsItem")
static let logLevelItem = NSToolbarItem.Identifier("LogLevelItem")
static let logFilterItem = NSToolbarItem.Identifier("logFilterItem")
static let searchItem = NSToolbarItem.Identifier("SearchItem")
}
@ -224,6 +233,14 @@ extension DashboardViewContoller: NSSearchFieldDelegate {
NotificationCenter.default.post(name: .logLevelChanged, object: nil, userInfo: ["level": level])
}
@objc func setLogFilter(_ sender: NSToolbarItemGroup) {
guard sender.selectedIndex < LogFilter.allCases.count, sender.selectedIndex >= 0 else { return }
let filter = LogFilter.allCases[sender.selectedIndex]
NotificationCenter.default.post(name: .logFilterChanged, object: nil, userInfo: ["filter": filter])
}
}
extension DashboardViewContoller: NSToolbarDelegate, NSToolbarItemValidation {
@ -254,7 +271,23 @@ extension DashboardViewContoller: NSToolbarDelegate, NSToolbarItemValidation {
group.controlRepresentation = .collapsed
group.selectedIndex = levels.firstIndex(of: ConfigManager.selectLoggingApiLevel) ?? 0
group.label = "Log Level"
return group
case .logFilterItem:
let titles = LogFilter.allCases.map {
$0.rawValue
}
let group = NSToolbarItemGroup(itemIdentifier: .logFilterItem, titles: titles, selectionMode: .selectOne, labels: titles, target: nil, action: #selector(setLogFilter(_:)))
group.selectionMode = .selectOne
group.controlRepresentation = .collapsed
group.selectedIndex = 0
group.label = "Log Filter"
return group
case .hideNamesItem:
let item = NSToolbarItem(itemIdentifier: .hideNamesItem)
item.target = self
@ -262,6 +295,9 @@ extension DashboardViewContoller: NSToolbarDelegate, NSToolbarItemValidation {
item.isBordered = true
item.tag = 0
item.image = NSImage(systemSymbolName: "wand.and.stars", accessibilityDescription: nil)
item.label = "Hide Names"
return item
case .stopConnsItem:
let item = NSToolbarItem(itemIdentifier: .stopConnsItem)
@ -269,6 +305,9 @@ extension DashboardViewContoller: NSToolbarDelegate, NSToolbarItemValidation {
item.action = #selector(stopConns(_:))
item.isBordered = true
item.image = NSImage(systemSymbolName: "stop.circle.fill", accessibilityDescription: nil)
item.label = "Stop All"
return item
default:
break
@ -284,6 +323,7 @@ extension DashboardViewContoller: NSToolbarDelegate, NSToolbarItemValidation {
.stopConnsItem,
.hideNamesItem,
.logLevelItem,
.logFilterItem,
.searchItem
]
}
@ -294,6 +334,7 @@ extension DashboardViewContoller: NSToolbarDelegate, NSToolbarItemValidation {
.stopConnsItem,
.hideNamesItem,
.logLevelItem,
.logFilterItem,
.searchItem
]
}

View File

@ -14,4 +14,5 @@ extension NSNotification.Name {
static let stopConns = NSNotification.Name("StopConns")
static let hideNames = NSNotification.Name("HideNames")
static let logLevelChanged = NSNotification.Name("LogLevelChanged")
static let logFilterChanged = NSNotification.Name("LogFilterChanged")
}

View File

@ -103,7 +103,7 @@ class DBProxy: ObservableObject {
switch delay {
case 0:
return .gray
return .red
case ..<200 where !httpsTest:
return .green
case ..<800 where httpsTest:
@ -118,3 +118,19 @@ class DBProxy: ObservableObject {
}
}
extension String {
var hiddenID: String {
guard UUID(uuidString: self) != nil else { return "" }
let components = split(separator: "-").map(String.init)
guard components.count == 5 else { return "" }
let re = components[0].prefix(2)
+ components[1].prefix(1)
+ components[2].prefix(1)
+ components[3].prefix(1)
+ components[4].suffix(3)
return String(re)
}
}

View File

@ -22,7 +22,7 @@ struct ConfigItemView<Content: View>: View {
HStack(content: content)
}
.padding(EdgeInsets(top: 10, leading: 13, bottom: 10, trailing: 13))
.background(Color(compatible: .textBackgroundColor))
.background(Color("SwiftUI Colors/ContentBackgroundColor"))
.cornerRadius(10)
}
}

View File

@ -46,6 +46,7 @@ struct ConfigView: View {
content2
.padding()
}
.background(Color("SwiftUI Colors/WindowBackgroundColor"))
.disabled(!configInited)
.onAppear {
configInited = false

View File

@ -17,6 +17,7 @@ struct LogsTableView<Item: Hashable>: NSViewRepresentable {
var data: [Item]
var filterString: String
var logFilter: DashboardViewContoller.LogFilter
class NonRespondingScrollView: NSScrollView {
override var acceptsFirstResponder: Bool { false }
@ -84,6 +85,29 @@ struct LogsTableView<Item: Hashable>: NSViewRepresentable {
"log",
]
switch logFilter {
case .all:
break
case .rule:
re = re.filter {
$0.log.starts(with: "[Rule")
|| $0.log.starts(with: "[TCP")
|| $0.log.starts(with: "[UDP")
}
case .dns:
re = re.filter {
$0.log.starts(with: "[DNS")
}
case .others:
re = re.filter {
!$0.log.starts(with: "[DNS")
&& !$0.log.starts(with: "[Rule")
&& !$0.log.starts(with: "[TCP")
&& !$0.log.starts(with: "[UDP")
}
}
re = re.filtered(filterString, for: filterKeys)
return re

View File

@ -11,11 +11,17 @@ struct LogsView: View {
@EnvironmentObject var logStorage: ClashLogStorage
@State var searchString: String = ""
@State var logFilter = DashboardViewContoller.LogFilter.all
@State var logLevel = ConfigManager.selectLoggingApiLevel
var body: some View {
Group {
LogsTableView(data: logStorage.logs.reversed(), filterString: searchString)
LogsTableView(
data: logStorage.logs.reversed(),
filterString: searchString,
logFilter: logFilter
)
}
.onAppear {
guard let s = ToolbarStore.shared.searchStrings["logs"] else { return }
@ -33,6 +39,10 @@ struct LogsView: View {
guard let level = $0.userInfo?["level"] as? ClashLogLevel else { return }
logLevelChanged(level)
}
.onReceive(NotificationCenter.default.publisher(for: .logFilterChanged)) {
guard let level = $0.userInfo?["filter"] as? DashboardViewContoller.LogFilter else { return }
logFilterChanged(level)
}
}
func logLevelChanged(_ level: ClashLogLevel) {
@ -40,6 +50,10 @@ struct LogsView: View {
ConfigManager.selectLoggingApiLevel = level
ApiRequest.shared.resetLogStreamApi()
}
func logFilterChanged(_ filter: DashboardViewContoller.LogFilter) {
logFilter = filter
}
}
struct LogsView_Previews: PreviewProvider {

View File

@ -24,7 +24,7 @@ struct OverviewTopItemView: View {
}
.frame(width: 125)
.padding(EdgeInsets(top: 10, leading: 13, bottom: 10, trailing: 13))
.background(Color(compatible: .textBackgroundColor))
.background(Color("SwiftUI Colors/ContentBackgroundColor"))
.cornerRadius(10)
}
}

View File

@ -72,6 +72,7 @@ struct OverviewView: View {
self.version = $0?.version ?? ""
}
}
.background(Color("SwiftUI Colors/WindowBackgroundColor"))
}
func updateColumnCount(_ width: Double) {

View File

@ -23,7 +23,7 @@ struct ProviderRowView: View {
VStack(spacing: 2) {
HStack(alignment: .center) {
Text(hideProxyNames.hide
? String(proxyProvider.id.prefix(8))
? String(proxyProvider.id.hiddenID)
: proxyProvider.name)
.font(.system(size: 15))
Spacer()

View File

@ -15,11 +15,11 @@ struct ProvidersView: View {
@StateObject private var hideProxyNames = HideProxyNames()
var body: some View {
NavigationView {
listView
EmptyView()
}
.background(Color("SwiftUI Colors/WindowBackgroundColor"))
.onReceive(NotificationCenter.default.publisher(for: .toolbarSearchString)) {
guard let string = $0.userInfo?["String"] as? String else { return }
searchString.string = string

View File

@ -36,7 +36,7 @@ struct ProxyProviderInfoView: View {
var header: some View {
HStack() {
Text(hideProxyNames.hide
? String(provider.id.prefix(8))
? String(provider.id.hiddenID)
: provider.name)
.font(.system(size: 17))
Text(provider.vehicleType.rawValue)

View File

@ -15,7 +15,7 @@ struct RuleProviderView: View {
VStack(alignment: .leading) {
HStack {
Text(provider.name)
.font(.title)
.font(.title2)
.fontWeight(.medium)
Text(provider.type)
Text(provider.behavior)

View File

@ -33,6 +33,7 @@ struct ProxiesView: View {
.listStyle(.plain)
EmptyView()
}
.background(Color("SwiftUI Colors/WindowBackgroundColor"))
.onReceive(NotificationCenter.default.publisher(for: .toolbarSearchString)) {
guard let string = $0.userInfo?["String"] as? String else { return }
searchString.string = string

View File

@ -24,7 +24,7 @@ struct ProxyGroupRowView: View {
VStack(spacing: 2) {
HStack(alignment: .center) {
Text(hideProxyNames.hide
? String(proxyGroup.id.prefix(8))
? String(proxyGroup.id.hiddenID)
: proxyGroup.name)
.font(.system(size: 15))
Spacer()
@ -40,7 +40,7 @@ struct ProxyGroupRowView: View {
Spacer()
if let proxy = proxyGroup.currentProxy {
Text(hideProxyNames.hide
? String(proxy.id.prefix(8))
? String(proxy.id.hiddenID)
: proxy.name)
}
}
@ -50,4 +50,3 @@ struct ProxyGroupRowView: View {
.padding(EdgeInsets(top: 3, leading: 4, bottom: 3, trailing: 4))
}
}

View File

@ -73,7 +73,7 @@ struct ProxyGroupView: View {
var proxyInfoView: some View {
HStack() {
Text(hideProxyNames.hide
? String(proxyGroup.id.prefix(8))
? String(proxyGroup.id.hiddenID)
: proxyGroup.name)
.font(.system(size: 17))
Text(proxyGroup.type.rawValue)

View File

@ -29,7 +29,7 @@ struct ProxyNodeView: View {
VStack {
HStack(alignment: .center) {
Text(hideProxyNames.hide
? String(proxy.id.prefix(8))
? String(proxy.id.hiddenID)
: proxy.name)
.truncationMode(.tail)
.lineLimit(1)
@ -62,7 +62,7 @@ struct ProxyNodeView: View {
guard selectable else { return }
mouseOver = $0
}
.frame(height: 36)
.frame(height: 34)
.padding(12)
.overlay(
RoundedRectangle(cornerRadius: 6)
@ -78,7 +78,7 @@ struct ProxyNodeView: View {
.padding(1)
)
.background(now == proxy.name ? Color.accentColor.opacity(0.7) : Color(compatible: .textBackgroundColor))
.background(now == proxy.name ? Color.accentColor.opacity(0.7) : Color("SwiftUI Colors/ContentBackgroundColor"))
}
}

View File

@ -0,0 +1,28 @@
{
"colors" : [
{
"color" : {
"platform" : "osx",
"reference" : "alternatingContentBackgroundColor"
},
"idiom" : "universal"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"color" : {
"platform" : "osx",
"reference" : "alternatingContentBackgroundColor"
},
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

View File

@ -0,0 +1,9 @@
{
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"provides-namespace" : true
}
}

View File

@ -0,0 +1,28 @@
{
"colors" : [
{
"color" : {
"platform" : "osx",
"reference" : "textBackgroundColor"
},
"idiom" : "universal"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"color" : {
"platform" : "osx",
"reference" : "textBackgroundColor"
},
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

View File

@ -31,6 +31,7 @@ enum ClashProxyType: String, Codable, CaseIterable {
case tuic = "Tuic"
case hysteria2 = "Hysteria2"
case ssh = "SSH"
case mieru = "mieru"
case pass = "Pass"