feat: add open config file in settings

This commit is contained in:
yicheng 2023-06-14 10:57:07 +08:00
parent d1fb3ffab5
commit fbe0fc4c99
8 changed files with 99 additions and 13 deletions

View File

@ -1587,10 +1587,10 @@
<font key="font" metaFont="system"/>
</buttonCell>
</button>
<stackView distribution="fill" orientation="horizontal" alignment="top" horizontalStackHuggingPriority="249.99998474121094" verticalStackHuggingPriority="249.99998474121094" detachesHiddenViews="YES" translatesAutoresizingMaskIntoConstraints="NO" id="BPB-SW-GgH">
<rect key="frame" x="0.0" y="40" width="240" height="20"/>
<stackView distribution="fill" orientation="horizontal" alignment="top" horizontalStackHuggingPriority="249.99998474121094" verticalStackHuggingPriority="249.99998474121094" verticalHuggingPriority="1000" verticalCompressionResistancePriority="1000" detachesHiddenViews="YES" translatesAutoresizingMaskIntoConstraints="NO" id="BPB-SW-GgH">
<rect key="frame" x="0.0" y="80" width="240" height="20"/>
<subviews>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="FdV-ph-XP8">
<textField horizontalHuggingPriority="251" verticalHuggingPriority="1000" translatesAutoresizingMaskIntoConstraints="NO" id="FdV-ph-XP8">
<rect key="frame" x="-2" y="4" width="82" height="16"/>
<textFieldCell key="cell" lineBreakMode="clipping" title="Proxy Helper" id="aSG-9A-eeG">
<font key="font" usesAppearanceFont="YES"/>
@ -1598,7 +1598,7 @@
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="tk3-Vg-1aq">
<button verticalHuggingPriority="1000" translatesAutoresizingMaskIntoConstraints="NO" id="tk3-Vg-1aq">
<rect key="frame" x="79" y="-7" width="168" height="32"/>
<buttonCell key="cell" type="push" title="Uninstall Proxy Helper" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="AY0-nP-cGT">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
@ -1618,10 +1618,10 @@
<real value="3.4028234663852886e+38"/>
</customSpacing>
</stackView>
<stackView distribution="fill" orientation="horizontal" alignment="top" horizontalStackHuggingPriority="249.99998474121094" verticalStackHuggingPriority="249.99998474121094" detachesHiddenViews="YES" translatesAutoresizingMaskIntoConstraints="NO" id="pyT-RY-vER">
<rect key="frame" x="0.0" y="0.0" width="152" height="20"/>
<stackView distribution="fill" orientation="horizontal" alignment="top" horizontalStackHuggingPriority="249.99998474121094" verticalStackHuggingPriority="249.99998474121094" verticalHuggingPriority="1000" verticalCompressionResistancePriority="1000" detachesHiddenViews="YES" translatesAutoresizingMaskIntoConstraints="NO" id="pyT-RY-vER">
<rect key="frame" x="0.0" y="40" width="152" height="20"/>
<subviews>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="7Zc-tX-dnG">
<textField horizontalHuggingPriority="251" verticalHuggingPriority="1000" translatesAutoresizingMaskIntoConstraints="NO" id="7Zc-tX-dnG">
<rect key="frame" x="-2" y="4" width="27" height="16"/>
<textFieldCell key="cell" lineBreakMode="clipping" title="Log" id="c01-0L-1SQ">
<font key="font" usesAppearanceFont="YES"/>
@ -1629,7 +1629,7 @@
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Ewf-N4-Rnt">
<button verticalHuggingPriority="1000" translatesAutoresizingMaskIntoConstraints="NO" id="Ewf-N4-Rnt">
<rect key="frame" x="24" y="-7" width="135" height="32"/>
<buttonCell key="cell" type="push" title="Open Log Folder" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="afj-4G-usr">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
@ -1649,19 +1649,64 @@
<real value="3.4028234663852886e+38"/>
</customSpacing>
</stackView>
<stackView distribution="fill" orientation="horizontal" alignment="top" horizontalStackHuggingPriority="249.99998474121094" verticalStackHuggingPriority="249.99998474121094" verticalHuggingPriority="1000" verticalCompressionResistancePriority="1000" detachesHiddenViews="YES" translatesAutoresizingMaskIntoConstraints="NO" id="pbl-Xp-HwK">
<rect key="frame" x="0.0" y="0.0" width="210" height="20"/>
<subviews>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="1000" translatesAutoresizingMaskIntoConstraints="NO" id="iZQ-h9-mnr">
<rect key="frame" x="-2" y="4" width="86" height="16"/>
<textFieldCell key="cell" lineBreakMode="clipping" title="Config Folder" id="ZA9-qc-wi4">
<font key="font" usesAppearanceFont="YES"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<button verticalHuggingPriority="1000" translatesAutoresizingMaskIntoConstraints="NO" id="GVp-Y0-b7S">
<rect key="frame" x="83" y="-7" width="67" height="32"/>
<buttonCell key="cell" type="push" title="Local" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="YF4-uZ-A0M">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="actionOpenLocalConfig:" target="kdV-Em-qBi" id="ZNG-HP-Xh8"/>
</connections>
</button>
<button verticalHuggingPriority="1000" translatesAutoresizingMaskIntoConstraints="NO" id="cOa-Pe-WNF">
<rect key="frame" x="144" y="-7" width="73" height="32"/>
<buttonCell key="cell" type="push" title="iCloud" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="URV-fZ-bJf">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="actionOpenIcloudConfig:" target="kdV-Em-qBi" id="tnA-j0-SoW"/>
</connections>
</button>
</subviews>
<visibilityPriorities>
<integer value="1000"/>
<integer value="1000"/>
<integer value="1000"/>
</visibilityPriorities>
<customSpacing>
<real value="3.4028234663852886e+38"/>
<real value="3.4028234663852886e+38"/>
<real value="3.4028234663852886e+38"/>
</customSpacing>
</stackView>
</subviews>
<constraints>
<constraint firstAttribute="height" constant="96" id="85d-JE-GA8"/>
<constraint firstAttribute="height" constant="136" id="V8q-wn-ghc"/>
</constraints>
<visibilityPriorities>
<integer value="1000"/>
<integer value="1000"/>
<integer value="1000"/>
<integer value="1000"/>
</visibilityPriorities>
<customSpacing>
<real value="3.4028234663852886e+38"/>
<real value="3.4028234663852886e+38"/>
<real value="3.4028234663852886e+38"/>
<real value="3.4028234663852886e+38"/>
</customSpacing>
</stackView>
</subviews>

