mirror of
https://github.com/Hello-hao/Tbed.git
synced 2026-09-20 03:18:28 +00:00
:memo:调整部分代码
This commit is contained in:
@@ -13,9 +13,9 @@
|
||||
|
||||
>:exclamation: 托管的所有开源代码可能存在作者修改/测试/调整等行为,均为实验性代码,故并不保证程序或功能的可用性,如果你想要部署程序,请下载我们提供的编译整合包进行安装部署。
|
||||
|
||||
### 感谢JetBrains对开发者的大力支持
|
||||
### 感谢[JetBrains](https://www.jetbrains.com)对开发者的大力支持
|
||||
|
||||
<a href="https://www.jetbrains.com/" target="_blank">
|
||||
<a href="https://www.jetbrains.com" target="_blank">
|
||||
<img width="80px" src="https://images.icon-icons.com/3053/PNG/512/intellij_macos_bigsur_icon_190061.png">
|
||||
<img width="80px" src="https://images.icon-icons.com/3053/PNG/512/intellij_webstorm_macos_bigsur_icon_190053.png">
|
||||
<img width="80px" src="https://images.icon-icons.com/3053/PNG/512/intellij_datagrip_macos_bigsur_icon_190058.png">
|
||||
|
||||
@@ -32,7 +32,6 @@ import java.util.*;
|
||||
/**
|
||||
* @author Hellohao
|
||||
* @version 1.0
|
||||
* @date 2019-07-17 14:22
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("/admin")
|
||||
|
||||
@@ -8,7 +8,7 @@ import cn.hellohao.service.impl.UploadServicel;
|
||||
import cn.hellohao.service.impl.WebDAVImageupload;
|
||||
import cn.hellohao.service.impl.deleImages;
|
||||
import cn.hellohao.utils.GetIPS;
|
||||
import cn.hellohao.utils.MyVersion;
|
||||
import cn.hellohao.utils.MyStringUtils;
|
||||
import cn.hellohao.utils.SetFiles;
|
||||
import cn.hutool.captcha.CaptchaUtil;
|
||||
import cn.hutool.captcha.ShearCaptcha;
|
||||
@@ -418,7 +418,7 @@ public class IndexController {
|
||||
AppClient app = appClientService.getAppClientData("app");
|
||||
if (!StringUtils.isBlank(app.getAppupdate())) {
|
||||
String version = app.getAppupdate().replaceAll("\\.", "");
|
||||
if (MyVersion.compareVersion(app.getAppupdate(), appv) == 1) {
|
||||
if (MyStringUtils.compareVersion(app.getAppupdate(), appv) == 1) {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("winpackurl", app.getWinpackurl());
|
||||
jsonObject.put("macpackurl", app.getMacpackurl());
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
package cn.hellohao.utils;
|
||||
|
||||
public class MyStringUtils {
|
||||
|
||||
/**
|
||||
* 版本号比较
|
||||
*
|
||||
* @param v1
|
||||
* @param v2
|
||||
* @return 0代表相等,1代表左边大,-1代表右边大
|
||||
* compareVersion("1.0.358_20180820090554","1.0.358_20180820090553")=1
|
||||
*/
|
||||
public static int compareVersion(String v1, String v2) {
|
||||
if (v1.equals(v2)) {
|
||||
return 0;
|
||||
}
|
||||
String[] version1Array = v1.split("[._]");
|
||||
String[] version2Array = v2.split("[._]");
|
||||
int index = 0;
|
||||
int minLen = Math.min(version1Array.length, version2Array.length);
|
||||
long diff = 0;
|
||||
|
||||
while (index < minLen
|
||||
&& (diff = Long.parseLong(version1Array[index])
|
||||
- Long.parseLong(version2Array[index])) == 0) {
|
||||
index++;
|
||||
}
|
||||
if (diff == 0) {
|
||||
for (int i = index; i < version1Array.length; i++) {
|
||||
if (Long.parseLong(version1Array[i]) > 0) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
for (int i = index; i < version2Array.length; i++) {
|
||||
if (Long.parseLong(version2Array[i]) > 0) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
} else {
|
||||
return diff > 0 ? 1 : -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除 URL 中的第一个 '/'
|
||||
* @return 如 path = '/folder1/file1', 返回 'folder1/file1'
|
||||
*/
|
||||
public static String removeFirstSeparator(String path) {
|
||||
if (!"".equals(path) && path.charAt(0) == '/') {
|
||||
path = path.substring(1);
|
||||
}
|
||||
return path;
|
||||
}
|
||||
/**
|
||||
* 移除 URL 中的最后一个 '/'
|
||||
* @return 如 path = '/folder1/file1/', 返回 '/folder1/file1'
|
||||
*/
|
||||
public static String removeLastSeparator(String path) {
|
||||
if (!"".equals(path) && path.charAt(path.length() - 1) == '/') {
|
||||
path = path.substring(0, path.length() - 1);
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将域名和路径组装成 URL, 主要用来处理分隔符 '/'
|
||||
* @param domain 域名
|
||||
* @param path 路径
|
||||
* @return URL
|
||||
*/
|
||||
public static String concatDomainAndPath(String domain, String path) {
|
||||
if (path != null && path.length() > 1 && path.charAt(0) != '/') {
|
||||
path = '/' + path;
|
||||
}
|
||||
if (domain.charAt(domain.length() - 1) == '/') {
|
||||
domain = domain.substring(0, domain.length() - 2);
|
||||
}
|
||||
return domain + path;
|
||||
}
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
package cn.hellohao.utils;
|
||||
|
||||
/**
|
||||
* @author Hellohao
|
||||
* @version 1.0
|
||||
* @date 2022/7/18 9:49
|
||||
*/
|
||||
public class MyVersion {
|
||||
/**
|
||||
* 版本号比较
|
||||
*
|
||||
* @param v1
|
||||
* @param v2
|
||||
* @return 0代表相等,1代表左边大,-1代表右边大
|
||||
* Utils.compareVersion("1.0.358_20180820090554","1.0.358_20180820090553")=1
|
||||
*/
|
||||
public static int compareVersion(String v1, String v2) {
|
||||
if (v1.equals(v2)) {
|
||||
return 0;
|
||||
}
|
||||
String[] version1Array = v1.split("[._]");
|
||||
String[] version2Array = v2.split("[._]");
|
||||
int index = 0;
|
||||
int minLen = Math.min(version1Array.length, version2Array.length);
|
||||
long diff = 0;
|
||||
|
||||
while (index < minLen
|
||||
&& (diff = Long.parseLong(version1Array[index])
|
||||
- Long.parseLong(version2Array[index])) == 0) {
|
||||
index++;
|
||||
}
|
||||
if (diff == 0) {
|
||||
for (int i = index; i < version1Array.length; i++) {
|
||||
if (Long.parseLong(version1Array[i]) > 0) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = index; i < version2Array.length; i++) {
|
||||
if (Long.parseLong(version2Array[i]) > 0) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
} else {
|
||||
return diff > 0 ? 1 : -1;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
package cn.hellohao.utils;
|
||||
|
||||
public class StringUtils {
|
||||
/**
|
||||
* 移除 URL 中的第一个 '/'
|
||||
* @return 如 path = '/folder1/file1', 返回 'folder1/file1'
|
||||
*/
|
||||
public static String removeFirstSeparator(String path) {
|
||||
if (!"".equals(path) && path.charAt(0) == '/') {
|
||||
path = path.substring(1);
|
||||
}
|
||||
return path;
|
||||
}
|
||||
/**
|
||||
* 移除 URL 中的最后一个 '/'
|
||||
* @return 如 path = '/folder1/file1/', 返回 '/folder1/file1'
|
||||
*/
|
||||
public static String removeLastSeparator(String path) {
|
||||
if (!"".equals(path) && path.charAt(path.length() - 1) == '/') {
|
||||
path = path.substring(0, path.length() - 1);
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将域名和路径组装成 URL, 主要用来处理分隔符 '/'
|
||||
* @param domain 域名
|
||||
* @param path 路径
|
||||
* @return URL
|
||||
*/
|
||||
public static String concatDomainAndPath(String domain, String path) {
|
||||
if (path != null && path.length() > 1 && path.charAt(0) != '/') {
|
||||
path = '/' + path;
|
||||
}
|
||||
if (domain.charAt(domain.length() - 1) == '/') {
|
||||
domain = domain.substring(0, domain.length() - 2);
|
||||
}
|
||||
return domain + path;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user