291 lines
9.9 KiB
Plaintext
291 lines
9.9 KiB
Plaintext
//无边框窗口
|
||
import win.ui;
|
||
/*DSG{{*/
|
||
var winform = win.form(text="Edge 浏览器控件 - web.view";right=759;bottom=469;border="none")
|
||
winform.add()
|
||
/*}}*/
|
||
|
||
import fsys.update.simpleMain;
|
||
if( fsys.update.simpleMain(
|
||
"SimpleNotes-aar",
|
||
"https://begin2019.com:3000/OTAHub/SimpleNotes-aar/raw/branch/main/version.txt", /*网址也可以改用目录名,并使用服务端代码动态返回version.txt*/
|
||
"/download/update-files", /*绿色软件建议改为 io.appData("/软件厂商名/软件名字/update-files") */
|
||
function(version,description,status){
|
||
/*
|
||
version参数包含最新版本号,
|
||
description包含最新版本更新说明,
|
||
status参数值见下面的列表:
|
||
"ready": 下载已完成并准备更新,
|
||
"updated": 已更新到新版本并准备启动新版
|
||
"complete": 当前已更新并已启动新版本主程序,所有操作已完成
|
||
"latest": 已经是最新版不需要更新
|
||
"failed": 出错了,description参数为错误信息
|
||
|
||
这个回调函数不是必须的,
|
||
在此检测更新代码之前或之后都可以在界面线程调用
|
||
fsys.update.simpleMain.onStatusChanged 订阅更新状态变更信息。
|
||
该认阅回调函数的参数与上面的回调参数相同。
|
||
*/
|
||
winform.msgbox(version);
|
||
winform.msgbox(description);
|
||
winform.msgbox(status);
|
||
} )){
|
||
return 0; //必须退出 main.aardio 以启动更新
|
||
}
|
||
|
||
import web.view;
|
||
var wb = web.view(winform);
|
||
|
||
//导出为 Javascript 中的 aardio 对象
|
||
wb.external = {
|
||
close = function(){
|
||
winform.close();
|
||
};
|
||
hitCaption = function(){
|
||
winform.hitCaption();
|
||
};
|
||
hitMin = function(){
|
||
winform.hitMin();
|
||
};
|
||
hitMax = function(){
|
||
return winform.hitMax();
|
||
};
|
||
upgrade = function(){
|
||
fsys.update.simpleMain.checkUpdate(true);
|
||
}
|
||
}
|
||
|
||
// wb.go("/res/index.html"); //直接打开资源目录下的文件
|
||
wb.html = /**
|
||
<!doctype html>
|
||
<html>
|
||
|
||
<head>
|
||
<meta charset="utf-8">
|
||
<style type="text/css">
|
||
#title-bar {
|
||
height: 32px;
|
||
padding: 0px;
|
||
margin: 0px;
|
||
}
|
||
|
||
#title-bar .caption {
|
||
position: fixed;
|
||
top: 0px;
|
||
left: 0px;
|
||
width: 100%;
|
||
padding-left: 10px;
|
||
color: #ADADAD;
|
||
line-height: 32px;
|
||
font-size: 14px;
|
||
cursor: default;
|
||
user-select: none;
|
||
}
|
||
|
||
#title-bar .buttons {
|
||
position: fixed;
|
||
top: 1px;
|
||
right: 1px;
|
||
}
|
||
|
||
#title-bar button {
|
||
font: 14px Marlett;
|
||
color: #000000; /* 改为黑色 */
|
||
background-color: transparent;
|
||
border: none;
|
||
height: 28px;
|
||
width: 28px;
|
||
vertical-align: middle;
|
||
}
|
||
|
||
#update-btn {
|
||
background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAACxMAAAsTAQCanBgAAAPsSURBVEhL3VR9aJVlFD/ned93970f3SBBJlQ6SZIwolZGm7E7qdTRH11ifUiYN2tSRNlWrdYgd0cSOKcrKBqFZU6SPkSIW1nJbk2lbLZQRDJiEEp/JIyw3O593uf0e9691K5bi/yvfvBw33PO757znHOec+g/D45+p+HSdeYSx6c1JLQM4sWgnmKRj+bP5feLXawnWf+MGQMsXm+yhuhJo+hVFfCoJ+KVHNJgL1OGmjzhh47184mIPiumBbjuQXO7FlrnMr1sDOUN00mwTiGTJQ6RIHAPaD1eQHd986b66apHJBUbl/S3l/HP1MUwV6IiQG2LJLxx+RzKdmHqBrvdNbQWrA8O7lD7rl9rbnCF+oS4Q4l0QH8OnJgQjSF4jRLadWAHvwS3UE1CRb8h0mflDj+gd+KGnotpak9q6kWANw7W8GfWjhsfjmvalihLY5Who46mZ796S61MaTqUNNTlGapuXC0bQ2cRKgLA+Y2+oRFfU5AKaFU8oPwXA+rw1NR/TfIeP+CG4k7VNjSgjlsdUtjvlWl1okzH8f+6FVkzLyQDFQHgMI5zxmduxe12JTQVI9OfGO7nMm6/IRJDJErUCuev4YIPIMMPL3KoPjL91YPmZnGqStKLiJ+8vVcVIvW/xn1Z8xgacHpgj3rPymEGLU1mZfqcDCE91zE0bnUXCmSQRTZVeHDh5fnRVcam00mGNimmh7Xi1lcKeHIXgJZa8bxqWQ5fKxyhhU6K7uWnbjMFtDCPeJs1U27rPvVDxA/xfINUj7u0OBIrEGg60VOcvEzHcrNUO7TFvk+UZQRD+rUKaImKlyiJtOrQoN5pzpeatCjZi6eamekkYLMcy8V8bImXOLv5U3VzleYzyQkqxQwmH85d3/BZ1G1O6HUK/Cq6P16meWktDTMda7Mcy4Uf6iryL/Y7FciRWECXwx7AOY1Smb5HXt19dYbSHu/MFTlsNN77HOjXPDHEg1Y+H1vrJYN6Z+w3KjDSd5NsVCxHNIYU/WzDqrnF9YQ6XJHdTomf0a4sGvuNfPDDAJgDQi1DPP2lWc+KwwHC8zj9Yj33YyAJyy/E2K38+NyPpRlL4kqsjTY0OW8cjKg1vn6tmY/ltgnCApxS+I9JLAiYc7lhHuzbb7pd4k6rLLO8sKFRdW6vlYwjsh2qUau3ECEn3FFM+dywOhAG+DvsvhopKxps/o4HCwUTw64ZtvqyotqmJjXx7jWSQRkydx/liv0zFRWr4nzYEtkyWFiHNRN0jz322+qszXJmw6wB/EACvyy2JyGuuFMdsycSydosJxJnxKwlOrTQLNKKtoGUiFQVwFD9HmDxZX5UJyPV/w5EfwA9C5hdvKK2PgAAAABJRU5ErkJggg==');
|
||
background-size: cover; /* 让图片填充整个按钮 */
|
||
}
|
||
|
||
#update-btn:hover {
|
||
opacity: 0.8; /* 在悬停时使图片稍微透明 */
|
||
}
|
||
|
||
#update-btn:active {
|
||
opacity: 0.6; /* 在点击时使图片更透明 */
|
||
}
|
||
|
||
#min-btn:hover {
|
||
background-color: #b6b4b4; /* 蓝色 */
|
||
}
|
||
|
||
#min-btn:active {
|
||
background-color: #979696; /* 深蓝色 */
|
||
}
|
||
|
||
#max-btn:hover {
|
||
background-color: #b6b4b4; /* 红色 */
|
||
}
|
||
|
||
#max-btn:active {
|
||
background-color: #979696/* 深红色 */
|
||
}
|
||
|
||
#close-btn:hover {
|
||
background-color: #f44336; /* 灰色 */
|
||
}
|
||
|
||
#close-btn:active {
|
||
background-color: #d32f2f; /* 深灰色 */
|
||
}
|
||
body {
|
||
font-family: 'Microsoft YaHei', Arial, sans-serif;
|
||
background-color: rgb(255, 255, 255);
|
||
margin: 0;
|
||
padding: 0;
|
||
height: 100vh;
|
||
width: 100vw;
|
||
overflow: hidden;
|
||
}
|
||
|
||
.note-container {
|
||
background-color: #fff;
|
||
box-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
|
||
width: 100vw;
|
||
height: 100vh;
|
||
padding: 20px;
|
||
border-radius: 8px;
|
||
box-sizing: border-box;
|
||
overflow-y: auto; /* 当内容超出容器时,显示纵向滚动条 */
|
||
}
|
||
|
||
.note-input {
|
||
width: 100%;
|
||
padding: 10px;
|
||
margin-bottom: 10px;
|
||
box-sizing: border-box;
|
||
border: 1px solid #ddd;
|
||
border-radius: 4px;
|
||
font-size: 16px;
|
||
resize: vertical;
|
||
font-family: 'Microsoft YaHei', Arial, sans-serif;
|
||
}
|
||
|
||
.note-list {
|
||
list-style: none;
|
||
padding: 0;
|
||
margin: 0;
|
||
}
|
||
|
||
.note-item {
|
||
background-color: #f9f9f9;
|
||
padding: 10px;
|
||
margin-bottom: 10px;
|
||
border-radius: 4px;
|
||
box-sizing: border-box;
|
||
word-wrap: break-word;
|
||
white-space: pre-line;
|
||
}
|
||
|
||
.delete-btn {
|
||
background-color: #ff5858;
|
||
color: #fff;
|
||
border: none;
|
||
padding: 5px 10px;
|
||
border-radius: 4px;
|
||
cursor: pointer;
|
||
}
|
||
|
||
.note-date {
|
||
color: #888;
|
||
font-size: 12px;
|
||
}
|
||
</style>
|
||
<script type="text/javascript">
|
||
|
||
</script>
|
||
</head>
|
||
|
||
<body>
|
||
<div id="title-bar">
|
||
<div class="caption" onmousedown="aardio.hitCaption()">SimpleNotes</div>
|
||
<div class="buttons">
|
||
<button id="update-btn" onclick="aardio.upgrade()"></button>
|
||
<button id="min-btn" onclick="aardio.hitMin()">0</button>
|
||
<button id="max-btn" onclick="aardio.hitMax()">1</button>
|
||
<button id="close-btn" onclick="aardio.close()">r</button>
|
||
</div>
|
||
</div>
|
||
<div id="main">
|
||
<div class="note-container">
|
||
<textarea id="noteInput" class="note-input" placeholder="添加便签..."></textarea>
|
||
<ul id="noteList" class="note-list"></ul>
|
||
</div>
|
||
</div>
|
||
<script>
|
||
document.addEventListener('DOMContentLoaded', function () {
|
||
const noteInput = document.getElementById('noteInput');
|
||
const noteList = document.getElementById('noteList');
|
||
|
||
noteInput.addEventListener('keydown', function (event) {
|
||
if (event.key === 'Enter' && !event.shiftKey && noteInput.value.trim() !== '') {
|
||
addNote();
|
||
event.preventDefault();
|
||
}
|
||
});
|
||
|
||
function addNote() {
|
||
const noteText = noteInput.value.trim();
|
||
const listItem = document.createElement('li');
|
||
listItem.className = 'note-item';
|
||
|
||
// 获取当前日期和时间
|
||
const now = new Date();
|
||
const dateTime = now.toLocaleString();
|
||
|
||
// 获取星期
|
||
const weekDays = ['周日', '周一', '周二', '周三', '周四', '周五', '周六'];
|
||
const weekDay = weekDays[now.getDay()];
|
||
|
||
// 获取第几周
|
||
const start = new Date(now.getFullYear(), 0, 0);
|
||
const diff = (now - start) + ((start.getTimezoneOffset() - now.getTimezoneOffset()) * 60 * 1000);
|
||
const oneDay = 1000 * 60 * 60 * 24;
|
||
const day = Math.floor(diff / oneDay);
|
||
const week = Math.ceil(day / 7);
|
||
|
||
listItem.innerHTML = `<div class="note-date">w${week} ${weekDay} ${dateTime}</div> <!-- 添加日期、时间、星期和第几周 -->
|
||
<div>${noteText}</div>
|
||
<button class="delete-btn" onclick="deleteNote(this)">删除</button>
|
||
`;
|
||
noteList.prepend(listItem);
|
||
noteInput.value = '';
|
||
}
|
||
|
||
window.deleteNote = function (btn) {
|
||
const listItem = btn.parentNode;
|
||
noteList.removeChild(listItem);
|
||
};
|
||
});
|
||
</script>
|
||
</body>
|
||
|
||
</html>
|
||
**/
|
||
|
||
//添加阴影边框
|
||
import win.ui.shadow;
|
||
win.ui.shadow(winform);
|
||
|
||
//设置窗口缩放范围
|
||
import win.ui.minmax;
|
||
win.ui.minmax(winform);
|
||
|
||
//切换最大化、还原按钮
|
||
winform.adjust = function( cx,cy,wParam ) {
|
||
if( wParam == 0x2/*_SIZE_MAXIMIZED*/ ){
|
||
wb.doScript(`document.getElementById("max-btn").innerText="2";`)
|
||
}
|
||
elseif( wParam == 0x0/*_SIZE_RESTORED*/ ){
|
||
wb.doScript(`document.getElementById("max-btn").innerText="1";`)
|
||
}
|
||
};
|
||
|
||
winform.show();
|
||
win.loopMessage(); |