ZHIWEI666 commited on
Commit
aa8aea7
·
verified ·
1 Parent(s): b5d7112

Upload 104 files

Browse files
前端页面/profile/个人列表组件.js CHANGED
@@ -630,18 +630,23 @@ function createTaskItem(task, statusColors, statusLabels, currentUser) {
630
  * 📅 格式化截止日期
631
  */
632
  function formatDeadline(deadline) {
633
- if (!deadline) return t('time.unlimited');
634
- try {
635
- const date = new Date(deadline);
636
- const now = new Date();
637
- const diff = date - now;
638
- if (diff < 0) return t('time.deadline_ended');
639
- const days = Math.floor(diff / (1000 * 60 * 60 * 24));
640
- if (days === 0) return t('time.deadline_today');
641
- if (days === 1) return t('time.deadline_tomorrow');
642
- if (days < 7) return t('time.deadline_days', { n: days });
643
- return `${date.getMonth() + 1}/${date.getDate()}`;
644
- } catch { return deadline; }
 
 
 
 
 
645
  }
646
 
647
  /**
 
630
  * 📅 格式化截止日期
631
  */
632
  function formatDeadline(deadline) {
633
+ if (deadline == null || deadline === '') return t('time.unlimited');
634
+ if (typeof deadline !== 'string' || deadline.trim() !== deadline
635
+ || !/^\d{4}-\d{2}-\d{2}(?:T\d{2}:\d{2}(?::\d{2}(?:\.\d{1,9})?)?(?:Z|[+-]\d{2}:?\d{2})?)?$/.test(deadline)) return t('common.unknown');
636
+ const day = deadline.slice(0, 10);
637
+ const date = new Date(day + 'T00:00:00Z');
638
+ if (Number(day.slice(0, 4)) < 1 || !Number.isFinite(date.getTime())
639
+ || date.toISOString().slice(0, 10) !== day || !Number.isFinite(Date.parse(deadline))) return t('common.unknown');
640
+ const now = new Date();
641
+ const today = new Date(0);
642
+ today.setUTCFullYear(now.getFullYear(), now.getMonth(), now.getDate());
643
+ const days = Math.round((date.getTime() - today.getTime()) / (1000 * 60 * 60 * 24));
644
+ if (!Number.isFinite(days)) return t('common.unknown');
645
+ if (days < 0) return t('time.deadline_ended');
646
+ if (days === 0) return t('time.deadline_today');
647
+ if (days === 1) return t('time.deadline_tomorrow');
648
+ if (days < 7) return t('time.deadline_days', { n: days });
649
+ return `${Number(day.slice(5, 7))}/${Number(day.slice(8, 10))}`;
650
  }
651
 
652
  /**
前端页面/social/私信聊天组件.js CHANGED
@@ -32,9 +32,9 @@ const formatRelativeTime = (timestamp) => {
32
  const hours = Math.floor(diff / 3600000);
33
  const days = Math.floor(diff / 86400000);
34
  if (minutes < 1) return t('chat.time_just_now');
35
- if (minutes < 60) return `${minutes}${t('chat.time_min_ago')}`;
36
- if (hours < 24) return `${hours}${t('chat.time_hour_ago')}`;
37
- if (days < 7) return `${days}${t('chat.time_day_ago')}`;
38
  const date = new Date(msgTime);
39
  // 🔧 去掉 || '月' / || '日' 兜底:这两个词条的英文值是刻意留空的(中文 9月8日 → 英文 9/8),
40
  // 加了兜底反而会把中文量词引回英文界面(同文件下方的 chat.chatting_suffix 同理)
 
32
  const hours = Math.floor(diff / 3600000);
33
  const days = Math.floor(diff / 86400000);
34
  if (minutes < 1) return t('chat.time_just_now');
35
+ if (minutes < 60) return t('time.minutes_ago', { n: minutes });
36
+ if (hours < 24) return t('time.hours_ago', { n: hours });
37
+ if (days < 7) return t('time.days_ago', { n: days });
38
  const date = new Date(msgTime);
39
  // 🔧 去掉 || '月' / || '日' 兜底:这两个词条的英文值是刻意留空的(中文 9月8日 → 英文 9/8),
40
  // 加了兜底反而会把中文量词引回英文界面(同文件下方的 chat.chatting_suffix 同理)