mirror of
https://github.com/fofolee/uTools-quickcommand.git
synced 2025-06-30 04:42:45 +08:00
使用统计以及历史数据处理
This commit is contained in:
parent
4fd73def58
commit
696e6398cb
64
src/App.vue
64
src/App.vue
@ -53,6 +53,8 @@ export default defineComponent({
|
|||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
startUp() {
|
startUp() {
|
||||||
|
// 处理旧版本数据
|
||||||
|
this.v2DataHandler();
|
||||||
// 读取用户配置
|
// 读取用户配置
|
||||||
let userProfile = this.utools.getDB(
|
let userProfile = this.utools.getDB(
|
||||||
this.utools.DBPRE.CFG + "preferences"
|
this.utools.DBPRE.CFG + "preferences"
|
||||||
@ -76,6 +78,8 @@ export default defineComponent({
|
|||||||
this.setCssVar("primary", this.profile.primaryColor);
|
this.setCssVar("primary", this.profile.primaryColor);
|
||||||
},
|
},
|
||||||
enterPlugin(enter) {
|
enterPlugin(enter) {
|
||||||
|
// 使用情况统计
|
||||||
|
this.usageStatistics(enter.code, this.parseDate(new Date()));
|
||||||
this.$q.dark.set(utools.isDarkColors());
|
this.$q.dark.set(utools.isDarkColors());
|
||||||
quickcommand.enterData = enter;
|
quickcommand.enterData = enter;
|
||||||
quickcommand.payload = enter.payload;
|
quickcommand.payload = enter.payload;
|
||||||
@ -117,6 +121,66 @@ export default defineComponent({
|
|||||||
window.runCodeFile(command.cmd, option, false, () => {});
|
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>
|
</script>
|
||||||
|
@ -10,7 +10,8 @@ let whole = window.utools
|
|||||||
const DBPRE = {
|
const DBPRE = {
|
||||||
QC: 'qc_',
|
QC: 'qc_',
|
||||||
CFG: 'cfg_',
|
CFG: 'cfg_',
|
||||||
PAN: 'pan_'
|
PAN: 'pan_',
|
||||||
|
STATUS: 'st_'
|
||||||
}
|
}
|
||||||
|
|
||||||
// 数据库函数封装
|
// 数据库函数封装
|
||||||
|
Loading…
x
Reference in New Issue
Block a user