forked from yanue/V2rayU
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
yuanxue.yang
committed
Oct 19, 2018
1 parent
4d2d0fd
commit ffac0fe
Showing
11 changed files
with
288 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,24 @@ | ||
PODS: | ||
- Alamofire (4.7.3) | ||
- LaunchAtLogin (2.3.0) | ||
- Preferences (0.2.0) | ||
- SwiftyJSON (4.2.0) | ||
|
||
DEPENDENCIES: | ||
- Alamofire (~> 4.7) | ||
- LaunchAtLogin | ||
- Preferences | ||
- SwiftyJSON (~> 4.0) | ||
|
||
SPEC REPOS: | ||
https://github.com/cocoapods/specs.git: | ||
- Alamofire | ||
- LaunchAtLogin | ||
- Preferences | ||
- SwiftyJSON | ||
|
||
SPEC CHECKSUMS: | ||
Alamofire: c7287b6e5d7da964a70935e5db17046b7fde6568 | ||
LaunchAtLogin: 7ca1e1ab83a07ce89443d321eea20451658181d1 | ||
Preferences: ebc036a176a298cde835155c73251173768a2f8d | ||
SwiftyJSON: c4bcba26dd9ec7a027fc8eade48e2c911f229e96 | ||
|
||
PODFILE CHECKSUM: 5f68cfc19b1d01d7c93f89ddcbd513b0f79ff679 | ||
PODFILE CHECKSUM: fb7a8a55278116ebdd4990811b0c58eba7bb91b1 | ||
|
||
COCOAPODS: 1.6.0.beta.1 |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
// | ||
// AppDelegate.swift | ||
// V2rayuHelper | ||
// | ||
// Created by yanue on 2018/10/19. | ||
// Copyright © 2018 yanue. All rights reserved. | ||
// | ||
|
||
import Cocoa | ||
|
||
class V2rayuHelperApplication: NSApplication { | ||
let strongDelegate = AppDelegate() | ||
|
||
override init() { | ||
super.init() | ||
self.delegate = strongDelegate | ||
} | ||
|
||
required init?(coder: NSCoder) { | ||
fatalError("init(coder:) has not been implemented") | ||
} | ||
} | ||
|
||
@NSApplicationMain | ||
class AppDelegate: NSObject, NSApplicationDelegate { | ||
|
||
public func applicationDidFinishLaunching(_ notification: Notification) { | ||
let mainAppIdentifier = "net.yanue.V2rayU" | ||
let running = NSWorkspace.shared.runningApplications | ||
var alreadyRunning = false | ||
|
||
for app in running { | ||
if app.bundleIdentifier == mainAppIdentifier { | ||
alreadyRunning = true | ||
break | ||
} | ||
} | ||
|
||
if !alreadyRunning { | ||
DistributedNotificationCenter.default().addObserver(NSApp, selector: #selector(NSApplication.terminate(_:)), name: Notification.Name("terminateV2ray"), object: mainAppIdentifier) | ||
|
||
let path = Bundle.main.bundlePath as NSString | ||
var components = path.pathComponents | ||
components.removeLast() | ||
components.removeLast() | ||
components.removeLast() | ||
components.append("MacOS") | ||
components.append("V2rayU") | ||
|
||
let newPath = NSString.path(withComponents: components) | ||
NSWorkspace.shared.launchApplication(newPath) | ||
} else { | ||
NSApp.terminate(self) | ||
} | ||
} | ||
|
||
func applicationWillTerminate(_ aNotification: Notification) { | ||
print("helper app terminated") | ||
// Insert code here to tear down your application | ||
} | ||
|
||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>CFBundleDevelopmentRegion</key> | ||
<string>$(DEVELOPMENT_LANGUAGE)</string> | ||
<key>CFBundleExecutable</key> | ||
<string>$(EXECUTABLE_NAME)</string> | ||
<key>CFBundleIconFile</key> | ||
<string></string> | ||
<key>CFBundleIdentifier</key> | ||
<string>net.yanue.v2rayu.v2rayuHelper</string> | ||
<key>CFBundleInfoDictionaryVersion</key> | ||
<string>6.0</string> | ||
<key>CFBundleName</key> | ||
<string>$(PRODUCT_NAME)</string> | ||
<key>CFBundlePackageType</key> | ||
<string>APPL</string> | ||
<key>CFBundleShortVersionString</key> | ||
<string>1.0</string> | ||
<key>CFBundleVersion</key> | ||
<string>2</string> | ||
<key>LSBackgroundOnly</key> | ||
<true/> | ||
<key>LSMinimumSystemVersion</key> | ||
<string>$(MACOSX_DEPLOYMENT_TARGET)</string> | ||
<key>LSUIElement</key> | ||
<true/> | ||
<key>NSPrincipalClass</key> | ||
<string>V2rayuHelper.V2rayuHelperApplication</string> | ||
</dict> | ||
</plist> |
File renamed without changes.