mirror of
https://gitee.com/willfree/minbrowser.git
synced 2026-10-05 01:15:42 +08:00
发现了更多的BUG
This commit is contained in:
1 parent
0cce25ab78
commit
d521fe2fa2
4 files changed
+62
-29
No files matched your search
@@ -7,6 +7,10 @@
|
||||
function showUserName(username) {
|
||||
document.getElementById("username").innerHTML=username;
|
||||
}
|
||||
function showUserNameTest() {
|
||||
document.getElementById("username").innerHTML="hhhh";
|
||||
}
|
||||
showUserNameTest();
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
@@ -5,12 +5,18 @@ package cn.minbrowser.view;
|
||||
*/
|
||||
import cn.minbrowser.MainApp;
|
||||
import cn.minbrowser.protocol.MinURL.MinURLStreamHandlerFactory;
|
||||
import cn.minbrowser.util.CustomUrlUtil;
|
||||
import cn.minbrowser.view.minibrowser.MiniTab;
|
||||
import javafx.application.Platform;
|
||||
import javafx.collections.ListChangeListener;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.Initializable;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.Tab;
|
||||
import javafx.scene.control.TabPane;
|
||||
import javafx.scene.image.Image;
|
||||
import javafx.scene.image.ImageView;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.ResourceBundle;
|
||||
@@ -28,6 +34,8 @@ public class NavigationBarController implements Initializable {
|
||||
@FXML
|
||||
private ImageView settingPhoto;
|
||||
|
||||
private final Double tabHeaderWidth = 200D;
|
||||
|
||||
public NavigationBarController() {
|
||||
}
|
||||
|
||||
@@ -51,8 +59,32 @@ public class NavigationBarController implements Initializable {
|
||||
//在fxml被载入时候被自动调用
|
||||
this.userPhoto.setImage(new Image("file:resources/images/user.png"));
|
||||
this.settingPhoto.setImage(new Image("file:resources/images/3dot.png"));
|
||||
// 初始化增加标签按钮
|
||||
Button addTabBtn=new Button("++++++++++++++++++");
|
||||
addTabBtn.setVisible(true);
|
||||
// 设置tabpane中tab的最大宽度
|
||||
tabPane.setTabMaxWidth(tabHeaderWidth);
|
||||
// 加载标签
|
||||
tabPane.getTabs().add(new MiniTab(this));
|
||||
tabPane.getSelectionModel().getSelectedItem().setClosable(true);
|
||||
// 设置标签监听
|
||||
// tabPane.getTabs().addListener((ListChangeListener.Change<? extends Tab> c) -> {
|
||||
// // 如果tab全部关闭,就退出系统
|
||||
// int size = c.getList().size();
|
||||
// if (size == 0) {
|
||||
// Platform.exit();
|
||||
// }
|
||||
// // 根据tabpane的个数变换AddTabBtn的位置
|
||||
// Double width = tabPane.getScene().getWidth();
|
||||
// Double left = tabHeaderWidth * size + (size - 1) * 12D + 20D;
|
||||
// if (left - 80D > width) {
|
||||
// left = width - 80D;
|
||||
// tabPane.setTabMinWidth(5D);
|
||||
// } else if (left < width - tabHeaderWidth) {
|
||||
// tabPane.setTabMinWidth(tabHeaderWidth);
|
||||
// }
|
||||
// AnchorPane.setLeftAnchor(addTabBtn, left);
|
||||
// });
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -82,9 +114,19 @@ public class NavigationBarController implements Initializable {
|
||||
}
|
||||
|
||||
/**
|
||||
* 显示设置界面
|
||||
* 在当前聚焦的Tab上,显示设置界面
|
||||
*/
|
||||
public void showSettingInfo(){
|
||||
tabPane.getTabs().add(new MiniTab(this));
|
||||
public void showSelectedSettingInfo(){
|
||||
MiniTab miniTab=getSelectedTab();
|
||||
miniTab.showSettingInfo();
|
||||
}
|
||||
|
||||
/**
|
||||
* 新建一个tab,显示设置界面
|
||||
*/
|
||||
public void showNewSettingInfo(){
|
||||
MiniTab miniTab=new MiniTab(CustomUrlUtil.Setting_URL,this);
|
||||
tabPane.getTabs().add(miniTab);
|
||||
tabPane.getSelectionModel().select(miniTab);
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,6 @@ import cn.minbrowser.view.login.RegisterHTMLController;
|
||||
import cn.minbrowser.view.setting.SettingHTMLController;
|
||||
import javafx.application.Platform;
|
||||
import javafx.beans.value.ObservableValue;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.geometry.Insets;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.Tab;
|
||||
@@ -70,9 +69,11 @@ public class MiniTab extends Tab {
|
||||
|
||||
public MiniTab(NavigationBarController navigationBarController){
|
||||
this(HOME_URL,navigationBarController);
|
||||
// setClosable(true);
|
||||
}
|
||||
|
||||
public MiniTab(String loc, NavigationBarController navigationBarController) {
|
||||
// setClosable(true);
|
||||
// 初始化类对象
|
||||
MiniTab.navigationBarController =navigationBarController;
|
||||
webview=new WebView();
|
||||
@@ -96,8 +97,7 @@ public class MiniTab extends Tab {
|
||||
initWebViewEvent();
|
||||
|
||||
// 加载页面
|
||||
input.setText(loc);
|
||||
analysisAddress();
|
||||
analysisAddress(loc);
|
||||
|
||||
// 将三个组件添加到AnchorPane中,注意顺序
|
||||
anchorPane = new AnchorPane(addressBox, webview);
|
||||
@@ -114,17 +114,13 @@ public class MiniTab extends Tab {
|
||||
*/
|
||||
public void load(String url) {
|
||||
Platform.runLater(() -> {
|
||||
if (url.equals(INDEX_URL)) {
|
||||
// 本地加载
|
||||
showHomePage();
|
||||
} else if (MinUrlUtil.isMinUrl(url)) {
|
||||
if (MinUrlUtil.isMinUrl(url)) {
|
||||
// min协议加载
|
||||
webview.getEngine().load(url);
|
||||
} else {
|
||||
// http及其它通用网络协议的加载
|
||||
webview.getEngine().load(url);
|
||||
}
|
||||
refreshUrlText(url);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -169,7 +165,7 @@ public class MiniTab extends Tab {
|
||||
input.setPrefWidth(1100D);
|
||||
input.setOnKeyReleased((event) -> {
|
||||
if (KeyCode.ENTER.equals(event.getCode())) {//回车加载页面
|
||||
analysisAddress();
|
||||
analysisAddress(input.getText().trim());
|
||||
}
|
||||
});
|
||||
input.setOnMouseClicked((event) -> {
|
||||
@@ -180,14 +176,6 @@ public class MiniTab extends Tab {
|
||||
return input;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据手动输入的url加载相应的网页
|
||||
*/
|
||||
private void analysisAddress() {
|
||||
String text = input.getText();
|
||||
load(text);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据尚未显示在input控件上的url,进行页面加载
|
||||
* @param url
|
||||
@@ -214,7 +202,7 @@ public class MiniTab extends Tab {
|
||||
private void initWebViewEvent() {
|
||||
// 监听到新的地址的改变,修改url地址
|
||||
webview.getEngine().locationProperty().addListener((ObservableValue<? extends String> ov, final String oldLoc, final String loc) -> {
|
||||
// refreshUrlText(loc);
|
||||
refreshUrlText(loc);
|
||||
});
|
||||
// 监听到名字的改变,修改tab的名字
|
||||
webview.getEngine().titleProperty().addListener((observable, oldValue, newValue) -> {
|
||||
@@ -314,7 +302,6 @@ public class MiniTab extends Tab {
|
||||
input.setText("minbrowser:/index");
|
||||
showUsernameByListenEngineState();
|
||||
}else {
|
||||
// url=MinUrlUtil.getOriginalPurePrefixMinUrl(url);
|
||||
try {
|
||||
input.setText(URLDecoder.decode(url, "UTF-8"));
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
@@ -370,8 +357,9 @@ public class MiniTab extends Tab {
|
||||
* 执行MainPage.html中的js代码,显示配置信息
|
||||
*/
|
||||
private void showUsernameByListenEngineState() {
|
||||
System.out.println("username: "+mainPageHTMLController.getUserName());
|
||||
webview.getEngine().executeScript("showUserName(\" " + mainPageHTMLController.getUserName() + " \");");
|
||||
System.out.println("username: " + mainPageHTMLController.getUserName());
|
||||
webview.getEngine().executeScript("showUserName(\" " + mainPageHTMLController.getUserName() + " \");");
|
||||
// webview.getEngine().executeScript("showUserNameTest();");
|
||||
}
|
||||
|
||||
// 显示用户注册页
|
||||
@@ -393,7 +381,7 @@ public class MiniTab extends Tab {
|
||||
}
|
||||
|
||||
// 显示设置页
|
||||
private void showSettingInfo(){
|
||||
public void showSettingInfo(){
|
||||
try {
|
||||
loadLocalPage("/resources/html" + "/BrowserSetting/setting.html");
|
||||
} catch (MalformedURLException e) {
|
||||
@@ -403,9 +391,8 @@ public class MiniTab extends Tab {
|
||||
|
||||
/**
|
||||
* 加载报错页面
|
||||
* @throws MalformedURLException
|
||||
*/
|
||||
private void showErrorPage() {
|
||||
public void showErrorPage() {
|
||||
try {
|
||||
loadLocalPage("/resources/html" + "/InfoUtil/error.html");
|
||||
} catch (MalformedURLException e) {
|
||||
@@ -417,7 +404,7 @@ public class MiniTab extends Tab {
|
||||
* 加载本地主页
|
||||
* @throws MalformedURLException
|
||||
*/
|
||||
private void showLocalHomePage() {
|
||||
public void showLocalHomePage() {
|
||||
try {
|
||||
loadLocalPage("/resources/html" + "/MainPage.html");
|
||||
} catch (MalformedURLException e) {
|
||||
|
||||
@@ -25,6 +25,6 @@
|
||||
<Image url="@../../../../resources/images/3dot.png" />
|
||||
</image>
|
||||
</ImageView>
|
||||
<Button fx:id="settingButton" mnemonicParsing="false" onAction="#showSettingInfo" opacity="0.0" prefHeight="40.0" prefWidth="30.0" text="S" AnchorPane.rightAnchor="18.0" AnchorPane.topAnchor="41.0" />
|
||||
<Button fx:id="settingButton" mnemonicParsing="false" onAction="#showNewSettingInfo" opacity="0.0" prefHeight="40.0" prefWidth="30.0" text="S" AnchorPane.rightAnchor="18.0" AnchorPane.topAnchor="41.0" />
|
||||
</children>
|
||||
</AnchorPane>
|
||||
Reference in new issue
Block a user