Compare commits

..
6 Commits
Author SHA1 Message Date
Cheney 51c5308be2 title 配置项 2024-10-17 15:44:35 +08:00
Cheney b3ece1ad61 url 配置项 2024-10-17 15:37:21 +08:00
Cheney 20782a7c24 程序关闭按钮实际上只关闭窗口 2024-08-20 20:57:21 +08:00
Cheney 153432e048 tray 显示正常,逻辑待调整。 2024-08-20 20:11:13 +08:00
Cheney a725c59c5e tray 未调试通过 2024-08-20 17:53:46 +08:00
Cheney 6f68c87114 动态窗口测试通过 2024-08-20 15:40:27 +08:00
9 changed files with 133 additions and 27 deletions
+7 -3
View File
@@ -4,6 +4,10 @@
## TODO ## TODO
[ ] 静态 tray ### 1.0
[ ] 动态 tray [x] 窗口大小配置
[ ] 日志模块 [ ] 后台服务启动/守护
[x] 前台页面
[x] 日志模块
[ ] tray
[ ] tray 右键
+14
View 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 -1
View File
@@ -1,7 +1,7 @@
{ {
"app" : "awin", "app" : "awin",
"title" : "awin", "title" : "awin",
"icon" : "", "icon" : "logo.png",
"backend" : "", "backend" : "",
"frontend" : "", "frontend" : "",
"window" : { "window" : {
+1 -1
View File
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<project ver="10" name="awin" libEmbed="true" icon="..." ui="win" output="awin.exe" CompanyName="aardio" FileDescription="awin" LegalCopyright="Copyright (C) 作者 2024" ProductName="awin" InternalName="awin" FileVersion="0.0.0.1" ProductVersion="0.0.0.1" publishDir="/dist/" dstrip="false" local="false" ignored="false"> <project ver="10" name="awin" libEmbed="true" icon="..." ui="win" output="awin.exe" CompanyName="aardio" FileDescription="awin" LegalCopyright="Copyright (C) 作者 2024" ProductName="awin" InternalName="awin" FileVersion="0.0.0.2" ProductVersion="0.0.0.2" publishDir="/dist/" dstrip="false" local="false" ignored="false">
<file name="main" path="main.aardio"/> <file name="main" path="main.aardio"/>
<folder name="窗体" path="forms" comment="" embed="true" local="false" ignored="false"/> <folder name="窗体" path="forms" comment="" embed="true" local="false" ignored="false"/>
<folder name="网页" path="web" embed="true" comment="目录" local="true" ignored="false"> <folder name="网页" path="web" embed="true" comment="目录" local="true" ignored="false">
+12 -2
View File
@@ -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);
@@ -63,10 +64,16 @@ namespace init{
object.merge(configs, appDataConfig, true); object.merge(configs, appDataConfig, true);
} }
checkConfig(configs);
gLog.print("configs", util.table.stringify(configs, true));
return configs; return configs;
}; };
/*
* 默认配置
*/
checkConfig = function (config){ checkConfig = function (config){
gLog.print("checkConfig");
if( ! config.window ){ if( ! config.window ){
config.window = {} config.window = {}
} }
@@ -76,6 +83,9 @@ namespace init{
if( ! config.window.height ) { if( ! config.window.height ) {
config.window.height = 500 config.window.height = 500
} }
if( (! config.frontend) or config.frontend == "" ){
config.frontend = "web/index.html"
}
return config; return config;
} }
Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

+86 -8
View File
@@ -7,15 +7,90 @@ init.init();
var gConfig = init.loadConfigs(); var gConfig = init.loadConfigs();
var gDebug = init.getDebug(); var gDebug = init.getDebug();
/*DSG{{*/
mainForm = win.form(text="awin";right=gConfig.window.width;bottom=gConfig.window.height;border="thin";max=false;min=false)
mainForm.add()
/*}}*/
// 启动界面 // 启动界面
/*DSG{{*/
mainForm = win.form(text="awin";right=1;bottom=1;border="thin";max=false;min=false)
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);
mainForm.text = gConfig.title
// 托盘
import win.util.tray;
var tray = win.util.tray(mainForm,"./logo.ico") //创建托盘图标,如果不能显示图标,可能是图标问题,要复合图标
tray.message = 0x400+9981/*_WM_TRAYMESSAGE*/
tray.tip = gConfig.app //设置鼠标提示
/*
mainForm.onClose = function(hwnd,message,wParam,lParam){
tray.delete(); //关闭窗口同时删掉托盘,避免关闭窗口后要鼠标移到托盘图标才消失
}
*/
//下面是添加托盘右键菜单
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;//阻击默认消息传递,取消最小化过程
}
if( wparam == 0xF060/*_SC_MINIMIZE*/ ){ //用户点击了最小化按钮
mainForm.show(false); //隐藏窗口
return true;//阻击默认消息传递,取消最小化过程
}
}
}
}
// 后台
if( gConfig.backend != "" ) {
gLog.print("backend=" , gConfig.backend)
thread.invoke(function(mainForm){
// 线程执行的代码
import process.popen;
var prcs = process.popen(gConfig.backend);
prcs.logResponse();
}, mainForm);
}
// 前端
import web.view; import web.view;
var theView = web.view(mainForm); var theView = web.view(mainForm);
@@ -36,13 +111,16 @@ import wsock.tcp.simpleHttpServer;
去掉下面的前端项目调试端口号 37151 或发布 EXE 后运行才会打开 "\web\index.html"。 去掉下面的前端项目调试端口号 37151 或发布 EXE 后运行才会打开 "\web\index.html"。
否则打开 http://localhost:37151 否则打开 http://localhost:37151
*/ */
var url = gConfig.frontend
gLog.print("url=" , url)
if( gDebug ){ if( gDebug ){
theView.go("\web\index.html",37151); theView.go(url,37151);
} else { } else {
theView.go("\web\index.html"); theView.go(url);
} }
mainForm.show(); mainForm.show();
win.loopMessage(); win.loopMessage();
// tray.delete();
+5 -5
View File
@@ -1,11 +1,11 @@
{ {
"app" : "", "app" : "awin-portable-template",
"title" : "", "title" : "awin portable template",
"icon" : "", "icon" : "",
"backend" : "", "backend" : "",
"frontend" : "", "frontend" : "dist/index.html",
"window" : { "window" : {
"width" : "", "width" : 1024,
"height" : "" "height" : 768
} }
} }