Browse Source

fix: 组件日期解析改用 parseDate(iOS/HarmonyOS 兼容)

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
asus 1 month ago
parent
commit
4f4a21cdb5

+ 3 - 1
cfc-frontend/components/ContactCard.vue

@@ -53,6 +53,7 @@
 
 <script>
 import config from '@/config.js'
+import { parseDate } from '@/utils/format.js'
 
 export default {
   props: {
@@ -94,7 +95,8 @@ export default {
     knownYears: function() {
       if (!this.contact.knownSince) return 0
       var now = new Date()
-      var known = new Date(this.contact.knownSince)
+      var known = parseDate(this.contact.knownSince)
+      if (!known) return 0
       return Math.floor((now - known) / (365.25 * 86400000))
     }
   },

+ 3 - 1
cfc-frontend/components/PsychCrisisBanner.vue

@@ -21,6 +21,7 @@
 
 <script>
 import config from '../config'
+import { parseDate } from '../utils/format'
 
 export default {
   props: {
@@ -102,7 +103,8 @@ export default {
 
     formatTime(dateStr) {
       if (!dateStr) return ''
-      var d = new Date(dateStr)
+      var d = parseDate(dateStr)
+      if (!d) return ''
       var m = d.getMonth() + 1
       var day = d.getDate()
       var h = d.getHours()

+ 3 - 1
cfc-frontend/components/member-detail-sections/action-section.vue

@@ -64,6 +64,7 @@
 
 <script>
 import { getTodayTasksByCategory, getCheckinStats, getActivityList } from '../../utils/api.js'
+import { parseDate } from '../../utils/format.js'
 
 export default {
   props: {
@@ -134,7 +135,8 @@ export default {
     },
     formatDate: function(dateStr) {
       if (!dateStr) return ''
-      var d = new Date(dateStr)
+      var d = parseDate(dateStr)
+      if (!d) return ''
       return d.getFullYear() + '-' + (d.getMonth() + 1) + '-' + d.getDate()
     },
     goTaskDetail: function(task) {

+ 3 - 1
cfc-frontend/components/member-detail-sections/body-section.vue

@@ -61,6 +61,7 @@
 <script>
 import RadarChart from '../RadarChart.vue'
 import { getHealthAnalysis, getDimensionOverview, getCheckinList } from '../../utils/api.js'
+import { parseDate } from '../../utils/format.js'
 
 export default {
   components: { RadarChart },
@@ -111,7 +112,8 @@ export default {
     },
     formatDate: function(dateStr) {
       if (!dateStr) return ''
-      var d = new Date(dateStr)
+      var d = parseDate(dateStr)
+      if (!d) return ''
       return d.getFullYear() + '-' + (d.getMonth()+1) + '-' + d.getDate()
     },
     goReportDetail: function() {

+ 3 - 1
cfc-frontend/components/member-detail-sections/wisdom-section.vue

@@ -44,6 +44,7 @@
 
 <script>
 import { getAssessmentLatestResult, getAssessmentHistory } from '../../utils/api.js'
+import { parseDate } from '../../utils/format.js'
 
 export default {
   props: {
@@ -105,7 +106,8 @@ export default {
     },
     formatDate: function(dateStr) {
       if (!dateStr) return ''
-      var d = new Date(dateStr)
+      var d = parseDate(dateStr)
+      if (!d) return ''
       return d.getFullYear() + '-' + (d.getMonth() + 1) + '-' + d.getDate()
     },
     goResultDetail: function() {