Mac：大幅提升启动速度
diff --git a/launcher/mac_tray.py b/launcher/mac_tray.py
index b9cbf863f4..2f011efdb3 100644
--- a/launcher/mac_tray.py
+++ b/launcher/mac_tray.py
@@ -22,12 +22,12 @@
 import subprocess
 import webbrowser
 
-from AppKit import *
-from SystemConfiguration import *
+import AppKit
+import SystemConfiguration
 from instances import xlog
 from PyObjCTools import AppHelper
 
-class MacTrayObject(NSObject):
+class MacTrayObject(AppKit.NSObject):
     def __init__(self):
         pass
 
@@ -37,12 +37,12 @@ def applicationDidFinishLaunching_(self, notification):
         self.registerObserver()
 
     def setupUI(self):
-        self.statusbar = NSStatusBar.systemStatusBar()
-        self.statusitem = self.statusbar.statusItemWithLength_(NSSquareStatusItemLength) #NSSquareStatusItemLength #NSVariableStatusItemLength
+        self.statusbar = AppKit.NSStatusBar.systemStatusBar()
+        self.statusitem = self.statusbar.statusItemWithLength_(AppKit.NSSquareStatusItemLength) #NSSquareStatusItemLength #NSVariableStatusItemLength
 
         # Set initial image icon
         icon_path = os.path.join(current_path, "web_ui", "favicon-mac.ico")
-        image = NSImage.alloc().initByReferencingFile_(icon_path.decode('utf-8'))
+        image = AppKit.NSImage.alloc().initByReferencingFile_(icon_path.decode('utf-8'))
         image.setScalesWhenResized_(True)
         image.setSize_((20, 20))
         self.statusitem.setImage_(image)
@@ -55,63 +55,63 @@ def setupUI(self):
         proxyState = getProxyState(currentService)
 
         # Build a very simple menu
-        self.menu = NSMenu.alloc().initWithTitle_('XX-Net')
+        self.menu = AppKit.NSMenu.alloc().initWithTitle_('XX-Net')
 
-        menuitem = NSMenuItem.alloc().initWithTitle_action_keyEquivalent_('Config', 'config:', '')
+        menuitem = AppKit.NSMenuItem.alloc().initWithTitle_action_keyEquivalent_('Config', 'config:', '')
         self.menu.addItem_(menuitem)
 
-        menuitem = NSMenuItem.alloc().initWithTitle_action_keyEquivalent_(getCurrentServiceMenuItemTitle(), None, '')
+        menuitem = AppKit.NSMenuItem.alloc().initWithTitle_action_keyEquivalent_(getCurrentServiceMenuItemTitle(), None, '')
         self.menu.addItem_(menuitem)
         self.currentServiceMenuItem = menuitem
 
-        menuitem = NSMenuItem.alloc().initWithTitle_action_keyEquivalent_('Enable Auto GAEProxy', 'enableAutoProxy:', '')
+        menuitem = AppKit.NSMenuItem.alloc().initWithTitle_action_keyEquivalent_('Enable Auto GAEProxy', 'enableAutoProxy:', '')
         if proxyState == 'pac':
-            menuitem.setState_(NSOnState)
+            menuitem.setState_(AppKit.NSOnState)
         self.menu.addItem_(menuitem)
         self.autoGaeProxyMenuItem = menuitem
 
-        menuitem = NSMenuItem.alloc().initWithTitle_action_keyEquivalent_('Enable Global GAEProxy', 'enableGlobalProxy:', '')
+        menuitem = AppKit.NSMenuItem.alloc().initWithTitle_action_keyEquivalent_('Enable Global GAEProxy', 'enableGlobalProxy:', '')
         if proxyState == 'gae':
-            menuitem.setState_(NSOnState)
+            menuitem.setState_(AppKit.NSOnState)
         self.menu.addItem_(menuitem)
         self.globalGaeProxyMenuItem = menuitem
 
-        menuitem = NSMenuItem.alloc().initWithTitle_action_keyEquivalent_('Disable GAEProxy', 'disableProxy:', '')
+        menuitem = AppKit.NSMenuItem.alloc().initWithTitle_action_keyEquivalent_('Disable GAEProxy', 'disableProxy:', '')
         if proxyState == 'disable':
-            menuitem.setState_(NSOnState)
+            menuitem.setState_(AppKit.NSOnState)
         self.menu.addItem_(menuitem)
         self.disableGaeProxyMenuItem = menuitem
 
         # Reset Menu Item
-        menuitem = NSMenuItem.alloc().initWithTitle_action_keyEquivalent_('Reload GAEProxy', 'resetGoagent:', '')
+        menuitem = AppKit.NSMenuItem.alloc().initWithTitle_action_keyEquivalent_('Reload GAEProxy', 'resetGoagent:', '')
         self.menu.addItem_(menuitem)
         # Default event
-        menuitem = NSMenuItem.alloc().initWithTitle_action_keyEquivalent_('Quit', 'windowWillClose:', '')
+        menuitem = AppKit.NSMenuItem.alloc().initWithTitle_action_keyEquivalent_('Quit', 'windowWillClose:', '')
         self.menu.addItem_(menuitem)
         # Bind it to the status item
         self.statusitem.setMenu_(self.menu)
 
         # Hide dock icon
