Chore: remove SpeedTestViewController

This commit is contained in:
yicheng 2018-12-22 20:19:29 +08:00
parent dd1845e88f
commit a1f5ea4700
3 changed files with 0 additions and 262 deletions

View File

@ -46,7 +46,6 @@
4997732520D251A60009B136 /* SWBApplication.m in Sources */ = {isa = PBXBuildFile; fileRef = 4997732320D251A60009B136 /* SWBApplication.m */; };
499976C821359F0400E7BF83 /* ClashWebViewContoller.swift in Sources */ = {isa = PBXBuildFile; fileRef = 499976C721359F0400E7BF83 /* ClashWebViewContoller.swift */; };
49B1086A216A356D0064FFCE /* String+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 49B10869216A356D0064FFCE /* String+Extension.swift */; };
49B7F9A02157C1DC00484470 /* SpeedTestViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 49B7F99F2157C1DC00484470 /* SpeedTestViewController.swift */; };
49BC061C212931F4005A0FE7 /* AboutViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 49BC061B212931F4005A0FE7 /* AboutViewController.swift */; };
49CF3B2120CD7463001EBF94 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 49CF3B2020CD7463001EBF94 /* AppDelegate.swift */; };
49CF3B2520CD7465001EBF94 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 49CF3B2420CD7465001EBF94 /* Assets.xcassets */; };
@ -154,7 +153,6 @@
4997732420D251A60009B136 /* SWBApplication.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SWBApplication.h; sourceTree = "<group>"; };
499976C721359F0400E7BF83 /* ClashWebViewContoller.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClashWebViewContoller.swift; sourceTree = "<group>"; };
49B10869216A356D0064FFCE /* String+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "String+Extension.swift"; sourceTree = "<group>"; };
49B7F99F2157C1DC00484470 /* SpeedTestViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SpeedTestViewController.swift; sourceTree = "<group>"; };
49BC061B212931F4005A0FE7 /* AboutViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AboutViewController.swift; sourceTree = "<group>"; };
49BC061E2129A34D005A0FE7 /* appcast.xml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = appcast.xml; sourceTree = "<group>"; };
49CF3B1D20CD7463001EBF94 /* ClashX.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ClashX.app; sourceTree = BUILT_PRODUCTS_DIR; };
@ -326,7 +324,6 @@
isa = PBXGroup;
children = (
49BC061B212931F4005A0FE7 /* AboutViewController.swift */,
49B7F99F2157C1DC00484470 /* SpeedTestViewController.swift */,
499976C721359F0400E7BF83 /* ClashWebViewContoller.swift */,
);
path = ViewControllers;
@ -665,7 +662,6 @@
4997732520D251A60009B136 /* SWBApplication.m in Sources */,
49BC061C212931F4005A0FE7 /* AboutViewController.swift in Sources */,
4949D154213242F600EF85E6 /* Paths.swift in Sources */,
49B7F9A02157C1DC00484470 /* SpeedTestViewController.swift in Sources */,
495340B320DE68C300B0D3FF /* StatusItemView.swift in Sources */,
495A44D320D267D000888A0A /* LaunchAtLogin.swift in Sources */,
49CF3B2120CD7463001EBF94 /* AppDelegate.swift in Sources */,

View File

