Files
company-celebration/packages/client-screen/src/views/MainDisplay.vue
let5sne 371f117064 fix: production deployment improvements and configuration fixes
## 主要改动

### 1. 修复二维码地址硬编码问题
- 将 MainDisplay.vue 中硬编码的移动端 URL 改为环境变量配置
- 添加 VITE_MOBILE_URL 环境变量支持
- 支持通过 .env 文件动态配置移动端地址

### 2. 修复音频文件路径问题
- 修正 display.ts 中音频文件路径,添加 /screen 前缀
- 修复 BGM、抽奖音效、胜利音效的加载路径

### 3. 修复 Docker 构建问题
- 添加中国 npm 镜像配置,解决构建超时问题
- 修复缺失的 tsconfig.base.json 文件拷贝
- 修复 Redis 环境变量配置(REDIS_HOST/REDIS_PORT)
- 添加 Lua 脚本文件拷贝到生产容器

### 4. 修复前端路由和资源加载
- 添加 Vite base path 配置 (/screen/)
- 修复 Vue Router base path 配置
- 修正 Caddyfile 路由顺序,确保 /screen 路径优先匹配

### 5. 修复 TypeScript 编译错误
- LuckyDrawView.vue: 添加 round 属性类型定义
- ProgramCard.vue: 添加非空断言处理

### 6. 修复 SCSS 变量问题
- 替换未定义的 SCSS 变量为硬编码颜色值
- 修复 VoteView、ConnectionStatus、HomeView、ScanLoginView 中的样式问题

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-26 16:59:02 +08:00

328 lines
7.0 KiB
Vue

