diff --git a/WeChatTweak.framework/Versions/A/Resources/Info.plist b/WeChatTweak.framework/Versions/A/Resources/Info.plist index ebfe4da..47e0878 100644 --- a/WeChatTweak.framework/Versions/A/Resources/Info.plist +++ b/WeChatTweak.framework/Versions/A/Resources/Info.plist @@ -3,7 +3,7 @@ BuildMachineOSBuild - 17A365 + 17C88 CFBundleDevelopmentRegion en CFBundleExecutable @@ -27,17 +27,17 @@ DTCompiler com.apple.compilers.llvm.clang.1_0 DTPlatformBuild - 9A235 + 9C40b DTPlatformVersion GM DTSDKBuild - 17A360 + 17C76 DTSDKName macosx10.13 DTXcode - 0900 + 0920 DTXcodeBuild - 9A235 + 9C40b NSHumanReadableCopyright Copyright © 2017年 Sunnyyoung. All rights reserved. diff --git a/WeChatTweak.framework/Versions/A/WeChatTweak b/WeChatTweak.framework/Versions/A/WeChatTweak index e231808..c81638d 100755 Binary files a/WeChatTweak.framework/Versions/A/WeChatTweak and b/WeChatTweak.framework/Versions/A/WeChatTweak differ diff --git a/WeChatTweak/WeChatTweak.m b/WeChatTweak/WeChatTweak.m index 068504d..29567cf 100755 --- a/WeChatTweak/WeChatTweak.m +++ b/WeChatTweak/WeChatTweak.m @@ -46,7 +46,7 @@ static void __attribute__((constructor)) tweak(void) { // Method Swizzling class_addMethod(objc_getClass("AppDelegate"), @selector(applicationDockMenu:), method_getImplementation(class_getInstanceMethod(objc_getClass("AppDelegate"), @selector(tweak_applicationDockMenu:))), "@:@"); [objc_getClass("AppDelegate") jr_swizzleMethod:NSSelectorFromString(@"applicationDidFinishLaunching:") withMethod:@selector(tweak_applicationDidFinishLaunching:) error:nil]; - [objc_getClass("AppDelegate") jr_swizzleMethod:NSSelectorFromString(@"applicationShouldTerminate:") withMethod:@selector(tweak_applicationShouldTerminate:) error:nil]; + [objc_getClass("LogoutCGI") jr_swizzleMethod:NSSelectorFromString(@"sendLogoutCGIWithCompletion:") withMethod:@selector(tweak_sendLogoutCGIWithCompletion:) error:nil]; [objc_getClass("MessageService") jr_swizzleMethod:NSSelectorFromString(@"onRevokeMsg:") withMethod:@selector(tweak_onRevokeMsg:) error:nil]; [objc_getClass("CUtility") jr_swizzleClassMethod:NSSelectorFromString(@"HasWechatInstance") withClassMethod:@selector(tweak_HasWechatInstance) error:nil]; [objc_getClass("MASPreferencesWindowController") jr_swizzleMethod:NSSelectorFromString(@"initWithViewControllers:") withMethod:@selector(tweak_initWithViewControllers:) error:nil]; @@ -153,13 +153,13 @@ static void __attribute__((constructor)) tweak(void) { [[AlfredManager sharedInstance] startListener]; } -- (NSApplicationTerminateReply)tweak_applicationShouldTerminate:(NSApplication *)sender { +- (void)tweak_sendLogoutCGIWithCompletion:(id)completion { BOOL enabledAutoAuth = [[NSUserDefaults standardUserDefaults] boolForKey:WeChatTweakPreferenceAutoAuthKey]; - if (enabledAutoAuth) { - return NSTerminateNow; - } else { - return [self tweak_applicationShouldTerminate:sender]; + WeChat *wechat = [objc_getClass("WeChat") sharedInstance]; + if (enabledAutoAuth && wechat.isAppTerminating) { + return; } + [self tweak_sendLogoutCGIWithCompletion:completion]; } #pragma mark - Preferences Window diff --git a/WeChatTweak/WeChatTweakHeaders.h b/WeChatTweak/WeChatTweakHeaders.h index c5d4a14..ec9aeac 100644 --- a/WeChatTweak/WeChatTweakHeaders.h +++ b/WeChatTweak/WeChatTweakHeaders.h @@ -11,6 +11,8 @@ @interface WeChat : NSObject +@property(nonatomic) BOOL isAppTerminating; + + (instancetype)sharedInstance; - (void)lock:(id)block; - (void)showMainWindow; @@ -92,6 +94,12 @@ @end +@interface LogoutCGI: NSObject + +- (void)sendLogoutCGIWithCompletion:(id)arg1; + +@end + @protocol MASPreferencesViewController @property(readonly, nonatomic) NSString *toolbarItemLabel; @@ -104,7 +112,7 @@ @end -@interface MASPreferencesWindowController : NSWindowController +@interface MASPreferencesWindowController: NSWindowController - (id)initWithViewControllers:(NSArray *)arg1;