2024-08-20 06:19:23 +00:00
|
|
|
|
import win.ui;
|
|
|
|
|
import init;
|
2024-08-20 12:11:13 +00:00
|
|
|
|
|
2024-08-20 06:19:23 +00:00
|
|
|
|
|
|
|
|
|
// 初始化
|
|
|
|
|
init.init();
|
|
|
|
|
var gConfig = init.loadConfigs();
|
|
|
|
|
var gDebug = init.getDebug();
|
|
|
|
|
|
2024-08-20 07:40:27 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 启动界面
|
2024-08-20 06:19:23 +00:00
|
|
|
|
/*DSG{{*/
|
2024-08-20 07:40:27 +00:00
|
|
|
|
mainForm = win.form(text="awin";right=1;bottom=1;border="thin";max=false;min=false)
|
2024-08-20 06:19:23 +00:00
|
|
|
|
mainForm.add()
|
|
|
|
|
/*}}*/
|
|
|
|
|
|
2024-08-20 07:40:27 +00:00
|
|
|
|
// 日志
|
2024-08-20 06:19:23 +00:00
|
|
|
|
var gLog = init.getLog();
|
2024-08-20 07:40:27 +00:00
|
|
|
|
gLog.print("width=" , gConfig.window.width)
|
|
|
|
|
gLog.print("height=" , gConfig.window.height)
|
2024-08-20 09:53:46 +00:00
|
|
|
|
|
|
|
|
|
// 主窗口
|
2024-08-20 07:40:27 +00:00
|
|
|
|
mainForm.resize(gConfig.window.width, gConfig.window.height);
|
2024-10-17 07:44:35 +00:00
|
|
|
|
mainForm.text = gConfig.title
|
2024-08-20 07:40:27 +00:00
|
|
|
|
|
2024-08-20 09:53:46 +00:00
|
|
|
|
// 托盘
|
2024-08-20 12:11:13 +00:00
|
|
|
|
import win.util.tray;
|
|
|
|
|
var tray = win.util.tray(mainForm,"./logo.ico") //创建托盘图标,如果不能显示图标,可能是图标问题,要复合图标
|
|
|
|
|
tray.message = 0x400+9981/*_WM_TRAYMESSAGE*/
|
|
|
|
|
tray.tip = gConfig.app //设置鼠标提示
|
2024-08-20 09:53:46 +00:00
|
|
|
|
|
2024-08-20 12:11:13 +00:00
|
|
|
|
/*
|
|
|
|
|
mainForm.onClose = function(hwnd,message,wParam,lParam){
|
|
|
|
|
tray.delete(); //关闭窗口同时删掉托盘,避免关闭窗口后要鼠标移到托盘图标才消失
|
|
|
|
|
}
|
|
|
|
|
*/
|
2024-08-20 09:53:46 +00:00
|
|
|
|
|
|
|
|
|
//下面是添加托盘右键菜单
|
|
|
|
|
import win.ui.menu;
|
|
|
|
|
mainForm.popmenu=win.ui.popmenu(mainForm);
|
|
|
|
|
mainForm.popmenu.add('打开',function(id){ //添加了一个打开主界面的菜单
|
|
|
|
|
mainForm.show();
|
|
|
|
|
})
|
|
|
|
|
mainForm.popmenu.add('退出',function(id){ //添加了一个退出程序的菜单
|
|
|
|
|
mainForm.close()
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
//下面是获取鼠标消息弹出上面的右键菜单
|
|
|
|
|
import mouse;
|
|
|
|
|
mainForm.wndproc = function(hwnd,message,wparam,lparam){
|
|
|
|
|
select(message) {//判断消息类型
|
|
|
|
|
case( 0x400+9981/*_WM_TRAYMESSAGE*/ ) { //托盘图标消息
|
2024-08-20 12:11:13 +00:00
|
|
|
|
|
2024-08-20 09:53:46 +00:00
|
|
|
|
if(lparam = 0x203/*_WM_LBUTTONDBLCLK)*/){ //鼠标双击
|
|
|
|
|
mainForm.show(true);
|
|
|
|
|
}
|
|
|
|
|
elseif(lparam =0x205/*_WM_RBUTTONUP*/){ //鼠标右键
|
|
|
|
|
x,y = mouse.getPos();
|
|
|
|
|
win.setForeground(mainForm.hwnd)
|
|
|
|
|
mainForm.popmenu.popup(x,y,true)
|
2024-08-20 12:11:13 +00:00
|
|
|
|
}
|
2024-08-20 09:53:46 +00:00
|
|
|
|
}
|
|
|
|
|
case( 0x112/*_WM_SYSCOMMAND*/ ){ //系统命令消息
|
|
|
|
|
if( wparam == 0xF020/*_SC_MINIMIZE*/ ){ //用户点击了最小化按钮
|
|
|
|
|
mainForm.show(false); //隐藏窗口
|
|
|
|
|
return true;//阻击默认消息传递,取消最小化过程
|
|
|
|
|
}
|
2024-08-20 12:57:21 +00:00
|
|
|
|
|
|
|
|
|
if( wparam == 0xF060/*_SC_MINIMIZE*/ ){ //用户点击了最小化按钮
|
|
|
|
|
mainForm.show(false); //隐藏窗口
|
|
|
|
|
return true;//阻击默认消息传递,取消最小化过程
|
|
|
|
|
}
|
2024-08-20 12:11:13 +00:00
|
|
|
|
}
|
2024-08-20 09:53:46 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-20 12:57:21 +00:00
|
|
|
|
// 后台
|
|
|
|
|
if( gConfig.backend != "" ) {
|
|
|
|
|
gLog.print("backend=" , gConfig.backend)
|
|
|
|
|
thread.invoke(function(mainForm){
|
|
|
|
|
// 线程执行的代码
|
|
|
|
|
import process.popen;
|
|
|
|
|
var prcs = process.popen(gConfig.backend);
|
|
|
|
|
prcs.logResponse();
|
|
|
|
|
|
|
|
|
|
}, mainForm);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-08-20 09:53:46 +00:00
|
|
|
|
// 前端
|
2024-08-20 06:19:23 +00:00
|
|
|
|
import web.view;
|
|
|
|
|
var theView = web.view(mainForm);
|
|
|
|
|
|
|
|
|
|
//导出为 JavaScript 中的 aardio 对象
|
|
|
|
|
theView.external = {
|
|
|
|
|
onCounterUpdate = function(name,value){
|
|
|
|
|
if(name!==null && value!==null){
|
|
|
|
|
return "aardio 返回的值:网页中 React 状态值改变了:value:"+value;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
import wsock.tcp.simpleHttpServer;
|
|
|
|
|
/*
|
|
|
|
|
如果导入 simpleHttpServer,则单个斜杠开头的路径会转换为嵌入式 HTTP 地址,
|
|
|
|
|
如果同时文件名为 index.html ,则上级目录自动设为根目录,前端应用发布根目录使用默认的 "/" 即可,不需要改动。
|
|
|
|
|
|
|
|
|
|
去掉下面的前端项目调试端口号 37151 或发布 EXE 后运行才会打开 "\web\index.html"。
|
|
|
|
|
否则打开 http://localhost:37151
|
|
|
|
|
*/
|
2024-10-17 07:37:21 +00:00
|
|
|
|
|
|
|
|
|
var url = gConfig.frontend
|
|
|
|
|
gLog.print("url=" , url)
|
2024-08-20 06:19:23 +00:00
|
|
|
|
if( gDebug ){
|
2024-10-17 07:37:21 +00:00
|
|
|
|
theView.go(url,37151);
|
2024-08-20 06:19:23 +00:00
|
|
|
|
} else {
|
2024-10-17 07:37:21 +00:00
|
|
|
|
theView.go(url);
|
2024-08-20 06:19:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mainForm.show();
|
|
|
|
|
win.loopMessage();
|
2024-10-17 07:37:21 +00:00
|
|
|
|
// tray.delete();
|