Skip to content

Commit 2625e14

Browse files
committed
完善多设备备份和恢复机制,每分钟检查是否有新设备文件产生,修改相关说明文档
1 parent 3396cfc commit 2625e14

File tree

7 files changed

+106
-56
lines changed

7 files changed

+106
-56
lines changed

README_CN.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
9. 实时显示控制键/状态键状态,包括大小写状态,scroll状态,数字键,Ctrl,Shift,Atl等键。
1616
10. 显示最近N个按键(不保存)
1717
11. 支持游戏手柄摇杆和按键检测
18+
12. 支持通过第三方工具(推荐FreeFileSync)实现多台设备记录的同步
1819

1920
## 系统要求
2021

@@ -43,6 +44,18 @@
4344
3. 有些公司可能安装了加密软件,将对配置文件进行加密,将导致参数全部失效,此时可以修改安装目录下的 `./httpdist/dist/node.exe` 重命名为 `./httpdist/dist/chrome.exe`(策略允许) ,修改安装目录的 showKeyBoard.ini 文件,增加参数` serverExecName=./httpdist/dist/chrome.exe`
4445
4. 如果系统时间不正确,比如某一天的时间变成了N年后,可能导致之后的应用时长数据丢失,请运行安装目录的 fixStat修复统计数据.bat
4546

47+
### 同步说明
48+
49+
此处以 FreeFileSync 同步FTP举例
50+
51+
1. 首先设定共享文件的保存目录,默认为安装目录下的 **share**
52+
2. 在 FreeFileSync 中配置本地share 和 FTP服务器双向同步,将同步文件生成为 ffs_batch文件,比如 Keyboard.ffs_batch
53+
3. 设定"**生成共享文件间隔小时数**" ,表示每隔多久将本地的记录打包
54+
4. 设置打包完成后自动执行的命令,如果安装了 FreeFileSync ,则可以直接执行 ffs_batch文件,比如命令可配置为上面的 Keyboard.ffs_batch
55+
5. 共享名默认为计算机名,可自行更改,将会在 历史和统计模块显示
56+
6. 系统每分钟会检查 共享文件目录的文件,解压到**dbs**目录中,如果有更新则会重新解压
57+
7. 在 历史和统计模块 可选择和查看本地解压后的其他设备的记录
58+
4659
## 截图演示
4760

4861
![实时显示按键状态和内容](screenshot/%E5%AE%9E%E6%97%B6%E6%98%BE%E7%A4%BA%E6%8C%89%E9%94%AE%E7%8A%B6%E6%80%81%E5%92%8C%E5%86%85%E5%AE%B9.gif)

build/release/httpdist/dist/server.js

Lines changed: 39 additions & 39 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

common.ahk

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,11 @@ ReadAllIni() {
138138

139139
global recordHistoryMax,recordHistoryMax := DescRead("common", "recordHistoryMax", "50")
140140

141+
global shareDbPath,shareDbPath := DescRead("common", "shareDbPath", "")
142+
global shareDbName,shareDbName := DescRead("common", "shareDbName", "")
143+
global shareDbHour,shareDbHour := DescRead("common", "shareDbHour", "")
144+
global shareDbExec,shareDbExec := DescRead("common", "shareDbExec", "")
145+
141146
; 配置参数
142147
global guiWidth,guiWidth := DescRead("dialog", "guiWidth", 300) ; 宽度
143148
global guiHeigth,guiHeigth := DescRead("dialog", "guiHeigth", 0) ;高度 0 为自动高度

events.ahk

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,33 @@ if(needRecordKey=1){
66
; 启动可能需要花费一些时间,CheckServer进行重复判断
77
CheckServer()
88
}
9+
; 定义哪些变量是重要变量,发生改变后返回true
10+
CriticalChange(){
11+
importantList := [
12+
[serverPort,"common","serverPort"],
13+
[remoteType,"common","remoteType"],
14+
[showHttpDebug,"common","showHttpDebug"],
15+
[joyMethod,"common","joyMethod"],
16+
[shareDbPath,"common","shareDbPath"],
17+
[shareDbName,"common","shareDbName"],
18+
[shareDbHour,"common","shareDbHour"],
19+
[shareDbExec,"common","shareDbExec"],
20+
]
21+
for index, item in importantList {
22+
; 解析数组项:[变量值, 节名, 键名]
23+
currentValue := item[1]
24+
section := item[2]
25+
key := item[3]
26+
; 从INI文件读取值
27+
iniValue := IniRead(IniFile,section, key, "")
28+
; 比较值是否一致(注意类型转换问题)
29+
if (currentValue != iniValue) {
30+
; 发现不一致,返回true
31+
return true
32+
}
33+
}
34+
return false
35+
}
936
; 设置检测间隔,单位为毫秒
1037
; SetTimer IniMonitor,2000 ; websoket 代替
1138
; 此函数改为重新读取参数配置文件参数
@@ -14,14 +41,10 @@ IniMonitor(reloadAll){
1441
if not FileExist(IniFile){
1542
return
1643
}
17-
; modified := FileGetTime(IniFile)
18-
; if (modified != lastModified)
1944
; 如果端口发生了变化则需要完全重启
2045
; OutputDebug('AHK IniMonitor')
21-
newPort :=IniRead(IniFile,"common","serverPort",9900 )
22-
newRemoteType :=IniRead(IniFile,"common","remoteType",1 )
23-
newShowHttpDebug :=IniRead(IniFile,"common","showHttpDebug",0 )
24-
if newPort != serverPort || newRemoteType != remoteType || newShowHttpDebug != showHttpDebug
46+
; 核心的,需要重启前后台服务的变量控制
47+
if CriticalChange()
2548
{
2649
ExitServer()
2750
if serverState = 1 {

http/src/shareDb.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ function autoShare() {
1414
let hour = config.common.shareDbHour
1515
if (hour > 0) {
1616
autoShareCore()
17-
setInterval(autoShareCore, 10000); // 10s定时检查
17+
setInterval(autoShareCore, 60000); // 每分钟定时检查
1818
}
1919
}
2020
// 需要记录 已经解压的文件清单时间,如果变化才重新解压覆盖
@@ -61,9 +61,9 @@ async function autoShareCore() {
6161
doExec(cmdLine)
6262
}
6363
}, true)
64-
// 解压共享文件
65-
await unzipShared(shareFilePath)
6664
}
65+
// 解压共享文件
66+
await unzipShared(shareFilePath)
6767
}
6868

