feat: remember remote controller selection
This commit is contained in:
parent
a65ce6b172
commit
da8528ef8f
|
@ -1074,17 +1074,28 @@
|
||||||
</connections>
|
</connections>
|
||||||
</buttonCell>
|
</buttonCell>
|
||||||
</button>
|
</button>
|
||||||
|
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="NYx-qw-0FN">
|
||||||
|
<rect key="frame" x="18" y="208" width="444" height="16"/>
|
||||||
|
<textFieldCell key="cell" lineBreakMode="clipping" title="This allows you to control the clash core running in the different machine" id="WkL-aX-66E">
|
||||||
|
<font key="font" metaFont="system"/>
|
||||||
|
<color key="textColor" name="secondaryLabelColor" catalog="System" colorSpace="catalog"/>
|
||||||
|
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
|
||||||
|
</textFieldCell>
|
||||||
|
</textField>
|
||||||
</subviews>
|
</subviews>
|
||||||
<constraints>
|
<constraints>
|
||||||
<constraint firstAttribute="bottom" secondItem="qwK-rg-RXo" secondAttribute="bottom" constant="20" id="1Dj-gP-2GM"/>
|
<constraint firstAttribute="bottom" secondItem="qwK-rg-RXo" secondAttribute="bottom" constant="20" id="1Dj-gP-2GM"/>
|
||||||
<constraint firstItem="Fs7-Ym-fVr" firstAttribute="leading" secondItem="qwK-rg-RXo" secondAttribute="trailing" constant="20" id="2VK-Ze-a7K"/>
|
<constraint firstItem="Fs7-Ym-fVr" firstAttribute="leading" secondItem="qwK-rg-RXo" secondAttribute="trailing" constant="20" id="2VK-Ze-a7K"/>
|
||||||
|
<constraint firstItem="NYx-qw-0FN" firstAttribute="top" secondItem="Apx-gL-RAm" secondAttribute="bottom" constant="8" symbolic="YES" id="3Jj-6X-1DG"/>
|
||||||
<constraint firstItem="qwK-rg-RXo" firstAttribute="leading" secondItem="hOe-c3-RXT" secondAttribute="leading" id="4Ls-h5-MsD"/>
|
<constraint firstItem="qwK-rg-RXo" firstAttribute="leading" secondItem="hOe-c3-RXT" secondAttribute="leading" id="4Ls-h5-MsD"/>
|
||||||
|
<constraint firstItem="NYx-qw-0FN" firstAttribute="leading" secondItem="Gao-fa-Dwr" secondAttribute="leading" constant="20" symbolic="YES" id="4QN-kP-92F"/>
|
||||||
<constraint firstItem="h2z-Vu-j5M" firstAttribute="leading" secondItem="Gao-fa-Dwr" secondAttribute="leading" constant="20" id="664-zM-zta"/>
|
<constraint firstItem="h2z-Vu-j5M" firstAttribute="leading" secondItem="Gao-fa-Dwr" secondAttribute="leading" constant="20" id="664-zM-zta"/>
|
||||||
<constraint firstItem="Apx-gL-RAm" firstAttribute="leading" secondItem="Gao-fa-Dwr" secondAttribute="leading" constant="20" id="Bqp-RP-QGF"/>
|
<constraint firstItem="Apx-gL-RAm" firstAttribute="leading" secondItem="Gao-fa-Dwr" secondAttribute="leading" constant="20" id="Bqp-RP-QGF"/>
|
||||||
|
<constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="NYx-qw-0FN" secondAttribute="trailing" constant="20" symbolic="YES" id="NDT-P5-GuC"/>
|
||||||
<constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="Fs7-Ym-fVr" secondAttribute="trailing" constant="100" id="Rnw-mk-spV"/>
|
<constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="Fs7-Ym-fVr" secondAttribute="trailing" constant="100" id="Rnw-mk-spV"/>
|
||||||
<constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="Apx-gL-RAm" secondAttribute="trailing" constant="20" symbolic="YES" id="T4S-3l-S7C"/>
|
<constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="Apx-gL-RAm" secondAttribute="trailing" constant="20" symbolic="YES" id="T4S-3l-S7C"/>
|
||||||
<constraint firstItem="Fs7-Ym-fVr" firstAttribute="width" secondItem="qwK-rg-RXo" secondAttribute="width" multiplier="0.971429" id="a5a-pA-stH"/>
|
<constraint firstItem="Fs7-Ym-fVr" firstAttribute="width" secondItem="qwK-rg-RXo" secondAttribute="width" multiplier="0.971429" id="a5a-pA-stH"/>
|
||||||
<constraint firstItem="h2z-Vu-j5M" firstAttribute="top" secondItem="Apx-gL-RAm" secondAttribute="bottom" constant="20" id="icD-eo-Zvk"/>
|
<constraint firstItem="h2z-Vu-j5M" firstAttribute="top" secondItem="NYx-qw-0FN" secondAttribute="bottom" constant="8" symbolic="YES" id="jG7-GJ-c7d"/>
|
||||||
<constraint firstAttribute="trailing" secondItem="h2z-Vu-j5M" secondAttribute="trailing" constant="20" id="lJG-V8-SxD"/>
|
<constraint firstAttribute="trailing" secondItem="h2z-Vu-j5M" secondAttribute="trailing" constant="20" id="lJG-V8-SxD"/>
|
||||||
<constraint firstItem="Apx-gL-RAm" firstAttribute="top" secondItem="Gao-fa-Dwr" secondAttribute="top" constant="20" id="mWI-7y-euZ"/>
|
<constraint firstItem="Apx-gL-RAm" firstAttribute="top" secondItem="Gao-fa-Dwr" secondAttribute="top" constant="20" id="mWI-7y-euZ"/>
|
||||||
<constraint firstItem="qwK-rg-RXo" firstAttribute="top" secondItem="h2z-Vu-j5M" secondAttribute="bottom" constant="20" id="pZe-fl-hIB"/>
|
<constraint firstItem="qwK-rg-RXo" firstAttribute="top" secondItem="h2z-Vu-j5M" secondAttribute="bottom" constant="20" id="pZe-fl-hIB"/>
|
||||||
|
|
|
@ -23,6 +23,12 @@ class RemoteControl: Codable {
|
||||||
}
|
}
|
||||||
|
|
||||||
class RemoteControlManager {
|
class RemoteControlManager {
|
||||||
|
enum Recorder {
|
||||||
|
@UserDefault("selectedRemoteControlConfigID", defaultValue: "")
|
||||||
|
static var selected: String
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static let shared = RemoteControlManager()
|
static let shared = RemoteControlManager()
|
||||||
static var configs: [RemoteControl] = loadConfig() {
|
static var configs: [RemoteControl] = loadConfig() {
|
||||||
didSet {
|
didSet {
|
||||||
|
@ -33,7 +39,12 @@ class RemoteControlManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static var selectConfig: RemoteControl?
|
static var selectConfig: RemoteControl? {
|
||||||
|
didSet {
|
||||||
|
Recorder.selected = selectConfig?.uuid ?? ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static var menuSeparator: NSMenuItem?
|
private static var menuSeparator: NSMenuItem?
|
||||||
|
|
||||||
static func loadConfig() -> [RemoteControl] {
|
static func loadConfig() -> [RemoteControl] {
|
||||||
|
@ -52,6 +63,21 @@ class RemoteControlManager {
|
||||||
menuSeparator = separator
|
menuSeparator = separator
|
||||||
updateMenuItems()
|
updateMenuItems()
|
||||||
updateDropDownMenuItems()
|
updateDropDownMenuItems()
|
||||||
|
DispatchQueue.main.asyncAfter(deadline: .now() + 3) {
|
||||||
|
RemoteControlManager.recoverSelection()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static private func recoverSelection() {
|
||||||
|
if Recorder.selected != "" {
|
||||||
|
if let config = configs.first(where: { $0.uuid == Recorder.selected }) {
|
||||||
|
selectConfig = config
|
||||||
|
updateRemoteControl()
|
||||||
|
updateMenuItems()
|
||||||
|
} else {
|
||||||
|
Recorder.selected = ""
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static func updateMenuItems() {
|
static func updateMenuItems() {
|
||||||
|
|
|
@ -16,6 +16,7 @@ class ExternalControlViewController: NSViewController {
|
||||||
override func viewDidLoad() {
|
override func viewDidLoad() {
|
||||||
super.viewDidLoad()
|
super.viewDidLoad()
|
||||||
updateButtonStatus()
|
updateButtonStatus()
|
||||||
|
NSApp.activate(ignoringOtherApps: true)
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateButtonStatus() {
|
func updateButtonStatus() {
|
||||||
|
|
|
@ -180,10 +180,13 @@
|
||||||
"yO6-uZ-IRv.headerCell.title" = "Api Url";
|
"yO6-uZ-IRv.headerCell.title" = "Api Url";
|
||||||
|
|
||||||
/* Class = "NSMenu"; title = "Remote Controller"; ObjectID = "1He-Eq-fSy"; */
|
/* Class = "NSMenu"; title = "Remote Controller"; ObjectID = "1He-Eq-fSy"; */
|
||||||
"1He-Eq-fSy.title" = "远程控制";
|
"1He-Eq-fSy.title" = "远程控制器";
|
||||||
|
|
||||||
/* Class = "NSMenuItem"; title = "Remote Controller"; ObjectID = "BRR-WK-aeP"; */
|
/* Class = "NSMenuItem"; title = "Remote Controller"; ObjectID = "BRR-WK-aeP"; */
|
||||||
"BRR-WK-aeP.title" = "远程控制";
|
"BRR-WK-aeP.title" = "远程控制器";
|
||||||
|
|
||||||
/* Class = "NSMenuItem"; title = " Manage"; ObjectID = "hlb-KQ-Fdr"; */
|
/* Class = "NSMenuItem"; title = " Manage"; ObjectID = "hlb-KQ-Fdr"; */
|
||||||
"hlb-KQ-Fdr.title" = "管理";
|
"hlb-KQ-Fdr.title" = "管理";
|
||||||
|
|
||||||
|
/* Class = "NSTextFieldCell"; title = "This allows you to control the clash core running in the different machine"; ObjectID = "WkL-aX-66E"; */
|
||||||
|
"WkL-aX-66E.title" = "远程控制器允许你控制其他设备上的 Clash 状态。";
|
||||||
|
|
Loading…
Reference in New Issue