perf: 数据看板支持选择时间粒度

This commit is contained in:
CaIon
2024-01-13 00:33:52 +08:00
parent d30b9321b2
commit 00306aa142
7 changed files with 132 additions and 65 deletions

View File

@@ -171,7 +171,7 @@ export function timestamp2string(timestamp) {
);
}
export function timestamp2string1(timestamp) {
export function timestamp2string1(timestamp, dataExportDefaultTime = 'hour') {
let date = new Date(timestamp * 1000);
// let year = date.getFullYear().toString();
let month = (date.getMonth() + 1).toString();
@@ -186,15 +186,22 @@ export function timestamp2string1(timestamp) {
if (hour.length === 1) {
hour = '0' + hour;
}
return (
// year +
// '-' +
month +
'-' +
day +
' ' +
hour + ":00"
);
let str = month + '-' + day
if (dataExportDefaultTime === 'hour') {
str += ' ' + hour + ":00"
} else if (dataExportDefaultTime === 'week') {
let nextWeek = new Date(timestamp * 1000 + 6 * 24 * 60 * 60 * 1000);
let nextMonth = (nextWeek.getMonth() + 1).toString();
let nextDay = nextWeek.getDate().toString();
if (nextMonth.length === 1) {
nextMonth = '0' + nextMonth;
}
if (nextDay.length === 1) {
nextDay = '0' + nextDay;
}
str += ' - ' + nextMonth + '-' + nextDay
}
return str;
}
export function downloadTextAsFile(text, filename) {