From 3ec41ee5207d8f1be1fdcf3ba3b57fec34a6a2fa Mon Sep 17 00:00:00 2001 From: lion <120344285@qq.com> Date: Wed, 11 Nov 2026 15:41:33 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=A4=A7=E5=B1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/dashboard/components/AlumniNews.vue | 23 +++++-- src/views/dashboard/index.vue | 66 +++++++++++++++---- 2 files changed, 69 insertions(+), 20 deletions(-) diff --git a/src/views/dashboard/components/AlumniNews.vue b/src/views/dashboard/components/AlumniNews.vue index 24c85d4..9502e70 100644 --- a/src/views/dashboard/components/AlumniNews.vue +++ b/src/views/dashboard/components/AlumniNews.vue @@ -23,13 +23,19 @@ import { alumniNews } from '@/api/home/index' export default { name: 'AlumniNews', props: { - displayMode: { type: Boolean, default: false } + displayMode: { type: Boolean, default: false }, + rotationPaused: { type: Boolean, default: false } }, data() { return { rows: [], page: 1, lastPage: 1, total: 0, loading: false, error: false, sequence: 0, rotationTimer: null } }, created() { this.load(1) }, mounted() { if (this.displayMode) this.startRotation() }, + watch: { + rotationPaused() { + if (this.displayMode) this.startRotation() + } + }, beforeDestroy() { clearInterval(this.rotationTimer) this.sequence++ @@ -38,11 +44,16 @@ export default { startRotation() { clearInterval(this.rotationTimer) this.rotationTimer = setInterval(() => { - if (!this.loading) this.load(this.page % this.lastPage + 1) + if (this.loading) return + if (this.rotationPaused) { + this.load(this.page) + } else { + this.load(this.page % this.lastPage + 1, true) + } }, 15000) }, changePage(direction) { - if (this.loading) return + if (this.loading && !this.displayMode) return const target = this.page + direction if (this.displayMode) { if (this.lastPage <= 1) return @@ -56,14 +67,14 @@ export default { if (typeof value !== 'string' || !/^https?:\/\//i.test(value.trim())) return '' try { const url = new URL(value.trim()); return ['http:', 'https:'].includes(url.protocol) ? url.href : '' } catch (_) { return '' } }, - async load(page) { + async load(page, automatic = false) { const sequence = ++this.sequence this.loading = true this.error = false try { const result = await alumniNews({ page }, this.displayMode) - if (sequence !== this.sequence) return - if (page > result.last_page && result.last_page >= 1) return this.load(result.last_page) + if (sequence !== this.sequence || (automatic && this.rotationPaused)) return + if (page > result.last_page && result.last_page >= 1) return this.load(result.last_page, automatic) this.rows = result.data this.page = result.current_page this.lastPage = Math.max(1, result.last_page) diff --git a/src/views/dashboard/index.vue b/src/views/dashboard/index.vue index af5fe22..4e7693c 100644 --- a/src/views/dashboard/index.vue +++ b/src/views/dashboard/index.vue @@ -1,5 +1,5 @@