Skip to content

Commit d8c43b8

Browse files
authored
Merge pull request #7 from 864381832/dev
Dev
2 parents 70e39e6 + cf6d5b0 commit d8c43b8

13 files changed

Lines changed: 189 additions & 127 deletions

File tree

README.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
[英文说明/English Documentation](README_EN.md)
1212

13-
**xJavaFxTool交流QQ群:== [387473650](https://jq.qq.com/?_wv=1027&k=59UDEAD) ==**
13+
**xJavaFxTool交流QQ群:== [387473650(此群已满)](https://jq.qq.com/?_wv=1027&k=59UDEAD) 请加群②[1104780992](https://jq.qq.com/?_wv=1027&k=bhAdkju9) ==**
1414
**xJavaFxTool吐个槽:== [进来吐槽](https://support.qq.com/product/127577) ==**
1515

1616
#### 项目简介:
@@ -19,11 +19,11 @@ xJavaFxTool是使用javaFx开发的实用小工具集,利用业余时间把工
1919
由于SpringBoot的火热,项目已经出SpringBoot-javafx版本,[xJavaFxTool-spring](https://gitee.com/xwintop/xJavaFxTool-spring) 欢迎参考,谢谢。
2020

2121
#### 下载试用地址:
22-
- 可直接运行的jar包(本地需要有jdk1.8环境)[xJavaFxTool-0.2.2.jar](https://xwintop.gitee.io/maven/package/xJavaFxTool/xJavaFxTool-0.2.2.jar)
23-
- Windows x86安装包(兼容xp、windows7、8、10等系统)[xJavaFxTool-0.2.2-windows-x86.exe](https://xwintop.gitee.io/maven/package/xJavaFxTool/xJavaFxTool-0.2.2-windows-x86.exe)
24-
- Windows x64安装包(兼容xp、windows7、8、10等系统)[xJavaFxTool-0.2.2-windows-x64.exe](https://xwintop.gitee.io/maven/package/xJavaFxTool/xJavaFxTool-0.2.2-windows-x64.exe)
25-
- Linux x64 [xJavaFxTool-0.2.2-linux-x64.zip](https://xwintop.coding.net/s/a9ae5e67-ba0d-4421-955b-7cba0662a976) (Linux平台64位运行压缩包,解压即可运行)
26-
- Mac OS X x64 [xJavaFxTool-0.2.2-macosx-x64.pkg](https://xwintop.gitee.io/maven/package/xJavaFxTool/xJavaFxTool-0.2.2-macosx-x64.pkg)
22+
- 可直接运行的jar包(本地需要有jdk1.8环境)[xJavaFxTool-0.2.3.jar](https://xwintop.gitee.io/maven/package/xJavaFxTool/xJavaFxTool-0.2.3.jar)
23+
- Windows x86安装包(兼容xp、windows7、8、10等系统)(请在下面网盘中下载)
24+
- Windows x64安装包(兼容xp、windows7、8、10等系统)[xJavaFxTool-0.2.3-windows-x64.exe](https://xwintop.gitee.io/maven/package/xJavaFxTool/xJavaFxTool-0.2.3-windows-x64.exe)
25+
- Linux x64 (请在下面网盘中下载)
26+
- Mac OS X x64 [xJavaFxTool-0.2.3-macosx-x64.pkg](https://xwintop.gitee.io/maven/package/xJavaFxTool/xJavaFxTool-0.2.3-macosx-x64.pkg)
2727
#### 若上面下链接失效可使用下面下载链接:
2828
- 百度云链接:[https://pan.baidu.com/s/193fhGnJL4dDWcqDnFJcHbA](https://pan.baidu.com/s/193fhGnJL4dDWcqDnFJcHbA) 提取码:mokl
2929
- 腾讯微云链接:[https://share.weiyun.com/5T6FPLW](https://share.weiyun.com/5T6FPLW) 提取码:java
@@ -100,6 +100,7 @@ xJavaFxTool是使用javaFx开发的实用小工具集,利用业余时间把工
100100
57. Sudoku:数独游戏
101101
58. LiteappCode:小程序码生成工具
102102
59. RdbmsSyncTool:关系型数据库同步工具
103+
60. FileBuildTool:文件生成工具
103104

104105
项目开发中,以后会陆续添加新工具,欢迎大家参与其中,多提提意见,谢谢。
105106

README_EN.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,9 @@ xJavaFxTool is a practical gadget set developed by javaFx. It uses some time to
2929
Due to the hot SpringBoot, the project has been released SpringBoot-javafx version, [xJavaFxTool-spring](https://gitee.com/xwintop/xJavaFxTool-spring) welcome reference, thank you.
3030

3131
#### Download trial address:
32-
- Jar package that can be run directly (local need to have jdk1.8 environment)[xJavaFxTool-0.2.1.jar](https://xwintop.gitee.io/maven/package/xJavaFxTool/xJavaFxTool-0.2.1.jar)
33-
- Windows x86 installation package (compatible with xp, windows7, 8, 10, etc.) [xJavaFxTool-0.2.1-windows-x86.exe](https://xwintop.gitee.io/maven/package/xJavaFxTool/xJavaFxTool-0.2.1-windows-x86.exe)
34-
- Windows x64 installation package (compatible with xp, windows7, 8, 10, etc.)[xJavaFxTool-0.2.1-windows-x64.exe](https://xwintop.gitee.io/maven/package/xJavaFxTool/xJavaFxTool-0.2.1-windows-x64.exe)
35-
- Linux x64 [xJavaFxTool-0.2.1-linux-x64.zip](https://xwintop.coding.net/s/5dc71c30-065d-4d0d-a238-3663291a18f7) (Linux platform 64-bit running compression package, decompression can run)
36-
- Mac OS X x64 [xJavaFxTool-0.2.1-macosx-x64.pkg](https://xwintop.gitee.io/maven/package/xJavaFxTool/xJavaFxTool-0.2.1-macosx-x64.pkg)
32+
- Jar package that can be run directly (local need to have jdk1.8 environment)[xJavaFxTool-0.2.3.jar](https://xwintop.gitee.io/maven/package/xJavaFxTool/xJavaFxTool-0.2.3.jar)
33+
- Windows x64 installation package (compatible with xp, windows7, 8, 10, etc.)[xJavaFxTool-0.2.3-windows-x64.exe](https://xwintop.gitee.io/maven/package/xJavaFxTool/xJavaFxTool-0.2.3-windows-x64.exe)
34+
- Mac OS X x64 [xJavaFxTool-0.2.3-macosx-x64.pkg](https://xwintop.gitee.io/maven/package/xJavaFxTool/xJavaFxTool-0.2.3-macosx-x64.pkg)
3735
#### If the above link fails, use the download link below:
3836
- Baidu cloud link: [https://pan.baidu.com/s/193fhGnJL4dDWcqDnFJcHbA](https://pan.baidu.com/s/193fhGnJL4dDWcqDnFJcHbA) extraction code: mokl
3937
- Tencent micro cloud link: [https://share.weiyun.com/5T6FPLW](https://share.weiyun.com/5T6FPLW) extraction code: java

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<groupId>com.xwintop</groupId>
66
<artifactId>xJavaFxTool</artifactId>
7-
<version>0.2.2</version>
7+
<version>0.2.3</version>
88
<packaging>jar</packaging>
99
<name>xJavaFxTool</name>
1010
<description>基于JavaFx搭建的实用小工具集合</description>
@@ -47,7 +47,7 @@
4747
<dependency>
4848
<groupId>com.xwintop</groupId>
4949
<artifactId>xcore</artifactId>
50-
<version>0.0.5</version>
50+
<version>0.0.6</version>
5151
</dependency>
5252
<dependency>
5353
<groupId>org.projectlombok</groupId>

src/main/java/com/xwintop/xJavaFxTool/Main.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import com.xwintop.xJavaFxTool.utils.XJavaFxSystemUtil;
99
import com.xwintop.xcore.javafx.FxApp;
1010
import com.xwintop.xcore.javafx.dialog.FxAlerts;
11-
import com.xwintop.xcore.javafx.helper.FxmlHelper;
1211
import com.xwintop.xcore.util.javafx.JavaFxViewUtil;
1312
import java.io.IOException;
1413
import java.util.ResourceBundle;
@@ -32,8 +31,7 @@ public class Main extends Application {
3231

3332
public static final String LOGO_PATH = "/images/icon.jpg";
3433

35-
public static final ResourceBundle RESOURCE_BUNDLE =
36-
ResourceBundle.getBundle("locale.Menu", Config.defaultLocale);
34+
public static ResourceBundle RESOURCE_BUNDLE;
3735

3836
private static Stage stage;
3937

@@ -69,8 +67,13 @@ public void start(Stage primaryStage) throws Exception {
6967
StageUtils.updateStageStyle(primaryStage);
7068
}
7169

72-
private void loadNewUI(Stage primaryStage) {
73-
FxmlHelper.loadIntoStage("/com/xwintop/xJavaFxTool/fxmlView/newui/main.fxml", primaryStage).show();
70+
private void loadNewUI(Stage primaryStage) throws IOException {
71+
FXMLLoader fxmlLoader = new FXMLLoader();
72+
fxmlLoader.setLocation(Main.class.getResource("/com/xwintop/xJavaFxTool/fxmlView/newui/main.fxml"));
73+
fxmlLoader.setResources(RESOURCE_BUNDLE);
74+
75+
Parent root = fxmlLoader.load();
76+
primaryStage.setScene(new Scene(root));
7477
}
7578

7679
private void loadClassicUI(Stage primaryStage) throws IOException {

src/main/java/com/xwintop/xJavaFxTool/controller/IndexController.java

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package com.xwintop.xJavaFxTool.controller;
22

3+
import static com.xwintop.xJavaFxTool.Main.RESOURCE_BUNDLE;
4+
import static com.xwintop.xJavaFxTool.utils.Config.Keys.NotepadEnabled;
5+
36
import com.xwintop.xJavaFxTool.controller.index.PluginManageController;
47
import com.xwintop.xJavaFxTool.model.ToolFxmlLoaderConfiguration;
58
import com.xwintop.xJavaFxTool.plugin.PluginManager;
@@ -13,6 +16,17 @@
1316
import com.xwintop.xcore.util.javafx.AlertUtil;
1417
import com.xwintop.xcore.util.javafx.JavaFxSystemUtil;
1518
import com.xwintop.xcore.util.javafx.JavaFxViewUtil;
19+
import java.io.File;
20+
import java.io.InputStream;
21+
import java.net.URL;
22+
import java.util.ArrayList;
23+
import java.util.Date;
24+
import java.util.HashMap;
25+
import java.util.List;
26+
import java.util.Map;
27+
import java.util.ResourceBundle;
28+
import java.util.jar.JarEntry;
29+
import java.util.jar.JarFile;
1630
import javafx.application.Platform;
1731
import javafx.event.ActionEvent;
1832
import javafx.fxml.FXML;
@@ -34,16 +48,6 @@
3448
import org.dom4j.Element;
3549
import org.dom4j.io.SAXReader;
3650

37-
import java.io.File;
38-
import java.io.InputStream;
39-
import java.net.URL;
40-
import java.util.*;
41-
import java.util.jar.JarEntry;
42-
import java.util.jar.JarFile;
43-
44-
import static com.xwintop.xJavaFxTool.Main.RESOURCE_BUNDLE;
45-
import static com.xwintop.xJavaFxTool.utils.Config.Keys.NotepadEnabled;
46-
4751
/**
4852
* @ClassName: IndexController
4953
* @Description: 主页
@@ -81,7 +85,7 @@ public void initialize(URL location, ResourceBundle resources) {
8185
initService();
8286
initNotepad();
8387

84-
this.indexService.addWebView("欢迎吐槽", QQ_URL, null);
88+
this.indexService.addWebView(RESOURCE_BUNDLE.getString("feedback"), QQ_URL, null);
8589
this.tongjiWebView.getEngine().load(STATISTICS_URL);
8690
}
8791

src/main/java/com/xwintop/xJavaFxTool/plugin/PluginManager.java

Lines changed: 63 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
11
package com.xwintop.xJavaFxTool.plugin;
22

3+
import cn.hutool.http.HttpStatus;
34
import cn.hutool.http.HttpUtil;
45
import com.alibaba.fastjson.JSON;
56
import com.xwintop.xJavaFxTool.model.PluginJarInfo;
67
import com.xwintop.xJavaFxTool.utils.Config;
78
import com.xwintop.xJavaFxTool.utils.Config.Keys;
89
import com.xwintop.xJavaFxTool.utils.XJavaFxSystemUtil;
10+
import lombok.extern.slf4j.Slf4j;
11+
import okhttp3.*;
12+
import okhttp3.Request.Builder;
13+
import okio.*;
14+
import org.apache.commons.io.FileUtils;
15+
import org.apache.commons.io.IOUtils;
16+
917
import java.io.File;
1018
import java.io.FileOutputStream;
1119
import java.io.IOException;
@@ -22,20 +30,6 @@
2230
import java.util.concurrent.CompletableFuture;
2331
import java.util.function.BiConsumer;
2432
import java.util.function.Consumer;
25-
import lombok.extern.slf4j.Slf4j;
26-
import okhttp3.Interceptor;
27-
import okhttp3.MediaType;
28-
import okhttp3.OkHttpClient;
29-
import okhttp3.Request.Builder;
30-
import okhttp3.Response;
31-
import okhttp3.ResponseBody;
32-
import okio.Buffer;
33-
import okio.BufferedSource;
34-
import okio.ForwardingSource;
35-
import okio.Okio;
36-
import okio.Source;
37-
import org.apache.commons.io.FileUtils;
38-
import org.apache.commons.io.IOUtils;
3933

4034
@Slf4j
4135
public class PluginManager {
@@ -46,6 +40,15 @@ public class PluginManager {
4640

4741
public static final Charset DEFAULT_CHARSET = StandardCharsets.UTF_8;
4842

43+
/**
44+
* 当下载插件时,模拟数种 UA
45+
*/
46+
public static final String[] OPTIONAL_UA_LIST = {
47+
"Mozilla/5.0 (Windows NT 6.1; rv:51.0) Gecko/20100101 Firefox/51.0",
48+
"Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.0 Safari/537.36",
49+
"Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko"
50+
};
51+
4952
private static PluginManager instance;
5053

5154
public static PluginManager getInstance() {
@@ -212,16 +215,27 @@ public File downloadPlugin(
212215
this.currentProgressListener =
213216
(bytesRead, contentLength, done) -> onProgressUpdate.accept(contentLength, bytesRead);
214217

215-
try (
216-
Response response = pluginDownloader
217-
.newCall(new Builder().url(pluginJarInfo.getDownloadUrl()).build())
218-
.execute();
219-
InputStream inputStream = response.body().byteStream();
220-
FileOutputStream outputStream = new FileOutputStream(file)
221-
) {
222-
IOUtils.copy(inputStream, outputStream);
218+
// 使用多个 UA 尝试下载
219+
Throwable downloadFailure = null;
220+
for (String ua : OPTIONAL_UA_LIST) {
221+
try {
222+
tryDownload(pluginJarInfo.getDownloadUrl(), ua, file);
223+
downloadFailure = null;
224+
break;
225+
} catch (Exception e) {
226+
downloadFailure = e;
227+
}
228+
}
229+
230+
if (downloadFailure != null) {
231+
if (downloadFailure instanceof IOException) {
232+
throw (IOException) downloadFailure;
233+
} else {
234+
throw new IOException("插件下载失败 " + pluginJarInfo.getJarName(), downloadFailure);
235+
}
223236
}
224237

238+
// 下载完毕
225239
plugin.setIsDownload(true);
226240
plugin.setIsEnable(true);
227241
plugin.setLocalVersionNumber(plugin.getVersionNumber());
@@ -233,8 +247,33 @@ public File downloadPlugin(
233247
return file;
234248
}
235249

250+
/**
251+
* 尝试指定的 UA 进行下载,如果下载失败则抛出异常
252+
*
253+
* @param url 下载地址
254+
* @param ua UA 字符串
255+
* @param file 下载到的目标文件
256+
*
257+
* @throws IOException 如果下载失败
258+
*/
259+
private void tryDownload(String url, String ua, File file) throws IOException {
260+
Request request = new Builder().header("User-Agent", ua).url(url).build();
261+
262+
try (Response response = pluginDownloader.newCall(request).execute()) {
263+
if (response.code() != HttpStatus.HTTP_OK) {
264+
throw new IOException("插件下载失败 : HTTP " + response.code());
265+
}
266+
267+
InputStream inputStream = Objects.requireNonNull(response.body()).byteStream();
268+
try (FileOutputStream outputStream = new FileOutputStream(file)) {
269+
IOUtils.copy(inputStream, outputStream);
270+
}
271+
}
272+
}
273+
236274
////////////////////////////////////////////////////////////// 保存配置
237275

276+
// 保存配置,如果失败则抛出异常
238277
public void saveToFile() throws IOException {
239278
String json = JSON.toJSONString(this.pluginList, true);
240279
Path path = Paths.get(this.localPluginsPath);
@@ -244,6 +283,7 @@ public void saveToFile() throws IOException {
244283
Files.write(path, json.getBytes(DEFAULT_CHARSET));
245284
}
246285

286+
// 保存配置,如果失败不抛出异常
247287
public void saveToFileQuietly() {
248288
try {
249289
saveToFile();
@@ -306,6 +346,7 @@ public BufferedSource source() {
306346

307347
private Source source(Source source) {
308348
return new ForwardingSource(source) {
349+
309350
long totalBytesRead = 0L;
310351

311352
@Override

src/main/java/com/xwintop/xJavaFxTool/services/index/SystemSettingService.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.xwintop.xJavaFxTool.services.index;
22

3+
import com.xwintop.xJavaFxTool.Main;
34
import com.xwintop.xJavaFxTool.controller.index.SystemSettingController;
45
import com.xwintop.xcore.javafx.FxApp;
56
import com.xwintop.xcore.javafx.dialog.FxDialog;
@@ -23,6 +24,7 @@ public class SystemSettingService {
2324
public static void openSystemSettings(String title) {
2425

2526
FxDialog<SystemSettingController> dialog = new FxDialog<SystemSettingController>()
27+
.setResourceBundle(Main.RESOURCE_BUNDLE)
2628
.setTitle(title)
2729
.setBodyFxml("/com/xwintop/xJavaFxTool/fxmlView/index/SystemSetting.fxml")
2830
.setOwner(FxApp.primaryStage)

src/main/java/com/xwintop/xJavaFxTool/utils/Config.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public class Config {
1414

1515
public static Locale defaultLocale = Locale.getDefault();// 设置系统语言
1616

17-
public static final String xJavaFxToolVersions = "V0.2.2";// xJavaFxTool版本信息
17+
public static final String xJavaFxToolVersions = "V0.2.3";// xJavaFxTool版本信息
1818

1919
///////////////////////////////////////////////////////////////
2020

src/main/java/com/xwintop/xJavaFxTool/utils/XJavaFxSystemUtil.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
package com.xwintop.xJavaFxTool.utils;
22

3+
import com.xwintop.xJavaFxTool.Main;
34
import com.xwintop.xJavaFxTool.plugin.PluginManager;
45
import com.xwintop.xJavaFxTool.services.index.PluginManageService;
56
import java.io.File;
67
import java.lang.reflect.Method;
78
import java.net.URL;
89
import java.net.URLClassLoader;
910
import java.util.Locale;
11+
import java.util.ResourceBundle;
1012
import lombok.extern.slf4j.Slf4j;
1113
import org.apache.commons.lang3.StringUtils;
1214

@@ -26,10 +28,13 @@ public class XJavaFxSystemUtil {
2628
public static void initSystemLocal() {
2729
try {
2830
String localeString = Config.get(Config.Keys.Locale, "");
31+
2932
if (StringUtils.isNotEmpty(localeString)) {
3033
String[] locale1 = localeString.split("_");
3134
Config.defaultLocale = new Locale(locale1[0], locale1[1]);
3235
}
36+
37+
Main.RESOURCE_BUNDLE = ResourceBundle.getBundle("locale.Menu", Config.defaultLocale);
3338
} catch (Exception e) {
3439
log.error("初始化本地语言失败", e);
3540
}

src/main/resources/banner.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,4 @@
4747
// ; iEEEL ,EEEEEL, EEEE //
4848
//////////////////////////////////////////////////////////////////////
4949
${AnsiColor.BRIGHT_BLUE}
50-
::: Project (version:0.2.1) ::: http://www.xwintop.com\(^O^)/ Spring-Boot ${spring-boot.version}
50+
::: Project (version:0.2.3) ::: http://www.xwintop.com\(^O^)/ Spring-Boot ${spring-boot.version}

0 commit comments

Comments
 (0)