From 7f7281355ce48871d7b23563515207e5a3c1de7f Mon Sep 17 00:00:00 2001 From: xingyu Date: Thu, 30 Mar 2023 22:53:24 +0800 Subject: [PATCH] feat: mp statistics init --- src/utils/dateUtil.ts | 50 +++++++++++ .../components/InterfaceSummaryChart.vue | 69 +++++++++++++++ .../components/UpstreamMessageChart.vue | 62 +++++++++++++ .../components/UserCumulateChart.vue | 73 ++++++++++++++++ .../components/UserSummaryChart.vue | 86 +++++++++++++++++++ src/views/mp/statistics/index.vue | 21 ++++- src/views/mp/statistics/statistics.data.ts | 0 7 files changed, 359 insertions(+), 2 deletions(-) create mode 100644 src/views/mp/statistics/components/InterfaceSummaryChart.vue create mode 100644 src/views/mp/statistics/components/UpstreamMessageChart.vue create mode 100644 src/views/mp/statistics/components/UserCumulateChart.vue create mode 100644 src/views/mp/statistics/components/UserSummaryChart.vue create mode 100644 src/views/mp/statistics/statistics.data.ts diff --git a/src/utils/dateUtil.ts b/src/utils/dateUtil.ts index 36b87e34..6b1e8366 100644 --- a/src/utils/dateUtil.ts +++ b/src/utils/dateUtil.ts @@ -14,4 +14,54 @@ export function formatToDate(date?: dayjs.ConfigType, format = DATE_FORMAT): str return dayjs(date).format(format) } +export function beginOfDay(date) { + return new Date(date.getFullYear(), date.getMonth(), date.getDate()) +} + +export function endOfDay(date) { + return new Date(date.getFullYear(), date.getMonth(), date.getDate(), 23, 59, 59, 999) +} + +export function betweenDay(date1, date2) { + date1 = convertDate(date1) + date2 = convertDate(date2) + // 计算差值 + return Math.floor((date2.getTime() - date1.getTime()) / (24 * 3600 * 1000)) +} + +export function formatDate(date, fmt) { + date = convertDate(date) + const o = { + 'M+': date.getMonth() + 1, //月份 + 'd+': date.getDate(), //日 + 'H+': date.getHours(), //小时 + 'm+': date.getMinutes(), //分 + 's+': date.getSeconds(), //秒 + 'q+': Math.floor((date.getMonth() + 3) / 3), //季度 + S: date.getMilliseconds() //毫秒 + } + if (/(y+)/.test(fmt)) { + // 年份 + fmt = fmt.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length)) + } + for (const k in o) { + if (new RegExp('(' + k + ')').test(fmt)) { + fmt = fmt.replace(RegExp.$1, RegExp.$1.length === 1 ? o[k] : ('00' + o[k]).substr(('' + o[k]).length)) + } + } + return fmt +} + +export function addTime(date, time) { + date = convertDate(date) + return new Date(date.getTime() + time) +} + +export function convertDate(date) { + if (typeof date === 'string') { + return new Date(date) + } + return date +} + export const dateUtil = dayjs diff --git a/src/views/mp/statistics/components/InterfaceSummaryChart.vue b/src/views/mp/statistics/components/InterfaceSummaryChart.vue new file mode 100644 index 00000000..4b23df46 --- /dev/null +++ b/src/views/mp/statistics/components/InterfaceSummaryChart.vue @@ -0,0 +1,69 @@ + diff --git a/src/views/mp/statistics/components/UpstreamMessageChart.vue b/src/views/mp/statistics/components/UpstreamMessageChart.vue new file mode 100644 index 00000000..f125a391 --- /dev/null +++ b/src/views/mp/statistics/components/UpstreamMessageChart.vue @@ -0,0 +1,62 @@ + diff --git a/src/views/mp/statistics/components/UserCumulateChart.vue b/src/views/mp/statistics/components/UserCumulateChart.vue new file mode 100644 index 00000000..85bc54cb --- /dev/null +++ b/src/views/mp/statistics/components/UserCumulateChart.vue @@ -0,0 +1,73 @@ + diff --git a/src/views/mp/statistics/components/UserSummaryChart.vue b/src/views/mp/statistics/components/UserSummaryChart.vue new file mode 100644 index 00000000..eb60cb60 --- /dev/null +++ b/src/views/mp/statistics/components/UserSummaryChart.vue @@ -0,0 +1,86 @@ + diff --git a/src/views/mp/statistics/index.vue b/src/views/mp/statistics/index.vue index 3b64cfc4..bf0719ae 100644 --- a/src/views/mp/statistics/index.vue +++ b/src/views/mp/statistics/index.vue @@ -1,3 +1,20 @@ -