feat(消息面板): 添加dayjs依赖并优化消息撤回时间计算

使用dayjs替换原有的日期处理逻辑,提高代码可读性并延长消息撤回时间至5分钟
This commit is contained in:
Phoenix 2025-06-10 13:28:54 +08:00
parent 8bba2d64af
commit e4354d42cd
3 changed files with 9 additions and 5 deletions

View File

@ -26,6 +26,7 @@
"@vueuse/core": "^10.7.0",
"ant-design-vue": "^4.2.6",
"axios": "^1.6.2",
"dayjs": "^1.11.13",
"highlight.js": "^11.5.0",
"js-audio-recorder": "^1.0.7",
"lodash-es": "^4.17.21",

View File

@ -44,6 +44,9 @@ importers:
axios:
specifier: ^1.6.2
version: 1.9.0
dayjs:
specifier: ^1.11.13
version: 1.11.13
highlight.js:
specifier: ^11.5.0
version: 11.11.1

View File

@ -1,4 +1,5 @@
import { reactive } from 'vue'
import dayjs from 'dayjs'
import { useDialogueStore } from '@/store/modules/dialogue.js'
interface IDropdown {
@ -14,11 +15,10 @@ const isRevoke = (uid: any, item: any): boolean => {
return false
}
const datetime = item.created_at.replace(/-/g, '/')
const time = new Date().getTime() - Date.parse(datetime)
return Math.floor(time / 1000 / 60) <= 2
const messageTime = dayjs(item.created_at)
const now = dayjs()
const diffInMinutes = now.diff(messageTime, 'minute')
return diffInMinutes <= 5
}
const dialogueStore = useDialogueStore()
export function useMenu() {