@ -71,13 +71,6 @@
<action selector="actionCopyExportCommand:" target="Voe-Tx-rLC" id="82r-sY-7xb"/>
</connections>
</menuItem>
<menuItem title="Speed test" id="5Mz-Qv-9Yc">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="actionSpeedTest:" target="Voe-Tx-rLC" id="deV-3n-Mtx"/>
<segue destination="gtD-dn-7Dy" kind="show" id="opl-HQ-q26"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="nXl-3B-Q18"/>
<menuItem title="Start at login" id="B1J-XB-BiZ">
<modifierMask key="keyEquivalentModifierMask"/>
@ -252,138 +245,6 @@
</objects>
<point key="canvasLocation" x="75" y="0.0"/>
</scene>
<!--SpeedTest-->
<scene sceneID="iIZ-Tp-XWx">
<objects>
<viewController title="SpeedTest" showSeguePresentationStyle="single" id="gtD-dn-7Dy" customClass="SpeedTestViewController" customModule="ClashX" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" id="0ac-CH-i5j">
<rect key="frame" x="0.0" y="0.0" width="450" height="300"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<scrollView autohidesScrollers="YES" horizontalLineScroll="19" horizontalPageScroll="10" verticalLineScroll="19" verticalPageScroll="10" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Ld6-8X-1go">
<rect key="frame" x="0.0" y="0.0" width="450" height="300"/>
<clipView key="contentView" id="JGj-of-TOa">
<rect key="frame" x="1" y="0.0" width="448" height="299"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" columnSelection="YES" multipleSelection="NO" autosaveColumns="NO" rowSizeStyle="automatic" headerView="BMy-KV-KKJ" viewBased="YES" id="deF-3p-7yH">
<rect key="frame" x="0.0" y="0.0" width="448" height="276"/>
<autoresizingMask key="autoresizingMask"/>
<size key="intercellSpacing" width="3" height="2"/>
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
<color key="gridColor" name="gridColor" catalog="System" colorSpace="catalog"/>
<tableColumns>
<tableColumn identifier="proxies" width="273.5" minWidth="40" maxWidth="1000" id="WQk-kX-Jr8">
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" title="Proxies">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="headerColor" catalog="System" colorSpace="catalog"/>
</tableHeaderCell>
<textFieldCell key="dataCell" lineBreakMode="truncatingTail" selectable="YES" editable="YES" title="Text Cell" id="DIu-9t-BTE">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
<prototypeCellViews>
<tableCellView identifier="ProxyNameCell" id="1Yx-TQ-4pZ">
<rect key="frame" x="1" y="1" width="274" height="17"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" tag="1" translatesAutoresizingMaskIntoConstraints="NO" id="XcN-cb-zuE">
<rect key="frame" x="0.0" y="0.0" width="274" height="17"/>
<textFieldCell key="cell" lineBreakMode="truncatingTail" enabled="NO" allowsUndo="NO" sendsActionOnEndEditing="YES" title="Proxy" id="Gh1-x5-fnZ">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
</subviews>
<constraints>
<constraint firstItem="XcN-cb-zuE" firstAttribute="leading" secondItem="1Yx-TQ-4pZ" secondAttribute="leading" constant="2" id="5ih-Pa-iH3"/>
<constraint firstItem="XcN-cb-zuE" firstAttribute="centerX" secondItem="1Yx-TQ-4pZ" secondAttribute="centerX" id="MMx-Zm-IX2"/>
<constraint firstItem="XcN-cb-zuE" firstAttribute="centerY" secondItem="1Yx-TQ-4pZ" secondAttribute="centerY" id="wjg-01-7Yi"/>
</constraints>
<connections>
<outlet property="textField" destination="XcN-cb-zuE" id="fta-YG-n0q"/>
</connections>
</tableCellView>
</prototypeCellViews>
</tableColumn>
<tableColumn identifier="delays" width="168.5" minWidth="40" maxWidth="1000" id="gNv-c4-4xR">
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" title="Delay(ms)">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="headerColor" catalog="System" colorSpace="catalog"/>
</tableHeaderCell>
<textFieldCell key="dataCell" lineBreakMode="truncatingTail" selectable="YES" editable="YES" title="Text Cell" id="JK9-7d-hkq">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
<prototypeCellViews>
<tableCellView identifier="delayCell" id="qZT-29-xCE">
<rect key="frame" x="278" y="1" width="168" height="17"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" tag="1" translatesAutoresizingMaskIntoConstraints="NO" id="QCv-NJ-qh9">
<rect key="frame" x="0.0" y="0.0" width="168" height="17"/>
<textFieldCell key="cell" lineBreakMode="truncatingTail" enabled="NO" sendsActionOnEndEditing="YES" title="100" id="TLq-Oj-0EH">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
</subviews>
<constraints>
<constraint firstItem="QCv-NJ-qh9" firstAttribute="leading" secondItem="qZT-29-xCE" secondAttribute="leading" constant="2" id="MOQ-o3-VoJ"/>
<constraint firstItem="QCv-NJ-qh9" firstAttribute="centerX" secondItem="qZT-29-xCE" secondAttribute="centerX" id="Pzq-Fj-OZr"/>
<constraint firstItem="QCv-NJ-qh9" firstAttribute="centerY" secondItem="qZT-29-xCE" secondAttribute="centerY" id="X4P-NQ-jvY"/>
</constraints>
<connections>
<outlet property="textField" destination="QCv-NJ-qh9" id="VlP-eG-GPw"/>
</connections>
</tableCellView>
</prototypeCellViews>
</tableColumn>
</tableColumns>
<connections>
<outlet property="dataSource" destination="gtD-dn-7Dy" id="4FR-Ct-8DI"/>
<outlet property="delegate" destination="gtD-dn-7Dy" id="Kfq-1d-WVq"/>
</connections>
</tableView>
</subviews>
</clipView>
<scroller key="horizontalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" horizontal="YES" id="iP6-D2-2yO">
<rect key="frame" x="1" y="283" width="448" height="16"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
<scroller key="verticalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" doubleValue="1" horizontal="NO" id="cen-QY-aDc">
<rect key="frame" x="224" y="17" width="15" height="102"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
<tableHeaderView key="headerView" id="BMy-KV-KKJ">
<rect key="frame" x="0.0" y="0.0" width="448" height="23"/>
<autoresizingMask key="autoresizingMask"/>
</tableHeaderView>
</scrollView>
</subviews>
<constraints>
<constraint firstItem="Ld6-8X-1go" firstAttribute="leading" secondItem="0ac-CH-i5j" secondAttribute="leading" id="MgC-QL-rZF"/>
<constraint firstItem="Ld6-8X-1go" firstAttribute="top" secondItem="0ac-CH-i5j" secondAttribute="top" id="W9F-ci-yWu"/>
<constraint firstAttribute="bottom" secondItem="Ld6-8X-1go" secondAttribute="bottom" id="g5S-Un-qwV"/>
<constraint firstAttribute="trailing" secondItem="Ld6-8X-1go" secondAttribute="trailing" id="hQz-S1-bj3"/>
</constraints>
</view>
<connections>
<outlet property="tableView" destination="deF-3p-7yH" id="nTi-WE-CQs"/>
</connections>
</viewController>
<customObject id="UQc-xG-eFM" userLabel="First Responder" customClass="NSResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="551" y="-207"/>
</scene>
<!--About View Controller-->
<scene sceneID="bW6-wi-r8Q">
<objects>

