feat: add uninstall proxy helper

This commit is contained in:
yicheng 2023-05-26 16:40:25 +08:00
parent b55de35e3b
commit 3a5f61b02c
4 changed files with 52 additions and 8 deletions

View File

@ -1521,31 +1521,64 @@
<objects>
<viewController title="Debug" showSeguePresentationStyle="single" id="kdV-Em-qBi" customClass="DebugSettingViewController" customModule="ClashX" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" id="mud-rj-Isy">
<rect key="frame" x="0.0" y="0.0" width="416" height="117"/>
<rect key="frame" x="0.0" y="0.0" width="416" height="157"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<box title="Debug Setting" translatesAutoresizingMaskIntoConstraints="NO" id="NLT-FZ-48V">
<rect key="frame" x="17" y="21" width="382" height="76"/>
<rect key="frame" x="17" y="21" width="382" height="116"/>
<view key="contentView" id="JPj-NU-Cwp">
<rect key="frame" x="4" y="5" width="374" height="56"/>
<rect key="frame" x="4" y="5" width="374" height="96"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<stackView distribution="fill" orientation="vertical" alignment="leading" horizontalStackHuggingPriority="249.99998474121094" verticalStackHuggingPriority="249.99998474121094" verticalHuggingPriority="1000" detachesHiddenViews="YES" translatesAutoresizingMaskIntoConstraints="NO" id="6bh-Rg-qaG">
<rect key="frame" x="20" y="20" width="334" height="16"/>
<subviews>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="CUS-EE-bqd">
<rect key="frame" x="-2" y="-1" width="336" height="18"/>
<rect key="frame" x="-2" y="39" width="336" height="18"/>
<buttonCell key="cell" type="check" title="Use SwiftUI to render status bar icon. (MacOS 13+)" bezelStyle="regularSquare" imagePosition="left" inset="2" id="eY9-1i-i7P">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<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="0.0" width="240" height="20"/>
<subviews>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" 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"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<button verticalHuggingPriority="750" 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"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="actionUnInstallProxyHelper:" target="kdV-Em-qBi" id="GzM-BT-c1B"/>
</connections>
</button>
</subviews>
<visibilityPriorities>
<integer value="1000"/>
<integer value="1000"/>
</visibilityPriorities>
<customSpacing>
<real value="3.4028234663852886e+38"/>
<real value="3.4028234663852886e+38"/>
</customSpacing>
</stackView>
</subviews>
<visibilityPriorities>
<integer value="1000"/>
<integer value="1000"/>
</visibilityPriorities>
<customSpacing>
<real value="3.4028234663852886e+38"/>
<real value="3.4028234663852886e+38"/>
</customSpacing>
</stackView>
</subviews>

View File

@ -88,10 +88,12 @@ extension PrivilegedHelperManager {
Thread.sleep(forTimeInterval: 5)
}
let script = """
launchctl remove \(PrivilegedHelperManager.machServiceName) || true
rm -rf /Library/LaunchDaemons/\(PrivilegedHelperManager.machServiceName).plist
rm -rf /Library/PrivilegedHelperTools/\(PrivilegedHelperManager.machServiceName)
/bin/launchctl remove \(PrivilegedHelperManager.machServiceName) || true
/usr/bin/killall -u root -9 \(PrivilegedHelperManager.machServiceName)
/bin/rm -rf /Library/LaunchDaemons/\(PrivilegedHelperManager.machServiceName).plist
/bin/rm -rf /Library/PrivilegedHelperTools/\(PrivilegedHelperManager.machServiceName)
"""
runScriptWithRootPermission(script: script)
}
}

View File

@ -19,4 +19,7 @@ class DebugSettingViewController: NSViewController {
Settings.useSwiftUiMenuBar = state == .on
}.disposed(by: disposeBag)
}
@IBAction func actionUnInstallProxyHelper(_ sender: Any) {
PrivilegedHelperManager.shared.removeInstallHelper()
}
}

View File

@ -251,7 +251,7 @@
"NLT-FZ-48V.title" = "调试设置";
/* Class = "NSButtonCell"; title = "Use SwiftUI to render status bar icon. (MacOS 13+)"; ObjectID = "eY9-1i-i7P"; */
"eY9-1i-i7P.title" = "使用 SwiftUI 进行菜单栏图标渲染";
"eY9-1i-i7P.title" = "使用 SwiftUI 进行菜单栏图标渲染 (MacOS 13+)";
/* Class = "NSViewController"; title = "Debug"; ObjectID = "kdV-Em-qBi"; */
"kdV-Em-qBi.title" = "调试";
@ -270,3 +270,9 @@
/* Class = "NSTextFieldCell"; title = "Please ensure to address any potential shortcut conflicts. Global shortcuts take precedence over regular shortcuts."; ObjectID = "GGx-F2-7kE"; */
"GGx-F2-7kE.title" = "请务必注意处理可能存在的快捷键冲突,全局快捷键将优先于普通快捷键。";
/* Class = "NSButtonCell"; title = "Uninstall Proxy Helper"; ObjectID = "AY0-nP-cGT"; */
"AY0-nP-cGT.title" = "移除助手程序";
/* Class = "NSTextFieldCell"; title = "Proxy Helper"; ObjectID = "aSG-9A-eeG"; */
"aSG-9A-eeG.title" = "助手程序";