声卡重构完善
This commit is contained in:
parent
46d8c6e174
commit
c1a82f2bd1
@ -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 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user