chore: message page list support sharedworker.js

This commit is contained in:
duorameng
2026-05-09 09:02:43 +08:00
parent f5f761e7ef
commit 0dad9dd541
7 changed files with 56 additions and 3 deletions
+5
View File
@@ -72,3 +72,8 @@ export const TASK_EVENTS = {
RUNNING: 'task_running',
QUEUED: 'task_queued',
} as const
// 日志事件类型
export const LOG_EVENTS = {
ADDED: 'app_log_added',
} as const
+12 -1
View File
@@ -3,9 +3,11 @@ import { ref, onMounted } from 'vue'
import Pagination from '@/components/Pagination.vue'
import { Loader2 } from 'lucide-vue-next'
import TextOverflow from '@/components/TextOverflow.vue'
import { api } from '@/api'
import { api, LOG_CATEGORY } from '@/api'
import { toast } from 'vue-sonner'
import { useSiteSettings } from '@/composables/useSiteSettings'
import { useEventBus } from '@/composables/useEventBus'
import { LOG_EVENTS } from '@/constants'
import BaihuDialog from '@/components/ui/BaihuDialog.vue'
const props = defineProps<{
@@ -91,6 +93,15 @@ function handlePageChange(page: number) {
onMounted(loadLogs)
// 实时更新:当有新登录产生且用户在第一页时刷新
useEventBus([LOG_EVENTS.ADDED], (payload) => {
if (payload && payload.category === LOG_CATEGORY.LOGIN_LOG) {
if (currentPage.value === 1) {
loadLogs()
}
}
})
defineExpose({
loadLogs
})
@@ -11,6 +11,8 @@ import BaihuDialog from '@/components/ui/BaihuDialog.vue'
import { toast } from 'vue-sonner'
import { format } from 'date-fns'
import { useSiteSettings } from '@/composables/useSiteSettings'
import { useEventBus } from '@/composables/useEventBus'
import { LOG_EVENTS } from '@/constants'
const props = defineProps<{
filters: {
@@ -85,6 +87,15 @@ onMounted(() => {
fetchLogs()
})
// 实时更新:当有新系统事件产生且用户在第一页时刷新
useEventBus([LOG_EVENTS.ADDED], (payload) => {
if (payload && payload.category === LOG_CATEGORY.SYSTEM_NOTICE) {
if (currentPage.value === 1) {
fetchLogs()
}
}
})
const selectedLog = computed(() => logs.value.find((l: AppLog) => l.id === selectedLogId.value))
defineExpose({
@@ -19,6 +19,8 @@ import {
AlertDialogTitle,
} from '@/components/ui/alert-dialog'
import { useSiteSettings } from '@/composables/useSiteSettings'
import { useEventBus } from '@/composables/useEventBus'
import { LOG_EVENTS } from '@/constants'
import BaihuDialog from '@/components/ui/BaihuDialog.vue'
const props = defineProps<{
@@ -94,6 +96,15 @@ onMounted(() => {
fetchLogs()
})
// 实时更新:当有新推送产生且用户在第一页时刷新
useEventBus([LOG_EVENTS.ADDED], (payload) => {
if (payload && payload.category === LOG_CATEGORY.PUSH_LOG) {
if (currentPage.value === 1) {
fetchLogs()
}
}
})
const selectedLog = computed(() => logs.value.find((l: AppLog) => l.id === selectedLogId.value))
defineExpose({