View File

@ -1,119 +0,0 @@
//
// SpeedTesdtViewController.swift
// ClashX
//
// Created by CYC on 2018/9/23.
// Copyright © 2018 west2online. All rights reserved.
//
import Cocoa
class SpeedTestViewController: NSViewController {
@IBOutlet weak var tableView: NSTableView!
@objc class ProxyModel:NSObject {
@objc var name:String
@objc var delay:Int
init(_ name:String) {
self.name = name
self.delay = -2
}
}
var proxies = [ProxyModel]()
override func viewDidLoad() {
super.viewDidLoad()
self.setupData()
}
override func viewWillAppear() {
super.viewWillAppear()
NSApp.activate(ignoringOtherApps: true)
}
func setupData() {
for columns in self.tableView.tableColumns {
let sortKey:String
if columns.identifier.rawValue == "proxies" {
sortKey = "name"
} else {
sortKey = "delay"
}
let sortDescriptor = NSSortDescriptor(key: sortKey, ascending: true)
columns.sortDescriptorPrototype = sortDescriptor
}
ApiRequest.getAllProxyList { [unowned self](proxies) in
for proxyName in proxies {
self.proxies.append(ProxyModel(proxyName))
}
self.tableView.reloadData()
self.speedTest()
}
}
func speedTest() {
for proxy in proxies {
ApiRequest.getProxyDelay(proxyName: proxy.name) {[weak self] (delay) in
guard let strongSelf = self else {return}
SpeedDataRecorder.shared.speedDict[proxy.name] = delay;
proxy.delay = delay
strongSelf.tableView.reloadData()
}
}
}
}
extension SpeedTestViewController:NSTableViewDataSource {
func numberOfRows(in tableView: NSTableView) -> Int {
return proxies.count
}
func tableView(_ tableView: NSTableView, viewFor tableColumn: NSTableColumn?, row: Int) -> NSView? {
if(tableColumn?.identifier.rawValue == "proxies") {
return cellForProxyName(tableView, atRow: row)
} else {
return cellForDelay(tableView, atRow: row)
}
}
func cellForProxyName(_ tableView:NSTableView, atRow row:Int) -> NSView? {
let cell = tableView.makeView(withIdentifier: NSUserInterfaceItemIdentifier(rawValue: "ProxyNameCell"), owner: nil)
let model = proxies[row]
let textField = cell?.viewWithTag(1) as! NSTextField
textField.stringValue = model.name
return cell
}
func cellForDelay(_ tableView:NSTableView, atRow row:Int) -> NSView? {
let cell = tableView.makeView(withIdentifier: NSUserInterfaceItemIdentifier(rawValue: "delayCell"), owner: nil)
let textField = cell?.viewWithTag(1) as! NSTextField
let model = proxies[row]
if (model.delay == -2) {
textField.stringValue = "testing"
} else if (model.delay == Int.max) {
textField.stringValue = "fail"
} else {
textField.stringValue = "\(model.delay)"
}
return cell
}
}
extension SpeedTestViewController:NSTableViewDelegate{
func tableView(_ tableView: NSTableView, sortDescriptorsDidChange oldDescriptors: [NSSortDescriptor]) {
self.proxies = (self.proxies as NSArray).sortedArray(using: tableView.sortDescriptors) as! [SpeedTestViewController.ProxyModel]
tableView.reloadData()
}
}