chore: message page list support sharedworker.js
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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({
|
||||
|
||||
Reference in New Issue
Block a user