From 3bc1854811e9b71f5548194338ee953899d52880 Mon Sep 17 00:00:00 2001
From: yuan <123@>
Date: 星期三, 09 九月 2026 00:25:33 +0800
Subject: [PATCH] fix: 优化

---
 src/utils/ruoyi.js |   41 +++++++++++++++++++++++++++++++++++++++++
 1 files changed, 41 insertions(+), 0 deletions(-)

diff --git a/src/utils/ruoyi.js b/src/utils/ruoyi.js
index 0d72c1a..a912074 100644
--- a/src/utils/ruoyi.js
+++ b/src/utils/ruoyi.js
@@ -4,6 +4,47 @@
  */
 
 // 鏃ユ湡鏍煎紡鍖�
+export function parseDate(time, pattern) {
+  if (arguments.length === 0 || !time) {
+    return null
+  }
+  const format = pattern || '{y}-{m}-{d}'
+  let date
+  if (typeof time === 'object') {
+    date = time
+  } else {
+    if ((typeof time === 'string') && (/^[0-9]+$/.test(time))) {
+      time = parseInt(time)
+    } else if (typeof time === 'string') {
+      time = time.replace(new RegExp(/-/gm), '/').replace('T', ' ').replace(new RegExp(/\.[\d]{3}/gm), '')
+    }
+    if ((typeof time === 'number') && (time.toString().length === 10)) {
+      time = time * 1000
+    }
+    date = new Date(time)
+  }
+  const formatObj = {
+    y: date.getFullYear(),
+    m: date.getMonth() + 1,
+    d: date.getDate(),
+    h: date.getHours(),
+    i: date.getMinutes(),
+    s: date.getSeconds(),
+    a: date.getDay()
+  }
+  const time_str = format.replace(/{(y|m|d|h|i|s|a)+}/g, (result, key) => {
+    let value = formatObj[key]
+    // Note: getDay() returns 0 on Sunday
+    if (key === 'a') { return ['鏃�', '涓�', '浜�', '涓�', '鍥�', '浜�', '鍏�'][value] }
+    if (result.length > 0 && value < 10) {
+      value = '0' + value
+    }
+    return value || 0
+  })
+  return time_str
+}
+
+// 鏃ユ湡鏍煎紡鍖�
 export function parseTime(time, pattern) {
   if (arguments.length === 0 || !time) {
     return null

--
Gitblit v1.9.3