<script setup lang="ts">
import { ref, onMounted, onUnmounted } from 'vue';
import { useDisplayStore } from '../stores/display';
import { BackgroundEffect } from '../pixi/BackgroundEffect';
import QRCodeLogin from '../components/QRCodeLogin.vue';
import EntryQRCode from '../components/EntryQRCode.vue';
const displayStore = useDisplayStore();
// QR Code Login (legacy - kept for direct access)
const showQRLogin = ref(false);
// Mobile URL for entry QR code - use environment variable or fallback to current origin
const mobileUrl = import.meta.env.VITE_MOBILE_URL || window.location.origin;
function handleLoginSuccess(data: { userId: string; userName: string; department: string; sessionToken: string }) {
console.log('Login success:', data);
showQRLogin.value = false;
// 可以在这里处理登录成功后的逻辑
}
function handleLoginCancel() {
showQRLogin.value = false;
}
// Pixi.js background
const canvasRef = ref<HTMLCanvasElement | null>(null);
let backgroundEffect: BackgroundEffect | null = null;
// Time display
const currentTime = ref(new Date().toLocaleTimeString('zh-CN'));
let timeInterval: ReturnType<typeof setInterval> | null = null;
onMounted(async () => {
// Connect to socket
displayStore.connect();
// Initialize Pixi.js background
if (canvasRef.value) {
backgroundEffect = new BackgroundEffect();
await backgroundEffect.init(canvasRef.value);
}
// Update time every second
timeInterval = setInterval(() => {
currentTime.value = new Date().toLocaleTimeString('zh-CN');
}, 1000);
});
onUnmounted(() => {
if (backgroundEffect) {
backgroundEffect.destroy();
}
if (timeInterval) {
clearInterval(timeInterval);
}
});
</script>
<template>
<div class="cinematic-display">
<!-- Pixi.js Canvas Background -->
<canvas ref="canvasRef" class="background-canvas"></canvas>
<!-- QR Code Login Modal (legacy) -->
<QRCodeLogin
v-if="showQRLogin"
server-url="http://192.168.1.5:3000"
@login-success="handleLoginSuccess"
@login-cancel="handleLoginCancel"
/>
<!-- Entry QR Code Modal (controlled by admin) -->
<EntryQRCode
v-if="displayStore.showEntryQR"
:mobile-url="mobileUrl"
@close="displayStore.showEntryQR = false"
/>
<!-- Corner Decorations -->
<div class="corner-decoration top-left"></div>
<div class="corner-decoration top-right"></div>
<div class="corner-decoration bottom-left"></div>
<div class="corner-decoration bottom-right"></div>
<!-- Main Content -->
<main class="content">
<!-- Central Title -->
<div class="title-section">
<h1 class="main-title liquid-gold">马到成功</h1>
<div class="subtitle-wrapper">
<span class="year">2026</span>
<span class="divider">·</span>
<span class="event">年度盛典</span>
</div>
</div>
<!-- Particle Ring Placeholder -->
<div class="particle-ring"></div>
</main>
<!-- Status Footer -->
<footer class="status-footer">
<div class="status-item">
<span class="dot online"></span>
<span class="label">{{ displayStore.onlineUsers }} 人在线</span>
</div>
<div class="status-item time">
<span class="label">{{ currentTime }}</span>
</div>
<div class="status-item">
<span class="dot" :class="displayStore.isConnected ? 'ready' : 'offline'"></span>
<span class="label">{{ displayStore.isConnected ? '已连接' : '未连接' }}</span>
</div>
</footer>
</div>
</template>
<style lang="scss" scoped>
@use '../assets/styles/variables.scss' as *;
.cinematic-display {
width: 100%;
height: 100%;
position: relative;
overflow: hidden;
background: $color-bg-wine;
}
.background-canvas {
position: absolute;
inset: 0;
width: 100%;
height: 100%;
z-index: 0;
}
// Corner decorations (Chinese knot pattern)
.corner-decoration {
position: absolute;
width: 120px;
height: 120px;
z-index: 10;
opacity: 0.6;
pointer-events: none;
&::before,
&::after {
content: '';
position: absolute;
background: $color-gold;
}
&::before {
width: 80px;
height: 2px;
}
&::after {
width: 2px;
height: 80px;
}
&.top-left {
top: 40px;
left: 40px;
&::before { top: 0; left: 0; }
&::after { top: 0; left: 0; }
}
&.top-right {
top: 40px;
right: 40px;
&::before { top: 0; right: 0; }
&::after { top: 0; right: 0; }
}
&.bottom-left {
bottom: 40px;
left: 40px;
&::before { bottom: 0; left: 0; }
&::after { bottom: 0; left: 0; }
}
&.bottom-right {
bottom: 40px;
right: 40px;
&::before { bottom: 0; right: 0; }
&::after { bottom: 0; right: 0; }
}
}
.content {
position: relative;
z-index: 5;
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.title-section {
text-align: center;
.main-title {
font-size: 160px;
font-weight: 900;
letter-spacing: 20px;
margin-bottom: 30px;
}
.subtitle-wrapper {
display: flex;
align-items: center;
justify-content: center;
gap: 20px;
font-size: 32px;
color: $color-text-muted;
letter-spacing: 8px;
.year {
color: $color-gold;
font-weight: bold;
}
.divider {
color: $color-gold-dark;
}
.event {
color: $color-text-light;
}
}
}
.particle-ring {
position: absolute;
width: 600px;
height: 600px;
border: 1px solid rgba($color-gold, 0.1);
border-radius: 50%;
animation: rotate-slow 60s linear infinite;
pointer-events: none;
&::before {
content: '';
position: absolute;
inset: 40px;
border: 1px solid rgba($color-gold, 0.15);
border-radius: 50%;
animation: rotate-slow 45s linear infinite reverse;
}
&::after {
content: '';
position: absolute;
inset: 80px;
border: 1px solid rgba($color-gold, 0.08);
border-radius: 50%;
animation: rotate-slow 30s linear infinite;
}
}
.status-footer {
position: absolute;
bottom: 0;
left: 0;
right: 0;
z-index: 10;
display: flex;
justify-content: space-between;
align-items: center;
padding: 20px 60px;
background: linear-gradient(to top, rgba(0, 0, 0, 0.5), transparent);
}
.status-item {
display: flex;
align-items: center;
gap: 10px;
font-size: 16px;
color: $color-text-muted;
.dot {
width: 8px;
height: 8px;
border-radius: 50%;
&.online {
background: #52c41a;
box-shadow: 0 0 10px rgba(82, 196, 26, 0.5);
animation: pulse 2s infinite;
}
&.ready {
background: $color-gold;
box-shadow: 0 0 10px rgba($color-gold, 0.5);
}
&.offline {
background: #666;
}
}
&.time {
font-size: 18px;
color: $color-text-light;
font-variant-numeric: tabular-nums;
}
}
@keyframes rotate-slow {
from { transform: rotate(0deg); }
to { transform: rotate(360deg); }
}
@keyframes pulse {
0%, 100% { opacity: 1; }
50% { opacity: 0.5; }
}
</style>