misc: swift lint
# Conflicts: # ClashX.xcodeproj/project.pbxproj # ClashX/General/ApiRequest.swift # ClashX/General/Managers/ProManager.swift # ClashX/General/Managers/Settings.swift # ClashX/General/Managers/TunManager.swift # ClashX/General/Utils/NetworkChangeNotifier.swift # ClashX/ViewControllers/ClashWebViewContoller.swift
This commit is contained in:
parent
6df282db23
commit
c6c74dd888
19
.swiftlint.yml
Normal file
19
.swiftlint.yml
Normal file
@ -0,0 +1,19 @@
|
||||
# By default, SwiftLint uses a set of sensible default rules you can adjust:
|
||||
disabled_rules: # rule identifiers turned on by default to exclude from running
|
||||
- colon
|
||||
- identifier_name
|
||||
- force_cast
|
||||
- closure_parameter_position
|
||||
- file_length
|
||||
- large_tuple
|
||||
- type_body_length
|
||||
included: # paths to include during linting. `--path` is ignored if present.
|
||||
- ClashX
|
||||
excluded: # paths to ignore during linting. Takes precedence over `included`.
|
||||
- ClashX/Vendor
|
||||
- Pods
|
||||
analyzer_rules: # Rules run by `swiftlint analyze`
|
||||
- explicit_self
|
||||
# implicitly
|
||||
line_length: 300
|
||||
# reporter: "xcode"
|
@ -53,7 +53,7 @@
|
||||
49B445162457CDF000B27E3E /* ClashStatusTool.swift in Sources */ = {isa = PBXBuildFile; fileRef = 49B445152457CDF000B27E3E /* ClashStatusTool.swift */; };
|
||||
49B4575D244F4A2A00463C39 /* PrivilegedHelperManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 49B4575C244F4A2A00463C39 /* PrivilegedHelperManager.swift */; };
|
||||
49B4575F244FD4D100463C39 /* PrivilegedHelperManager+Legacy.swift in Sources */ = {isa = PBXBuildFile; fileRef = 49B4575E244FD4D100463C39 /* PrivilegedHelperManager+Legacy.swift */; };
|
||||
49BB31E7246853EA008A4CB0 /* iCloudManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 49BB31E6246853EA008A4CB0 /* iCloudManager.swift */; };
|
||||
49BB31E7246853EA008A4CB0 /* ICloudManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 49BB31E6246853EA008A4CB0 /* ICloudManager.swift */; };
|
||||
49BC061C212931F4005A0FE7 /* AboutViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 49BC061B212931F4005A0FE7 /* AboutViewController.swift */; };
|
||||
49C9EF64223E78F5005D8B6A /* ClashProxy.swift in Sources */ = {isa = PBXBuildFile; fileRef = 49C9EF63223E78F5005D8B6A /* ClashProxy.swift */; };
|
||||
49CF3B2120CD7463001EBF94 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 49CF3B2020CD7463001EBF94 /* AppDelegate.swift */; };
|
||||
@ -176,7 +176,7 @@
|
||||
49B445152457CDF000B27E3E /* ClashStatusTool.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClashStatusTool.swift; sourceTree = "<group>"; };
|
||||
49B4575C244F4A2A00463C39 /* PrivilegedHelperManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PrivilegedHelperManager.swift; sourceTree = "<group>"; };
|
||||
49B4575E244FD4D100463C39 /* PrivilegedHelperManager+Legacy.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "PrivilegedHelperManager+Legacy.swift"; sourceTree = "<group>"; };
|
||||
49BB31E6246853EA008A4CB0 /* iCloudManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = iCloudManager.swift; sourceTree = "<group>"; };
|
||||
49BB31E6246853EA008A4CB0 /* ICloudManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ICloudManager.swift; sourceTree = "<group>"; };
|
||||
49BC061B212931F4005A0FE7 /* AboutViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AboutViewController.swift; sourceTree = "<group>"; };
|
||||
49C9EF63223E78F5005D8B6A /* ClashProxy.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClashProxy.swift; sourceTree = "<group>"; };
|
||||
49CF3B1D20CD7463001EBF94 /* ClashX.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ClashX.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
@ -299,7 +299,7 @@
|
||||
F9E754CF239CC21F00CEE7CC /* WebPortalManager.swift */,
|
||||
49B4575C244F4A2A00463C39 /* PrivilegedHelperManager.swift */,
|
||||
49B4575E244FD4D100463C39 /* PrivilegedHelperManager+Legacy.swift */,
|
||||
49BB31E6246853EA008A4CB0 /* iCloudManager.swift */,
|
||||
49BB31E6246853EA008A4CB0 /* ICloudManager.swift */,
|
||||
499ADAFC2498CC5900C488FE /* RemoteControlManager.swift */,
|
||||
4929F67E258CE04700A435F6 /* Settings.swift */,
|
||||
);
|
||||
@ -751,7 +751,7 @@
|
||||
F976275C23634DF8000EDEFE /* LoginServiceKit.swift in Sources */,
|
||||
4966E9E6211824F300A391FB /* NSImage+extension.swift in Sources */,
|
||||
F92D0B2E236D35C000575E15 /* ProxyItemView.swift in Sources */,
|
||||
49BB31E7246853EA008A4CB0 /* iCloudManager.swift in Sources */,
|
||||
49BB31E7246853EA008A4CB0 /* ICloudManager.swift in Sources */,
|
||||
49B1086A216A356D0064FFCE /* String+Extension.swift in Sources */,
|
||||
F92D0B2C236C7C3600575E15 /* MenuItemBaseView.swift in Sources */,
|
||||
499ADAFD2498CC5900C488FE /* RemoteControlManager.swift in Sources */,
|
||||
|
@ -1,10 +1,28 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "1020"
|
||||
version = "1.3">
|
||||
version = "1.7">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
buildImplicitDependencies = "YES">
|
||||
<PreActions>
|
||||
<ExecutionAction
|
||||
ActionType = "Xcode.IDEStandardExecutionActionsCore.ExecutionActionType.ShellScriptAction">
|
||||
<ActionContent
|
||||
title = "Run Script"
|
||||
scriptText = "export PATH="$PATH:/opt/homebrew/bin" if which swiftlint > /dev/null; then cd $PROJECT_DIR && swiftlint --fix && swiftlint else echo "warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint" fi ">
|
||||
<EnvironmentBuildable>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "49CF3B1C20CD7463001EBF94"
|
||||
BuildableName = "ClashX Pro.app"
|
||||
BlueprintName = "ClashX Pro"
|
||||
ReferencedContainer = "container:ClashX.xcodeproj">
|
||||
</BuildableReference>
|
||||
</EnvironmentBuildable>
|
||||
</ActionContent>
|
||||
</ExecutionAction>
|
||||
</PreActions>
|
||||
<BuildActionEntries>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
|
@ -15,7 +15,6 @@ import RxSwift
|
||||
import AppCenter
|
||||
import AppCenterAnalytics
|
||||
|
||||
|
||||
private let statusItemLengthWithSpeed: CGFloat = 72
|
||||
|
||||
@NSApplicationMain
|
||||
@ -90,7 +89,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
||||
}
|
||||
setupStatusMenuItemData()
|
||||
AppVersionUtil.showUpgradeAlert()
|
||||
iCloudManager.shared.setup()
|
||||
ICloudManager.shared.setup()
|
||||
setupExperimentalMenuItem()
|
||||
|
||||
// install proxy helper
|
||||
@ -121,7 +120,6 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
||||
|
||||
RemoteConfigManager.shared.autoUpdateCheck()
|
||||
|
||||
|
||||
setupNetworkNotifier()
|
||||
}
|
||||
|
||||
@ -492,7 +490,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
||||
if WebPortalManager.hasWebProtal {
|
||||
WebPortalManager.shared.addWebProtalMenuItem(&statusMenu)
|
||||
}
|
||||
iCloudManager.shared.addEnableMenuItem(&experimentalMenu)
|
||||
ICloudManager.shared.addEnableMenuItem(&experimentalMenu)
|
||||
AutoUpgardeManager.shared.setup()
|
||||
AutoUpgardeManager.shared.addChanelMenuItem(&experimentalMenu)
|
||||
updateExperimentalFeatureStatus()
|
||||
@ -590,7 +588,7 @@ extension AppDelegate {
|
||||
}
|
||||
let config = ConfigManager.shared.currentConfig?.copy()
|
||||
config?.mode = mode
|
||||
ApiRequest.updateOutBoundMode(mode: mode) { success in
|
||||
ApiRequest.updateOutBoundMode(mode: mode) { _ in
|
||||
ConfigManager.shared.currentConfig = config
|
||||
ConfigManager.selectOutBoundMode = mode
|
||||
MenuItemFactory.recreateProxyMenuItems()
|
||||
@ -697,8 +695,8 @@ extension AppDelegate {
|
||||
|
||||
extension AppDelegate {
|
||||
@IBAction func openConfigFolder(_ sender: Any) {
|
||||
if iCloudManager.shared.isICloudEnable() {
|
||||
iCloudManager.shared.getUrl() {
|
||||
if ICloudManager.shared.isICloudEnable() {
|
||||
ICloudManager.shared.getUrl {
|
||||
url in
|
||||
if let url = url {
|
||||
NSWorkspace.shared.open(url)
|
||||
@ -747,6 +745,7 @@ extension AppDelegate {
|
||||
@IBAction func actionUpdateProxyGroupMenu(_ sender: Any) {
|
||||
ConfigManager.shared.disableShowCurrentProxyInMenu = !ConfigManager.shared.disableShowCurrentProxyInMenu
|
||||
updateExperimentalFeatureStatus()
|
||||
print("211")
|
||||
MenuItemFactory.recreateProxyMenuItems()
|
||||
}
|
||||
|
||||
@ -780,7 +779,7 @@ extension AppDelegate {
|
||||
#else
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 5) {
|
||||
AppCenter.start(withAppSecret: "dce6e9a3-b6e3-4fd2-9f2d-35c767a99663", services: [
|
||||
Analytics.self,
|
||||
Analytics.self
|
||||
])
|
||||
}
|
||||
|
||||
@ -842,8 +841,8 @@ extension AppDelegate {
|
||||
}
|
||||
}
|
||||
|
||||
if iCloudManager.shared.isICloudEnable() {
|
||||
iCloudManager.shared.getConfigFilesList { list in
|
||||
if ICloudManager.shared.isICloudEnable() {
|
||||
ICloudManager.shared.getConfigFilesList { list in
|
||||
action(list)
|
||||
}
|
||||
} else {
|
||||
|
@ -16,7 +16,7 @@ extension NSImage {
|
||||
|
||||
color.set()
|
||||
|
||||
let imageRect = NSRect(origin: NSZeroPoint, size: image.size)
|
||||
let imageRect = NSRect(origin: NSPoint.zero, size: image.size)
|
||||
imageRect.fill(using: .sourceIn)
|
||||
|
||||
image.unlockFocus()
|
||||
|
@ -27,7 +27,7 @@ extension NSUserNotificationCenter {
|
||||
self?.postNotification(title: title, info: info, identifier: identifier)
|
||||
}
|
||||
case .notDetermined:
|
||||
notificationCenter.requestAuthorization(options: .alert) { granted, err in
|
||||
notificationCenter.requestAuthorization(options: .alert) { granted, _ in
|
||||
if granted {
|
||||
DispatchQueue.main.async {
|
||||
self?.postNotification(title: title, info: info, identifier: identifier)
|
||||
@ -60,7 +60,7 @@ extension NSUserNotificationCenter {
|
||||
notificationCenter.delegate = UserNotificationCenterDelegate.shared
|
||||
notificationCenter.removeAllDeliveredNotifications()
|
||||
notificationCenter.removeAllPendingNotificationRequests()
|
||||
let content = UNMutableNotificationContent();
|
||||
let content = UNMutableNotificationContent()
|
||||
content.title = title
|
||||
content.body = info
|
||||
content.userInfo = userInfo
|
||||
@ -176,4 +176,3 @@ class UserNotificationCenterDelegate: NSObject, NSUserNotificationCenterDelegate
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,3 @@
|
||||
|
||||
import Alamofire
|
||||
import AppKit
|
||||
import Foundation
|
||||
|
@ -55,8 +55,8 @@ class ConfigManager {
|
||||
}
|
||||
|
||||
static func watchCurrentConfigFile() {
|
||||
if iCloudManager.shared.isICloudEnable() {
|
||||
iCloudManager.shared.getUrl { url in
|
||||
if ICloudManager.shared.isICloudEnable() {
|
||||
ICloudManager.shared.getUrl { url in
|
||||
guard let url = url else { return }
|
||||
let configUrl = url.appendingPathComponent(Paths.configFileName(for: selectConfigName))
|
||||
ConfigFileManager.shared.watchFile(path: configUrl.path)
|
||||
|
@ -8,8 +8,8 @@
|
||||
|
||||
import Cocoa
|
||||
|
||||
class iCloudManager {
|
||||
static let shared = iCloudManager()
|
||||
class ICloudManager {
|
||||
static let shared = ICloudManager()
|
||||
private let queue = DispatchQueue(label: "com.clashx.icloud")
|
||||
private var metaQuery: NSMetadataQuery?
|
||||
private var enableMenuItem: NSMenuItem?
|
||||
@ -104,7 +104,7 @@ class iCloudManager {
|
||||
}
|
||||
}
|
||||
|
||||
extension iCloudManager {
|
||||
extension ICloudManager {
|
||||
func addEnableMenuItem(_ menu: inout NSMenu) {
|
||||
let item = NSMenuItem(title: NSLocalizedString("Use iCloud", comment: ""), action: #selector(enableMenuItemTap(sender:)), keyEquivalent: "")
|
||||
menu.addItem(item)
|
@ -83,8 +83,8 @@ class MenuItemFactory {
|
||||
return
|
||||
}
|
||||
|
||||
if iCloudManager.shared.isICloudEnable() {
|
||||
iCloudManager.shared.getConfigFilesList {
|
||||
if ICloudManager.shared.isICloudEnable() {
|
||||
ICloudManager.shared.getConfigFilesList {
|
||||
complete($0.map { generateMenuItem($0) })
|
||||
}
|
||||
} else {
|
||||
@ -113,8 +113,7 @@ class MenuItemFactory {
|
||||
|
||||
private static func generateSelectorMenuItem(proxyGroup: ClashProxy,
|
||||
proxyInfo: ClashProxyResp,
|
||||
leftPadding: Bool) -> NSMenuItem?
|
||||
{
|
||||
leftPadding: Bool) -> NSMenuItem? {
|
||||
let proxyMap = proxyInfo.proxiesMap
|
||||
|
||||
let isGlobalMode = ConfigManager.shared.currentConfig?.mode == .global
|
||||
@ -150,8 +149,7 @@ class MenuItemFactory {
|
||||
|
||||
private static func generateUrlTestFallBackMenuItem(proxyGroup: ClashProxy,
|
||||
proxyInfo: ClashProxyResp,
|
||||
leftPadding: Bool) -> NSMenuItem?
|
||||
{
|
||||
leftPadding: Bool) -> NSMenuItem? {
|
||||
let proxyMap = proxyInfo.proxiesMap
|
||||
let selectedName = proxyGroup.now ?? ""
|
||||
let menu = NSMenuItem(title: proxyGroup.name, action: nil, keyEquivalent: "")
|
||||
|
@ -112,8 +112,6 @@ class PrivilegedHelperManager {
|
||||
return .success
|
||||
}
|
||||
|
||||
|
||||
|
||||
func helper(failture: (() -> Void)? = nil) -> ProxyConfigRemoteProcessProtocol? {
|
||||
connection = NSXPCConnection(machServiceName: PrivilegedHelperManager.machServiceName, options: NSXPCConnection.Options.privileged)
|
||||
connection?.remoteObjectInterface = NSXPCInterface(with: ProxyConfigRemoteProcessProtocol.self)
|
||||
@ -225,7 +223,7 @@ extension PrivilegedHelperManager {
|
||||
}
|
||||
}
|
||||
|
||||
fileprivate struct AppAuthorizationRights {
|
||||
private struct AppAuthorizationRights {
|
||||
static let rightName: NSString = "\(PrivilegedHelperManager.machServiceName).config" as NSString
|
||||
static let rightDefaultRule: Dictionary = adminRightsRule
|
||||
static let rightDescription: CFString = "ProxyConfigHelper wants to configure your proxy setting'" as CFString
|
||||
@ -235,7 +233,7 @@ fileprivate struct AppAuthorizationRights {
|
||||
"version": 1]
|
||||
}
|
||||
|
||||
fileprivate enum DaemonInstallResult {
|
||||
private enum DaemonInstallResult {
|
||||
case success
|
||||
case authorizationFail
|
||||
case getAdminFail
|
||||
|
@ -173,7 +173,7 @@ class RemoteConfigManager {
|
||||
}
|
||||
config.isPlaceHolderName = false
|
||||
|
||||
if iCloudManager.shared.isICloudEnable() {
|
||||
if ICloudManager.shared.isICloudEnable() {
|
||||
ConfigFileManager.shared.stopWatchConfigFile()
|
||||
} else if config.name == ConfigManager.selectConfigName {
|
||||
ConfigFileManager.shared.pauseForNextChange()
|
||||
@ -192,8 +192,8 @@ class RemoteConfigManager {
|
||||
}
|
||||
}
|
||||
|
||||
if iCloudManager.shared.isICloudEnable() {
|
||||
iCloudManager.shared.getUrl { url in
|
||||
if ICloudManager.shared.isICloudEnable() {
|
||||
ICloudManager.shared.getUrl { url in
|
||||
guard let url = url else { return }
|
||||
let saveUrl = url.appendingPathComponent(Paths.configFileName(for: config.name))
|
||||
saveAction(saveUrl.path)
|
||||
|
@ -28,7 +28,6 @@ class RemoteControlManager {
|
||||
static var selected: String
|
||||
}
|
||||
|
||||
|
||||
static let shared = RemoteControlManager()
|
||||
static var configs: [RemoteControl] = loadConfig() {
|
||||
didSet {
|
||||
|
@ -16,7 +16,7 @@ class JsBridgeUtil {
|
||||
|
||||
bridge.setWebViewDelegate(delegate)
|
||||
|
||||
bridge.registerHandler("isSystemProxySet") { anydata, responseCallback in
|
||||
bridge.registerHandler("isSystemProxySet") { _, responseCallback in
|
||||
responseCallback?(ConfigManager.shared.proxyPortAutoSet)
|
||||
}
|
||||
|
||||
@ -89,13 +89,13 @@ class JsBridgeUtil {
|
||||
let data = [
|
||||
"host": host,
|
||||
"port": port,
|
||||
"secret": ConfigManager.shared.overrideSecret ?? ConfigManager.shared.apiSecret,
|
||||
"secret": ConfigManager.shared.overrideSecret ?? ConfigManager.shared.apiSecret
|
||||
]
|
||||
callback?(data)
|
||||
}
|
||||
|
||||
// ping-pong
|
||||
bridge.registerHandler("ping") { [weak bridge] anydata, responseCallback in
|
||||
bridge.registerHandler("ping") { [weak bridge] _, responseCallback in
|
||||
bridge?.callHandler("pong")
|
||||
responseCallback?(true)
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ class NetworkChangeNotifier {
|
||||
name: NSWorkspace.didWakeNotification, object: nil
|
||||
)
|
||||
|
||||
let changed: SCDynamicStoreCallBack = { dynamicStore, _, _ in
|
||||
let changed: SCDynamicStoreCallBack = { _, _, _ in
|
||||
NotificationCenter.default.post(name: .systemNetworkStatusDidChange, object: nil)
|
||||
}
|
||||
var dynamicContext = SCDynamicStoreContext(version: 0, info: nil, retain: nil, release: nil, copyDescription: nil)
|
||||
@ -43,7 +43,7 @@ class NetworkChangeNotifier {
|
||||
}
|
||||
|
||||
private static func startIPChangeWatch() {
|
||||
let changed: SCDynamicStoreCallBack = { dynamicStore, _, _ in
|
||||
let changed: SCDynamicStoreCallBack = { _, _, _ in
|
||||
NotificationCenter.default.post(name: .systemNetworkStatusIPUpdate, object: nil)
|
||||
}
|
||||
var dynamicContext = SCDynamicStoreContext(version: 0, info: nil, retain: nil, release: nil, copyDescription: nil)
|
||||
|
@ -58,8 +58,8 @@ class ClashProxySpeedHistory: Codable {
|
||||
let time: Date
|
||||
let delay: Int
|
||||
|
||||
class hisDateFormaterInstance {
|
||||
static let shared = hisDateFormaterInstance()
|
||||
class HisDateFormaterInstance {
|
||||
static let shared = HisDateFormaterInstance()
|
||||
lazy var formater: DateFormatter = {
|
||||
var f = DateFormatter()
|
||||
f.dateFormat = "HH:mm"
|
||||
@ -75,7 +75,7 @@ class ClashProxySpeedHistory: Codable {
|
||||
}()
|
||||
|
||||
lazy var dateDisplay: String = {
|
||||
return hisDateFormaterInstance.shared.formater.string(from: time)
|
||||
return HisDateFormaterInstance.shared.formater.string(from: time)
|
||||
}()
|
||||
|
||||
lazy var displayString: String = "\(dateDisplay) \(delayDisplay)"
|
||||
@ -87,8 +87,8 @@ class ClashProxy: Codable {
|
||||
let all: [ClashProxyName]?
|
||||
let history: [ClashProxySpeedHistory]
|
||||
let now: ClashProxyName?
|
||||
weak var enclosingResp: ClashProxyResp? = nil
|
||||
weak var enclosingProvider: ClashProvider? = nil
|
||||
weak var enclosingResp: ClashProxyResp?
|
||||
weak var enclosingProvider: ClashProvider?
|
||||
|
||||
enum SpeedtestAbleItem {
|
||||
case proxy(name: ClashProxyName)
|
||||
|
@ -15,7 +15,7 @@ class ClashRule: Codable {
|
||||
}
|
||||
|
||||
class ClashRuleResponse: Codable {
|
||||
var rules: [ClashRule]? = nil
|
||||
var rules: [ClashRule]?
|
||||
|
||||
static func empty() -> ClashRuleResponse {
|
||||
return ClashRuleResponse()
|
||||
|
1
ClashX/Vendor/UserDefaultWrapper.swift
vendored
1
ClashX/Vendor/UserDefaultWrapper.swift
vendored
@ -64,7 +64,6 @@ extension UInt64: PropertyListValue {}
|
||||
extension Double: PropertyListValue {}
|
||||
extension Float: PropertyListValue {}
|
||||
|
||||
|
||||
extension Array: PropertyListValue where Element: PropertyListValue {}
|
||||
|
||||
extension Dictionary: PropertyListValue where Key == String, Value: PropertyListValue {}
|
||||
|
@ -64,7 +64,7 @@ class HyperlinkTextField: NSTextField {
|
||||
super.awakeFromNib()
|
||||
let attributes: [NSAttributedString.Key: Any] = [
|
||||
NSAttributedString.Key.foregroundColor: NSColor.linkColor,
|
||||
NSAttributedString.Key.underlineStyle: NSUnderlineStyle.single.rawValue as AnyObject,
|
||||
NSAttributedString.Key.underlineStyle: NSUnderlineStyle.single.rawValue as AnyObject
|
||||
]
|
||||
attributedStringValue = NSAttributedString(string: stringValue, attributes: attributes)
|
||||
}
|
||||
|
@ -137,7 +137,7 @@ class ExternalControlAddView: NSView {
|
||||
nameField.leadingAnchor.constraint(equalTo: urlTextField.leadingAnchor),
|
||||
nameLabel.centerYAnchor.constraint(equalTo: nameField.centerYAnchor),
|
||||
nameLabel.leadingAnchor.constraint(greaterThanOrEqualTo: leadingAnchor),
|
||||
nameField.leadingAnchor.constraint(equalTo: nameLabel.trailingAnchor, constant: 5),
|
||||
nameField.leadingAnchor.constraint(equalTo: nameLabel.trailingAnchor, constant: 5)
|
||||
])
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
//
|
||||
import AppKit
|
||||
|
||||
@objc protocol ProxyGroupMenuHighlightDelegate: class {
|
||||
@objc protocol ProxyGroupMenuHighlightDelegate: AnyObject {
|
||||
func highlight(item: NSMenuItem?)
|
||||
}
|
||||
|
||||
|
@ -66,7 +66,7 @@ extension ProxyGroupSpeedTestMenuItem: ProxyGroupMenuHighlightDelegate {
|
||||
}
|
||||
}
|
||||
|
||||
fileprivate class ProxyGroupSpeedTestMenuItemView: MenuItemBaseView {
|
||||
private class ProxyGroupSpeedTestMenuItemView: MenuItemBaseView {
|
||||
private let label: NSTextField
|
||||
|
||||
init(_ title: String) {
|
||||
|
@ -108,7 +108,7 @@ extension ProxyMenuItem {
|
||||
func getAttributedTitle(name: String, delay: String?) -> NSAttributedString {
|
||||
let paragraph = NSMutableParagraphStyle()
|
||||
paragraph.tabStops = [
|
||||
NSTextTab(textAlignment: .right, location: 65 + maxProxyNameLength, options: [:]),
|
||||
NSTextTab(textAlignment: .right, location: 65 + maxProxyNameLength, options: [:])
|
||||
]
|
||||
let proxyName = name.replacingOccurrences(of: "\t", with: " ")
|
||||
let str: String
|
||||
@ -122,7 +122,7 @@ extension ProxyMenuItem {
|
||||
string: str,
|
||||
attributes: [
|
||||
NSAttributedString.Key.paragraphStyle: paragraph,
|
||||
NSAttributedString.Key.font: NSFont.menuBarFont(ofSize: 14),
|
||||
NSAttributedString.Key.font: NSFont.menuBarFont(ofSize: 14)
|
||||
]
|
||||
)
|
||||
|
||||
|
@ -89,7 +89,6 @@ class StatusItemView: NSView {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
func updateSpeedLabel(up: Int, down: Int) {
|
||||
guard !speedContainerView.isHidden else { return }
|
||||
let finalUpStr = getSpeedString(for: up)
|
||||
|
Loading…
Reference in New Issue
Block a user