Skip to content

Commit

Permalink
图标增加256*256, 彻底解决尝试重启时导致备份文件增多的异常
Browse files Browse the repository at this point in the history
  • Loading branch information
pattazl committed Mar 7, 2024
1 parent c76a7f9 commit 3f4902c
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 35 deletions.
2 changes: 1 addition & 1 deletion build/showKeyBoard(node).nsi
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

; 安装程序初始定义常量
!define PRODUCT_NAME $(ToolLang)
!define PRODUCT_VERSION "v1.32"
!define PRODUCT_VERSION "v1.33"
!define /date DATESTR "%y%m%d"
!define ExeName "showKeyBoard.exe"
!define PRODUCT_PUBLISHER "Austin.Young"
Expand Down
2 changes: 1 addition & 1 deletion build/showKeyBoard.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

; 安装程序初始定义常量
!define PRODUCT_NAME $(ToolLang)
!define PRODUCT_VERSION "v1.32"
!define PRODUCT_VERSION "v1.33"
!define /date DATESTR "%y%m%d"
!define ExeName "showKeyBoard.exe"
!define PRODUCT_PUBLISHER "Austin.Young"
Expand Down
4 changes: 2 additions & 2 deletions events.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -213,14 +213,14 @@ SendPCInfo(flag)
global minTop := Min(minTop,Top)
global maxRight := Max(maxRight,Right)
global maxBottom := Max(maxBottom,Bottom)
tmp := '{"Left":' Left ',"Top":' Top ',"Right":' Right ',"Bottom":' Bottom ',"flag":' flag '}'
tmp := '{"Left":' Left ',"Top":' Top ',"Right":' Right ',"Bottom":' Bottom '}'
JSONStr := JSONStr tmp
}catch{
; 出现异常无需发送数据
return
}
}
JSONStr := JSONStr ']}'
JSONStr := JSONStr '],"flag":' flag '}'
if serverState = 1 {
StartHttp('sendPCInfo','/sendPCInfo',JSONStr,timeout:=8000)
}
Expand Down
2 changes: 1 addition & 1 deletion http/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"main": "server.js",
"version": "1.32.0",
"version": "1.33.0",
"name": "httpserver",
"binary": {
"module_name": "node_sqlite3",
Expand Down
54 changes: 29 additions & 25 deletions http/src/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -604,43 +604,47 @@ function autoBackup() {
if (!fs.existsSync(backupPath)) {
fs.mkdirSync(backupPath)
}
let lastBackUp = backupPath + getDateStr(0, 'day')
let currentFile = getDateStr(0, 'day')
let lastBackUpPath = backupPath + currentFile
if (days > 0) {
// 清理 days前的文件
let maxFile = ''
let beforeStr = getDateStr(days, 'day')
fs.readdir(backupPath, (err, files) => {
if (err) {
console.error('无法读取文件夹内容', err);
return;
let files = []
try {
files = fs.readdirSync(backupPath);
} catch (err) {
console.error('无法读取文件夹内容:', err);
return;
}
// 遍历文件列表
files.forEach((file) => {
// 取符合格式的文件名 `skb_${beforeDays.format('YYYY-MM-DD-HH-mm-ss')}.zip`
if (!/^skb_\d{4}-\d{2}-\d{2}-\d{2}-\d{2}-\d{2}\.zip$/i.test(file)) {
return
}
// 遍历文件列表
files.forEach((file) => {
// 取符合格式的文件名 `skb_${beforeDays.format('YYYY-MM-DD-HH-mm-ss')}.zip`
if (!/^skb_\d{4}-\d{2}-\d{2}-\d{2}-\d{2}-\d{2}\.zip$/i.test(file)) {
return
}
if (file < beforeStr) {
// 如果文件名表示的数字小于阈值数字,就删除该文件
fs.unlink(path.join(backupPath, file), (err) => {
if (err) {
console.error('无法删除文件', file, err);
} else {
console.log('已删除文件', file);
}
});
}
// 取符合格式的最大文件名
if (file < beforeStr) {
// 如果文件名表示的数字小于阈值数字,就删除该文件
fs.unlink(path.join(backupPath, file), (err) => {
if (err) {
console.error('无法删除文件', file, err);
} else {
console.log('已删除文件', file);
}
});
}
// 取符合格式的最大文件名,必须是小于当前要写入文件的时间
if(file<currentFile){
maxFile = file > maxFile ? file : maxFile
});
}
});
// backup 下保存文件
let minBackUp = backupPath + getDateStr(3, 'minutes') // 备份时间间隔需要小于3分钟,防止持续重复备份
let minBackUp = getDateStr(3, 'minutes') // 备份时间间隔需要小于3分钟,防止持续重复备份
// 只有当前备份的时间大于已经备份的最大时间 3分钟
if (minBackUp > maxFile) {
zipCore(function (content) {
// see FileSaver.js
fs.writeFileSync(lastBackUp, content);
fs.writeFileSync(lastBackUpPath, content);
})
}
}
Expand Down
4 changes: 2 additions & 2 deletions http/src/version.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
* @version 配置显示在登录页面的前端版本,格式为 v.主版本号.次版本号.日期.小版本序号 v1.0.190827.1
*/
// 对于发布版 YYMMDD 和 verNo 会在Webpack中自动替换为真实的日期和版本序号,如下格式不能随便改,参考vue.config.js的代码
const replaceYYMMDD = '240305';
const replaceYYMMDD = '240307';
const replaceVerNo = '0';
// 主版本可从 package.json中获取
const mainVersion = '1.32.0';
const mainVersion = '1.33.0';
const strVersion = mainVersion+'.'+replaceYYMMDD+'.'+replaceVerNo; // 可以支持旧版浏览器
//export default strVersion
module.exports = {strVersion};
Binary file modified res/keyboard.ico
Binary file not shown.
6 changes: 3 additions & 3 deletions showKeyBoard.ahk
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
;编译信息
;@Ahk2Exe-SetName ShowKeyBoard
;@Ahk2Exe-SetDescription Show and Analyse Mouse/KeyBoard
;@Ahk2Exe-SetProductVersion 1.32.0.0
;@Ahk2Exe-SetFileVersion 1.32.0.0
;@Ahk2Exe-SetProductVersion 1.33.0.0
;@Ahk2Exe-SetFileVersion 1.33.0.0
;@Ahk2Exe-SetCopyright Austing.Young (2023 - )
;@Ahk2Exe-SetMainIcon res\keyboard.ico
;@Ahk2Exe-ExeName build/release/ShowKeyBoard.exe
#Requires AutoHotkey v2
#SingleInstance Ignore
global APPName:="ShowKeyBoard", ver:="1.32"
global APPName:="ShowKeyBoard", ver:="1.33"
#include common.ahk
#include langVars.ahk
#Include events.ahk
Expand Down

0 comments on commit 3f4902c

Please sign in to comment.