mirror of
https://gitee.com/willfree/minbrowser.git
synced 2026-10-05 01:15:42 +08:00
增加支持多标签页面下的登录、设置页面跳转
git commit -m 增加支持多标签页面下的登录、设置页面跳转
This commit is contained in:
1 parent
b37928552a
commit
9473358dfb
7 files changed
+80
-52
No files matched your search
@@ -2,7 +2,7 @@
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>登录界面</title>
|
||||
<title>用户登录</title>
|
||||
<link rel="stylesheet" type="text/css" href="login.css"/>
|
||||
<script type="text/javascript" src="login.js"></script>
|
||||
</head>
|
||||
|
||||
@@ -9,8 +9,12 @@ package cn.minbrowser.util;
|
||||
*/
|
||||
public class CustomUrlUtil {
|
||||
public static final String INDEX_URL = "index";
|
||||
public static final String INDEX_SHOW_URL = "minbrowser:/index";
|
||||
public static final String Setting_URL = "setting";
|
||||
public static final String Setting_SHOW_URL = "minbrowser:/settings";
|
||||
public static final String LOGIN_URL = "login";
|
||||
public static final String LOGIN_SHOW_URL = "minbrowser:/user/login";
|
||||
public static final String REGISTER_URL = "register";
|
||||
public static final String REGISTER_SHOW_URL = "minbrowser:/user/register";
|
||||
public static final String ERROR_URL = "error";
|
||||
}
|
||||
@@ -100,33 +100,58 @@ public class NavigationBarController implements Initializable {
|
||||
}
|
||||
|
||||
/**
|
||||
* 这里应该执行一个展示主页的界面,目前先只加载一个新的tab页
|
||||
* 获取当前聚焦的tab,显示主页
|
||||
*/
|
||||
public void showHomePage(){
|
||||
tabPane.getTabs().add(new MiniTab(this));
|
||||
}
|
||||
|
||||
/**
|
||||
* 这里应该执行一个显示登录页的界面,目前先只加载一个新的tab页
|
||||
*/
|
||||
public void showUserCenter(){
|
||||
tabPane.getTabs().add(new MiniTab(this));
|
||||
}
|
||||
|
||||
/**
|
||||
* 在当前聚焦的Tab上,显示设置界面
|
||||
*/
|
||||
public void showSelectedSettingInfo(){
|
||||
public void showSelectedHomePage(){
|
||||
MiniTab miniTab=getSelectedTab();
|
||||
miniTab.showSettingInfo();
|
||||
miniTab.showLocalHomePage();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前聚焦的tab,显示登录界面
|
||||
*/
|
||||
public void showSelectedLoginPage(){
|
||||
MiniTab miniTab=getSelectedTab();
|
||||
miniTab.showLoginPage();
|
||||
}
|
||||
|
||||
/**
|
||||
* 新建一个tab,显示登录界面
|
||||
*/
|
||||
public void showNewLoginPage(){
|
||||
// 遍历tab:如果没登录界面,就打开一个新的设置界面;有,则将焦点改到该界面
|
||||
int flag=0; //0表示没界面,>0表示有
|
||||
for (Tab tab: tabPane.getTabs()) {
|
||||
MiniTab miniTab= (MiniTab) tab;
|
||||
if(miniTab.getUrlText().equals(CustomUrlUtil.LOGIN_SHOW_URL)){
|
||||
flag++;
|
||||
tabPane.getSelectionModel().select(tab);
|
||||
}
|
||||
}
|
||||
if(flag==0) {
|
||||
MiniTab miniTab = new MiniTab(CustomUrlUtil.LOGIN_URL, this);
|
||||
tabPane.getTabs().add(miniTab);
|
||||
tabPane.getSelectionModel().select(miniTab);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 新建一个tab,显示设置界面
|
||||
*/
|
||||
public void showNewSettingInfo(){
|
||||
MiniTab miniTab=new MiniTab(CustomUrlUtil.Setting_URL,this);
|
||||
tabPane.getTabs().add(miniTab);
|
||||
tabPane.getSelectionModel().select(miniTab);
|
||||
// 遍历tab:如果没设置界面,就打开一个新的设置界面;有,则将焦点改到该界面
|
||||
int flag=0; //0表示没设置界面,>0表示有
|
||||
for (Tab tab: tabPane.getTabs()) {
|
||||
MiniTab miniTab= (MiniTab) tab;
|
||||
if(miniTab.getUrlText().equals(CustomUrlUtil.Setting_SHOW_URL)){
|
||||
flag++;
|
||||
tabPane.getSelectionModel().select(tab);
|
||||
}
|
||||
}
|
||||
if(flag==0) {
|
||||
MiniTab miniTab = new MiniTab(CustomUrlUtil.Setting_URL, this);
|
||||
tabPane.getTabs().add(miniTab);
|
||||
tabPane.getSelectionModel().select(miniTab);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -41,6 +41,6 @@ public class LoginHTMLController {
|
||||
* 支持跳转到主页
|
||||
*/
|
||||
public void showHomePage(){
|
||||
navigationBarController.showHomePage();
|
||||
navigationBarController.showSelectedHomePage();
|
||||
}
|
||||
}
|
||||
@@ -41,6 +41,6 @@ public class RegisterHTMLController {
|
||||
* 支持跳转到登录页
|
||||
*/
|
||||
public void showLoginPage(){
|
||||
navigationBarController.showUserCenter();
|
||||
navigationBarController.showSelectedLoginPage();
|
||||
}
|
||||
}
|
||||
@@ -178,18 +178,25 @@ public class MiniTab extends Tab {
|
||||
return input;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前url
|
||||
*/
|
||||
public String getUrlText(){
|
||||
return input.getText().trim();
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据尚未显示在input控件上的url,进行页面加载
|
||||
* @param url
|
||||
*/
|
||||
private void analysisAddress(String url){
|
||||
if(url.equals(INDEX_URL)){
|
||||
if(url.equals(INDEX_URL) || url.equals(INDEX_SHOW_URL)){
|
||||
showLocalHomePage();
|
||||
}else if(url.equals(Setting_URL)){
|
||||
}else if(url.equals(Setting_URL) || url.equals(Setting_SHOW_URL)){
|
||||
showSettingInfo();
|
||||
}else if(url.equals(LOGIN_URL)){
|
||||
}else if(url.equals(LOGIN_URL) || url.equals(LOGIN_SHOW_URL)){
|
||||
showLoginPage();
|
||||
}else if(url.equals(REGISTER_URL)){
|
||||
}else if(url.equals(REGISTER_URL) || url.equals(REGISTER_SHOW_URL)){
|
||||
showRegisterPage();
|
||||
}else if(url.equals(ERROR_URL)){
|
||||
showErrorPage();
|
||||
@@ -203,9 +210,6 @@ 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);
|
||||
// });
|
||||
webview.getEngine().getLoadWorker().stateProperty().addListener(
|
||||
new ChangeListener<State>() {
|
||||
public void changed(ObservableValue ov, State oldState, State newState) {
|
||||
@@ -299,18 +303,26 @@ public class MiniTab extends Tab {
|
||||
|
||||
// 刷新urlText的显示,以及js和java的数据交互
|
||||
public void refreshUrlText(String url) {
|
||||
if (url.contains("resources/html/UserCenter/login.html")) {
|
||||
input.setText("minbrowser:/user/login");
|
||||
if (url.contains("resources/html/UserCenter/login.html")
|
||||
|| url.equals(LOGIN_URL)
|
||||
|| url.equals(LOGIN_SHOW_URL)) {
|
||||
input.setText(LOGIN_SHOW_URL);
|
||||
setLoginListener();
|
||||
} else if(url.contains("resources/html/UserCenter/register.html")) {
|
||||
input.setText("minbrowser:/user/register");
|
||||
} else if(url.contains("resources/html/UserCenter/register.html")
|
||||
|| url.equals(REGISTER_URL)
|
||||
|| url.equals(REGISTER_SHOW_URL)) {
|
||||
input.setText(REGISTER_SHOW_URL);
|
||||
setRegisterListener();
|
||||
} else if (url.contains("resources/html/BrowserSetting")) {
|
||||
input.setText("minbrowser:/settings");
|
||||
} else if (url.contains("resources/html/BrowserSetting")
|
||||
|| url.equals(Setting_URL)
|
||||
|| url.equals(Setting_SHOW_URL)) {
|
||||
input.setText(Setting_SHOW_URL);
|
||||
showSettingInfoByListenEngineState();
|
||||
setChangingSettingInfoListener();
|
||||
} else if(url.contains("resources/html/MainPage.html")||url.equals(INDEX_URL)){
|
||||
input.setText("minbrowser:/index");
|
||||
} else if(url.contains("resources/html/MainPage.html")
|
||||
|| url.equals(INDEX_URL)
|
||||
|| url.equals(INDEX_SHOW_URL)){
|
||||
input.setText(INDEX_SHOW_URL);
|
||||
showUsernameByListenEngineState();
|
||||
}else {
|
||||
try {
|
||||
@@ -331,7 +343,6 @@ public class MiniTab extends Tab {
|
||||
webview.getEngine().executeScript("showDownloadDir(\" " + settingHTMLController.getDownloadDir() + " \");");
|
||||
webview.getEngine().executeScript("showMisIP(\" " + settingHTMLController.getMisIP() + " \");");
|
||||
webview.getEngine().executeScript("showMisPort(\" " + settingHTMLController.getMisPort() + " \");");
|
||||
// mainWebView.getEngine().executeScript("showInfo()");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -370,7 +381,6 @@ public class MiniTab extends Tab {
|
||||
private void showUsernameByListenEngineState() {
|
||||
System.out.println("username: " + mainPageHTMLController.getUserName());
|
||||
webview.getEngine().executeScript("showUserName(\" " + mainPageHTMLController.getUserName() + " \");");
|
||||
// webview.getEngine().executeScript("showUserNameTest();");
|
||||
}
|
||||
|
||||
// 显示用户注册页
|
||||
@@ -418,7 +428,6 @@ public class MiniTab extends Tab {
|
||||
public void showLocalHomePage() {
|
||||
try {
|
||||
loadLocalPage("/resources/html" + "/MainPage.html");
|
||||
// webview.getEngine().executeScript("showUserName(\" " + mainPageHTMLController.getUserName() + " \");");
|
||||
} catch (MalformedURLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -435,15 +444,5 @@ public class MiniTab extends Tab {
|
||||
System.out.println(filepath);
|
||||
System.out.println(fileUrl.toString());
|
||||
webview.getEngine().load(fileUrl.toString());
|
||||
// try {
|
||||
// Thread.sleep(1000);
|
||||
// } catch (InterruptedException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// webview.getEngine().executeScript("function showUserName(username) {\n" +
|
||||
// " document.getElementById(\"username\").innerHTML=username;\n" +
|
||||
// " }" +
|
||||
// "showUserName('hhhh');");
|
||||
// webview.getEngine().executeScript("showUserName(\" " + mainPageHTMLController.getUserName() + " \")");
|
||||
}
|
||||
}
|
||||
@@ -19,7 +19,7 @@
|
||||
<Image url="@../../../../resources/images/user.png" />
|
||||
</image>
|
||||
</ImageView>
|
||||
<Button fx:id="userButton" layoutX="1313.0" layoutY="50.0" mnemonicParsing="false" onAction="#showUserCenter" opacity="0.0" prefHeight="40.0" prefWidth="40.0" text="U" AnchorPane.rightAnchor="60.0" AnchorPane.topAnchor="41.0" />
|
||||
<Button fx:id="userButton" layoutX="1313.0" layoutY="50.0" mnemonicParsing="false" onAction="#showNewLoginPage" opacity="0.0" prefHeight="40.0" prefWidth="40.0" text="U" AnchorPane.rightAnchor="60.0" AnchorPane.topAnchor="41.0" />
|
||||
<ImageView fx:id="settingPhoto" fitWidth="25.0" pickOnBounds="true" preserveRatio="true" AnchorPane.rightAnchor="20.0" AnchorPane.topAnchor="50.0">
|
||||
<image>
|
||||
<Image url="@../../../../resources/images/3dot.png" />
|
||||
|
||||
Reference in new issue
Block a user