- 图标优化、视频缩略图

This commit is contained in:
Pine
2026-05-13 01:19:41 +08:00
parent a5b96eed6e
commit d9b0aa27e5
5 changed files with 67 additions and 22 deletions
+7 -6
View File
@@ -1,5 +1,6 @@
import { useState, useEffect, useRef, useCallback } from 'react';
import * as api from '../utils/api';
import { API_BASE } from '../utils/api';
import '../styles/screen.css';
/* ============ Loader ============ */
@@ -59,7 +60,7 @@ export default function Screen() {
useEffect(() => { soundBlockedRef.current = soundBlocked; }, [soundBlocked]);
const getUrl = useCallback((item) => {
return item.source === 'url' ? item.relative_path : `/file/${item.relative_path}`;
return item.source === 'url' ? item.relative_path : `${API_BASE}/file/${item.relative_path}`;
}, []);
// ============ 核心播放控制 ============
@@ -103,12 +104,12 @@ export default function Screen() {
const item = list[index];
if (!item) return;
// 同步状态到后端
// 同步状态到后端(字段名 type 与 Rust PlaybackState 的 #[serde(rename = "type")] 匹配)
api.updateState({
status: 'playing',
index,
name: item.name || '',
media_type: item.type || '',
type: item.type || '',
}).catch(() => {});
if (item.type === 'video') {
@@ -208,7 +209,7 @@ export default function Screen() {
// SSE 连接
useEffect(() => {
const es = new EventSource('/api/events');
const es = new EventSource(`${API_BASE}/api/events`);
es.onmessage = (e) => {
try {
const msg = JSON.parse(e.data);
@@ -362,7 +363,7 @@ export default function Screen() {
{/* Corner Info — Now Playing */}
<div className={`corner-info${loaded && currentItem ? ' visible' : ''}`}>
<div className="ci-dot"></div>
<span className="ci-text">{currentItem ? currentItem.name : '就绪'}</span>
<span className="ci-text">{'昆明市大学生创业园'}</span>
</div>
{/* Connection Indicator */}
@@ -382,7 +383,7 @@ export default function Screen() {
{/* Sound Hint */}
<div id="soundHint" style={{ display: soundBlocked && loaded ? 'block' : 'none' }} onClick={enableSound}>
点击启用声音
声音
</div>
</div>
);