mirror of
https://github.com/jxxghp/MoviePilot-Frontend.git
synced 2026-09-06 16:16:42 +08:00
fix 消息控重
This commit is contained in:
@@ -162,6 +162,8 @@ onMounted(() => {
|
|||||||
<VCol cols="12" md="6">
|
<VCol cols="12" md="6">
|
||||||
<VCheckbox v-model="cookieCloudSetting.COOKIECLOUD_ENABLE_LOCAL" label="启用本地CookieCloud服务器" />
|
<VCheckbox v-model="cookieCloudSetting.COOKIECLOUD_ENABLE_LOCAL" label="启用本地CookieCloud服务器" />
|
||||||
</VCol>
|
</VCol>
|
||||||
|
</VRow>
|
||||||
|
<VRow>
|
||||||
<VCol cols="12" md="6">
|
<VCol cols="12" md="6">
|
||||||
<VTextField
|
<VTextField
|
||||||
v-model="cookieCloudSetting.COOKIECLOUD_HOST"
|
v-model="cookieCloudSetting.COOKIECLOUD_HOST"
|
||||||
|
|||||||
@@ -21,6 +21,9 @@ const loading = ref(false)
|
|||||||
// 当前页码
|
// 当前页码
|
||||||
const page = ref(1)
|
const page = ref(1)
|
||||||
|
|
||||||
|
// 存量消息最新时间
|
||||||
|
const lastTime = ref('')
|
||||||
|
|
||||||
// SSE持续获取消息
|
// SSE持续获取消息
|
||||||
function startSSEMessager() {
|
function startSSEMessager() {
|
||||||
const token = store.state.auth.token
|
const token = store.state.auth.token
|
||||||
@@ -33,6 +36,8 @@ function startSSEMessager() {
|
|||||||
const message = event.data
|
const message = event.data
|
||||||
if (message) {
|
if (message) {
|
||||||
const object = JSON.parse(message)
|
const object = JSON.parse(message)
|
||||||
|
if (compareTime(object.date, lastTime.value) <= 0)
|
||||||
|
return
|
||||||
messages.value.push(object)
|
messages.value.push(object)
|
||||||
emit('scroll')
|
emit('scroll')
|
||||||
}
|
}
|
||||||
@@ -61,6 +66,8 @@ async function loadMessages({ done }: { done: any }) {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
if (currData.value.length > 0) {
|
if (currData.value.length > 0) {
|
||||||
|
// 取最后一条时间为存量消息最新时间
|
||||||
|
lastTime.value = currData.value[currData.value.length - 1].reg_time
|
||||||
// 合并数据
|
// 合并数据
|
||||||
messages.value = [...currData.value, ...messages.value]
|
messages.value = [...currData.value, ...messages.value]
|
||||||
// 加载完成
|
// 加载完成
|
||||||
@@ -83,6 +90,15 @@ async function loadMessages({ done }: { done: any }) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 比较yyyy-MM-dd HH:mm:ss时间大小
|
||||||
|
function compareTime(time1: string, time2: string) {
|
||||||
|
if (!time1)
|
||||||
|
return -1
|
||||||
|
if (!time2)
|
||||||
|
return 1
|
||||||
|
return new Date(time1).getTime() - new Date(time2).getTime()
|
||||||
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
// 监听新消息
|
// 监听新消息
|
||||||
startSSEMessager()
|
startSSEMessager()
|
||||||
|
|||||||
Reference in New Issue
Block a user