refactor(sj_1.1.0_beta1): 优化默认时间获取方法
This commit is contained in:
parent
9e1bc3c9f5
commit
9fa5bf4bed
@ -1,4 +1,5 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import dayjs from 'dayjs';
|
||||||
import { ref, watch } from 'vue';
|
import { ref, watch } from 'vue';
|
||||||
|
|
||||||
defineOptions({
|
defineOptions({
|
||||||
@ -39,18 +40,9 @@ watch(
|
|||||||
);
|
);
|
||||||
|
|
||||||
function getDefaultDate(): [number, number] {
|
function getDefaultDate(): [number, number] {
|
||||||
const today = new Date();
|
const endOfDayTimestamp = dayjs().endOf('day').valueOf();
|
||||||
const endOfDay = new Date(today.getFullYear(), today.getMonth(), today.getDate(), 23, 59, 59);
|
const startOfDayOneMonthAgoTimestamp = dayjs().subtract(1, 'month').startOf('day').valueOf();
|
||||||
const oneMonthAgo = new Date(today.getFullYear(), today.getMonth() - 1, today.getDate());
|
return [endOfDayTimestamp, startOfDayOneMonthAgoTimestamp];
|
||||||
const startOfDayOneMonthAgo = new Date(
|
|
||||||
oneMonthAgo.getFullYear(),
|
|
||||||
oneMonthAgo.getMonth(),
|
|
||||||
oneMonthAgo.getDate(),
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0
|
|
||||||
);
|
|
||||||
return [startOfDayOneMonthAgo.getTime(), endOfDay.getTime()];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function initDefaultDate() {
|
function initDefaultDate() {
|
||||||
|
Loading…
Reference in New Issue
Block a user