Compare commits

...
4 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
5 changed files with 52 additions and 34 deletions
+1 -1
View File
@@ -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">
+8
View File
@@ -64,11 +64,16 @@ 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 = {}
}
@@ -78,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

+38 -28
View File
@@ -1,6 +1,6 @@
import win.ui;
import init;
import win.util.tray;
// 初始化
init.init();
@@ -16,7 +16,6 @@ mainForm = win.form(text="awin";right=1;bottom=1;border="thin";max=false;min=fal
mainForm.add()
/*}}*/
// 日志
var gLog = init.getLog();
gLog.print("width=" , gConfig.window.width)
@@ -24,27 +23,19 @@ gLog.print("height=" , gConfig.window.height)
// 主窗口
mainForm.resize(gConfig.window.width, gConfig.window.height);
mainForm.text = gConfig.title
// 托盘
//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);
import win.util.tray;
var tray = win.util.tray(mainForm,"./logo.ico") //创建托盘图标,如果不能显示图标,可能是图标问题,要复合图标
tray.message = 0x400+9981/*_WM_TRAYMESSAGE*/
tray.tip = gConfig.app //设置鼠标提示
var tmId = mainForm.setInterval(
120,
function(id) {
currectIcon = currectIcon == 4 ? 1 : currectIcon + 1;
tray.icon = icon[currectIcon];
}
);
/*
mainForm.onClose = function(hwnd,message,wParam,lParam){
tray.delete(); //关闭窗口同时删掉托盘,避免关闭窗口后要鼠标移到托盘图标才消失
}
*/
//下面是添加托盘右键菜单
import win.ui.menu;
@@ -61,7 +52,7 @@ import mouse;
mainForm.wndproc = function(hwnd,message,wparam,lparam){
select(message) {//判断消息类型
case( 0x400+9981/*_WM_TRAYMESSAGE*/ ) { //托盘图标消息
if(lparam = 0x203/*_WM_LBUTTONDBLCLK)*/){ //鼠标双击
mainForm.show(true);
}
@@ -69,20 +60,36 @@ mainForm.wndproc = function(hwnd,message,wparam,lparam){
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;//阻击默认消息传递,取消最小化过程
}
}
}
}
mainForm.onClose = function(hwnd,message,wParam,lParam){
tray.delete(); //关闭窗口同时删掉托盘,避免关闭窗口后要鼠标移到托盘图标才消失
// 后台
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);
@@ -104,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();
// tray.delete();
+5 -5
View File
@@ -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
}
}