Skip to content

Commit

Permalink
Add ==> 新增小助手更新检测
Browse files Browse the repository at this point in the history
  • Loading branch information
TKkk-iOSer committed Feb 24, 2018
1 parent f3b8861 commit 1947891
Show file tree
Hide file tree
Showing 18 changed files with 192 additions and 11 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,13 @@
# 更新日志

### [v1.5.0 (2018-02-24)](https://github.com/TKkk-iOSer/WeChatPlugin-MacOS/releases/tag/v1.5.0)

* 优化防撤回提醒
* 新增自动登录开关
* 新增小助手检测更新
* 新增通知中心快捷回复
* 新增表情包复制 & 存储
* 自动回复 & 远程控制设置存储到本地

### [v1.4.0 (2017-10-11)](https://github.com/TKkk-iOSer/WeChatPlugin-MacOS/releases/tag/v1.4.0)

Expand Down
Expand Up @@ -17,7 +17,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<string>1.5.0</string>
<key>CFBundleSupportedPlatforms</key>
<array>
<string>MacOSX</string>
Expand All @@ -40,5 +40,7 @@
<string>9C40b</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2017年 tk. All rights reserved.</string>
<key>versionInfo</key>
<string>👉 优化防撤回提醒。 \n👉🏻 新增自动登录开关。 \n👉🏼 新增小助手检测更新。 \n👉🏽 新增通知中心快捷回复。\n👉🏾 新增表情包复制 &amp; 存储。\n👉🏿 自动回复 &amp; 远程控制设置存储到本地。\n\n</string>
</dict>
</plist>
Expand Up @@ -17,7 +17,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<string>1.5.0</string>
<key>CFBundleSupportedPlatforms</key>
<array>
<string>MacOSX</string>
Expand All @@ -40,5 +40,7 @@
<string>9C40b</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2017年 tk. All rights reserved.</string>
<key>versionInfo</key>
<string>👉 优化防撤回提醒。 \n👉🏻 新增自动登录开关。 \n👉🏼 新增小助手检测更新。 \n👉🏽 新增通知中心快捷回复。\n👉🏾 新增表情包复制 &amp; 存储。\n👉🏿 自动回复 &amp; 远程控制设置存储到本地。\n\n</string>
</dict>
</plist>
Binary file not shown.
Expand Up @@ -17,7 +17,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<string>1.5.0</string>
<key>CFBundleSupportedPlatforms</key>
<array>
<string>MacOSX</string>
Expand All @@ -40,5 +40,7 @@
<string>9C40b</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2017年 tk. All rights reserved.</string>
<key>versionInfo</key>
<string>👉 优化防撤回提醒。 \n👉🏻 新增自动登录开关。 \n👉🏼 新增小助手检测更新。 \n👉🏽 新增通知中心快捷回复。\n👉🏾 新增表情包复制 &amp; 存储。\n👉🏿 自动回复 &amp; 远程控制设置存储到本地。\n\n</string>
</dict>
</plist>
Binary file not shown.
Binary file modified Other/Products/Debug/WeChatPlugin.framework/WeChatPlugin
Binary file not shown.
Binary file added Other/ScreenShots/emotion_copy_export.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Other/ScreenShots/wechatplugin.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 9 additions & 4 deletions README.md
@@ -1,11 +1,9 @@

## WeChatPlugin-MacOS

