Skip to content

Commit

Permalink
修正前端异常通讯提示处理
Browse files Browse the repository at this point in the history
  • Loading branch information
pattazl committed Mar 5, 2024
1 parent 1d6f49b commit c76a7f9
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 23 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.31"
!define PRODUCT_VERSION "v1.32"
!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.31"
!define PRODUCT_VERSION "v1.32"
!define /date DATESTR "%y%m%d"
!define ExeName "showKeyBoard.exe"
!define PRODUCT_PUBLISHER "Austin.Young"
Expand Down
1 change: 1 addition & 0 deletions common.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ global maxBottom := 0
global ctrlKeyCount := 0
global repeatRecord := 0

global countOfConnectFail := 0
; 获取1970年开始的时间戳
AllKeyRecord['tick'] := DateDiff(A_NowUTC, '19700101', 'Seconds')*1000 + A_MSec ; tick数据不一样表示程序重启过,需要累计计数

Expand Down
4 changes: 2 additions & 2 deletions events.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ CheckServer(){

}
; 服务核心处理
countOfConnectFail := 0
ServerCore()
{
state := HttpCtrlObj['state'] ; 此值会随时变化,先记录下
Expand Down Expand Up @@ -111,10 +110,11 @@ ServerCore()
}
}else{
; 常规数据发送处理
global countOfConnectFail
if state !='succ'{
ShowTxt HttpCtrlObj['task'] ',connect fail!' ; 可能后端服务被关闭了
OutputDebug 'connect fail'
global countOfConnectFail += 1
countOfConnectFail += 1
if(countOfConnectFail >= maxCountOfConnectFail){
MsgBox msgTry countOfConnectFail msgTimes msgConnectFail
countOfConnectFail := 0 ; 成功一次则复位
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.31.0",
"version": "1.32.0",
"name": "httpserver",
"binary": {
"module_name": "node_sqlite3",
Expand Down
23 changes: 12 additions & 11 deletions http/src/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -607,14 +607,14 @@ function autoBackup() {
let lastBackUp = backupPath + getDateStr(0, 'day')
if (days > 0) {
// 清理 days前的文件
let maxFile = ''
let beforeStr = getDateStr(days, 'day')
fs.readdir(backupPath, (err, files) => {
if (err) {
console.error('无法读取文件夹内容', err);
return;
}
// 遍历文件列表
let maxFile = ''
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)) {
Expand All @@ -633,18 +633,19 @@ function autoBackup() {
// 取符合格式的最大文件名
maxFile = file > maxFile ? file : maxFile
});
// backup 下保存文件
let minBackUp = backupPath + getDateStr(3, 'minutes') // 备份时间间隔需要小于3分钟,防止持续重复备份
// 只有当前备份的时间大于已经备份的最大时间 3分钟
if (minBackUp > maxFile) {
zipCore(function (content) {
// see FileSaver.js
fs.writeFileSync(lastBackUp, content);
})
});
});
// backup 下保存文件
let minBackUp = backupPath + getDateStr(3, 'minutes') // 备份时间间隔需要小于3分钟,防止持续重复备份
// 只有当前备份的时间大于已经备份的最大时间 3分钟
if (minBackUp > maxFile) {
zipCore(function (content) {
// see FileSaver.js
fs.writeFileSync(lastBackUp, content);
})
}
}
}
}

module.exports = {
startUp, getParaFun, setParaFun, app, dataFun, exitFun, sendPCInfo, saveLastData, optKeymapFun,
deleteDataFun, zipDownload, zipUpload
Expand Down
2 changes: 2 additions & 0 deletions http/src/records.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,8 @@ async function getDataSetting() {
rows.forEach(r => {
dataSetting[r.keyname] = r.val
})
globalTopN = dataSetting.topN??globalTopN
globalAppTopN = dataSetting.appTopN??globalAppTopN
return dataSetting
// 关闭数据库连接
}
Expand Down
6 changes: 3 additions & 3 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 = '240215';
const replaceVerNo = '1';
const replaceYYMMDD = '240305';
const replaceVerNo = '0';
// 主版本可从 package.json中获取
const mainVersion = '1.31.0';
const mainVersion = '1.32.0';
const strVersion = mainVersion+'.'+replaceYYMMDD+'.'+replaceVerNo; // 可以支持旧版浏览器
//export default strVersion
module.exports = {strVersion};
2 changes: 1 addition & 1 deletion langVars.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ global msgTry := '尝试'
global msgTimes := '次,'
global msgLaunch := '无法启动Node,请确保已经安装node环境或使用非node的安装包'
global msgLaunchSucc := '启动服务成功!'
global msgConnectFail:= '后台服务无法连接,请重启应用!'
global msgConnectFail:= '后台服务无法连接,请检查或重启应用!'
if defaultLang = 'en-US' {
L_menu_startup:="Auto Start"
L_menu_reload :="Reset Client"
Expand Down
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.31.0.0
;@Ahk2Exe-SetFileVersion 1.31.0.0
;@Ahk2Exe-SetProductVersion 1.32.0.0
;@Ahk2Exe-SetFileVersion 1.32.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.31"
global APPName:="ShowKeyBoard", ver:="1.32"
#include common.ahk
#include langVars.ahk
#Include events.ahk
Expand Down

0 comments on commit c76a7f9

Please sign in to comment.