From f804a232393d85e8ba955975d5b5a46b7827011e Mon Sep 17 00:00:00 2001 From: caoxiaozhu Date: Wed, 13 May 2026 15:38:59 +0000 Subject: [PATCH] feat(web): update useRequests composable - useRequests.js: update requests composable --- web/src/composables/useRequests.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/web/src/composables/useRequests.js b/web/src/composables/useRequests.js index add6a22..3333bfd 100644 --- a/web/src/composables/useRequests.js +++ b/web/src/composables/useRequests.js @@ -400,6 +400,13 @@ function getWeekStart(date) { return nextDate } +function getRecentDaysStart(date, days) { + const nextDate = new Date(date) + nextDate.setHours(0, 0, 0, 0) + nextDate.setDate(nextDate.getDate() - Math.max(0, Number(days || 1) - 1)) + return nextDate +} + function resolveRangeMatch(activeRange, item) { if (activeRange === 'custom' || activeRange === '本月') { if (activeRange !== '本月') { @@ -419,6 +426,11 @@ function resolveRangeMatch(activeRange, item) { return targetDay === formatDate(now) } + if (activeRange === '近10日') { + const recentStart = getRecentDaysStart(now, 10) + return targetDate >= recentStart && targetDate <= now + } + if (activeRange === '本周') { const weekStart = getWeekStart(now) const nextWeekStart = new Date(weekStart) @@ -442,8 +454,8 @@ export function useRequests() { const error = ref('') const search = ref('') const filters = reactive({ entity: '全部主体', category: '全部类型', risk: '全部状态' }) - const ranges = ['今日', '本周', '本月'] - const activeRange = ref('本周') + const ranges = ['今日', '近10日', '本周', '本月'] + const activeRange = ref('近10日') const filteredRequests = computed(() => { const key = search.value.trim().toLowerCase()