From c1a82f2bd13f3150395a8e46eb1c5fa82f8d6431 Mon Sep 17 00:00:00 2001 From: 1 <1> Date: Fri, 27 Jun 2025 17:38:20 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A3=B0=E5=8D=A1=E9=87=8D=E6=9E=84=E5=AE=8C?= =?UTF-8?q?=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pagesA/home/device/status/addProgram.vue | 63 ++++++++++++++++++++++-- 1 file changed, 60 insertions(+), 3 deletions(-) diff --git a/pagesA/home/device/status/addProgram.vue b/pagesA/home/device/status/addProgram.vue index fb76aec..0c4b345 100644 --- a/pagesA/home/device/status/addProgram.vue +++ b/pagesA/home/device/status/addProgram.vue @@ -205,6 +205,7 @@ // Clear any remaining timers this.animationStates.forEach(state => { if (state.standTimer) clearTimeout(state.standTimer); + if (state.pageTimer) clearTimeout(state.pageTimer); }); }, data() { @@ -229,7 +230,23 @@ // 选项数组 playTypes: ['文字', '图片'], modes: ['模式1', '模式2(上下)', '模式3(左右)', '模式4(上中下)', '模式5', '模式6'], - commonPhrases: ['自定义', '欢迎光临', '限速'], + commonPhrases: ['自定义', "公安交警正在巡逻", + "公安交警停车检查", + "前方事故减速慢行", + "警察临检请您配合", + "交警临检请您配合", + "《《《《《", + "》》》》》", + "禁止停车", + "交通管制禁止通行", + "公安检查靠边停车", + "前方事故道路封闭", + "禁止掉头", + "雨雪天气注意安全", + "大雾天气减速慢行", + "靠右停车接受检查", + "警察临检靠边停车" + ], fonts: ['宋体(中)', '黑体(中)', '楷体(中)'], fontShapes: ['圆角(英)', '直角(英)'], fontSizes: ['16px', '24px', '32px'], @@ -375,6 +392,7 @@ } this.animationStates.forEach(state => { if (state.standTimer) clearTimeout(state.standTimer); + if (state.pageTimer) clearTimeout(state.pageTimer); }); this.animationStates = this.form.zones.map(zone => { @@ -385,6 +403,7 @@ currentX: 0, currentY: 0, standTimer: null, + pageTimer: null, ...this.getInitialPosition(zone, assetInfo) }; }); @@ -448,7 +467,8 @@ // Setup font for drawing const fontSize = parseInt(this.fontSizes[zone.fontSize] || '16px'); const scaledFontSize = Math.max(1, Math.round(fontSize * scale)); - ctx.font = `${this.mapBold(zone.fontBold)} ${scaledFontSize}px ${this.mapFont(zone.font)}`; + ctx.font = + `${this.mapBold(zone.fontBold)} ${scaledFontSize}px ${this.mapFont(zone.font)}`; ctx.fillStyle = this.mapColor(zone.fontColor); // Get the lines for the current page @@ -541,7 +561,23 @@ const animationSpeed = (speedMap[zone.speed] || 5) / 5; // Normalize speed const effect = zone.effect; + // Handle multi-page text cycling for non-scroll effects + if (effect !== 5 && state.pages.length > 1) { + // If we don't have a timer yet, start one + if (!state.pageTimer) { + const stayTimeMap = [0, 100, 500, 1000, 2000, 3000, 4000, 5000, 6000, 8000, 10000]; + const stayTime = stayTimeMap[zone.stayTime] || 3000; + + state.pageTimer = setTimeout(() => { + state.currentPage = (state.currentPage + 1) % state.pages.length; + state.pageTimer = null; // Clear timer so it can be set again + }, stayTime); + } + } + switch (effect) { + case 0: // 立即显示 - 不需要动画,只需要页面切换 + break; case 1: // Left if (state.currentX > 0) state.currentX = Math.max(0, state.currentX - animationSpeed); break; @@ -560,6 +596,17 @@ state.currentX = 0; } break; + case 6: // 闪烁换页 - 特殊处理 + if (!state.pageTimer) { + const stayTimeMap = [0, 100, 500, 1000, 2000, 3000, 4000, 5000, 6000, 8000, 10000]; + const stayTime = stayTimeMap[zone.stayTime] || 3000; + + state.pageTimer = setTimeout(() => { + state.currentPage = (state.currentPage + 1) % state.pages.length; + state.pageTimer = null; + }, stayTime); + } + break; } }, @@ -611,12 +658,22 @@ } const lineHeight = fontSize; - const maxLinesPerPage = zone.height > 0 ? Math.floor(zone.height / lineHeight) : 0; + const maxLinesPerPage = zone.height > 0 ? Math.floor(zone.height / lineHeight) : 1; const pages = []; + + // 确保至少有一页,即使高度不够 if (maxLinesPerPage > 0) { for (let i = 0; i < lines.length; i += maxLinesPerPage) { pages.push(lines.slice(i, i + maxLinesPerPage)); } + } else { + // 如果高度不够,将所有行放在一页中 + pages.push(lines); + } + + // 确保至少有一页(即使是空的) + if (pages.length === 0) { + pages.push([]); } return {