mirror of
https://gitee.com/willfree/minbrowser.git
synced 2026-10-05 01:15:42 +08:00
修改min协议请求逻辑,使得点击一次越权文件夹时触发的越权访问为一次[将所有重定向的逻辑都放在URL类中去处理]
This commit is contained in:
1 parent
d89fcc1c18
commit
22adbeabb6
10 files changed
+201
-115
No files matched your search
@@ -15,3 +15,5 @@
|
||||
文件名:/MIN/Nginx/test2/%E5%8C%97%E4%BA%AC%E5%A4%A7%E5%AD%A6/%E4%BF%A1%E6%81%AF%E5%B7%A5%E7%A8%8B%E5%AD%A6%E9%99%A2/%E8%AE%A1%E7%AE%97%E6%9C%BA%E5%BA%94%E7%94%A8%E6%8A%80%E6%9C%AF/A218/%E6%9D%8E%E6%9B%B4%E6%96%B0_%E5%91%A8%E6%8A%A58-21.pdf 文件操作:下载 文件耗时:334ms
|
||||
文件名:/MIN/Nginx/test2/%E5%8C%97%E4%BA%AC%E5%A4%A7%E5%AD%A6/%E4%BF%A1%E6%81%AF%E5%B7%A5%E7%A8%8B%E5%AD%A6%E9%99%A2/%E8%AE%A1%E7%AE%97%E6%9C%BA%E5%BA%94%E7%94%A8%E6%8A%80%E6%9C%AF/A218/%E5%86%AF%E6%96%87%E7%BF%B0-8%E6%9C%8821%E6%97%A5%E5%91%A8%E6%8A%A5.pdf 文件操作:下载 文件耗时:701ms
|
||||
文件名:/MIN/Nginx/test2/%E5%8C%97%E4%BA%AC%E5%A4%A7%E5%AD%A6/%E4%BF%A1%E6%81%AF%E5%B7%A5%E7%A8%8B%E5%AD%A6%E9%99%A2/%E8%AE%A1%E7%AE%97%E6%9C%BA%E5%BA%94%E7%94%A8%E6%8A%80%E6%9C%AF/A218/%E6%9D%A8%E6%9F%B3%E5%91%A8%E6%8A%A5-20200824.pptx 文件操作:下载 文件耗时:3280ms
|
||||
文件名:/MIN/Nginx/test2/%E5%8C%97%E4%BA%AC%E5%A4%A7%E5%AD%A6/%E4%BF%A1%E6%81%AF%E5%B7%A5%E7%A8%8B%E5%AD%A6%E9%99%A2/%E8%AE%A1%E7%AE%97%E6%9C%BA%E5%BA%94%E7%94%A8%E6%8A%80%E6%9C%AF/A218/%E8%B0%A2%E9%91%AB-20200822.pptx 文件操作:下载 文件耗时:469ms
|
||||
文件名:/MIN/Nginx/test2/%E5%8C%97%E4%BA%AC%E5%A4%A7%E5%AD%A6/%E4%BF%A1%E6%81%AF%E5%B7%A5%E7%A8%8B%E5%AD%A6%E9%99%A2/%E8%AE%A1%E7%AE%97%E6%9C%BA%E5%BA%94%E7%94%A8%E6%8A%80%E6%9C%AF/A218/%E5%B7%A5%E4%BD%9C%E8%BF%9B%E5%B1%95--%E5%B0%B9%E6%96%8C-20200821(1).docx 文件操作:下载 文件耗时:415ms
|
||||
Binary file not shown.
@@ -1,25 +0,0 @@
|
||||
MIIEowIBAAKCAQEAjlnSxaNbGiI65dF1VfbUzgBxdUA1anoPqpmkXKx4uKqUhtJR
|
||||
+nqX0SEr8nMioHMD+/umJS0SExtVdATmNkK4A9lfX9k+wdAg2E+dOFpJDinr16eb
|
||||
V8KV5C6Shosqp2M02W7fA71dkxfUrNPAkl4iXOcvuwTWzTg2K0RMaiwVrvvyNa3W
|
||||
TL+Ka8ZpQGsvDkoxeHfLuAmqcNfwUbMJgeRh9LWbbmDEIONiHwdd8QUDDAn8lpfb
|
||||
VbGriBDrOjJo0h91wlaTHof/vA0EwLYQYKvMfwecnD5FFGXNer8TDjvVOUwOm1de
|
||||
Teaag3u/hvUvFUmtb+8qu+uqsDdgstdXadgQqwIDAQABAoIBAAk2NNaHULDrQCZ5
|
||||
HH+4nmLKUo1E33AJgBQJJ0K8An/owf3LhHSSFFr7K43f94CskLhwu3qyZPYJkckV
|
||||
PBSM0r2lBm/8bfw6zLVSyZjI9utMuS9WcE4IkIyYmvDL9rGoUNY1P4dNbM3FAAVD
|
||||
GrYeE1kxuLwAfyn+ljrMi6lfOvP8zhTeaFAVJzcS9BlMYBCO/feShZClNRxN3r+Y
|
||||
8TVr6+4HmVxCInFYKZP6GTL5ZMNn2Jrbxjl/mAIMzaFfSCXqyNFJWKKmUjBhgOC3
|
||||
2CAIApdOlV7wwWHaqjCeU2YO5i2ntFWvXOFoVyqucdpRlh3Pzrwq2bRXjhqXaxTe
|
||||
gwnX1/ECgYEA/9AxoVbR7/K3vEkOal9xk0Z3SZeQrGM9LhZzjw19d/oKvQkEGypU
|
||||
y0MEHgzTIgjjCTJZDokwCmn0R+PfZZyeeHn+KOwJc4k7eNcy9YQ07TEYQKMrYHFG
|
||||
5gyRoZbC9dNaJcqoxojJEtwcCBNYzxjuqFs0VLCcBmtSW3WyVb3NsXkCgYEAjnRs
|
||||
/AI2zk+jVu8A7x9MmqkCMK/ZSUuJyyMPn0EV4q2cuGAzgqn64qrGomZNTLZVXo3Q
|
||||
B1WpjyaibAiz3SsQq20JSJNCUKNanZXOJU+/7zidxIz0sSvHrTklxq0d85YfLrEw
|
||||
0oRkiul+tgRlPLWsx2QxVi74VGZdWAopihI+DkMCgYEAq1ZPl4dmD3ebFpI8BIUu
|
||||
tfzRcsoATWYemRrShXL8oXoo7Rn31RYSOx4EyPfABiC7p/I/8dtzANaclfYLL6yp
|
||||
+3mCAPivD+JPog1JBWZqaJ+kZc6kA/F7EiRC+l7W7/2CeKN3TZpaSraAU+xZZESH
|
||||
vN1xfHPZ3PbO75EyQ/lfpskCgYA8VzSSyp1MZo9Zk4NhxnA8UrqKxPHVChoj4YYM
|
||||
fxU2HzPzJUysXDPZL11UDOFRTSp8ErW7ZZ2c9VB3UnhdhpBZDKaSB05fudH4Tiwz
|
||||
wcQbIHAzgUFkipbZ2QsXTN0TANPUg1ma0lmEPcNedh4ryQiWrOn5B4xIs9N2J1fR
|
||||
FEkU4QKBgDtQw8cJRXRxV1jD++c1nLbJm69eAPbhfzAF8YM+IkbwZ8AzIrWXrIsO
|
||||
GwR9E3G+RSU2kXAR+rEbn5Lz2YHO6+LEVh2a93+xTjjC45Q0MDeDMnxqAmVP/MZm
|
||||
fU7RWbez+Ar4x6pMki4DSl0neXuowzyAQ/wP6jxjqHNb/kYbjsow
|
||||
@@ -29,8 +29,12 @@ public class MainApp extends Application {
|
||||
return primaryStage;
|
||||
}
|
||||
|
||||
// 控制器
|
||||
NavigationBarController navigationBarController;
|
||||
// 导航栏界面控制器
|
||||
private NavigationBarController navigationBarController;
|
||||
|
||||
public NavigationBarController getNavigationBarController(){
|
||||
return navigationBarController;
|
||||
}
|
||||
|
||||
public MainApp(){
|
||||
// 初始化配置文件
|
||||
|
||||
@@ -153,57 +153,57 @@ public class MinDataAPI {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 渲染较大HTML、JS等网页文件时,需要借助基于PCON的文件传输接口
|
||||
* @param filePrefix 要渲染的网页文件(HTML、JS、CSS)
|
||||
* @return
|
||||
*/
|
||||
public static byte[] getWebRenderContent(String filePrefix) {
|
||||
// 获取文件信息:type
|
||||
byte[] fileInfoByte = getWebServerResponse(filePrefix);
|
||||
System.out.println("fileInfoByte"+new String(fileInfoByte));
|
||||
Integer type;
|
||||
try {
|
||||
type = JsonPraseUtil.getIntegerFormJson(fileInfoByte, "type");
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
// 第一种type: type=3,直接获取文件数据
|
||||
if (type == 3) {
|
||||
System.out.println("type=3-filePrefix: "+filePrefix);
|
||||
String indexData;
|
||||
try {
|
||||
indexData = JsonPraseUtil.getStringFormJson(fileInfoByte, "index");
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
return indexData.getBytes(StandardCharsets.UTF_8);
|
||||
} else if (type == 1) {
|
||||
// 获取其它文件信息
|
||||
String fileRelativePath;
|
||||
Long fileLen;
|
||||
Integer sliceSize;
|
||||
try {
|
||||
fileRelativePath = JsonPraseUtil.getStringFormJson(fileInfoByte, "requestName");
|
||||
fileLen = JsonPraseUtil.getLongFormJson(fileInfoByte, "size");
|
||||
sliceSize = JsonPraseUtil.getIntegerFormJson(fileInfoByte, "chunkSize");
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
// 文件传输开始
|
||||
DownLoadWebClientBasedFacePool downLoadWebClientBasedFacePool = new DownLoadWebClientBasedFacePool(
|
||||
OrderIPrefixUtil.getValidFilePrefix(globelPrefix, fileRelativePath),
|
||||
fileLen, sliceSize,
|
||||
facepoolnumber,
|
||||
minServerIpString, minServerPortInteger
|
||||
);
|
||||
downLoadWebClientBasedFacePool.downloadData();
|
||||
return downLoadWebClientBasedFacePool.getData();
|
||||
}else{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
// /**
|
||||
// * 渲染较大HTML、JS等网页文件时,需要借助基于PCON的文件传输接口
|
||||
// * @param filePrefix 要渲染的网页文件(HTML、JS、CSS)
|
||||
// * @return
|
||||
// */
|
||||
// public static byte[] getWebRenderContent(String filePrefix) {
|
||||
// // 获取文件信息:type
|
||||
// byte[] fileInfoByte = getWebServerResponse(filePrefix);
|
||||
// System.out.println("fileInfoByte"+new String(fileInfoByte));
|
||||
// Integer type;
|
||||
// try {
|
||||
// type = JsonPraseUtil.getIntegerFormJson(fileInfoByte, "type");
|
||||
// } catch (JSONException e) {
|
||||
// e.printStackTrace();
|
||||
// return null;
|
||||
// }
|
||||
// // 第一种type: type=3,直接获取文件数据
|
||||
// if (type == 3) {
|
||||
// System.out.println("type=3-filePrefix: "+filePrefix);
|
||||
// String indexData;
|
||||
// try {
|
||||
// indexData = JsonPraseUtil.getStringFormJson(fileInfoByte, "index");
|
||||
// } catch (JSONException e) {
|
||||
// e.printStackTrace();
|
||||
// return null;
|
||||
// }
|
||||
// return indexData.getBytes(StandardCharsets.UTF_8);
|
||||
// } else if (type == 1) {
|
||||
// // 获取其它文件信息
|
||||
// String fileRelativePath;
|
||||
// Long fileLen;
|
||||
// Integer sliceSize;
|
||||
// try {
|
||||
// fileRelativePath = JsonPraseUtil.getStringFormJson(fileInfoByte, "requestName");
|
||||
// fileLen = JsonPraseUtil.getLongFormJson(fileInfoByte, "size");
|
||||
// sliceSize = JsonPraseUtil.getIntegerFormJson(fileInfoByte, "chunkSize");
|
||||
// } catch (JSONException e) {
|
||||
// e.printStackTrace();
|
||||
// return null;
|
||||
// }
|
||||
// // 文件传输开始
|
||||
// DownLoadWebClientBasedFacePool downLoadWebClientBasedFacePool = new DownLoadWebClientBasedFacePool(
|
||||
// OrderIPrefixUtil.getValidFilePrefix(globelPrefix, fileRelativePath),
|
||||
// fileLen, sliceSize,
|
||||
// facepoolnumber,
|
||||
// minServerIpString, minServerPortInteger
|
||||
// );
|
||||
// downLoadWebClientBasedFacePool.downloadData();
|
||||
// return downLoadWebClientBasedFacePool.getData();
|
||||
// }else{
|
||||
// return null;
|
||||
// }
|
||||
// }
|
||||
}
|
||||
@@ -14,7 +14,9 @@ import java.net.URLConnection;
|
||||
|
||||
/**
|
||||
* Register a protocol handler for URLs like this: <code>myapp:///pics/sland.gif</code><br>
|
||||
* 说明:这里引入MainApp的原因,是为了做有进度条显示的文件下载。
|
||||
* 说明:这里引入MainApp的原因,是为了做有进度条显示的文件下载;
|
||||
* 以及利用mainApp.NavigationBarController.Webview.Engine,
|
||||
* 做url的重定向。
|
||||
*/
|
||||
public class MinURLConnection extends URLConnection {
|
||||
|
||||
@@ -26,7 +28,7 @@ public class MinURLConnection extends URLConnection {
|
||||
* 构造到指定URL的URL连接。不会创建到URL引用的对象的连接
|
||||
* @param url the specified URL.
|
||||
*/
|
||||
protected MinURLConnection(MainApp mainApp,URL url) throws MalformedURLException {
|
||||
protected MinURLConnection(MainApp mainApp,URL url){
|
||||
super(url);
|
||||
this.mainApp=mainApp;
|
||||
minWebRender=new MinWebRender(this.mainApp);
|
||||
@@ -37,7 +39,7 @@ public class MinURLConnection extends URLConnection {
|
||||
* 构造到指定URL的URL连接。不会创建到URL引用的对象的连接
|
||||
* @param url the specified URL.
|
||||
*/
|
||||
protected MinURLConnection(URL url) throws MalformedURLException {
|
||||
protected MinURLConnection(URL url){
|
||||
super(url);
|
||||
System.out.println("MIN URL: " + url);
|
||||
}
|
||||
@@ -106,10 +108,17 @@ public class MinURLConnection extends URLConnection {
|
||||
}
|
||||
System.out.println("min prefix: "+minPrefix);
|
||||
// 交由MinWebRender处理该min标识:从web服务器上面拉取数据
|
||||
byte[] responseData= minWebRender.handleMinPrefix(minPrefix);
|
||||
// 将拉取到的数据投喂给浏览器进行渲染
|
||||
System.out.println(new String(responseData));
|
||||
data=responseData;
|
||||
MinWebRender.WebRenderResponse webRenderResponse = minWebRender.handleMinPrefix(minPrefix);
|
||||
// 根据MinWebRender的返回内容,进行不同的操作
|
||||
if(webRenderResponse.isRedirect){
|
||||
// 重定向
|
||||
data=webRenderResponse.urlData;
|
||||
mainApp.getNavigationBarController().loadUrl(MinUrlUtil.MinUrlHead
|
||||
+webRenderResponse.newMinPrefix.substring(1));
|
||||
}else{
|
||||
// 直接渲染
|
||||
data=webRenderResponse.urlData;
|
||||
}
|
||||
}
|
||||
|
||||
// 去掉协议头/获得MIN协议前缀部分
|
||||
|
||||
@@ -9,7 +9,9 @@ import java.net.URLConnection;
|
||||
import java.net.URLStreamHandler;
|
||||
|
||||
/**
|
||||
* 说明:这里引入MainApp的原因,是为了做有进度条显示的文件下载。
|
||||
* 说明:这里引入MainApp的原因,是为了做有进度条显示的文件下载;
|
||||
* 以及利用mainApp.NavigationBarController.Webview.Engine,
|
||||
* 做url的重定向。
|
||||
*/
|
||||
public class MinURLStreamHandler extends URLStreamHandler
|
||||
{
|
||||
@@ -30,7 +32,7 @@ public class MinURLStreamHandler extends URLStreamHandler
|
||||
|
||||
// this.mainWebView.getEngine().load();
|
||||
// 重定向
|
||||
return new MinURLConnection(mainApp,MinUrlUtil.filterMinUrl(url));
|
||||
return new MinURLConnection(mainApp,url);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -6,7 +6,9 @@ import java.net.URLStreamHandler;
|
||||
import java.net.URLStreamHandlerFactory;
|
||||
|
||||
/**
|
||||
* 说明:这里引入MainApp的原因,是为了做有进度条显示的文件下载。
|
||||
* 说明:这里引入MainApp的原因,是为了做有进度条显示的文件下载;
|
||||
* 以及利用mainApp.NavigationBarController.Webview.Engine,
|
||||
* 做url的重定向。
|
||||
*/
|
||||
public class MinURLStreamHandlerFactory implements URLStreamHandlerFactory
|
||||
{
|
||||
|
||||
@@ -5,13 +5,21 @@ package cn.minbrowser.protocol;
|
||||
*/
|
||||
|
||||
import cn.minbrowser.MainApp;
|
||||
import cn.minbrowser.MiniMinData.FileTransfer.DownLoadWebClientBasedFacePool;
|
||||
import cn.minbrowser.MiniMinData.MinDataAPI;
|
||||
import cn.minbrowser.MiniMinData.util.JsonPraseUtil;
|
||||
import cn.minbrowser.MiniMinData.util.OrderIPrefixUtil;
|
||||
import cn.minbrowser.protocol.util.PrefixTypeUtil;
|
||||
import org.json.JSONException;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 负责处理一个MIN前缀地址
|
||||
* 说明:这里引入MainApp的原因,是为了做有进度条显示的文件下载;
|
||||
* 以及利用mainApp.NavigationBarController.Webview.Engine,
|
||||
* 做url的重定向。
|
||||
*/
|
||||
public class MinWebRender {
|
||||
private MainApp mainApp;
|
||||
@@ -24,9 +32,10 @@ public class MinWebRender {
|
||||
* @param minPrefix MIN前缀
|
||||
* @return 返回该MIN前缀代表的数据
|
||||
*/
|
||||
public byte[] handleMinPrefix(String minPrefix){
|
||||
public WebRenderResponse handleMinPrefix(String minPrefix){
|
||||
PrefixTypeUtil.PrefixType prefixType=PrefixTypeUtil.recognizePrefixType(minPrefix);
|
||||
System.out.println("PrefixTypeUtil.PrefixType("+minPrefix+"): "+prefixType.toString());
|
||||
WebRenderResponse webRenderResponse=new WebRenderResponse(minPrefix);
|
||||
switch (prefixType){
|
||||
case INDEX_HTML:
|
||||
// return MinDataAPI.getWebServerResponse(minPrefix);
|
||||
@@ -49,7 +58,9 @@ public class MinWebRender {
|
||||
});
|
||||
thread.start();
|
||||
// mainApp.downloadFileWithShowingProgressBar(minPrefix,MinDataAPI.downloadDirectory);
|
||||
return "download success".getBytes(StandardCharsets.UTF_8);
|
||||
webRenderResponse.urlType=100;
|
||||
webRenderResponse.urlData="download success".getBytes(StandardCharsets.UTF_8);
|
||||
return webRenderResponse;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,9 +71,96 @@ public class MinWebRender {
|
||||
/**
|
||||
* 处理诸如HTML、JS、CSS等可以被浏览器解析并渲染的文件所对应的MIN前缀标识
|
||||
* @param webPrefix 对应web文件的MIN前缀
|
||||
* @return 文件数据
|
||||
* @return 文件数据、文件类型、重定向到的地址(如果需要重定向的话)
|
||||
*/
|
||||
private byte[] handleWebRenderPrefix(String webPrefix){
|
||||
return MinDataAPI.getWebRenderContent(webPrefix);
|
||||
private WebRenderResponse handleWebRenderPrefix(String webPrefix){
|
||||
WebRenderResponse webRenderResponse=new WebRenderResponse(webPrefix);
|
||||
// 请求该前缀的具体信息
|
||||
byte[] fileInfoByte = MinDataAPI.getWebServerResponse(webPrefix);
|
||||
System.out.println("fileInfoByte: "+new String(fileInfoByte));
|
||||
// 解析Type
|
||||
Integer type;
|
||||
try {
|
||||
type = JsonPraseUtil.getIntegerFormJson(fileInfoByte, "type");
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
webRenderResponse.urlType=type;
|
||||
// 根据Type的不同,做相对应的处理
|
||||
if (type == 1) {
|
||||
// type=1: 文件 => 分块请求其数据,拼接后返回
|
||||
String fileRelativePath;
|
||||
Long fileLen;
|
||||
Integer sliceSize;
|
||||
try {
|
||||
fileRelativePath = JsonPraseUtil.getStringFormJson(fileInfoByte, "requestName");
|
||||
fileLen = JsonPraseUtil.getLongFormJson(fileInfoByte, "size");
|
||||
sliceSize = JsonPraseUtil.getIntegerFormJson(fileInfoByte, "chunkSize");
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
// 文件传输开始
|
||||
DownLoadWebClientBasedFacePool downLoadWebClientBasedFacePool = new DownLoadWebClientBasedFacePool(
|
||||
OrderIPrefixUtil.getValidFilePrefix(MinDataAPI.globelPrefix, fileRelativePath),
|
||||
fileLen, sliceSize,
|
||||
MinDataAPI.facepoolnumber,
|
||||
MinDataAPI.minServerIpString, MinDataAPI.minServerPortInteger
|
||||
);
|
||||
downLoadWebClientBasedFacePool.downloadData();
|
||||
webRenderResponse.urlData=downLoadWebClientBasedFacePool.getData();
|
||||
return webRenderResponse;
|
||||
} else if(type==2){
|
||||
webRenderResponse.isRedirect=true;
|
||||
// type=2: 需要重定向的文件 => 先解析其要重定向到的url,
|
||||
// 然后递归调用本方法,获取重定向到的url的data
|
||||
String indexData;
|
||||
try {
|
||||
indexData = JsonPraseUtil.getStringFormJson(fileInfoByte, "index");
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
if(webPrefix.endsWith("/")){
|
||||
webRenderResponse.newMinPrefix=webPrefix+indexData;
|
||||
}else{
|
||||
webRenderResponse.newMinPrefix=webPrefix+"/"+indexData;
|
||||
}
|
||||
webRenderResponse.urlData="redirecting...".getBytes(StandardCharsets.UTF_8);
|
||||
// webRenderResponse.urlData= Objects.requireNonNull(handleWebRenderPrefix(webRenderResponse.newMinPrefix)).urlData;
|
||||
return webRenderResponse;
|
||||
}else if (type == 3) {
|
||||
// type=3: 字符串 => 解析本次的应答数据之后,直接返回
|
||||
String indexData;
|
||||
try {
|
||||
indexData = JsonPraseUtil.getStringFormJson(fileInfoByte, "index");
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
webRenderResponse.urlType=type;
|
||||
webRenderResponse.urlData=indexData.getBytes(StandardCharsets.UTF_8);
|
||||
return webRenderResponse;
|
||||
}else{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public class WebRenderResponse {
|
||||
// 该minurl中的前缀
|
||||
public String minPrefix;
|
||||
|
||||
public WebRenderResponse(String minPrefix){
|
||||
this.minPrefix=minPrefix;
|
||||
}
|
||||
// 该minPrefix的type
|
||||
public Integer urlType;
|
||||
// 该minPrefix(或其重定向到的minPrefix)所含有的data
|
||||
public byte[] urlData;
|
||||
// 该minPrefix是否需要重定向
|
||||
public boolean isRedirect=false;
|
||||
// 重定向到的minPrefix
|
||||
public String newMinPrefix;
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,7 @@ import cn.minbrowser.util.SettingPropertyUtil;
|
||||
import cn.minbrowser.view.login.LoginHTMLController;
|
||||
import cn.minbrowser.view.login.RegisterHTMLController;
|
||||
import cn.minbrowser.view.setting.SettingHTMLController;
|
||||
import javafx.application.Platform;
|
||||
import javafx.beans.value.ChangeListener;
|
||||
import javafx.beans.value.ObservableValue;
|
||||
import javafx.fxml.FXML;
|
||||
@@ -141,19 +142,19 @@ public class NavigationBarController implements Initializable {
|
||||
*
|
||||
* @param url url
|
||||
*/
|
||||
private void loadUrl(String url) {
|
||||
if (url.equals("index")) {
|
||||
// 本地加载
|
||||
showHomePage();
|
||||
} else if (MinUrlUtil.isMinUrl(url)) {
|
||||
// 进行重定向的预处理
|
||||
url = MinUrlUtil.redirectUrl(url);
|
||||
// min协议加载
|
||||
mainWebView.getEngine().load(url);
|
||||
} else {
|
||||
// http及其它通用网络协议的加载
|
||||
mainWebView.getEngine().load(url);
|
||||
}
|
||||
public void loadUrl(String url) {
|
||||
Platform.runLater(() -> {
|
||||
if (url.equals("index")) {
|
||||
// 本地加载
|
||||
showHomePage();
|
||||
} else if (MinUrlUtil.isMinUrl(url)) {
|
||||
// min协议加载
|
||||
mainWebView.getEngine().load(url);
|
||||
} else {
|
||||
// http及其它通用网络协议的加载
|
||||
mainWebView.getEngine().load(url);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -189,13 +190,6 @@ public class NavigationBarController implements Initializable {
|
||||
new ChangeListener<State>() {
|
||||
public void changed(ObservableValue ov, State oldState, State newState) {
|
||||
if (newState == State.SUCCEEDED) {
|
||||
String currentLoc = mainWebView.getEngine().getLocation();
|
||||
// 如果是一个纯前缀URL,且type!=2,则重新load
|
||||
if (MinUrlUtil.isPurePrefixMinUrl(currentLoc)
|
||||
&&(MinUrlUtil.getUrlType(currentLoc)==2)
|
||||
) {
|
||||
mainWebView.getEngine().load(MinUrlUtil.redirectUrl(currentLoc));
|
||||
}
|
||||
// 将新url回显到文本输入框
|
||||
showUrlText(mainWebView.getEngine().getLocation());
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user