使用统计以及历史数据处理

This commit is contained in:
fofolee 2022-04-19 11:25:09 +08:00
parent 4fd73def58
commit 696e6398cb
2 changed files with 66 additions and 1 deletions

View File

@ -53,6 +53,8 @@ export default defineComponent({
return true;
},
startUp() {
//
this.v2DataHandler();
//
let userProfile = this.utools.getDB(
this.utools.DBPRE.CFG + "preferences"
@ -76,6 +78,8 @@ export default defineComponent({
this.setCssVar("primary", this.profile.primaryColor);
},
enterPlugin(enter) {
// 使
this.usageStatistics(enter.code, this.parseDate(new Date()));
this.$q.dark.set(utools.isDarkColors());
quickcommand.enterData = enter;
quickcommand.payload = enter.payload;
@ -117,6 +121,66 @@ export default defineComponent({
window.runCodeFile(command.cmd, option, false, () => {});
}
},
usageStatistics(featureCode, runTime) {
let statisticsData = this.utools.getDB(
this.utools.DBPRE.CFG + "statisticsData"
);
let thisYear = runTime.year;
if (!statisticsData[thisYear]) statisticsData[thisYear] = [];
statisticsData[thisYear].push({
code: featureCode,
time: {
month: runTime.month,
day: runTime.day,
hour: runTime.hour,
minute: runTime.minute,
},
});
this.utools.putDB(
statisticsData,
this.utools.DBPRE.CFG + "statisticsData"
);
},
parseDate: (dateString) => {
return {
year: dateString.getFullYear(),
month: dateString.getMonth() + 1,
day: dateString.getDate(),
hour: dateString.getHours(),
minute: dateString.getMinutes(),
second: dateString.getSeconds(),
};
},
v2DataHandler() {
let v2DataHandled = this.utools.whole.dbStorage.getItem(
this.utools.DBPRE.STATUS + "v2DataHandled"
);
if (v2DataHandled) return;
//
let statisticsData = this.utools.getDB(
this.utools.DBPRE.CFG + "statisticsData"
);
_.forIn(statisticsData, (data, year) => {
statisticsData[year] = data.map((x) => {
let code =
x.command.code === "options" ? "configuration" : x.command.code;
return {
code: code,
time: x.time,
};
});
});
this.utools.putDB(
statisticsData,
this.utools.DBPRE.CFG + "statisticsData"
);
//
// ...
this.utools.whole.dbStorage.setItem(
this.utools.DBPRE.STATUS + "v2DataHandled",
true
);
},
},
});
</script>

View File

@ -10,7 +10,8 @@ let whole = window.utools
const DBPRE = {
QC: 'qc_',
CFG: 'cfg_',
PAN: 'pan_'
PAN: 'pan_',
STATUS: 'st_'
}
// 数据库函数封装