View File

@ -15,7 +15,7 @@ class ICloudManager {
private let queue = DispatchQueue(label: "com.clashx.icloud")
private var metaQuery: NSMetadataQuery?
private var enableMenuItem: NSMenuItem?
private var icloudAvailable = false {
private(set) var icloudAvailable = false {
didSet { useiCloud.accept(userEnableiCloud && icloudAvailable) }
}
private var disposeBag = DisposeBag()

View File

@ -88,6 +88,9 @@
/* No comment provided by engineer. */
"hours" = "hours";
/* No comment provided by engineer. */
"iCloud not available" = "iCloud not available";
/* No comment provided by engineer. */
"If you can not find ClashX in the settings, you can try reset daemon" = "If you can not find ClashX in the settings, you can try reset daemon";

View File

@ -88,6 +88,9 @@
/* No comment provided by engineer. */
"hours" = "小时";
/* No comment provided by engineer. */
"iCloud not available" = "iCloud 不可用";
/* No comment provided by engineer. */
"If you can not find ClashX in the settings, you can try reset daemon" = "如果在设置里没找到ClashX,可以尝试重置守护程序";

View File

@ -88,6 +88,9 @@
/* No comment provided by engineer. */
"hours" = "小時";
/* No comment provided by engineer. */
"iCloud not available" = "iCloud 不可用";
/* No comment provided by engineer. */
"If you can not find ClashX in the settings, you can try reset daemon" = "如果在設定裡沒找到ClashX,可以嘗試重置守護程序";

View File

@ -25,4 +25,21 @@ class DebugSettingViewController: NSViewController {
@IBAction func actionOpenLogFolder(_ sender: Any) {
NSWorkspace.shared.openFile(Logger.shared.logFolder())
}
@IBAction func actionOpenLocalConfig(_ sender: Any) {
NSWorkspace.shared.openFile(kConfigFolderPath)
}
@IBAction func actionOpenIcloudConfig(_ sender: Any) {
if ICloudManager.shared.icloudAvailable {
ICloudManager.shared.getUrl {
url in
if let url = url {
NSWorkspace.shared.open(url)
}
}
} else {
NSAlert.alert(with: NSLocalizedString("iCloud not available", comment: ""))
}
}
}

View File

@ -288,3 +288,12 @@
/* Class = "NSTextFieldCell"; title = "Api Secret:"; ObjectID = "ckH-Er-PfX"; */
"ckH-Er-PfX.title" = "Api秘钥";
/* Class = "NSButtonCell"; title = "iCloud"; ObjectID = "URV-fZ-bJf"; */
"URV-fZ-bJf.title" = "iCloud";
/* Class = "NSButtonCell"; title = "Local"; ObjectID = "YF4-uZ-A0M"; */
"YF4-uZ-A0M.title" = "本地";
/* Class = "NSTextFieldCell"; title = "Config Folder"; ObjectID = "ZA9-qc-wi4"; */
"ZA9-qc-wi4.title" = "配置文件夹";

View File

@ -283,11 +283,17 @@
/* Class = "NSTextFieldCell"; title = "Core Version"; ObjectID = "zwo-q5-k5N"; */
"zwo-q5-k5N.title" = "核心版本";
/* Class = "NSTextFieldCell"; title = "Proxy Helper"; ObjectID = "aSG-9A-eeG"; */
"aSG-9A-eeG.title" = "代理程式";
/* Class = "NSButtonCell"; title = "Override Config Setting"; ObjectID = "LW4-cA-3bB"; */
"LW4-cA-3bB.title" = "覆蓋配置文件設置";
/* Class = "NSTextFieldCell"; title = "Api Secret:"; ObjectID = "ckH-Er-PfX"; */
"ckH-Er-PfX.title" = "API 秘鑰";
/* Class = "NSButtonCell"; title = "iCloud"; ObjectID = "URV-fZ-bJf"; */
"URV-fZ-bJf.title" = "iCloud";
/* Class = "NSButtonCell"; title = "Local"; ObjectID = "YF4-uZ-A0M"; */
"YF4-uZ-A0M.title" = "本地";
/* Class = "NSTextFieldCell"; title = "Config Folder"; ObjectID = "ZA9-qc-wi4"; */
"ZA9-qc-wi4.title" = "配置文件夾";