2024-08-20 06:19:23 +00:00
|
|
|
|
import win.ui;
|
|
|
|
|
import init;
|
2024-08-20 09:53:46 +00:00
|
|
|
|
import win.util.tray;
|
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-08-20 09:53:46 +00:00
|
|
|
|
// 托盘
|
|
|
|
|
//var trayIcon = win.util.tray(mainForm, gConfig.icon, "双击打开主界面");
|
|
|
|
|
//trayIcon.orphanWindow(true);
|
|
|
|
|
//trayIcon.show();
|
|
|
|
|
var icon = {
|
|
|
|
|
'\0\0\1\0\1\0\16\16\2\0\1\0\1\0\xb0\0\0\0\22\0\0\0\40\0\0\0\16\0\0\0 \0\0\0\1\0\1\0\0\0\0\0\x80\0\0\0\0\0\0\0\0\0\0\0\2\0\0\0\0\0\0\0\0\0\0\0\xff\xff\xff\0\0\0\0\0\0\0\0\0\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0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\31\xf8\xff\xff\xe7\xe7\xff\xff\xfb\xdf\xff\xff\xfd\xbf\xff\xff}\xbe\xff\xff\xbe}\xff\xff\xfe\x7f\xff\xff\xfe\x7f\xff\xff\xfe\x7f\xff\xff\xces\xff\xff\xces\xff\xff\xfd\xbf\xff\xff\xfd\xbf\xff\xff\xfb\xdf\xff\xff\xe7\xe7\xff\xff\31\xf8\xff\xff';
|
|
|
|
|
'\0\0\1\0\1\0\16\16\2\0\1\0\1\0\xb0\0\0\0\22\0\0\0\40\0\0\0\16\0\0\0 \0\0\0\1\0\1\0\0\0\0\0\x80\0\0\0\0\0\0\0\0\0\0\0\2\0\0\0\0\0\0\0\0\0\0\0\xff\xff\xff\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x81\xff\xff\xff\x7e\x7e\xff\xff\xff\xbd\xff\xff\xff\xdb\xff\xff\xe7\xdb\xff\xff\xdb\xe7\xff\xff\xff\xe7\xff\xff\xff\xe7\xff\xff\xff\xe7\xff\xff<\xe7\xff\xff<\xe7\xff\xff\xff\xdb\xff\xff\xff\xdb\xff\xff\xff\xbd\xff\xff\x7e\x7e\xff\xff\x81\xff\xff\xff';
|
|
|
|
|
}
|
|
|
|
|
var currectIcon = 1;
|
|
|
|
|
var tray = win.util.tray(mainForm, icon[currectIcon], mainForm.text);
|
|
|
|
|
|
|
|
|
|
var tmId = mainForm.setInterval(
|
|
|
|
|
120,
|
|
|
|
|
function(id) {
|
|
|
|
|
currectIcon = currectIcon == 4 ? 1 : currectIcon + 1;
|
|
|
|
|
tray.icon = icon[currectIcon];
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
//下面是添加托盘右键菜单
|
|
|
|
|
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*/ ) { //托盘图标消息
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
case( 0x112/*_WM_SYSCOMMAND*/ ){ //系统命令消息
|
|
|
|
|
if( wparam == 0xF020/*_SC_MINIMIZE*/ ){ //用户点击了最小化按钮
|
|
|
|
|
mainForm.show(false); //隐藏窗口
|
|
|
|
|
return true;//阻击默认消息传递,取消最小化过程
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mainForm.onClose = function(hwnd,message,wParam,lParam){
|
|
|
|
|
tray.delete(); //关闭窗口同时删掉托盘,避免关闭窗口后要鼠标移到托盘图标才消失
|
|
|
|
|
}
|
|
|
|
|
// 前端
|
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
|
|
|
|
|
*/
|
|
|
|
|
if( gDebug ){
|
|
|
|
|
theView.go("\web\index.html",37151);
|
|
|
|
|
} else {
|
|
|
|
|
theView.go("\web\index.html");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mainForm.show();
|
|
|
|
|
win.loopMessage();
|
2024-08-20 09:53:46 +00:00
|
|
|
|
tray.delete();
|