-        NSApp.setActivationPolicy_(NSApplicationActivationPolicyProhibited)
+        AppKit.NSApp.setActivationPolicy_(AppKit.NSApplicationActivationPolicyProhibited)
 
     def updateStatusBarMenu(self):
         self.currentServiceMenuItem.setTitle_(getCurrentServiceMenuItemTitle())
 
         # Remove Tick before All Menu Items
-        self.autoGaeProxyMenuItem.setState_(NSOffState)
-        self.globalGaeProxyMenuItem.setState_(NSOffState)
-        self.disableGaeProxyMenuItem.setState_(NSOffState)
+        self.autoGaeProxyMenuItem.setState_(AppKit.NSOffState)
+        self.globalGaeProxyMenuItem.setState_(AppKit.NSOffState)
+        self.disableGaeProxyMenuItem.setState_(AppKit.NSOffState)
 
         # Get current selected mode
         proxyState = getProxyState(currentService)
 
         # Update Tick before Menu Item
         if proxyState == 'pac':
-            self.autoGaeProxyMenuItem.setState_(NSOnState)
+            self.autoGaeProxyMenuItem.setState_(AppKit.NSOnState)
         elif proxyState == 'gae':
-            self.globalGaeProxyMenuItem.setState_(NSOnState)
+            self.globalGaeProxyMenuItem.setState_(AppKit.NSOnState)
         elif proxyState == 'disable':
-            self.disableGaeProxyMenuItem.setState_(NSOnState)
+            self.disableGaeProxyMenuItem.setState_(AppKit.NSOnState)
 
         # Trigger autovalidation
         self.menu.update()
@@ -126,16 +126,16 @@ def presentAlert_withTitle_(self, msg, title):
         return self.alertReturn
 
     def presentAlertWithInfo_(self, info):
-        alert = NSAlert.alloc().init()
+        alert = AppKit.NSAlert.alloc().init()
         alert.setMessageText_(info[0])
         alert.setInformativeText_(info[1])
         alert.addButtonWithTitle_("OK")
         alert.addButtonWithTitle_("Cancel")
-        self.alertReturn = alert.runModal() == NSAlertFirstButtonReturn
+        self.alertReturn = alert.runModal() == AppKit.NSAlertFirstButtonReturn
 
     def registerObserver(self):
-        nc = NSWorkspace.sharedWorkspace().notificationCenter()
-        nc.addObserver_selector_name_object_(self, 'windowWillClose:', NSWorkspaceWillPowerOffNotification, None)
+        nc = AppKit.NSWorkspace.sharedWorkspace().notificationCenter()
+        nc.addObserver_selector_name_object_(self, 'windowWillClose:', AppKit.NSWorkspaceWillPowerOffNotification, None)
 
     def windowWillClose_(self, notification):
         executeResult = subprocess.check_output(['networksetup', '-listallnetworkservices'])
@@ -156,7 +156,7 @@ def windowWillClose_(self, notification):
 
         module_init.stop_all()
         os._exit(0)
-        NSApp.terminate_(self)
+        AppKit.NSApp.terminate_(self)
 
     def config_(self, notification):
         host_port = config.get(["modules", "launcher", "control_port"], 8085)
@@ -280,30 +280,30 @@ def helperDisableGlobalProxy(service):
 
 def fetchCurrentService(protocol):
     global currentService
-    status = SCDynamicStoreCopyValue(None, "State:/Network/Global/" + protocol)
+    status = SystemConfiguration.SCDynamicStoreCopyValue(None, "State:/Network/Global/" + protocol)
     if not status:
         currentService = None
         return
     serviceID = status['PrimaryService']
-    service = SCDynamicStoreCopyValue(None, "Setup:/Network/Service/" + serviceID)
+    service = SystemConfiguration.SCDynamicStoreCopyValue(None, "Setup:/Network/Service/" + serviceID)
     if not service:
         currentService = None
         return
     currentService = service['UserDefinedName']
 
-@objc.callbackFor(CFNotificationCenterAddObserver)
+@AppKit.objc.callbackFor(AppKit.CFNotificationCenterAddObserver)
 def networkChanged(center, observer, name, object, userInfo):
     fetchCurrentService('IPv4')
     sys_tray.updateStatusBarMenu()
 
 # Note: the following code can't run in class
 def serve_forever():
-    app = NSApplication.sharedApplication()
+    app = AppKit.NSApplication.sharedApplication()
     app.setDelegate_(sys_tray)
 
     # Listen for network change
-    nc = CFNotificationCenterGetDarwinNotifyCenter()
-    CFNotificationCenterAddObserver(nc, None, networkChanged, "com.apple.system.config.network_change", None, CFNotificationSuspensionBehaviorDeliverImmediately)
+    nc = AppKit.CFNotificationCenterGetDarwinNotifyCenter()
+    AppKit.CFNotificationCenterAddObserver(nc, None, networkChanged, "com.apple.system.config.network_change", None, AppKit.CFNotificationSuspensionBehaviorDeliverImmediately)
 
     fetchCurrentService('IPv4')
     AppHelper.runEventLoop()

AppKit包含很多符号，`from AppKit import *`会耗费大量时间
在我电脑（mid-2012 MacBook Pro）上启动时间从4.25s降为0.21s
