Skip to content

Commit

Permalink
1. 增加相同名称合并统计的功能 2. 支持历史数据按范围合并统计 3. 柱状图支持缩放 v1.20
Browse files Browse the repository at this point in the history
  • Loading branch information
pattazl committed Nov 6, 2023
1 parent 9f48813 commit 38c0480
Show file tree
Hide file tree
Showing 9 changed files with 74 additions and 35 deletions.
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.19"
!define PRODUCT_VERSION "v1.20"
!define /date DATESTR "%y%m%d"
!define ExeName "showKeyBoard.exe"
!define PRODUCT_PUBLISHER "Austin.Young"
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.16.0",
"version": "1.20.0",
"name": "httpserver",
"binary": {
"module_name": "node_sqlite3",
Expand Down
4 changes: 2 additions & 2 deletions http/src/records.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ function getRecords(begin, end) {
sql = 'SELECT keyname, keycount, date, tick FROM events where date between ? and ?'
} else {
if(begin == end){
sql = 'SELECT keyname, keycount, date FROM stat where date = ? '
sql = 'SELECT keyname, keycount, date FROM stat where date between ? and ? '
}else{
sql = 'SELECT keyname, sum(keycount), min(date) FROM stat where date between ? and ? group by keyname '
sql = 'SELECT keyname, sum(keycount) as keycount, min(date) as date FROM stat where date between ? and ? group by keyname '
}
// sql = 'SELECT keyname, keycount, date FROM stat where date between ? and ? '
}
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 = '231029';
const replaceVerNo = '0';
const replaceYYMMDD = '231106';
const replaceVerNo = '1';
// 主版本可从 package.json中获取
const mainVersion = '1.16.0';
const mainVersion = '1.20.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.19.0.0
;@Ahk2Exe-SetFileVersion 1.19.0.0
;@Ahk2Exe-SetProductVersion 1.20.0.0
;@Ahk2Exe-SetFileVersion 1.20.0.0
;@Ahk2Exe-SetCopyright Austing.Young (2023 - )
;@Ahk2Exe-SetMainIcon res\keyboard.ico
;@Ahk2Exe-ExeName build/ShowKeyBoard.exe
#Requires AutoHotkey v2
#SingleInstance Ignore
global APPName:="ShowKeyBoard", ver:="1.19"
global APPName:="ShowKeyBoard", ver:="1.20"
#include "common.ahk"
#Include events.ahk
; 正式代码开始
Expand Down
26 changes: 17 additions & 9 deletions ui-helper/src/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,30 +125,38 @@ function arrRemove(arr /*out */, key) {
})
}
// 控制应用图形显示,将 leftKey 中 App-开头的按键剥离出去
function showAppChart(leftKey, keyStatHash, opt, chart) {
function showAppChart(leftKey, keyStatHash, opt, chart, mergeApp) {
let appArr = leftKey.filter(x => x.indexOf('App-') > -1)
arrRemove(leftKey, appArr) // 清除应用信息
// 所有应用的数组清单
//let newSet = new Set<string>(); let nameList = Array.from(newSet)
let myList = [], myHash = [], retArr= [];
let myList = [] /**用于过滤唯一应用名 */, myHash = [] /**用于图形 */, retArr= [] /**用于表格 */;
appArr.forEach(x => {
let appName = x.replace(/^(App-Mouse-|App-Key-)/, '');
let mouse = keyStatHash['App-Mouse-' + appName] ?? 0
let key = keyStatHash['App-Key-' + appName] ?? 0
let keyType = 'Keyboard'
let keyCount = key
if(/^App-Mouse-/.test(x)){
keyType = 'Mouse'
keyCount = mouse
let total = mouse + key
// 如果能找到且需要合并名称
if(mergeApp!=null)
{
appName = mergeApp[appName]??appName
}
retArr.push({appPath:appName,keyType,keyCount})
if (myList.indexOf(appName) == -1) {
// 不存在就插入,并找对应的鼠标和键盘信息
myList.push(appName)
let total = mouse + key
retArr.push({appPath:appName,keyType:'Keyboard',keyCount:key})
retArr.push({appPath:appName,keyType:'Mouse',keyCount:mouse})
// 如果没有预先匹配则取文件名
// let appPath = appName.replace(/^App-/,'')
myHash.push({ appName, mouse, key, total })
}else{
// 需要叠加数据
retArr.find(x=>x.appPath == appName&&x.keyType == 'Keyboard').keyCount +=key
retArr.find(x=>x.appPath == appName&&x.keyType == 'Mouse').keyCount +=mouse
let obj = myHash.find(x=>x.appName == appName)
obj.mouse += mouse
obj.key += key
obj.total += total
}
})
// 对 myHash 进行排序
Expand Down
49 changes: 36 additions & 13 deletions ui-helper/src/components/dataui/History.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@
{{ contentText.intro112 }}
<n-select v-model:value="beginDate" filterable :options="historyDate" @update:value="handleUpdateValue" />

<n-switch :round="false" :rail-style="railStyle" v-model:value="showEndDate" >
<template #unchecked>
{{ contentText.intro159 }}
</template>
<template #checked>
{{ contentText.intro160 }}
</template>
</n-switch>
<n-select v-show="showEndDate" v-model:value="endDate" filterable :options="historyDate" @update:value="handleUpdateValue" />
<n-switch :round="false" :rail-style="railStyle" v-model:value="showEndDate" @update:value="endDate = beginDate">
<template #unchecked>
{{ contentText.intro159 }}
</template>
<template #checked>
{{ contentText.intro160 }}
</template>
</n-switch>
<n-select v-show="showEndDate" v-model:value="endDate" filterable :options="historyDate"
@update:value="handleUpdateValue" />
</n-space>


Expand Down Expand Up @@ -62,7 +63,8 @@ import {
GridComponent,
DatasetComponent,
TransformComponent,
VisualMapComponent
VisualMapComponent,
DataZoomComponent,
} from 'echarts/components';
// 标签自动布局、全局过渡动画等特性
import { LabelLayout, UniversalTransition } from 'echarts/features';
Expand All @@ -82,6 +84,7 @@ echarts.use([
CanvasRenderer,
HeatmapChart,
VisualMapComponent,
DataZoomComponent,
BarChart,
]);
Expand Down Expand Up @@ -208,6 +211,13 @@ let option2 = {
type: 'value'
}
],
dataZoom: [
{
show: true,
startValue: 0,
endValue: 14 // 前15个数据
}
],
series: [
{
name: 'Mouse',
Expand Down Expand Up @@ -407,7 +417,20 @@ export default defineComponent({
]
}
async function handleUpdateValue(value) {
historyData = await getHistory(value, value)
// console.log(value, beginDate.value, endDate.value)
let b = beginDate.value, e = b;
if (showEndDate.value) {
if (beginDate.value > endDate.value) {
if (value == endDate.value) {
endDate.value = beginDate.value
} else {
beginDate.value = endDate.value
}
}
b = beginDate.value
e = endDate.value
}
historyData = await getHistory(b, e)
let keyStatHash = getHash('')
showHash(keyStatHash)
}
Expand Down Expand Up @@ -444,7 +467,8 @@ export default defineComponent({
arrRemove(leftKey, 'tick'); // 去掉
arrRemove(leftKey, 'mouseDistance'); // 去掉
// 显示 chart2
appListData.value = showAppChart(leftKey, keyStatHash, option2, myChart2);
appListData.value = showAppChart(leftKey, keyStatHash, option2, myChart2
, store.data.dataSetting.mergeAppName ? appNameListMap : null);
//leftKey.sort((a, b) => keyStatHash[b] - keyStatHash[a]) // 排序
//let leftKeyVal = []
//leftKey.forEach(k => leftKeyVal.push(k + ' : ' + keyStatHash[k]))
Expand Down Expand Up @@ -484,7 +508,6 @@ export default defineComponent({
historyDate.value = dateArr.map((x) => {
return { label: x, value: x }
})
endDate.value = dateArr[0]??''
if (dateArr.length > 0) {
beginDate.value = dateArr[0];// 设置选择第一个
handleUpdateValue(dateArr[0])
Expand Down
10 changes: 9 additions & 1 deletion ui-helper/src/components/dataui/Today.vue
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,13 @@ let option2 = {
type: 'value'
}
],
dataZoom: [
{
show: true,
startValue: 0,
endValue: 14 // 前15个数据
}
],
series: [
{
name: 'Mouse',
Expand Down Expand Up @@ -537,7 +544,8 @@ export default defineComponent({
arrRemove(leftKey, 'tick'); // 去掉
arrRemove(leftKey, 'mouseDistance'); // 去掉
// 显示 chart2
appListData.value = showAppChart(leftKey, keyStatHash, option2, myChart2);
appListData.value = showAppChart(leftKey, keyStatHash, option2, myChart2
,store.data.dataSetting.mergeAppName?appNameListMap:null);
/**const appListData0 = [
{ appPath: 'c:/123',
keyCount: 32,
Expand Down
4 changes: 2 additions & 2 deletions ui-helper/src/version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
* @version 配置显示在登录页面的前端版本,格式为 v.主版本号.次版本号.日期.小版本序号 v1.0.190827.1
*/
// 对于发布版 YYMMDD 和 verNo 会在Webpack中自动替换为真实的日期和版本序号,如下格式不能随便改,参考vue.config.js的代码
const replaceYYMMDD = '231031';
const replaceYYMMDD = '231106';
const replaceVerNo = '0';
const mainVersion = ' v1.17';
const mainVersion = ' v1.20';
const strVersion = mainVersion+'.'+replaceYYMMDD+'.'+replaceVerNo; // 可以支持旧版浏览器
//export default strVersion
export {strVersion};

0 comments on commit 38c0480

Please sign in to comment.