Skip to content
This repository has been archived by the owner on Dec 28, 2023. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
4ra1n committed Jan 30, 2023
1 parent c4552a0 commit d1cf1d4
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 1 deletion.
3 changes: 2 additions & 1 deletion CHANGELOG.MD
Original file line number Diff line number Diff line change
Expand Up @@ -256,4 +256,5 @@ Others:
- [important] 提供MacOS的APP版本 #141
- [important] [feat] 支持拖拽xray文件加载 #140
- [bug] CPU占用较高问题RAD修复不完善 #139
- [feat] 增加一键修复/还原的功能 #143
- [feat] 增加一键修复/还原的功能 #143
- [feat] 自动检查版本更新并提示 #142
52 changes: 52 additions & 0 deletions src/main/java/com/chaitin/xray/form/MainForm.java
Original file line number Diff line number Diff line change
Expand Up @@ -1560,6 +1560,58 @@ public void mouseClicked(MouseEvent e) {
}
}
});
new Thread() {
@Override
public void run() {
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("https://api.github.com/repos/4ra1n/super-xray/releases/latest")
.addHeader("Connection", "close")
.build();

try {
Thread.sleep(3000);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
client.newCall(request).enqueue(new Callback() {
@Override
public void onFailure(Call call, IOException e) {
// ignored
}

@Override
public void onResponse(Call call, Response response) {
try {
if (response.body() == null) {
return;
}
String body = response.body().string();
String ver = body.split("\"tag_name\":")[1].split(",")[0];
ver = ver.substring(1, ver.length() - 1);

if (!ver.equals(Const.CurVersion)) {
String output;
if (LANG == CHINESE) {
output = String.format("新版本!\n%s: %s\n%s: %s\n%s",
"您当前的版本", Const.CurVersion,
"目前最新版本", ver,
"https://github.com/4ra1n/super-xray/releases/latest");
JOptionPane.showMessageDialog(instance.SuperXray, output);
} else {
output = String.format("New Version!\n%s: %s\n%s: %s\n%s",
"Your Current Version", Const.CurVersion,
"Latest Version", ver,
"https://github.com/4ra1n/super-xray/releases/latest");
JOptionPane.showMessageDialog(instance.SuperXray, output);
}
}
} catch (Exception ignored) {
}
}
});
}
}.start();
}

public static final int CHINESE = 0;
Expand Down

0 comments on commit d1cf1d4

Please sign in to comment.