Compare commits
2 Commits
76abef7a94
...
a725c59c5e
Author | SHA1 | Date | |
---|---|---|---|
|
a725c59c5e | ||
|
6f68c87114 |
22
Readme.md
22
Readme.md
@ -1,9 +1,13 @@
|
|||||||
# AWin
|
# AWin
|
||||||
一个基于 aardio 简单封装的窗口,只运行于 Windows 下。用于使用 web 技术快速开发 windows 程序。
|
一个基于 aardio 简单封装的窗口,只运行于 Windows 下。用于使用 web 技术快速开发 windows 程序。
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## TODO
|
## TODO
|
||||||
[ ] 静态 tray
|
### 1.0
|
||||||
[ ] 动态 tray
|
[x] 窗口大小配置
|
||||||
[ ] 日志模块
|
[ ] 后台服务启动/守护
|
||||||
|
[x] 前台页面
|
||||||
|
[x] 日志模块
|
||||||
|
[ ] tray
|
||||||
|
[ ] tray 右键
|
||||||
|
14
aardiowin/Readme.md
Normal file
14
aardiowin/Readme.md
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
## 编译
|
||||||
|
1. 使用 aardio 打开项目
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## 辅助 AI
|
||||||
|
https://yuanqi.tencent.com/agent/ZsUaavawqWFp
|
||||||
|
|
||||||
|
## 托盘
|
||||||
|
https://bbs.aardio.com/forum.php?mod=viewthread&tid=10257&highlight=%E6%89%98%E7%9B%98
|
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"app" : "awin",
|
"app" : "awin",
|
||||||
"title" : "awin",
|
"title" : "awin",
|
||||||
"icon" : "",
|
"icon" : "logo.png",
|
||||||
"backend" : "",
|
"backend" : "",
|
||||||
"frontend" : "",
|
"frontend" : "",
|
||||||
"window" : {
|
"window" : {
|
||||||
|
@ -24,9 +24,10 @@ namespace init{
|
|||||||
|
|
||||||
// 配置载入函数
|
// 配置载入函数
|
||||||
loadConfigs = function() {
|
loadConfigs = function() {
|
||||||
|
import io;
|
||||||
|
import util;
|
||||||
|
|
||||||
|
gLog.print("loadConfigs");
|
||||||
gLog.print("dir");
|
|
||||||
var configs = {};
|
var configs = {};
|
||||||
var currentPath = fsys.getCurDir();
|
var currentPath = fsys.getCurDir();
|
||||||
gLog.print("currentPath", currentPath);
|
gLog.print("currentPath", currentPath);
|
||||||
@ -62,7 +63,8 @@ namespace init{
|
|||||||
// 合并配置,后读取的覆盖先读取的
|
// 合并配置,后读取的覆盖先读取的
|
||||||
object.merge(configs, appDataConfig, true);
|
object.merge(configs, appDataConfig, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gLog.print("configs", util.table.stringify(configs, true));
|
||||||
return configs;
|
return configs;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
BIN
aardiowin/logo.png
Normal file
BIN
aardiowin/logo.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 16 KiB |
@ -1,21 +1,89 @@
|
|||||||
import win.ui;
|
import win.ui;
|
||||||
import init;
|
import init;
|
||||||
|
import win.util.tray;
|
||||||
|
|
||||||
// 初始化
|
// 初始化
|
||||||
init.init();
|
init.init();
|
||||||
var gConfig = init.loadConfigs();
|
var gConfig = init.loadConfigs();
|
||||||
var gDebug = init.getDebug();
|
var gDebug = init.getDebug();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// 启动界面
|
||||||
/*DSG{{*/
|
/*DSG{{*/
|
||||||
mainForm = win.form(text="awin";right=gConfig.window.width;bottom=gConfig.window.height;border="thin";max=false;min=false)
|
mainForm = win.form(text="awin";right=1;bottom=1;border="thin";max=false;min=false)
|
||||||
mainForm.add()
|
mainForm.add()
|
||||||
/*}}*/
|
/*}}*/
|
||||||
|
|
||||||
|
|
||||||
// 启动界面
|
// 日志
|
||||||
var gLog = init.getLog();
|
var gLog = init.getLog();
|
||||||
gLog.print("web view")
|
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\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\xf8\31\xff\xff\xe7\xe7\xff\xff\xdf\xfb\xff\xff\xbf\xfd\xff\xff\xbe}\xff\xff}\xbe\xff\xff\x7f\xfe\xff\xff\x7f\xfe\xff\xff\x7f\xfe\xff\xffs\xce\xff\xffs\xce\xff\xff\xbf\xfd\xff\xff\xbf\xfd\xff\xff\xdf\xfb\xff\xff\xe7\xe7\xff\xff\xf8\31\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\xff\x81\xff\xff\x7e\x7e\xff\xff\xbd\xff\xff\xff\xdb\xff\xff\xff\xdb\xe7\xff\xff\xe7\xdb\xff\xff\xe7\xff\xff\xff\xe7\xff\xff\xff\xe7\xff\xff\xff\xe7<\xff\xff\xe7<\xff\xff\xdb\xff\xff\xff\xdb\xff\xff\xff\xbd\xff\xff\xff\x7e\x7e\xff\xff\xff\x81\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\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;
|
import web.view;
|
||||||
var theView = web.view(mainForm);
|
var theView = web.view(mainForm);
|
||||||
|
|
||||||
@ -45,4 +113,4 @@ if( gDebug ){
|
|||||||
|
|
||||||
mainForm.show();
|
mainForm.show();
|
||||||
win.loopMessage();
|
win.loopMessage();
|
||||||
|
tray.delete();
|
||||||
|
Loading…
Reference in New Issue
Block a user