Skip to content

Commit

Permalink
解决应用计数被重复计算的bug,重新发布1.20
Browse files Browse the repository at this point in the history
  • Loading branch information
pattazl committed Nov 6, 2023
1 parent 38c0480 commit 78b2d3c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 19 deletions.
39 changes: 21 additions & 18 deletions ui-helper/src/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ async function ajax(path, data = null) {
return result
}
// 布尔类型清单,bool list
const boolArr = ['skipCtrlKey', 'recordMouseMove', 'needShowKey', 'needRecordKey', 'ctrlState', 'guiBgTrans',
'guiTrans', 'guiEdge', 'guiDpiscale', 'showHttpDebug', 'hideInWinPwd','mergeControl','fillDate','statProcInfo',
'mergeAppName']
const boolArr = ['skipCtrlKey', 'recordMouseMove', 'needShowKey', 'needRecordKey', 'ctrlState', 'guiBgTrans',
'guiTrans', 'guiEdge', 'guiDpiscale', 'showHttpDebug', 'hideInWinPwd', 'mergeControl', 'fillDate', 'statProcInfo',
'mergeAppName']
// 转换字符串为数字或boolean
function str2Type(hash, flag) {
for (let k in hash) {
Expand Down Expand Up @@ -104,7 +104,7 @@ function setWS(callback) {
};
}
function closeWS() {
if(socket!=null){
if (socket != null) {
socket.close()
socket = null
}
Expand All @@ -130,30 +130,33 @@ function showAppChart(leftKey, keyStatHash, opt, chart, mergeApp) {
arrRemove(leftKey, appArr) // 清除应用信息
// 所有应用的数组清单
//let newSet = new Set<string>(); let nameList = Array.from(newSet)
let myList = [] /**用于过滤唯一应用名 */, myHash = [] /**用于图形 */, retArr= [] /**用于表格 */;
let myList = [] /**用于过滤唯一应用名 */, myHash = [] /**用于图形 */, retArr = [] /**用于表格 */;
let appSet = new Set<string>(); // 保存唯一APP名
appArr.forEach(x => {
let appName = x.replace(/^(App-Mouse-|App-Key-)/, '');
appSet.add(appName)
})
appSet.forEach(appName => {
let mouse = keyStatHash['App-Mouse-' + appName] ?? 0
let key = keyStatHash['App-Key-' + appName] ?? 0
let total = mouse + key
// 如果能找到且需要合并名称
if(mergeApp!=null)
{
appName = mergeApp[appName]??appName
if (mergeApp != null) {
appName = mergeApp[appName] ?? appName
}
if (myList.indexOf(appName) == -1) {
// 不存在就插入,并找对应的鼠标和键盘信息
myList.push(appName)
retArr.push({appPath:appName,keyType:'Keyboard',keyCount:key})
retArr.push({appPath:appName,keyType:'Mouse',keyCount:mouse})
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{
} 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)
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
Expand Down Expand Up @@ -252,14 +255,14 @@ function railStyle({
return style
}
// 应用程序名转换为显示名
function appPath2Name(val,map){
function appPath2Name(val, map) {
let newName = map[val] ?? val.split(/[\\\/]/).pop().replace(/\.exe$/i, '')
if(newName.length>20){
newName = newName.substring(0,18)+'...'
if (newName.length > 20) {
newName = newName.substring(0, 18) + '...'
}
return newName
}
export {
deepCopy, ajax, splitArr, str2Type, setWS, arrRemove, getHistory, getServer,
getKeyDesc, showLeftKey, railStyle, showAppChart,appPath2Name,closeWS
getKeyDesc, showLeftKey, railStyle, showAppChart, appPath2Name, closeWS
}
2 changes: 1 addition & 1 deletion ui-helper/src/version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @version 配置显示在登录页面的前端版本,格式为 v.主版本号.次版本号.日期.小版本序号 v1.0.190827.1
*/
// 对于发布版 YYMMDD 和 verNo 会在Webpack中自动替换为真实的日期和版本序号,如下格式不能随便改,参考vue.config.js的代码
const replaceYYMMDD = '231106';
const replaceYYMMDD = '231107';
const replaceVerNo = '0';
const mainVersion = ' v1.20';
const strVersion = mainVersion+'.'+replaceYYMMDD+'.'+replaceVerNo; // 可以支持旧版浏览器
Expand Down

0 comments on commit 78b2d3c

Please sign in to comment.