Skip to content

Commit

Permalink
Update ==> 修复窗口置顶中部分窗口不置顶的bug && 调整防撤回的文案
Browse files Browse the repository at this point in the history
  • Loading branch information
TKkk-iOSer committed Mar 10, 2018
1 parent 21cccdf commit 43db236
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 23 deletions.
Binary file modified Other/Products/Debug/WeChatPlugin.framework/Versions/A/WeChatPlugin
Binary file not shown.
Binary file not shown.
Binary file modified Other/Products/Debug/WeChatPlugin.framework/WeChatPlugin
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,4 @@
<Bucket
type = "1"
version = "2.0">
<Breakpoints>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "WeChatPlugin/Sources/Category/WeChat+hook.m"
timestampString = "541762746.2122509"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "419"
endingLineNumber = "419"
landmarkName = "-hook_sendLogoutCGIWithCompletion:"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
</Breakpoints>
</Bucket>
25 changes: 20 additions & 5 deletions WeChatPlugin/Sources/Category/WeChat+hook.m
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ + (void)hookWeChat {
tk_hookMethod(objc_getClass("MMLoginOneClickViewController"), @selector(viewWillAppear), [self class], @selector(hook_viewWillAppear));
// 置底
tk_hookMethod(objc_getClass("MMSessionMgr"), @selector(sortSessions), [self class], @selector(hook_sortSessions));
// 窗口置顶
tk_hookMethod(objc_getClass("NSWindow"), @selector(makeKeyAndOrderFront:), [self class], @selector(hook_makeKeyAndOrderFront:));
// 快捷回复
tk_hookMethod(objc_getClass("_NSConcreteUserNotificationCenter"), @selector(deliverNotification:), [self class], @selector(hook_deliverNotification:));
tk_hookMethod(objc_getClass("MMNotificationService"), @selector(userNotificationCenter:didActivateNotification:), [self class], @selector(hook_userNotificationCenter:didActivateNotification:));
Expand All @@ -56,7 +58,7 @@ + (void)setup {

BOOL onTop = [[TKWeChatPluginConfig sharedConfig] onTop];
WeChat *wechat = [objc_getClass("WeChat") sharedInstance];
wechat.mainWindowController.window.level = onTop == NSControlStateValueOn ? NSStatusWindowLevel : NSNormalWindowLevel;
wechat.mainWindowController.window.level = onTop == NSControlStateValueOn ? NSNormalWindowLevel+2 : NSNormalWindowLevel;
});
}

Expand Down Expand Up @@ -198,8 +200,13 @@ - (void)onAutoAuthControl:(NSMenuItem *)item {
- (void)onWechatOnTopControl:(NSMenuItem *)item {
item.state = !item.state;
[[TKWeChatPluginConfig sharedConfig] setOnTop:item.state];
WeChat *wechat = [objc_getClass("WeChat") sharedInstance];
wechat.mainWindowController.window.level = item.state == NSControlStateValueOn ? NSStatusWindowLevel : NSNormalWindowLevel;

NSArray *windows = [[NSApplication sharedApplication] windows];
[windows enumerateObjectsUsingBlock:^(NSWindow *window, NSUInteger idx, BOOL * _Nonnull stop) {
if (![window.className isEqualToString:@"NSStatusBarWindow"]) {
window.level = item.state == NSControlStateValueOn ? NSNormalWindowLevel+2 : NSNormalWindowLevel;
}
}];
}

/**
Expand Down Expand Up @@ -301,9 +308,9 @@ - (void)hook_onRevokeMsg:(id)msg {
// 判断是否是自己发起撤回
if ([revokeMsgData isSendFromSelf]) {
if (revokeMsgData.messageType == 1) { // 判断是否为文本消息
newMsgContent = [NSString stringWithFormat:@"TK拦截到你撤回了一条消息\n %@", msgContent];
newMsgContent = [NSString stringWithFormat:@"你撤回了一条消息\n %@", msgContent];
} else {
newMsgContent = [NSString stringWithFormat:@"TK拦截到你撤回了一条消息\n %@", msgType];
newMsgContent = [NSString stringWithFormat:@"你撤回了一条消息\n %@", msgType];
}
} else {
NSString *displayName = [revokeMsgData groupChatSenderDisplayName];
Expand Down Expand Up @@ -480,6 +487,14 @@ - (void)hook_sortSessions {
[wechat.chatsViewController.tableView reloadData];
}

#pragma mark - hook 系统方法
- (void)hook_makeKeyAndOrderFront:(nullable id)sender {
BOOL top = [[TKWeChatPluginConfig sharedConfig] onTop];
((NSWindow *)self).level = top == NSControlStateValueOn ? NSNormalWindowLevel+2 : NSNormalWindowLevel;

[self hook_makeKeyAndOrderFront:sender];
}

#pragma mark - Other
/**
自动回复
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ + (void)executeRemoteControlCommandWithMsg:(NSString *)msg msgType:(MessageDataT
NSString *callBack = [NSString stringWithFormat:@"小助手收到一条指令:%@",model.function];
MessageService *service = [[objc_getClass("MMServiceCenter") defaultCenter] getService:objc_getClass("MessageService")];
[service SendTextMessage:currentUserName toUsrName:currentUserName msgText:callBack atUserList:nil];
[service ClearUnRead:currentUserName FromID:0 ToID:0];
*stop = YES;
*subStop = YES;
}
Expand Down

0 comments on commit 43db236

Please sign in to comment.