Browse Source

fix:1.修改写游记时间格式问题,
2.分享链接的问题

suwenjiang 3 months ago
parent
commit
cd0d104f01

+ 7 - 1
src/components/CreateNote/Form.vue

@@ -183,7 +183,13 @@ const showCalendar = ref(false)
 
 // 展示时间的格式
 const onConfirm = (date) => {
-  departureTime.value = date ? `${date.getFullYear()}-${date.getMonth() + 1}-${date.getDate()}` : ''
+  let year = date?.getFullYear()
+  let month = date?.getMonth() + 1 // getMonth() 返回的月份从 0 开始,所以需要加 1
+  let day = date?.getDate()
+  month = month < 10 ? '0' + month : month
+  day = day < 10 ? '0' + day : day
+
+  departureTime.value = date ? `${year}-${month}-${day}` : ''
   showCalendar.value = false
 }
 

+ 3 - 1
src/components/Profile/Notes/Published/index.vue

@@ -97,7 +97,9 @@ const shareToWeChat = (type) => {
 
 // 复制链接
 const copyLink = () => {
-  const url = `${import.meta.env.VITE_APP_BASE_URL}yj/${yjId.value}`
+  let protocol = location.protocol
+  let hostname = location.hostname
+  let url = `${protocol}//${hostname}/yj/${yjId.value}`
   navigator.clipboard.writeText(url).then(
     () => {
       showNotify({ type: 'success', message: '链接已复制' })