Compare commits
6
Commits
76abef7a94
..
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
51c5308be2 | ||
|
|
b3ece1ad61 | ||
|
|
20782a7c24 | ||
|
|
153432e048 | ||
|
|
a725c59c5e | ||
|
|
6f68c87114 |
@@ -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 右键
|
||||
|
||||
@@ -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",
|
||||
"title" : "awin",
|
||||
"icon" : "",
|
||||
"icon" : "logo.png",
|
||||
"backend" : "",
|
||||
"frontend" : "",
|
||||
"window" : {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?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"/>
|
||||
<folder name="窗体" path="forms" comment="" embed="true" local="false" ignored="false"/>
|
||||
<folder name="网页" path="web" embed="true" comment="目录" local="true" ignored="false">
|
||||
|
||||
@@ -24,9 +24,10 @@ namespace init{
|
||||
|
||||
// 配置载入函数
|
||||
loadConfigs = function() {
|
||||
import io;
|
||||
import util;
|
||||
|
||||
|
||||
gLog.print("dir");
|
||||
gLog.print("loadConfigs");
|
||||
var configs = {};
|
||||
var currentPath = fsys.getCurDir();
|
||||
gLog.print("currentPath", currentPath);
|
||||
@@ -62,11 +63,17 @@ namespace init{
|
||||
// 合并配置,后读取的覆盖先读取的
|
||||
object.merge(configs, appDataConfig, true);
|
||||
}
|
||||
|
||||
|
||||
checkConfig(configs);
|
||||
gLog.print("configs", util.table.stringify(configs, true));
|
||||
return configs;
|
||||
};
|
||||
|
||||
/*
|
||||
* 默认配置
|
||||
*/
|
||||
checkConfig = function (config){
|
||||
gLog.print("checkConfig");
|
||||
if( ! config.window ){
|
||||
config.window = {}
|
||||
}
|
||||
@@ -76,6 +83,9 @@ namespace init{
|
||||
if( ! config.window.height ) {
|
||||
config.window.height = 500
|
||||
}
|
||||
if( (! config.frontend) or config.frontend == "" ){
|
||||
config.frontend = "web/index.html"
|
||||
}
|
||||
return config;
|
||||
}
|
||||
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 15 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 16 KiB |
+86
-8
@@ -7,15 +7,90 @@ init.init();
|
||||
var gConfig = init.loadConfigs();
|
||||
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();
|
||||
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;
|
||||
var theView = web.view(mainForm);
|
||||
|
||||
@@ -36,13 +111,16 @@ import wsock.tcp.simpleHttpServer;
|
||||
去掉下面的前端项目调试端口号 37151 或发布 EXE 后运行才会打开 "\web\index.html"。
|
||||
否则打开 http://localhost:37151
|
||||
*/
|
||||
|
||||
var url = gConfig.frontend
|
||||
gLog.print("url=" , url)
|
||||
if( gDebug ){
|
||||
theView.go("\web\index.html",37151);
|
||||
theView.go(url,37151);
|
||||
} else {
|
||||
theView.go("\web\index.html");
|
||||
theView.go(url);
|
||||
}
|
||||
|
||||
|
||||
mainForm.show();
|
||||
win.loopMessage();
|
||||
|
||||
// tray.delete();
|
||||
@@ -1,11 +1,11 @@
|
||||
{
|
||||
"app" : "",
|
||||
"title" : "",
|
||||
"app" : "awin-portable-template",
|
||||
"title" : "awin portable template",
|
||||
"icon" : "",
|
||||
"backend" : "",
|
||||
"frontend" : "",
|
||||
"frontend" : "dist/index.html",
|
||||
"window" : {
|
||||
"width" : "",
|
||||
"height" : ""
|
||||
"width" : 1024,
|
||||
"height" : 768
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user