增加启动时自动打开官网
This commit is contained in:
@@ -1,24 +1,18 @@
|
|||||||
package cn.wenat;
|
package cn.wenat;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import cn.wenat.form.MainForm;
|
||||||
import java.util.Map;
|
import cn.wenat.utils.HttpClientUtils;
|
||||||
import java.util.Set;
|
import com.alibaba.fastjson.JSON;
|
||||||
import java.util.Timer;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import java.util.TimerTask;
|
import io.socket.client.IO;
|
||||||
|
import io.socket.client.IO.Options;
|
||||||
|
import io.socket.client.Socket;
|
||||||
import org.apache.http.client.methods.HttpGet;
|
import org.apache.http.client.methods.HttpGet;
|
||||||
import org.apache.http.client.methods.HttpPost;
|
import org.apache.http.client.methods.HttpPost;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
import java.util.*;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
|
||||||
|
|
||||||
import cn.wenat.form.MainForm;
|
|
||||||
import cn.wenat.utils.HttpClientUtils;
|
|
||||||
import io.socket.client.IO;
|
|
||||||
import io.socket.client.IO.Options;
|
|
||||||
import io.socket.client.Socket;
|
|
||||||
|
|
||||||
public class LocalServer {
|
public class LocalServer {
|
||||||
|
|
||||||
|
|||||||
@@ -50,10 +50,8 @@ public class MainForm extends BaseForm {
|
|||||||
private JLabel label_3;
|
private JLabel label_3;
|
||||||
|
|
||||||
private JLabel lblSpeed;
|
private JLabel lblSpeed;
|
||||||
private JLabel lblPing;
|
|
||||||
|
|
||||||
public MainForm() {
|
public MainForm() {
|
||||||
setTitle("Wezoz NAT");
|
setTitle("WeNAT-HTTP内网穿透");
|
||||||
this.setSize(546, 432);
|
this.setSize(546, 432);
|
||||||
setLocationRelativeTo(null);
|
setLocationRelativeTo(null);
|
||||||
|
|
||||||
@@ -73,7 +71,7 @@ public class MainForm extends BaseForm {
|
|||||||
try {
|
try {
|
||||||
String host = txtHost.getText();
|
String host = txtHost.getText();
|
||||||
server = new LocalServer();
|
server = new LocalServer();
|
||||||
server.setServer("http://127.0.0.1:3001");
|
server.setServer("http://wezoz.com:3001");
|
||||||
server.setForward(host);
|
server.setForward(host);
|
||||||
server.setDomain(txtDomain.getText());
|
server.setDomain(txtDomain.getText());
|
||||||
server.setCallListener(new CallListener() {
|
server.setCallListener(new CallListener() {
|
||||||
@@ -198,7 +196,7 @@ public class MainForm extends BaseForm {
|
|||||||
super.append(str);
|
super.append(str);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
txtConsole.setText("准备就绪\n");
|
txtConsole.setText("官方网站:https://www.wezoz.com\n");
|
||||||
txtConsole.setBounds(19, 181, 437, 129);
|
txtConsole.setBounds(19, 181, 437, 129);
|
||||||
panelConsole = new JScrollPane(txtConsole, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
|
panelConsole = new JScrollPane(txtConsole, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
|
||||||
panelConsole.setLocation(20, 210);
|
panelConsole.setLocation(20, 210);
|
||||||
@@ -214,6 +212,30 @@ public class MainForm extends BaseForm {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
change();
|
change();
|
||||||
|
//打开网站
|
||||||
|
openBrowser();
|
||||||
|
}
|
||||||
|
|
||||||
|
private JLabel lblPing;
|
||||||
|
|
||||||
|
private void openBrowser(){
|
||||||
|
if(java.awt.Desktop.isDesktopSupported()){
|
||||||
|
try{
|
||||||
|
//创建一个URI实例,注意不是URL
|
||||||
|
java.net.URI uri=java.net.URI.create("https://www.wezoz.com");
|
||||||
|
//获取当前系统桌面扩展
|
||||||
|
java.awt.Desktop dp=java.awt.Desktop.getDesktop();
|
||||||
|
//判断系统桌面是否支持要执行的功能
|
||||||
|
if(dp.isSupported(java.awt.Desktop.Action.BROWSE)){
|
||||||
|
//获取系统默认浏览器打开链接
|
||||||
|
dp.browse(uri);
|
||||||
|
}
|
||||||
|
}catch(java.lang.NullPointerException e){
|
||||||
|
//此为uri为空时抛出异常
|
||||||
|
}catch(java.io.IOException e){
|
||||||
|
//此为无法获取系统默认浏览器
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String formatNumber(long traffic) {
|
private String formatNumber(long traffic) {
|
||||||
|
|||||||
Reference in New Issue
Block a user