![](https://img.shields.io/badge/platform-osx-lightgrey.svg) ![](https://img.shields.io/badge/support-wechat%202.2.8-green.svg)

微信小助手 v1.4.0
微信小助手 v1.5.0

![微信小助手.png](http://upload-images.jianshu.io/upload_images/965383-31708af611b55ca4.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
![微信小助手.png](./Other/ScreenShots/wechatplugin.png)

**iOS版本请戳→_→ [WeChatPlugin-iOS](https://github.com/TKkk-iOSer/WeChatPlugin-iOS)**

Expand All @@ -15,6 +13,8 @@

### 更新日志

[新增小助手检测更新&表情包复制存储等等 (2018-02-24)](https://github.com/TKkk-iOSer/WeChatPlugin-MacOS/releases/tag/v1.5.0)

[新增窗口置顶&多选删除等等 (2017-10-11)](https://github.com/TKkk-iOSer/WeChatPlugin-MacOS/releases/tag/v1.4.0)

[新增置底&免认证 (2017-09-17)](https://github.com/TKkk-iOSer/WeChatPlugin-MacOS/releases/tag/v1.3.0)
Expand All @@ -38,6 +38,8 @@
* 会话多选删除
* 自动登录开关
* 通知中心快捷回复
* 聊天窗口表情包复制 & 存储
* 小助手检测更新提醒

远程控制:

Expand Down Expand Up @@ -86,6 +88,9 @@
* 通知中心快捷回复
![快捷回复](./Other/ScreenShots/notification_quick_reply.gif)

* 聊天窗口表情复制 & 存储
![表情复制存储](./Other/ScreenShots/emotion_copy_export.png)

---

### 安装
Expand Down
8 changes: 8 additions & 0 deletions WeChatPlugin.xcodeproj/project.pbxproj
Expand Up @@ -15,6 +15,8 @@
522547E11F4C312A00226A2A /* TKRemoteControlWindowController.h in Headers */ = {isa = PBXBuildFile; fileRef = 522547DB1F4C312A00226A2A /* TKRemoteControlWindowController.h */; };
522547E21F4C312A00226A2A /* TKRemoteControlWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = 522547DC1F4C312A00226A2A /* TKRemoteControlWindowController.m */; };
522547E31F4C312A00226A2A /* TKRemoteControlWindowController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 522547DD1F4C312A00226A2A /* TKRemoteControlWindowController.xib */; };
5226D5CA2040FC3E0013C048 /* TKVersionManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 5226D5C82040FC3E0013C048 /* TKVersionManager.h */; };
5226D5CB2040FC3E0013C048 /* TKVersionManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 5226D5C92040FC3E0013C048 /* TKVersionManager.m */; };
5228EABA1F70B59500D808CF /* NSButton+Action.h in Headers */ = {isa = PBXBuildFile; fileRef = 5228EAB81F70B59500D808CF /* NSButton+Action.h */; };
5228EABB1F70B59500D808CF /* NSButton+Action.m in Sources */ = {isa = PBXBuildFile; fileRef = 5228EAB91F70B59500D808CF /* NSButton+Action.m */; };
523848AB1F70E73500771BA3 /* NSTextField+Action.h in Headers */ = {isa = PBXBuildFile; fileRef = 523848A91F70E73500771BA3 /* NSTextField+Action.h */; };
Expand Down Expand Up @@ -66,6 +68,8 @@
522547DB1F4C312A00226A2A /* TKRemoteControlWindowController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TKRemoteControlWindowController.h; sourceTree = "<group>"; };
522547DC1F4C312A00226A2A /* TKRemoteControlWindowController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TKRemoteControlWindowController.m; sourceTree = "<group>"; };
522547DD1F4C312A00226A2A /* TKRemoteControlWindowController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = TKRemoteControlWindowController.xib; sourceTree = "<group>"; };
5226D5C82040FC3E0013C048 /* TKVersionManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TKVersionManager.h; sourceTree = "<group>"; };
5226D5C92040FC3E0013C048 /* TKVersionManager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = TKVersionManager.m; sourceTree = "<group>"; };
5228EAB81F70B59500D808CF /* NSButton+Action.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSButton+Action.h"; sourceTree = "<group>"; };
5228EAB91F70B59500D808CF /* NSButton+Action.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSButton+Action.m"; sourceTree = "<group>"; };
523848A91F70E73500771BA3 /* NSTextField+Action.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSTextField+Action.h"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -307,6 +311,8 @@
52B5CF031F3B4631000D9DD9 /* TKHelper.m */,
52B5CF041F3B4631000D9DD9 /* XMLReader.h */,
52B5CF051F3B4631000D9DD9 /* XMLReader.m */,
5226D5C82040FC3E0013C048 /* TKVersionManager.h */,
5226D5C92040FC3E0013C048 /* TKVersionManager.m */,
);
path = Utils;
sourceTree = "<group>";
Expand Down Expand Up @@ -352,6 +358,7 @@
52475C321F6BA43800760E3E /* TKIgnoreSessonModel.h in Headers */,
526F4D8D1F4AAC3800E46004 /* TKRemoteControlCell.h in Headers */,
52B5CF181F3B4631000D9DD9 /* TKRemoteControlModel.h in Headers */,
5226D5CA2040FC3E0013C048 /* TKVersionManager.h in Headers */,
522547CF1F4AE5A700226A2A /* NSView+Action.h in Headers */,
526F4D911F4AAE6F00E46004 /* TKAutoReplyCell.h in Headers */,
52475C2E1F6B993E00760E3E /* MMChatsTableCellView+hook.h in Headers */,
Expand Down Expand Up @@ -466,6 +473,7 @@
526F4D841F4AAC1900E46004 /* TKAutoReplyModel.m in Sources */,
526F4D8C1F4AAC3800E46004 /* TKAutoReplyContentView.m in Sources */,
522547DF1F4C312A00226A2A /* TKAutoReplyWindowController.m in Sources */,
5226D5CB2040FC3E0013C048 /* TKVersionManager.m in Sources */,
52B5CF191F3B4631000D9DD9 /* TKRemoteControlModel.m in Sources */,
5228EABB1F70B59500D808CF /* NSButton+Action.m in Sources */,
52EE9515203FE58500B76873 /* MMStickerMessageCellView+hook.m in Sources */,
Expand Down
Binary file not shown.
4 changes: 3 additions & 1 deletion WeChatPlugin/Info.plist
Expand Up @@ -15,12 +15,14 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<string>1.5.0</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2017年 tk. All rights reserved.</string>
<key>NSPrincipalClass</key>
<string></string>
<key>versionInfo</key>
<string>👉 优化防撤回提醒。 \n👉🏻 新增自动登录开关。 \n👉🏼 新增小助手检测更新。 \n👉🏽 新增通知中心快捷回复。\n👉🏾 新增表情包复制 &amp; 存储。\n👉🏿 自动回复 &amp; 远程控制设置存储到本地。\n\n</string>
</dict>
</plist>
57 changes: 57 additions & 0 deletions WeChatPlugin/Sources/Category/WeChat+hook.m
Expand Up @@ -14,6 +14,7 @@
#import "TKRemoteControlWindowController.h"
#import "TKIgnoreSessonModel.h"
#import "fishhook.h"
#import "TKVersionManager.h"

static char tkAutoReplyWindowControllerKey; // 自动回复窗口的关联 key
static char tkRemoteControlWindowControllerKey; // 远程控制窗口的关联 key
Expand Down Expand Up @@ -46,6 +47,7 @@ + (void)hookWeChat {
}, 2);

