Skip to content
This repository has been archived by the owner on Jul 30, 2024. It is now read-only.

Commit

Permalink
兼容windows xp
Browse files Browse the repository at this point in the history
  • Loading branch information
monkeyWie committed Nov 2, 2018
1 parent 6d9bb37 commit 0e633f5
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
15 changes: 9 additions & 6 deletions main/src/main/java/org/pdown/gui/DownApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public class DownApplication extends Application {

private static final String OS = OsUtil.isWindows() ? "windows"
: (OsUtil.isMac() ? "mac" : "linux");
private static final String ICON_NAME = OS + "/logo.png";
private static final String ICON_PATH = OS + (OsUtil.isWindowsXP() ? "/logo_xp.png" : "/logo.png");

public static DownApplication INSTANCE;

Expand Down Expand Up @@ -91,8 +91,11 @@ public void start(Stage primaryStage) throws Exception {
initEmbedHttpServer();
initExtension();
initTray();
initWindow();
initBrowser();
//xp不支持webview
if (!OsUtil.isWindowsXP()) {
initWindow();
initBrowser();
}
loadUri(null, true, true);
}

Expand Down Expand Up @@ -217,7 +220,7 @@ private void initTray() throws AWTException {
// 获得系统托盘对象
SystemTray systemTray = SystemTray.getSystemTray();
// 获取图片所在的URL
URL url = Thread.currentThread().getContextClassLoader().getResource(ICON_NAME);
URL url = Thread.currentThread().getContextClassLoader().getResource(ICON_PATH);
// 为系统托盘加托盘图标
Image trayImage = Toolkit.getDefaultToolkit().getImage(url);
Dimension trayIconSize = systemTray.getTrayIconSize();
Expand Down Expand Up @@ -280,7 +283,7 @@ private void initWindow() {
stage.setY((bounds.getHeight() - height) / 2);
stage.setMinWidth(width);
stage.setMinHeight(height);
stage.getIcons().add(new javafx.scene.image.Image(Thread.currentThread().getContextClassLoader().getResourceAsStream(ICON_NAME)));
stage.getIcons().add(new javafx.scene.image.Image(Thread.currentThread().getContextClassLoader().getResourceAsStream(ICON_PATH)));
stage.setResizable(true);
//关闭窗口监听
stage.setOnCloseRequest(event -> {
Expand Down Expand Up @@ -319,7 +322,7 @@ public void show(boolean isTray) {
public void loadUri(String uri, boolean isTray, boolean isStartup) {
String url = "http://127.0.0.1:" + FRONT_PORT + (uri == null ? "" : uri);
boolean autoOpen = PDownConfigContent.getInstance().get().isAutoOpen();
if (PDownConfigContent.getInstance().get().getUiMode() == 0) {
if (OsUtil.isWindowsXP() || PDownConfigContent.getInstance().get().getUiMode() == 0) {
if (!isStartup || autoOpen) {
try {
Desktop.getDesktop().browse(URI.create(url));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ public FullHttpResponse checkCert(Channel channel, FullHttpRequest request) thro
public FullHttpResponse installCert(Channel channel, FullHttpRequest request) throws Exception {
Map<String, Object> data = new HashMap<>();
boolean status;
if (OsUtil.isUnix()) {
if (OsUtil.isUnix() || OsUtil.isWindowsXP()) {
if (!AppUtil.checkIsInstalledCert()) {
ExtensionCertUtil.buildCert(AppUtil.SSL_PATH, AppUtil.SUBJECT);
}
Expand Down
2 changes: 1 addition & 1 deletion main/src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: 3.3
version: 3.31
spring:
profiles:
active: @environment@
Expand Down
Binary file added main/src/main/resources/windows/logo_xp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 0e633f5

Please sign in to comment.