修复 Android 版本获取方法错误

修复 iOS 解析不完善问题
添加钉钉 WebHookAPI
This commit is contained in:
yizhaorong
2019-08-11 11:22:08 +08:00
parent f58e79634f
commit ab033d0941
16 changed files with 3081 additions and 221 deletions
+21 -1
View File
@@ -5,14 +5,34 @@
#### 效果
样式与 fir 一致,直接扒的,未进行无用样式清理
样式与 fir 一致,直接扒的。
##### 首页
![首页](images/index.jpg)
##### 更新列表
![首页](images/list.jpg)
##### 基本信息
![](images/list_info.jpg)
##### 钉钉集成
![](images/list_web_hook.jpg)
##### 钉钉机器人消息
![](images/ding_ding.jpg)
##### PC安装页
![首页](images/install.jpg)
##### 手机安装页
![首页](images/mobile_install.jpg)
##### 证书信任设置
Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 59 KiB

BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 29 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 19 KiB

@@ -11,9 +11,9 @@ import org.yzr.model.App;
import org.yzr.model.Package;
import org.yzr.service.AppService;
import org.yzr.service.PackageService;
import org.yzr.utils.DingdingUtils;
import org.yzr.utils.PathManager;
import org.yzr.utils.ipa.PlistGenerator;
import org.yzr.utils.webhook.WebHookClient;
import org.yzr.vo.AppViewModel;
import org.yzr.vo.PackageViewModel;
@@ -95,8 +95,8 @@ public class PackageController {
app = this.appService.save(app);
// URL
String codeURL = this.pathManager.getBaseURL(false) + "p/code/" + app.getCurrentPackage().getId();
// 发送钉钉消息
DingdingUtils.sendMarkdown(app, pathManager);
// 发送WebHook消息
WebHookClient.sendMessage(app, pathManager);
map.put("code", codeURL);
map.put("success", true);
} catch (Exception e) {
@@ -212,6 +212,7 @@ public class PackageController {
String newFileName = UUID.randomUUID().toString() + "." + ext;
// 转存到 tmp
String destPath = FileUtils.getTempDirectoryPath() + File.separator + newFileName;
destPath = destPath.replaceAll("//", "/");
srcFile.transferTo(new File(destPath));
return destPath;
} catch (Exception e) {
+1 -1
View File
@@ -13,7 +13,7 @@ import javax.persistence.*;
@Getter
public class WebHook {
// 钉钉
public static final String WEB_HOOK_TYPE_DING_DING="DING_DING";
public static final String WEB_HOOK_TYPE_DING_DING="DingDing";
// 主键
@Id
@@ -25,6 +25,7 @@ public class IPAParser implements PackageParser {
String targetPath = ZipUtils.unzip(filePath);
String appPath = appPath(targetPath);
String infoPlistPath = appPath + File.separator + "Info.plist";
infoPlistPath = infoPlistPath.replaceAll("//", "/");
File infoPlistFile = new File(infoPlistPath);
// Plist 文件获取失败
if (!infoPlistFile.exists()) return null;
@@ -46,7 +47,11 @@ public class IPAParser implements PackageParser {
aPackage.setPlatform("ios");
// 获取应用图标
String iconPath = appIcon(appPath, infoPlist.stringValueForKeyPath("CFBundleIcons.CFBundlePrimaryIcon.CFBundleIconName"));
String iconName = infoPlist.stringValueForKeyPath("CFBundleIcons.CFBundlePrimaryIcon.CFBundleIconName");
if (iconName == null) {
iconName = infoPlist.stringValueForKeyPath("CFBundleIconFile");
}
String iconPath = appIcon(appPath, iconName);
String iconTempPath = PathManager.getTempIconPath(aPackage);
PNGConverter.convert(iconPath, iconTempPath);
@@ -72,7 +77,7 @@ public class IPAParser implements PackageParser {
File[] listFiles = payloadFile.listFiles();
String appName = null;
for (File file : listFiles) {
if (file.getName().contains(".app")) {
if (file.getName().endsWith(".app")) {
appName = file.getName();
break;
}
@@ -95,6 +100,8 @@ public class IPAParser implements PackageParser {
boolean isMatch = Pattern.matches(pattern, file.getName());
if (isMatch) {
iconNames.add(file.getName());
} else if (file.getName().equals(iconName)) {
iconNames.add(file.getName());
}
}
if (iconNames.size() > 0) {
@@ -1,14 +1,16 @@
package org.yzr.utils;
package org.yzr.utils.webhook;
import com.alibaba.fastjson.JSONObject;
import okhttp3.*;
import org.yzr.model.App;
import org.yzr.model.WebHook;
import org.yzr.utils.ImageUtils;
import org.yzr.utils.PathManager;
import java.util.HashMap;
import java.util.Map;
public class DingdingUtils {
public class DingDingWebHook implements IWebHook {
private static OkHttpClient client = new OkHttpClient();
/**
@@ -37,7 +39,8 @@ public class DingdingUtils {
}
}
public static void sendMarkdown(App app, PathManager pathManager) {
@Override
public void sendMessage(App app, PathManager pathManager) {
if (app.getWebHookList() == null || app.getWebHookList().size() < 1) {
return;
}
@@ -0,0 +1,8 @@
package org.yzr.utils.webhook;
import org.yzr.model.App;
import org.yzr.utils.PathManager;
public interface IWebHook {
void sendMessage(App app, PathManager pathManager);
}
@@ -0,0 +1,64 @@
package org.yzr.utils.webhook;
import org.yzr.model.App;
import org.yzr.model.WebHook;
import org.yzr.utils.PathManager;
import java.util.HashMap;
import java.util.Map;
public class WebHookClient {
static Map<String, Object> webHookList;
static {
webHookList = new HashMap<>();
}
/**
* 向 webHook 发送消息
* @param app
* @param pathManager
*/
public static void sendMessage(App app, PathManager pathManager) {
if (app.getWebHookList() == null || app.getWebHookList().size() < 1) {
return;
}
for (WebHook webHook :
app.getWebHookList()) {
String webHookType = webHook.getType();
IWebHook iWebHook = getWebHook(webHookType);
if (iWebHook != null) {
iWebHook.sendMessage(app, pathManager);
}
}
}
/**
* 通过类型获取 WebHook 实现
* @param webHookType
* @return
*/
private static IWebHook getWebHook(String webHookType) {
if (webHookType == null || webHookType.length() < 1) {
return null;
}
IWebHook iWebHook = (IWebHook) webHookList.get(webHookType);
if (iWebHook != null) {
return iWebHook;
}
try {
// 动态获取 WebHook
Class aClass = Class.forName("org.yzr.utils.webhook." + webHookType +"WebHook");
iWebHook = (IWebHook) aClass.newInstance();
webHookList.put(webHookType, iWebHook);
return iWebHook;
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
}
File diff suppressed because it is too large Load Diff
@@ -12,6 +12,7 @@
<meta name="apple-mobile-web-app-status-bar-style" content="white">
<meta name="format-detection" content="telephone=no">
<link rel="icon" type="image/x-icon" th:href="@{/images/favicon.ico}" />
<link rel="stylesheet" th:href="@{/css/bootstrap.css}">
<link rel="stylesheet" th:href="@{/css/download.css}">
<script type="text/javascript" th:src="@{/js/qrcode.js}"></script>
<script type="text/javascript" th:src="@{/js/jquery-1.11.0.min.js}"></script>