Skip to content

Commit 89102b0

Browse files
committed
排除锁屏时间,自动刷新昨天的使用时长数据
1 parent fe42a8b commit 89102b0

File tree

11 files changed

+52
-30
lines changed

11 files changed

+52
-30
lines changed

build/release/httpdist/dist/server.js

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

build/showKeyBoard(node).nsi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
; 安装程序初始定义常量
55
!define PRODUCT_NAME $(ToolLang)
6-
!define PRODUCT_VERSION "v1.51"
6+
!define PRODUCT_VERSION "v1.52"
77
!define /date DATESTR "%y%m%d"
88
!define ExeName "showKeyBoard.exe"
99
!define PRODUCT_PUBLISHER "Austin.Young"

build/showKeyBoard.nsi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
; 安装程序初始定义常量
55
!define PRODUCT_NAME $(ToolLang)
6-
!define PRODUCT_VERSION "v1.51"
6+
!define PRODUCT_VERSION "v1.52"
77
!define /date DATESTR "%y%m%d"
88
!define ExeName "showKeyBoard.exe"
99
!define PRODUCT_PUBLISHER "Austin.Young"

common.ahk

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,9 +231,17 @@ mouseDistance := 0
231231
; 全局键盘鼠标统计
232232
globalKeyCount := 0
233233
globalMouseCount := 0
234-
globalAppPath := '' ; 当前激活的窗口路径
235234
GetMinuteDataFlag := False ; 标记正在处理分钟数据
236235
; 主显示器编号
237236
LastScreenNum := MonitorGetPrimary()
238237

239-
global recordHistory := Array() ; 保存按键历史数据
238+
global recordHistory := Array() ; 保存按键历史数据
239+
240+
SystemLocked(){
241+
if (ProcessExist("LogonUI.exe"))
242+
{
243+
return true ; 系统锁定
244+
}else{
245+
return false
246+
}
247+
}

dialog.ahk

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,10 @@ AddRecord(key,isMouse){
509509
; 获取活动窗口的路径
510510
GetProcPath(){
511511
ProcPath := 'NotFoundActive' ; 当没有默认窗口时 SysDefault
512+
if (SystemLocked())
513+
{
514+
return '' ; 系统锁定不检查和记录
515+
}
512516
try {
513517
FocusedHwnd := WinActive("A") ; ControlGetFocus("A") WinExist("A") ;
514518
}catch{
@@ -580,11 +584,11 @@ GetAppInfo(isMouse){
580584
if ProcPath = ''{
581585
return
582586
}
583-
global globalAppPath := ProcPath
587+
AppPath := ProcPath
584588
if isMouse {
585-
appName .= 'Mouse-' globalAppPath
589+
appName .= 'Mouse-' AppPath
586590
}else{
587-
appName .= 'Key-' globalAppPath
591+
appName .= 'Key-' AppPath
588592
}
589593
AddKeyToMap(appName) ; 以应用维度,按键汇总
590594
}

events.ahk

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,8 +240,15 @@ AutoSendData()
240240
StartHttp('data','/data',AllKeyRecord,timeout:=8000)
241241
}
242242
}
243-
244-
SetTimer(AutoSendData,30000) ; 30秒提交一次,防止30秒内无任何按键,从而不发送数据,无法统计分钟数据
243+
; 空闲时候发送数据给后端,距离控制在 GetMinuteDataCore 中实现
244+
AutoSendDataIdle(){
245+
; 锁屏期间不要发送,后续可以考虑计算锁屏时长
246+
if( SystemLocked() ){
247+
return
248+
}
249+
AutoSendData()
250+
}
251+
SetTimer(AutoSendDataIdle,30000) ; 30秒提交一次,防止30秒内无任何按键,从而不发送数据,无法统计分钟数据
245252
; 发送退出数据
246253
ExitServer()
247254
{

http/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"main": "server.js",
3-
"version": "1.51.0",
3+
"version": "1.52.0",
44
"name": "httpserver",
55
"binary": {
66
"module_name": "node_sqlite3",

http/src/records.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -189,15 +189,14 @@ async function doCleanData() {
189189
let lines = await runExec(db, `delete FROM statFreq where freqType = 0 and date < ? `, [beforeDays])
190190
console.log('删除分钟统计条数: ', lines)
191191
// 删除 events 中的旧数据
192-
rows = await runQuery(db, "select date FROM appFreq where freqType = 0 and date < ? limit 1", [beforeDays]) // 获取 appStat 中最老的数据
192+
rows = await runQuery(db, "SELECT MAX(date) AS max_date FROM appStat HAVING max_date < date('now', '-1 day')" ) // 最大日期小于昨天则要汇总数据
193193
if (rows.length > 0) {
194194
// 将数据转移到 appStat表中
195195
lines = mergeAppStat()
196-
// 删除旧数据
197-
lines = await runExec(db, `delete FROM appFreq where freqType = 0 and date < ? `, [beforeDays])
198-
console.log('删除分钟应用条数: ', lines)
199196
}
200-
197+
// 删除旧数据
198+
lines = await runExec(db, `delete FROM appFreq where freqType = 0 and date < ? `, [beforeDays])
199+
console.log('删除分钟应用条数: ', lines)
201200
// statFreq 的 小时日期数据小于昨天 则要进行24小时数据整理函数
202201
rows = await runQuery(db, "SELECT COALESCE(max(date),'1900-00-00') as maxDate FROM statFreq where freqType = 1", [])
203202
let maxDate = rows[0].maxDate;

http/src/version.js

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

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "1.51",
2+
"version": "1.52",
33
"name": "node",
44
"scripts": {
55
"build": "node ./build/buildMain.js"

0 commit comments

Comments
 (0)