Skip to content

Commit

Permalink
配置文件增加 serverExecName 参数,可以用于修改后台服务的进程名,默认为 node.exe
Browse files Browse the repository at this point in the history
解决node10不支持 flat 函数问题
  • Loading branch information
pattazl committed Mar 31, 2024
1 parent 3f4902c commit 37fb4cb
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 13 deletions.
2 changes: 2 additions & 0 deletions build/release/httpdist/dist/showKeyBoard.desc.ini
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ CheckServerMax = 9
; 启动时最大重启尝试连接次数
maxCountOfConnectFail = 60
; 连续通讯失败多少次后提示报错
serverExecName = node.exe
; 后端服务执行程序文件名
[dialog]
guiWidth = 240
; 宽度
Expand Down
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.33"
!define PRODUCT_VERSION "v1.34"
!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.33"
!define PRODUCT_VERSION "v1.34"
!define /date DATESTR "%y%m%d"
!define ExeName "showKeyBoard.exe"
!define PRODUCT_PUBLISHER "Austin.Young"
Expand Down
3 changes: 3 additions & 0 deletions common.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ hideInWinPwd :=DescRead("common","hideInWinPwd", "0" )
statProcInfo :=DescRead("common","statProcInfo", "1" )
; 是否发送按键对应的进程信息,可用于统计不同进程下的按键数
defaultLang :=DescRead("common","defaultLang", "zh-CN" )

; 后端服务执行程序文件名
serverExecName :=DescRead("common","serverExecName", "node.exe" )
; 默认语言
; 配置参数
guiWidth :=DescRead("dialog","guiWidth", 300 ) ; 宽度
Expand Down
6 changes: 3 additions & 3 deletions events.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ GetCommand(procId)
; 启动服务
startServer()
{
cmdExe := 'node.exe ' ; Node命令带空格支持后面的参数
cmdExe := serverExecName ' ' ; Node命令带空格支持后面的参数
cmd := cmdExe '"' httpPath 'server.js"' ; 完整命令行
global serverState :=0 ; 假设启动失败
; 读取 httpPath+ kbserver.pid 进程文件检查是否是node的
Expand All @@ -163,7 +163,7 @@ startServer()
canKill := ((OutDir '\') = httpPath)
}
if canKill {
ProcessClose(iPid) ;如果是 node.exe则杀进程
ProcessClose(iPid) ;如果是 自己的进程则杀进程
}
}
}
Expand All @@ -179,7 +179,7 @@ startServer()
Run cmd,httpPath,ShowFlag, &OutputVarPID
Sleep 1000 ;启动服务需要等待
}catch{
MsgBox msgLaunch
MsgBox msgLaunch "`n" cmd
}
}
; 自动发送 AllKeyRecord 数据
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.33.0",
"version": "1.34.0",
"name": "httpserver",
"binary": {
"module_name": "node_sqlite3",
Expand Down
8 changes: 7 additions & 1 deletion http/src/records.js
Original file line number Diff line number Diff line change
Expand Up @@ -264,13 +264,19 @@ async function getKeymaps() {
return arr
}
// 保存统计的相关配置
function flattenArray(arr) {
return arr.reduce((acc, val) => Array.isArray(val) ? acc.concat(flattenArray(val)) : acc.concat(val), []);
}

async function setDataSetting(hash) {
const db = new sqlite3.Database(dbName);
// 动态保存参数 mapDetail 参数在另外的表中,无需保存
delete hash['mapDetail'];
const placeholders = Object.keys(hash).map(() => '(?, ?)').join(', ');
// 需要将内容全部按数组顺序排列
const values = Object.entries(hash).flat(3); // Infinity 数组展开配置参数表
const entries = Object.entries(hash);
const values = flattenArray(entries); // Infinity 数组展开配置参数表
// const values = Object.entries(hash).flat(3); // Infinity 数组展开配置参数表 node 10不支持 flat
await runExec(db, `INSERT OR REPLACE INTO dataSetting2 (keyname, val) VALUES ${placeholders}`, values)
// 输出记录集
globalTopN = hash.topN
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 = '240307';
const replaceVerNo = '0';
const replaceYYMMDD = '240331';
const replaceVerNo = '1';
// 主版本可从 package.json中获取
const mainVersion = '1.33.0';
const mainVersion = '1.34.0';
const strVersion = mainVersion+'.'+replaceYYMMDD+'.'+replaceVerNo; // 可以支持旧版浏览器
//export default strVersion
module.exports = {strVersion};
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.33.0.0
;@Ahk2Exe-SetFileVersion 1.33.0.0
;@Ahk2Exe-SetProductVersion 1.34.0.0
;@Ahk2Exe-SetFileVersion 1.34.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.33"
global APPName:="ShowKeyBoard", ver:="1.34"
#include common.ahk
#include langVars.ahk
#Include events.ahk
Expand Down

0 comments on commit 37fb4cb

Please sign in to comment.