tray 未调试通过

This commit is contained in:
Cheney 2024-08-20 17:53:46 +08:00
parent 6f68c87114
commit a725c59c5e
5 changed files with 81 additions and 13 deletions

View File

@ -1,9 +1,13 @@
# AWin
一个基于 aardio 简单封装的窗口,只运行于 Windows 下。用于使用 web 技术快速开发 windows 程序。
## TODO
[ ] 静态 tray
[ ] 动态 tray
[ ] 日志模块
# AWin
一个基于 aardio 简单封装的窗口,只运行于 Windows 下。用于使用 web 技术快速开发 windows 程序。
## TODO
### 1.0
[x] 窗口大小配置
[ ] 后台服务启动/守护
[x] 前台页面
[x] 日志模块
[ ] tray
[ ] tray 右键

View File

@ -8,4 +8,7 @@
## 辅助 AI
https://yuanqi.tencent.com/agent/ZsUaavawqWFp
https://yuanqi.tencent.com/agent/ZsUaavawqWFp
## 托盘
https://bbs.aardio.com/forum.php?mod=viewthread&tid=10257&highlight=%E6%89%98%E7%9B%98

View File

@ -1,7 +1,7 @@
{
"app" : "awin",
"title" : "awin",
"icon" : "",
"icon" : "logo.png",
"backend" : "",
"frontend" : "",
"window" : {

BIN
aardiowin/logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

View File

@ -1,6 +1,6 @@
import win.ui;
import init;
import win.util.tray;
// 初始化
init.init();
@ -21,8 +21,69 @@ mainForm.add()
var gLog = init.getLog();
gLog.print("width=" , gConfig.window.width)
gLog.print("height=" , gConfig.window.height)
// 主窗口
mainForm.resize(gConfig.window.width, gConfig.window.height);
// 托盘
//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\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0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\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(); //关闭窗口同时删掉托盘,避免关闭窗口后要鼠标移到托盘图标才消失
}
// 前端
import web.view;
var theView = web.view(mainForm);
@ -52,4 +113,4 @@ if( gDebug ){
mainForm.show();
win.loopMessage();
tray.delete();