From 8f63d53b734eb9a8b8464c5722e412536bab65c6 Mon Sep 17 00:00:00 2001 From: wujingjing <gersonwu@qq.com> Date: 星期六, 12 十月 2024 18:00:37 +0800 Subject: [PATCH] format --- src/utils/util.ts | 13 ++++++++++++- 1 files changed, 12 insertions(+), 1 deletions(-) diff --git a/src/utils/util.ts b/src/utils/util.ts index d35d575..83c85ba 100644 --- a/src/utils/util.ts +++ b/src/utils/util.ts @@ -541,7 +541,8 @@ * 鏈�杩� n 澶╃殑 startDate銆乪ndDate * @param dates */ -export const getRecentDateRange = (dates: number) => { +export const getRecentDateRange = (dates: number, includesCurrent = true) => { + dates = includesCurrent ? dates - 1 : dates; // 鑾峰彇褰撳墠鏃ユ湡 const endDate = new Date(); const startDate = new Date(); @@ -704,6 +705,7 @@ }; export function getTextWidth(text: string, option: GetTextWidthOption) { + if (!text) return 0; const { size = '14px', family = 'Microsoft YaHei' } = option; const spanEle = document.createElement('span'); document.body.appendChild(spanEle); @@ -721,3 +723,12 @@ document.body.removeChild(spanEle); return width; } + +export function decodeFormData(formDataString) { + const params = new URLSearchParams(formDataString); + const decodedData = {}; + for (const [key, value] of params) { + decodedData[key] = decodeURIComponent(value); + } + return decodedData; +} -- Gitblit v1.9.3