6969
async function unzipShared(shareFilePath) {
@@ -155,7 +155,9 @@ function doExec(command)
155155
{
156156
// 开启子进程执行命令
157157
console.log(`${new Date()}-exec command: ${command}`);
158-
const child = exec(command, (error, stdout, stderr) => {
158+
const child = exec(command, {
159+
cwd: basePath
160+
}, (error, stdout, stderr) => {
159161
if (error) {
160162
console.error(`exec error: ${error.message}`);
161163
return;

http/src/version.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
* @version 配置显示在登录页面的前端版本,格式为 v.主版本号.次版本号.日期.小版本序号 v1.0.190827.1
33
*/
44
// 对于发布版 YYMMDD 和 verNo 会在Webpack中自动替换为真实的日期和版本序号,如下格式不能随便改,参考vue.config.js的代码
5-
const replaceYYMMDD = '250903';
6-
const replaceVerNo = '8';
5+
const replaceYYMMDD = '250904';
6+
const replaceVerNo = '2';
77
// 主版本可从 package.json中获取
88
const mainVersion = '1.50.0';
99
const strVersion = mainVersion+'.'+replaceYYMMDD+'.'+replaceVerNo; // 可以支持旧版浏览器

readme.md

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
9. Display the status of control keys/status keys in real-time, including the status of the Caps Lock, Scroll Lock, Num Lock keys, as well as the Ctrl, Shift, and Alt keys.
1616
10. Show the last N keystrokes (not saved)
1717
11. Support gamepad joystick and button detection.
18+
12. Support the synchronization of multiple device records through third-party tools (FreeFileSync is recommended)
1819

1920
## System Requirements
2021

@@ -39,16 +40,22 @@ Follow the prompts to select during installation, such as whether to keep the co
3940

4041
**Note**:
4142
1. Due to the use of system hooks, some computers may report viruses by mistake and need to be trusted.
42-
4343
2. On some systems, you may need to run in administrator mode, otherwise showKeyBoard will not be able to listen to the keys
44-
4544
3. Some companies may have installed encryption software, which will encrypt the configuration files, causing all parameters to become invalid. In this case, you can rename `./httpdist/dist/node.exe` in the installation directory to `./httpdist/dist/chrome.exe`, and modify the `showKeyBoard.ini` file in the installation directory by adding the parameter `serverExecName=./httpdist/dist/chrome.exe`.
46-
4745
4. If the system time is incorrect, for example, the time of a certain day changes to N years later, it may lead to the loss of application usage duration data. Please run the `fixStat修复统计数据.bat` file in the installation directory.
4846

49-
47+
### Synchronization
48+
Here is an example of FreeFileSync synchronization FTP
49+
50+
1. First set the directory where shared files are saved. The default directory is share in the installation directory
51+
2. Configure synchronization between local share and FTP server in FreeFileSync, and generate the synchronization file as ffs_batch file, such as Keyboard.ffs_batch
52+
3. Set the **Interval hours for generating shared files** to indicate how often local records are packaged
53+
4. Set the command to be automatically executed after packaging. If FreeFileSync is installed, you can directly execute the ffs_batch file. For example, the command can be configured as Keyboard.ffs_batch above
54+
5. The share name defaults to the computer name, which can be changed by itself and will be displayed in the history and statistics module
55+
6. The system will check the files in the shared file directory every minute and decompress them to the **dbs** directory. If there are updates, they will be decompressed again
56+
7. In the history and statistics module, you can select and view the records of other devices after local decompression
5057

51-
分享
58+
分享
5259

5360
## Screenshot
5461

0 commit comments

Comments
 (0)