[self setup];
[self checkPluginVersion];
}

+ (void)setup {
Expand All @@ -58,6 +60,30 @@ + (void)setup {
});
}

+ (void)checkPluginVersion {
if ([[TKWeChatPluginConfig sharedConfig] forbidCheckVersion]) return;

[[TKVersionManager shareManager] checkVersionFinish:^(TKVersionStatus status, NSString *message) {
if (status == TKVersionStatusNew) {
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
NSAlert *alert = [[NSAlert alloc] init];
[alert addButtonWithTitle:@"前往Github"];
[alert addButtonWithTitle:@"不再提示"];
[alert addButtonWithTitle:@"取消"];
[alert setMessageText:@"检测到新版本!主要内容:👇"];
[alert setInformativeText:message];
NSModalResponse respose = [alert runModal];
if (respose == NSAlertFirstButtonReturn) {
NSURL *url = [NSURL URLWithString:@"https://github.com/TKkk-iOSer/WeChatPlugin-MacOS"];
[[NSWorkspace sharedWorkspace] openURL:url];
} else if (respose == NSAlertSecondButtonReturn) {
[[TKWeChatPluginConfig sharedConfig] setForbidCheckVersion:YES];
}
});
}
}];
}

/**
菜单栏添加 menuItem
*/
Expand All @@ -77,6 +103,8 @@ + (void)addAssistantMenuItem {
// 免认证登录
NSMenuItem *autoAuthItem = [[NSMenuItem alloc] initWithTitle:@"免认证登录" action:@selector(onAutoAuthControl:) keyEquivalent:@"M"];
autoAuthItem.state = [[TKWeChatPluginConfig sharedConfig] autoAuthEnable];
// 更新小助手
NSMenuItem *updatePluginItem = [[NSMenuItem alloc] initWithTitle:@"更新小助手…" action:@selector(onUpdatePluginControl:) keyEquivalent:@""];

NSMenu *subMenu = [[NSMenu alloc] initWithTitle:@"微信小助手"];
[subMenu addItem:preventRevokeItem];
Expand All @@ -85,6 +113,7 @@ + (void)addAssistantMenuItem {
[subMenu addItem:newWeChatItem];
[subMenu addItem:onTopItem];
[subMenu addItem:autoAuthItem];
[subMenu addItem:updatePluginItem];

NSMenuItem *menuItem = [[NSMenuItem alloc] init];
[menuItem setTitle:@"微信小助手"];
Expand Down Expand Up @@ -173,6 +202,34 @@ - (void)onWechatOnTopControl:(NSMenuItem *)item {
wechat.mainWindowController.window.level = item.state == NSControlStateValueOn ? NSStatusWindowLevel : NSNormalWindowLevel;
}

/**
菜单栏-微信小助手-更新小助手
@param item 更新小助手的 item
*/
- (void)onUpdatePluginControl:(NSMenuItem *)item {
[[TKWeChatPluginConfig sharedConfig] setForbidCheckVersion:NO];
[[TKVersionManager shareManager] checkVersionFinish:^(TKVersionStatus status, NSString *message) {
if (status == TKVersionStatusNew) {
NSAlert *alert = [[NSAlert alloc] init];
[alert addButtonWithTitle:@"前往Github"];
[alert addButtonWithTitle:@"取消"];
[alert setMessageText:@"检测到新版本!主要内容:👇"];
[alert setInformativeText:message];
NSModalResponse respose = [alert runModal];
if (respose == NSAlertFirstButtonReturn) {
NSURL *url = [NSURL URLWithString:@"https://github.com/TKkk-iOSer/WeChatPlugin-MacOS"];
[[NSWorkspace sharedWorkspace] openURL:url];
}
} else {
NSAlert *alert = [[NSAlert alloc] init];
[alert setMessageText:@"当前为最新版本!主要内容:👇"];
[alert setInformativeText:message];
[alert runModal];
}
}];
}

/**
登录界面-自动登录
Expand Down
5 changes: 4 additions & 1 deletion WeChatPlugin/Sources/Config/TKWeChatPluginConfig.h
Expand Up @@ -13,15 +13,18 @@

@property (nonatomic, assign) BOOL preventRevokeEnable; /**< 是否开启防撤回 */
@property (nonatomic, assign) BOOL autoAuthEnable; /**< 是否免认证登录 */
@property (nonatomic, assign) BOOL autoLoginEnable; /**< 是否自动登录 */
@property (nonatomic, assign) BOOL autoLoginEnable; /**< 是否自动登录 */
@property (nonatomic, assign) BOOL onTop; /**< 是否要置顶微信 */
@property (nonatomic, assign) BOOL multipleSelectionEnable; /**< 是否要进行多选 */
@property (nonatomic, assign) BOOL forbidCheckVersion; /**< 禁止检测版本 */
@property (nonatomic, copy) NSMutableArray *autoReplyModels; /**< 自动回复的数组 */
@property (nonatomic, copy) NSMutableArray *remoteControlModels; /**< 远程控制的数组 */
@property (nonatomic, copy) NSMutableArray *ignoreSessionModels; /**< 聊天置底的数组 */
@property (nonatomic, copy) NSMutableArray *selectSessions; /**< 已经选中的会话 */
@property (nonatomic, copy) NSMutableSet *revokeMsgSet; /**< 撤回的消息集合 */
@property (nonatomic, copy) NSString *currentUserName; /**< 当前用户的id */
@property (nonatomic, copy, readonly) NSDictionary *localInfoPlist;
@property (nonatomic, copy, readonly) NSDictionary *romoteInfoPlist;

- (void)saveAutoReplyModels;
- (void)saveRemoteControlModels;
Expand Down
31 changes: 29 additions & 2 deletions WeChatPlugin/Sources/Config/TKWeChatPluginConfig.m
Expand Up @@ -15,6 +15,7 @@
static NSString * const kTKAutoAuthEnableKey = @"kTKAutoAuthEnableKey";
static NSString * const kTKAutoLoginEnableKey = @"kTKAutoLoginEnableKey";
static NSString * const kTKOnTopKey = @"kTKOnTopKey";
static NSString * const kTKForbidCheckVersionKey = @"kTKForbidCheckVersionKey";
static NSString * const kTKWeChatResourcesPath = @"/Applications/WeChat.app/Contents/MacOS/WeChatPlugin.framework/Resources/";

@interface TKWeChatPluginConfig ()
Expand All @@ -23,6 +24,9 @@ @interface TKWeChatPluginConfig ()
@property (nonatomic, copy) NSString *autoReplyPlistFilePath;
@property (nonatomic, copy) NSString *ignoreSessionPlistFilePath;

@property (nonatomic, copy) NSDictionary *localInfoPlist;
@property (nonatomic, copy) NSDictionary *romoteInfoPlist;

@end

@implementation TKWeChatPluginConfig
Expand All @@ -43,6 +47,7 @@ - (instancetype)init {
_autoAuthEnable = [[NSUserDefaults standardUserDefaults] boolForKey:kTKAutoAuthEnableKey];
_autoLoginEnable = [[NSUserDefaults standardUserDefaults] boolForKey:kTKAutoLoginEnableKey];
_onTop = [[NSUserDefaults standardUserDefaults] boolForKey:kTKOnTopKey];
_forbidCheckVersion = [[NSUserDefaults standardUserDefaults] boolForKey:kTKForbidCheckVersionKey];
}
return self;
}
Expand Down Expand Up @@ -71,6 +76,12 @@ - (void)setOnTop:(BOOL)onTop {
[[NSUserDefaults standardUserDefaults] synchronize];
}

- (void)setForbidCheckVersion:(BOOL)forbidCheckVersion {
_forbidCheckVersion = forbidCheckVersion;
[[NSUserDefaults standardUserDefaults] setBool:_forbidCheckVersion forKey:kTKForbidCheckVersionKey];
[[NSUserDefaults standardUserDefaults] synchronize];
}

#pragma mark - 自动回复
- (NSArray *)autoReplyModels {
if (!_autoReplyModels) {
Expand Down Expand Up @@ -151,7 +162,7 @@ - (NSMutableArray *)selectSessions {
return _selectSessions;
}

#pragma mark - 选中的会话
#pragma mark - 撤回的消息集合
- (NSMutableSet *)revokeMsgSet {
if (!_revokeMsgSet) {
_revokeMsgSet = [NSMutableSet set];
Expand Down Expand Up @@ -181,6 +192,23 @@ - (NSString *)ignoreSessionPlistFilePath {
return _ignoreSessionPlistFilePath;
}

#pragma mark - 获取本地 & github 上的小助手 info 信息
- (NSDictionary *)localInfoPlist {
if (!_localInfoPlist) {
NSString *localInfoPath = [kTKWeChatResourcesPath stringByAppendingString:@"info.plist"];
_localInfoPlist = [NSDictionary dictionaryWithContentsOfFile:localInfoPath];
}
return _localInfoPlist;
}

- (NSDictionary *)romoteInfoPlist {
if (!_romoteInfoPlist) {
NSURL *url = [NSURL URLWithString:@"https://raw.githubusercontent.com/TKkk-iOSer/WeChatPlugin-MacOS/master/Other/Products/Debug/WeChatPlugin.framework/Resources/Info.plist"];
_romoteInfoPlist = [NSDictionary dictionaryWithContentsOfURL:url];
}
return _romoteInfoPlist;
}

#pragma mark - common
- (NSMutableArray *)getModelsWithClass:(Class)class filePath:(NSString *)filePath {
NSArray *originModels = [NSArray arrayWithContentsOfFile:filePath];
Expand Down Expand Up @@ -213,7 +241,6 @@ - (NSString *)getSandboxFilePathWithPlistName:(NSString *)plistName {
if (!error) {
return plistFilePath;
}

return resourcesFilePath;
}

Expand Down
21 changes: 21 additions & 0 deletions WeChatPlugin/Sources/Utils/TKVersionManager.h
@@ -0,0 +1,21 @@
//
// TKVersionManager.h
// WeChatPlugin
//
// Created by TK on 2018/2/24.
// Copyright © 2018年 tk. All rights reserved.
//

#import <Foundation/Foundation.h>

typedef NS_ENUM(NSUInteger, TKVersionStatus) {
TKVersionStatusOld,
TKVersionStatusNew,
};

@interface TKVersionManager : NSObject

+ (instancetype)shareManager;
- (void)checkVersionFinish:(void (^)(TKVersionStatus, NSString *))finish;

@end

0 comments on commit 1947891

Please sign in to comment.