Add files via upload

This commit is contained in:
Zheng ze Ou authored and GitHub committed 2026-03-16 18:10:55 +08:00
1 parent d71f8a5b26
commit 84c63be156
9 files changed
+2891

No files matched your search

+256
View File
@@ -0,0 +1,256 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<title>OBS 下三分之一条 管理</title>
<style>
:root {
color-scheme: dark;
--bg: #05060a;
--bg-elevated: #10121a;
--accent: #ffb347;
--accent-soft: rgba(255, 179, 71, 0.12);
--border-soft: rgba(255, 255, 255, 0.08);
--fg: #f5f5f5;
--fg-muted: #a0a4b3;
}
* { box-sizing: border-box; }
body {
margin: 0;
padding: 20px 24px 32px;
font-family: system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
background: radial-gradient(circle at 0% 0%, #1d2333, #05060a 55%);
color: var(--fg);
}
h1 {
font-size: 20px;
margin: 0 0 6px;
}
h2 {
font-size: 16px;
margin: 0 0 8px;
}
p { margin: 0 0 10px; color: var(--fg-muted); font-size: 13px; }
code { background: rgba(0,0,0,0.3); padding: 2px 4px; border-radius: 4px; font-size: 12px; }
.card {
background: rgba(10, 12, 22, 0.9);
border-radius: 14px;
border: 1px solid var(--border-soft);
box-shadow: 0 18px 40px rgba(0,0,0,0.75);
padding: 14px 16px 16px;
margin-bottom: 14px;
backdrop-filter: blur(18px);
}
label { display: block; margin-top: 8px; font-size: 13px; color: var(--fg-muted); }
input, textarea, select {
width: 100%;
padding: 6px 8px;
margin-top: 4px;
border-radius: 8px;
border: 1px solid var(--border-soft);
background: rgba(3, 5, 12, 0.9);
color: var(--fg);
font-size: 13px;
}
textarea { resize: vertical; min-height: 60px; }
button {
margin-top: 10px;
padding: 6px 11px;
border-radius: 999px;
border: 1px solid rgba(255,255,255,0.1);
background: linear-gradient(135deg, rgba(255,179,71,0.85), rgba(255,94,98,0.9));
color: #1a1110;
font-size: 13px;
cursor: pointer;
}
button.secondary {
background: rgba(18, 20, 30, 0.9);
color: var(--fg-muted);
}
button.inline { margin-right: 6px; }
.row { margin-top: 14px; }
#presetList { margin-top: 6px; }
.preset-item {
border-radius: 10px;
border: 1px solid var(--border-soft);
background: rgba(12, 16, 26, 0.95);
padding: 8px 10px;
margin-top: 8px;
font-size: 13px;
}
.preset-item.active {
border-color: rgba(255,179,71,0.85);
box-shadow: 0 0 0 1px rgba(255,179,71,0.3);
background: linear-gradient(135deg, rgba(255,179,71,0.15), rgba(15,18,26,0.9));
}
.preset-item small { color: var(--fg-muted); }
</style>
</head>
<body>
<h1>OBS 节目信息下三分之一条 - 预设管理</h1>
<p>1. 在 OBS 中添加 Browser Source,URL 指向 <code>http://本机或服务器/widget.html</code><br>
2. 在下方新增 / 编辑预设,点击“激活”即可在 OBS 中显示该条;点击“清空当前显示”则隐藏。</p>
<section>
<h2>创建 / 编辑外观预设</h2>
<label>
预设名称(仅管理用,不会在节目中显示)
<input id="name" placeholder="例如:晚会右侧信息区 · 主题 1" />
</label>
<label>
预设类型
<select id="kind">
<option value="iframe">自定义 HTML + CSS + JS(iframe)</option>
</select>
</label>
<label>
对齐方式(OBS 画面内的位置)
<select id="align">
<option value="right">右侧</option>
<option value="center">居中</option>
<option value="left">左侧</option>
</select>
</label>
<label>
自定义 HTML(整个 widget 的内容,包含 &lt;style&gt; / &lt;script&gt; 都可以)
<textarea id="html" rows="12" placeholder="<!DOCTYPE html>..."></textarea>
</label>
<label>
额外 CSS(可选,对外层容器 .lt-root / .lt-container 做额外修饰)
<textarea id="extraCss" rows="3" placeholder=".lt-container { border-radius: 24px; }"></textarea>
</label>
<button id="savePreset">保存为新预设</button>
<button id="updatePreset" disabled>更新当前选中预设</button>
<button id="clearForm" type="button" class="secondary">清空表单</button>
</section>
<section class="row">
<h2>预设列表</h2>
<div id="presetList"></div>
</section>
<section class="row">
<button id="clearActive">清空当前显示(透明)</button>
</section>
<script>
let presets = [];
let activePresetId = null;
let selectedPresetId = null;
async function fetchPresets() {
const res = await fetch('/api/presets');
const data = await res.json();
presets = data.presets || [];
activePresetId = data.activePresetId || null;
renderList();
}
function renderList() {
const list = document.getElementById('presetList');
list.innerHTML = '';
if (!presets.length) {
list.textContent = '暂无预设,请先上面创建一条。';
return;
}
presets.forEach(p => {
const div = document.createElement('div');
div.className = 'preset-item' + (p.id === activePresetId ? ' active' : '');
div.innerHTML = `
<strong>${p.name || '(未命名外观)'}</strong><br>
<small>类型: ${p.kind || 'iframe'} · 对齐: ${p.align || 'right'}</small><br>
<button class="inline" data-act="select">选中编辑</button>
<button class="inline" data-act="activate">激活</button>
<button class="inline" data-act="delete">删除</button>
`;
div.dataset.id = p.id;
list.appendChild(div);
});
}
function readForm() {
return {
name: document.getElementById('name').value.trim(),
kind: document.getElementById('kind').value || 'iframe',
align: document.getElementById('align').value || 'right',
html: document.getElementById('html').value,
extraCss: document.getElementById('extraCss').value
};
}
function fillForm(preset) {
document.getElementById('name').value = preset.name || '';
document.getElementById('kind').value = preset.kind || 'iframe';
document.getElementById('align').value = preset.align || 'right';
document.getElementById('html').value = preset.html || '';
document.getElementById('extraCss').value = preset.extraCss || '';
}
document.getElementById('savePreset').onclick = async () => {
const body = readForm();
const res = await fetch('/api/presets', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(body)
});
await res.json();
selectedPresetId = null;
document.getElementById('updatePreset').disabled = true;
fetchPresets();
};
document.getElementById('updatePreset').onclick = async () => {
if (!selectedPresetId) return;
const body = readForm();
const res = await fetch('/api/presets/' + selectedPresetId, {
method: 'PUT',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(body)
});
await res.json();
fetchPresets();
};
document.getElementById('clearForm').onclick = () => {
selectedPresetId = null;
document.getElementById('updatePreset').disabled = true;
fillForm({ title: '', subtitle: '', themeColor: '#ff6600', align: 'left', extraCss: '' });
};
document.getElementById('presetList').onclick = async (e) => {
const btn = e.target.closest('button');
if (!btn) return;
const container = btn.closest('.preset-item');
const id = container.dataset.id;
const act = btn.dataset.act;
if (act === 'select') {
const preset = presets.find(p => p.id === id);
if (!preset) return;
selectedPresetId = id;
document.getElementById('updatePreset').disabled = false;
fillForm(preset);
} else if (act === 'activate') {
await fetch('/api/presets/' + id + '/activate', { method: 'POST' });
fetchPresets();
} else if (act === 'delete') {
await fetch('/api/presets/' + id, { method: 'DELETE' });
if (selectedPresetId === id) {
selectedPresetId = null;
document.getElementById('updatePreset').disabled = true;
}
fetchPresets();
}
};
document.getElementById('clearActive').onclick = async () => {
await fetch('/api/clear', { method: 'POST' });
fetchPresets();
};
fetchPresets();
</script>
</body>
</html>
+288
View File
@@ -0,0 +1,288 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<style>
html, body {
margin: 0;
padding: 0;
width: 100%;
height: 100%;
overflow: hidden;
font-family: system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
color: #fff;
background: transparent;
}
.container {
position: relative;
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
justify-content: center;
align-items: flex-start;
padding: 20px 24px;
box-sizing: border-box;
overflow: hidden;
}
/* 几何图形背景动画 */
.geometric-background {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 0;
opacity: 0.7;
}
.shape {
position: absolute;
border-radius: 50%;
background: linear-gradient(135deg, rgba(255,105,180,0.4), rgba(0,191,255,0.4));
animation: float 8s infinite ease-in-out;
}
.shape:nth-child(1) {
width: 80px;
height: 80px;
top: 20%;
left: 10%;
animation-delay: 0s;
background: linear-gradient(135deg, rgba(255,105,180,0.5), rgba(255,20,147,0.3));
}
.shape:nth-child(2) {
width: 60px;
height: 60px;
top: 60%;
left: 15%;
animation-delay: 1s;
background: linear-gradient(135deg, rgba(0,191,255,0.5), rgba(30,144,255,0.3));
border-radius: 10px;
}
.shape:nth-child(3) {
width: 100px;
height: 100px;
top: 30%;
right: 10%;
animation-delay: 2s;
background: linear-gradient(135deg, rgba(50,205,50,0.5), rgba(0,255,127,0.3));
border-radius: 0;
clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
}
.shape:nth-child(4) {
width: 70px;
height: 70px;
bottom: 20%;
right: 20%;
animation-delay: 3s;
background: linear-gradient(135deg, rgba(255,215,0,0.5), rgba(255,140,0,0.3));
border-radius: 20px;
}
.shape:nth-child(5) {
width: 90px;
height: 90px;
top: 10%;
left: 40%;
animation-delay: 4s;
background: linear-gradient(135deg, rgba(138,43,226,0.5), rgba(75,0,130,0.3));
border-radius: 50%;
}
@keyframes float {
0%, 100% {
transform: translateY(0) rotate(0deg);
}
50% {
transform: translateY(-20px) rotate(180deg);
}
}
@keyframes pulse {
0%, 100% {
opacity: 0.7;
transform: scale(1);
}
50% {
opacity: 1;
transform: scale(1.1);
}
}
@keyframes slideIn {
0% {
opacity: 0;
transform: translateX(-30px);
}
100% {
opacity: 1;
transform: translateX(0);
}
}
/* 内容区域 */
.content {
position: relative;
z-index: 1;
background: rgba(0, 0, 0, 0.6);
backdrop-filter: blur(10px);
border-radius: 16px;
padding: 20px;
border: 1px solid rgba(255, 255, 255, 0.2);
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
animation: slideIn 0.8s ease-out;
}
.tag {
font-size: 12px;
letter-spacing: 0.15em;
text-transform: uppercase;
opacity: 0.9;
color: #ff69b4;
margin-bottom: 8px;
font-weight: 600;
}
.title {
font-size: 24px;
font-weight: 800;
margin-bottom: 8px;
background: linear-gradient(90deg, #ff69b4, #00bfff);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
animation: pulse 3s infinite;
}
.subtitle {
font-size: 16px;
opacity: 0.9;
line-height: 1.4;
margin-bottom: 12px;
}
.info-grid {
display: grid;
grid-template-columns: repeat(2, 1fr);
gap: 12px;
margin-top: 16px;
}
.info-item {
background: rgba(255, 255, 255, 0.1);
border-radius: 8px;
padding: 10px;
border-left: 3px solid #00bfff;
}
.info-label {
font-size: 11px;
opacity: 0.7;
margin-bottom: 4px;
}
.info-value {
font-size: 14px;
font-weight: 600;
}
/* 连接线动画 */
.connector {
position: absolute;
height: 2px;
background: linear-gradient(90deg, transparent, #ff69b4, transparent);
z-index: 0;
animation: connectorFlow 4s infinite linear;
}
@keyframes connectorFlow {
0% {
opacity: 0;
width: 0;
}
50% {
opacity: 1;
width: 100px;
}
100% {
opacity: 0;
width: 0;
transform: translateX(100px);
}
}
</style>
</head>
<body>
<div class="container">
<!-- 几何图形背景 -->
<div class="geometric-background">
<div class="shape"></div>
<div class="shape"></div>
<div class="shape"></div>
<div class="shape"></div>
<div class="shape"></div>
</div>
<!-- 连接线 -->
<div class="connector" style="top: 30%; left: 20%;"></div>
<div class="connector" style="top: 60%; right: 25%; animation-delay: 1s;"></div>
<div class="connector" style="bottom: 30%; left: 40%; animation-delay: 2s;"></div>
<!-- 主要内容 -->
<div class="content">
<div class="tag">GEOMETRIC ANIMATION PRESET</div>
<div class="title">集合图形动画演示</div>
<div class="subtitle">这是一个包含多种几何图形组合的动画预设,包含圆形、方形、三角形等元素的动态效果。</div>
<div class="info-grid">
<div class="info-item">
<div class="info-label">动画类型</div>
<div class="info-value">几何图形浮动</div>
</div>
<div class="info-item">
<div class="info-label">包含图形</div>
<div class="info-value">5种几何形状</div>
</div>
<div class="info-item">
<div class="info-label">颜色主题</div>
<div class="info-value">渐变彩虹色</div>
</div>
<div class="info-item">
<div class="info-label">动画时长</div>
<div class="info-value">8秒循环</div>
</div>
</div>
</div>
</div>
<script>
// 动态调整图形位置
document.addEventListener('DOMContentLoaded', function() {
const shapes = document.querySelectorAll('.shape');
const connectors = document.querySelectorAll('.connector');
// 为每个图形添加随机动画延迟
shapes.forEach((shape, index) => {
const randomDelay = Math.random() * 2;
shape.style.animationDelay = `${randomDelay}s`;
});
// 动态创建更多连接线
for (let i = 0; i < 3; i++) {
const connector = document.createElement('div');
connector.className = 'connector';
connector.style.top = `${Math.random() * 80 + 10}%`;
connector.style.left = `${Math.random() * 80 + 10}%`;
connector.style.animationDelay = `${Math.random() * 3}s`;
document.querySelector('.container').appendChild(connector);
}
});
</script>
</body>
</html>
+417
View File
@@ -0,0 +1,417 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<style>
html, body {
margin: 0;
padding: 0;
width: 100%;
height: 100%;
overflow: hidden;
font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
color: #fff;
background: transparent;
}
.preset-container {
position: relative;
width: 100%;
height: 100%;
padding: 15px 20px;
box-sizing: border-box;
display: flex;
align-items: center;
justify-content: flex-end;
}
/* 几何网格背景 */
.grid-background {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background:
linear-gradient(90deg, rgba(255,105,180,0.05) 1px, transparent 1px) 0 0 / 50px 50px,
linear-gradient(rgba(0,191,255,0.05) 1px, transparent 1px) 0 0 / 50px 50px;
z-index: 0;
animation: gridMove 20s linear infinite;
}
@keyframes gridMove {
0% {
background-position: 0 0;
}
100% {
background-position: 50px 50px;
}
}
/* 浮动几何体 */
.floating-geometry {
position: absolute;
width: 100%;
height: 100%;
z-index: 1;
}
.geo-element {
position: absolute;
opacity: 0.4;
filter: blur(0.5px);
mix-blend-mode: screen;
}
/* 内容面板 */
.content-panel {
position: relative;
z-index: 2;
background: rgba(15, 20, 30, 0.9);
backdrop-filter: blur(20px);
border-radius: 16px;
padding: 20px 24px;
border: 1px solid rgba(255, 255, 255, 0.15);
box-shadow:
0 10px 40px rgba(0, 0, 0, 0.6),
inset 0 1px 0 rgba(255, 255, 255, 0.1);
max-width: 400px;
min-width: 320px;
transform-style: preserve-3d;
perspective: 1000px;
}
.panel-header {
display: flex;
align-items: center;
margin-bottom: 16px;
padding-bottom: 12px;
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
.geo-badge {
width: 36px;
height: 36px;
background: linear-gradient(135deg, #ff69b4, #00bfff);
border-radius: 10px;
margin-right: 12px;
display: flex;
align-items: center;
justify-content: center;
font-size: 18px;
transform: rotate(45deg);
animation: badgeRotate 8s infinite linear;
}
.geo-badge span {
transform: rotate(-45deg);
}
@keyframes badgeRotate {
0% {
transform: rotate(45deg);
}
100% {
transform: rotate(405deg);
}
}
.header-text {
flex: 1;
}
.preset-name {
font-size: 22px;
font-weight: 700;
background: linear-gradient(90deg, #ff69b4, #00bfff, #9d4edd);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
margin-bottom: 4px;
}
.preset-tag {
font-size: 11px;
letter-spacing: 0.08em;
text-transform: uppercase;
color: #9d4edd;
font-weight: 600;
}
.preset-description {
font-size: 14px;
line-height: 1.5;
opacity: 0.9;
margin-bottom: 20px;
}
.features-grid {
display: grid;
grid-template-columns: repeat(2, 1fr);
gap: 12px;
margin-bottom: 20px;
}
.feature {
background: rgba(255, 255, 255, 0.05);
border-radius: 10px;
padding: 12px;
border: 1px solid rgba(255, 255, 255, 0.08);
transition: all 0.3s ease;
}
.feature:hover {
background: rgba(255, 255, 255, 0.1);
transform: translateY(-2px);
border-color: rgba(255, 105, 180, 0.3);
}
.feature-icon {
font-size: 20px;
margin-bottom: 6px;
opacity: 0.8;
}
.feature-title {
font-size: 13px;
font-weight: 600;
margin-bottom: 4px;
}
.feature-desc {
font-size: 11px;
opacity: 0.7;
line-height: 1.3;
}
.status-bar {
display: flex;
align-items: center;
justify-content: space-between;
padding-top: 12px;
border-top: 1px solid rgba(255, 255, 255, 0.1);
}
.status-indicator {
display: flex;
align-items: center;
gap: 6px;
}
.status-dot {
width: 8px;
height: 8px;
background: #00ff88;
border-radius: 50%;
animation: statusPulse 2s infinite;
}
@keyframes statusPulse {
0%, 100% {
opacity: 1;
box-shadow: 0 0 0 0 rgba(0, 255, 136, 0.7);
}
50% {
opacity: 0.7;
box-shadow: 0 0 0 6px rgba(0, 255, 136, 0);
}
}
.status-text {
font-size: 12px;
opacity: 0.8;
}
.timestamp {
font-size: 11px;
opacity: 0.6;
}
</style>
</head>
<body>
<div class="preset-container">
<!-- 网格背景 -->
<div class="grid-background"></div>
<!-- 浮动几何体 -->
<div class="floating-geometry" id="floatingGeo"></div>
<!-- 内容面板 -->
<div class="content-panel">
<div class="panel-header">
<div class="geo-badge">
<span>◈</span>
</div>
<div class="header-text">
<div class="preset-name">几何集合动画</div>
<div class="preset-tag">ANIMATED GEOMETRY PRESET</div>
</div>
</div>
<div class="preset-description">
专为OBS设计的动态几何图形动画预设,包含多种形状的3D浮动效果和交互式元素,适合科技展示、创意直播等场景。
</div>
<div class="features-grid">
<div class="feature">
<div class="feature-icon">●</div>
<div class="feature-title">动态图形</div>
<div class="feature-desc">12种几何形状随机生成,实时动画效果</div>
</div>
<div class="feature">
<div class="feature-icon">■</div>
<div class="feature-title">渐变色彩</div>
<div class="feature-desc">彩虹渐变配色方案,支持自定义调整</div>
</div>
<div class="feature">
<div class="feature-icon">▲</div>
<div class="feature-title">3D透视</div>
<div class="feature-desc">CSS 3D变换效果,增强视觉层次感</div>
</div>
<div class="feature">
<div class="feature-icon">◆</div>
<div class="feature-title">响应交互</div>
<div class="feature-desc">鼠标悬停效果,增强用户参与感</div>
</div>
</div>
<div class="status-bar">
<div class="status-indicator">
<div class="status-dot"></div>
<div class="status-text">动画运行中</div>
</div>
<div class="timestamp" id="timeDisplay">15:30</div>
</div>
</div>
</div>
<script>
// 初始化时间显示
function updateTime() {
const now = new Date();
const hours = now.getHours().toString().padStart(2, '0');
const minutes = now.getMinutes().toString().padStart(2, '0');
document.getElementById('timeDisplay').textContent = `${hours}:${minutes}`;
}
// 创建浮动几何体
function createFloatingGeometry() {
const container = document.getElementById('floatingGeo');
const shapes = ['circle', 'square', 'triangle', 'diamond', 'pentagon'];
const colors = [
'rgba(255,105,180,0.25)',
'rgba(0,191,255,0.25)',
'rgba(50,205,50,0.25)',
'rgba(255,215,0,0.25)',
'rgba(138,43,226,0.25)',
'rgba(255,69,0,0.25)',
'rgba(64,224,208,0.25)',
'rgba(255,20,147,0.25)'
];
// 创建15个几何体
for (let i = 0; i < 15; i++) {
const element = document.createElement('div');
element.className = 'geo-element';
const shape = shapes[Math.floor(Math.random() * shapes.length)];
const color = colors[Math.floor(Math.random() * colors.length)];
const size = Math.random() * 80 + 20;
const left = Math.random() * 100;
const top = Math.random() * 100;
const duration = Math.random() * 10 + 10;
const delay = Math.random() * 5;
// 设置基本样式
element.style.width = `${size}px`;
element.style.height = `${size}px`;
element.style.left = `${left}%`;
element.style.top = `${top}%`;
element.style.background = color;
element.style.animation = `float3D ${duration}s infinite ease-in-out ${delay}s`;
// 根据形状设置不同的样式
switch(shape) {
case 'circle':
element.style.borderRadius = '50%';
element.style.background = `radial-gradient(circle at 30% 30%, ${color}, transparent 70%)`;
break;
case 'square':
element.style.borderRadius = '8px';
element.style.transform = 'rotate(45deg)';
break;
case 'triangle':
element.style.width = '0';
element.style.height = '0';
element.style.background = 'none';
element.style.borderLeft = `${size/2}px solid transparent`;
element.style.borderRight = `${size/2}px solid transparent`;
element.style.borderBottom = `${size}px solid ${color}`;
break;
case 'diamond':
element.style.transform = 'rotate(45deg)';
element.style.borderRadius = '4px';
break;
case 'pentagon':
element.style.clipPath = 'polygon(50% 0%, 100% 38%, 82% 100%, 18% 100%, 0% 38%)';
break;
}
// 添加3D浮动动画
const keyframes = `
@keyframes float3D_${i} {
0%, 100% {
transform: translate3d(0, 0, 0) rotateX(0deg) rotateY(0deg);
opacity: 0.3;
}
25% {
transform: translate3d(20px, -30px, 50px) rotateX(90deg) rotateY(90deg);
opacity: 0.6;
}
50% {
transform: translate3d(-20px, 20px, -30px) rotateX(180deg) rotateY(180deg);
opacity: 0.4;
}
75% {
transform: translate3d(30px, 10px, 20px) rotateX(270deg) rotateY(270deg);
opacity: 0.7;
}
}
`;
// 动态添加关键帧
const style = document.createElement('style');
style.textContent = keyframes;
document.head.appendChild(style);
element.style.animation = `float3D_${i} ${duration}s infinite ease-in-out ${delay}s`;
container.appendChild(element);
}
}
// 初始化
document.addEventListener('DOMContentLoaded', function() {
updateTime();
createFloatingGeometry();
// 更新时间
setInterval(updateTime, 60000);
// 添加面板悬停效果
const panel = document.querySelector('.content-panel');
panel.addEventListener('mouseenter', function() {
this.style.transform = 'translateZ(20px) rotateX(2deg) rotateY(-2deg)';
this.style.boxShadow =
'0 20px 60px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.15)';
});
panel.addEventListener('mouseleave', function() {
this.style.transform = 'translateZ(0) rotateX(0deg) rotateY(0deg)';
this.style.boxShadow =
'0 10px 40px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.1)';
});
});
</script>
</body>
</html>
+319
View File
@@ -0,0 +1,319 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<style>
html, body {
margin: 0;
padding: 0;
width: 100%;
height: 100%;
overflow: hidden;
font-family: system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
color: #fff;
background: transparent;
}
.container {
position: relative;
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
justify-content: center;
align-items: flex-start;
padding: 16px 20px;
box-sizing: border-box;
overflow: hidden;
}
/* 几何图形动画 */
.geometric-shapes {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 0;
}
.shape {
position: absolute;
opacity: 0.6;
filter: blur(1px);
}
.circle {
border-radius: 50%;
background: radial-gradient(circle, rgba(255,105,180,0.4), transparent 70%);
}
.square {
border-radius: 8px;
background: linear-gradient(135deg, rgba(0,191,255,0.4), rgba(30,144,255,0.2));
}
.triangle {
width: 0;
height: 0;
border-left: 30px solid transparent;
border-right: 30px solid transparent;
border-bottom: 52px solid rgba(50,205,50,0.4);
background: none;
}
.hexagon {
width: 50px;
height: 28.87px;
background: rgba(255,215,0,0.4);
position: relative;
clip-path: polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%);
}
/* 动画 */
@keyframes float {
0%, 100% {
transform: translate(0, 0) rotate(0deg);
}
33% {
transform: translate(10px, -15px) rotate(120deg);
}
66% {
transform: translate(-10px, 10px) rotate(240deg);
}
}
@keyframes pulse {
0%, 100% {
opacity: 0.4;
transform: scale(1);
}
50% {
opacity: 0.8;
transform: scale(1.2);
}
}
@keyframes glow {
0%, 100% {
box-shadow: 0 0 10px rgba(255,105,180,0.3);
}
50% {
box-shadow: 0 0 30px rgba(255,105,180,0.6);
}
}
/* 内容卡片 */
.content-card {
position: relative;
z-index: 1;
background: rgba(10, 10, 20, 0.85);
backdrop-filter: blur(15px);
border-radius: 14px;
padding: 18px;
border: 1px solid rgba(255, 255, 255, 0.15);
box-shadow:
0 8px 32px rgba(0, 0, 0, 0.4),
0 0 0 1px rgba(255, 255, 255, 0.05);
min-width: 300px;
max-width: 450px;
animation: glow 4s infinite;
}
.header {
display: flex;
align-items: center;
margin-bottom: 12px;
}
.icon {
width: 40px;
height: 40px;
background: linear-gradient(135deg, #ff69b4, #00bfff);
border-radius: 10px;
margin-right: 12px;
display: flex;
align-items: center;
justify-content: center;
font-size: 20px;
animation: pulse 3s infinite;
}
.title-section {
flex: 1;
}
.tag {
font-size: 11px;
letter-spacing: 0.1em;
text-transform: uppercase;
color: #00bfff;
font-weight: 600;
margin-bottom: 2px;
}
.title {
font-size: 20px;
font-weight: 700;
background: linear-gradient(90deg, #ff69b4, #00bfff);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
}
.description {
font-size: 14px;
line-height: 1.5;
opacity: 0.9;
margin-bottom: 16px;
padding-bottom: 12px;
border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
.stats {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 10px;
}
.stat-item {
text-align: center;
padding: 8px;
background: rgba(255, 255, 255, 0.05);
border-radius: 8px;
border: 1px solid rgba(255, 255, 255, 0.08);
}
.stat-value {
font-size: 18px;
font-weight: 700;
color: #ff69b4;
margin-bottom: 2px;
}
.stat-label {
font-size: 10px;
opacity: 0.7;
text-transform: uppercase;
letter-spacing: 0.05em;
}
.footer {
margin-top: 12px;
font-size: 11px;
opacity: 0.6;
text-align: center;
padding-top: 8px;
border-top: 1px solid rgba(255, 255, 255, 0.1);
}
</style>
</head>
<body>
<div class="container">
<!-- 几何图形 -->
<div class="geometric-shapes" id="shapesContainer">
<!-- 图形将通过JS动态生成 -->
</div>
<!-- 内容卡片 -->
<div class="content-card">
<div class="header">
<div class="icon">◈</div>
<div class="title-section">
<div class="tag">GEOMETRIC ANIMATION</div>
<div class="title">集合图形预设</div>
</div>
</div>
<div class="description">
这是一个动态几何图形动画预设,包含多种形状的浮动效果,适合科技、设计、创意类内容的直播展示。
</div>
<div class="stats">
<div class="stat-item">
<div class="stat-value">12</div>
<div class="stat-label">图形数量</div>
</div>
<div class="stat-item">
<div class="stat-value">4</div>
<div class="stat-label">形状类型</div>
</div>
<div class="stat-item">
<div class="stat-value">6s</div>
<div class="stat-label">动画周期</div>
</div>
</div>
<div class="footer">
实时渲染 · 几何动画系统
</div>
</div>
</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
const container = document.getElementById('shapesContainer');
const shapes = ['circle', 'square', 'triangle', 'hexagon'];
const colors = [
'rgba(255,105,180,0.3)',
'rgba(0,191,255,0.3)',
'rgba(50,205,50,0.3)',
'rgba(255,215,0,0.3)',
'rgba(138,43,226,0.3)',
'rgba(255,69,0,0.3)'
];
// 创建12个随机几何图形
for (let i = 0; i < 12; i++) {
const shape = document.createElement('div');
const shapeType = shapes[Math.floor(Math.random() * shapes.length)];
const color = colors[Math.floor(Math.random() * colors.length)];
shape.className = `shape ${shapeType}`;
// 随机位置和大小
const size = Math.random() * 60 + 20;
const left = Math.random() * 100;
const top = Math.random() * 100;
const duration = Math.random() * 4 + 4;
const delay = Math.random() * 2;
// 设置样式
if (shapeType === 'triangle') {
shape.style.borderBottomColor = color;
} else if (shapeType === 'hexagon') {
shape.style.width = `${size}px`;
shape.style.height = `${size * 0.577}px`;
shape.style.background = color;
} else {
shape.style.width = `${size}px`;
shape.style.height = `${size}px`;
if (shapeType === 'circle') {
shape.style.background = `radial-gradient(circle, ${color}, transparent 70%)`;
} else {
shape.style.background = color;
}
}
shape.style.left = `${left}%`;
shape.style.top = `${top}%`;
shape.style.animation = `float ${duration}s infinite ease-in-out ${delay}s`;
container.appendChild(shape);
}
// 添加一些交互效果
const contentCard = document.querySelector('.content-card');
contentCard.addEventListener('mouseenter', function() {
this.style.transform = 'translateY(-2px)';
this.style.boxShadow = '0 15px 40px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.1)';
});
contentCard.addEventListener('mouseleave', function() {
this.style.transform = 'translateY(0)';
this.style.boxShadow = '0 8px 32px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.05)';
});
});
</script>
</body>
</html>
+8
View File
@@ -0,0 +1,8 @@
{
"name": "几何集合动画预设",
"description": "动态几何图形动画,包含多种形状的浮动效果",
"kind": "iframe",
"align": "right",
"html": "<!DOCTYPE html><html><head><meta charset='utf-8'/><style>html,body{margin:0;padding:0;width:100%;height:100%;overflow:hidden;font-family:system-ui,sans-serif;color:#fff;background:transparent}.container{position:relative;width:100%;height:100%;padding:15px 20px;box-sizing:border-box;display:flex;align-items:center;justify-content:flex-end}.geometric-bg{position:absolute;top:0;left:0;width:100%;height:100%;z-index:0}.shape{position:absolute;opacity:0.4;animation:float 8s infinite ease-in-out}.circle{border-radius:50%;background:radial-gradient(circle,rgba(255,105,180,0.3),transparent 70%)}.square{border-radius:8px;background:linear-gradient(135deg,rgba(0,191,255,0.3),rgba(30,144,255,0.2))}.triangle{width:0;height:0;border-left:25px solid transparent;border-right:25px solid transparent;border-bottom:43px solid rgba(50,205,50,0.3);background:none}@keyframes float{0%,100%{transform:translate(0,0) rotate(0deg)}50%{transform:translate(10px,-15px) rotate(180deg)}}.content-panel{position:relative;z-index:1;background:rgba(15,20,30,0.9);backdrop-filter:blur(15px);border-radius:14px;padding:18px 22px;border:1px solid rgba(255,255,255,0.15);box-shadow:0 10px 40px rgba(0,0,0,0.6);max-width:380px;min-width:300px}.panel-header{display:flex;align-items:center;margin-bottom:12px}.geo-icon{width:32px;height:32px;background:linear-gradient(135deg,#ff69b4,#00bfff);border-radius:8px;margin-right:10px;display:flex;align-items:center;justify-content:center;font-size:16px;animation:rotate 6s infinite linear}.geo-icon span{transform:rotate(-45deg)}@keyframes rotate{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}.header-text{flex:1}.title{font-size:20px;font-weight:700;background:linear-gradient(90deg,#ff69b4,#00bfff);-webkit-background-clip:text;-webkit-text-fill-color:transparent;background-clip:text;margin-bottom:2px}.tag{font-size:11px;letter-spacing:0.08em;text-transform:uppercase;color:#00bfff;font-weight:600}.description{font-size:13px;line-height:1.5;opacity:0.9;margin-bottom:16px}.features{display:grid;grid-template-columns:repeat(2,1fr);gap:10px;margin-bottom:16px}.feature-item{background:rgba(255,255,255,0.05);border-radius:8px;padding:10px;border:1px solid rgba(255,255,255,0.08)}.feature-title{font-size:12px;font-weight:600;margin-bottom:4px}.feature-desc{font-size:10px;opacity:0.7;line-height:1.3}.status{display:flex;align-items:center;justify-content:space-between;padding-top:12px;border-top:1px solid rgba(255,255,255,0.1)}.status-dot{width:6px;height:6px;background:#00ff88;border-radius:50%;animation:pulse 2s infinite}@keyframes pulse{0%,100%{opacity:1}50%{opacity:0.5}}.status-text{font-size:11px;opacity:0.8}.time{font-size:10px;opacity:0.6}</style></head><body><div class='container'><div class='geometric-bg' id='geoContainer'></div><div class='content-panel'><div class='panel-header'><div class='geo-icon'><span>◈</span></div><div class='header-text'><div class='title'>几何动画预设</div><div class='tag'>GEOMETRIC PRESET</div></div></div><div class='description'>动态几何图形动画效果,适合科技展示和创意直播场景。</div><div class='features'><div class='feature-item'><div class='feature-title'>动态图形</div><div class='feature-desc'>多种几何形状浮动动画</div></div><div class='feature-item'><div class='feature-title'>渐变色彩</div><div class='feature-desc'>彩虹渐变配色方案</div></div><div class='feature-item'><div class='feature-title'>3D效果</div><div class='feature-desc'>CSS 3D变换动画</div></div><div class='feature-item'><div class='feature-title'>实时交互</div><div class='feature-desc'>鼠标悬停响应效果</div></div></div><div class='status'><div style='display:flex;align-items:center;gap:6px'><div class='status-dot'></div><div class='status-text'>动画运行中</div></div><div class='time' id='timeDisplay'>15:30</div></div></div></div><script>function updateTime(){const e=new Date,t=e.getHours().toString().padStart(2,'0'),o=e.getMinutes().toString().padStart(2,'0');document.getElementById('timeDisplay').textContent=`${t}:${o}`}function createGeometry(){const e=document.getElementById('geoContainer'),t=['circle','square','triangle'],o=['rgba(255,105,180,0.25)','rgba(0,191,255,0.25)','rgba(50,205,50,0.25)','rgba(255,215,0,0.25)','rgba(138,43,226,0.25)'];for(let n=0;n<10;n++){const a=document.createElement('div');a.className=`shape ${t[Math.floor(Math.random()*t.length)]}`;const r=Math.random()*60+20,i=Math.random()*100,l=Math.random()*100,c=Math.random()*6+4,d=Math.random()*2,s=o[Math.floor(Math.random()*o.length)];a.style.width=`${r}px`,a.style.height=`${r}px`,a.style.left=`${i}%`,a.style.top=`${l}%`,a.style.animationDelay=`${d}s`,a.style.animationDuration=`${c}s`,a.className.includes('triangle')?(a.style.width='0',a.style.height='0',a.style.borderLeft=`${r/2}px solid transparent`,a.style.borderRight=`${r/2}px solid transparent`,a.style.borderBottom=`${r}px solid ${s}`,a.style.background='none'):a.className.includes('circlLine truncated
"extraCss": ".lt-root { justify-content: flex-end !important; padding: 5vh 6vw !important; } .lt-container { min-width: 380px !important; max-width: 450px !important; }"
}
+335
View File
@@ -0,0 +1,335 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>几何动画预设测试</title>
<style>
body {
font-family: system-ui, sans-serif;
margin: 0;
padding: 20px;
background: #1a1a2e;
color: #fff;
}
.container {
max-width: 1200px;
margin: 0 auto;
}
h1 {
color: #ff69b4;
text-align: center;
margin-bottom: 30px;
}
.test-area {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 30px;
margin-bottom: 40px;
}
.widget-frame {
width: 100%;
height: 200px;
border: 2px solid #333;
border-radius: 10px;
overflow: hidden;
background: #000;
}
.controls {
background: rgba(255, 255, 255, 0.05);
padding: 20px;
border-radius: 10px;
border: 1px solid rgba(255, 255, 255, 0.1);
}
.control-group {
margin-bottom: 20px;
}
label {
display: block;
margin-bottom: 8px;
color: #00bfff;
font-weight: 600;
}
select, button {
width: 100%;
padding: 10px;
border-radius: 6px;
border: 1px solid #444;
background: #2a2a3e;
color: #fff;
font-size: 14px;
}
button {
background: linear-gradient(135deg, #ff69b4, #00bfff);
border: none;
cursor: pointer;
font-weight: 600;
transition: transform 0.2s;
}
button:hover {
transform: translateY(-2px);
}
.info {
background: rgba(0, 191, 255, 0.1);
padding: 15px;
border-radius: 8px;
border-left: 4px solid #00bfff;
margin-top: 20px;
}
.info h3 {
margin-top: 0;
color: #00bfff;
}
.preset-list {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
gap: 20px;
margin-top: 30px;
}
.preset-card {
background: rgba(255, 255, 255, 0.05);
border-radius: 10px;
padding: 20px;
border: 1px solid rgba(255, 255, 255, 0.1);
transition: all 0.3s ease;
}
.preset-card:hover {
transform: translateY(-5px);
border-color: #ff69b4;
box-shadow: 0 10px 30px rgba(255, 105, 180, 0.2);
}
.preset-name {
font-size: 18px;
font-weight: 700;
color: #ff69b4;
margin-bottom: 8px;
}
.preset-desc {
font-size: 14px;
opacity: 0.8;
margin-bottom: 15px;
}
.preset-meta {
display: flex;
justify-content: space-between;
font-size: 12px;
opacity: 0.6;
}
</style>
</head>
<body>
<div class="container">
<h1>几何动画预设测试</h1>
<div class="test-area">
<div>
<h2>预设预览</h2>
<div class="widget-frame" id="widgetFrame">
<!-- 预设将在这里加载 -->
</div>
</div>
<div class="controls">
<h2>控制面板</h2>
<div class="control-group">
<label for="presetSelect">选择预设</label>
<select id="presetSelect">
<option value="">请选择预设...</option>
</select>
</div>
<div class="control-group">
<label for="alignSelect">对齐方式</label>
<select id="alignSelect">
<option value="left">左对齐</option>
<option value="center">居中</option>
<option value="right" selected>右对齐</option>
</select>
</div>
<button id="loadPresetBtn">加载预设</button>
<button id="refreshBtn" style="margin-top: 10px; background: linear-gradient(135deg, #9d4edd, #ff69b4);">刷新预设列表</button>
<div class="info">
<h3>使用说明</h3>
<p>1. 选择预设类型</p>
<p>2. 调整对齐方式</p>
<p>3. 点击"加载预设"按钮</p>
<p>4. 预设将显示在左侧预览区域</p>
</div>
</div>
</div>
<h2>可用预设列表</h2>
<div class="preset-list" id="presetList">
<!-- 预设列表将通过JS动态生成 -->
</div>
</div>
<script>
// 获取DOM元素
const widgetFrame = document.getElementById('widgetFrame');
const presetSelect = document.getElementById('presetSelect');
const alignSelect = document.getElementById('alignSelect');
const loadPresetBtn = document.getElementById('loadPresetBtn');
const refreshBtn = document.getElementById('refreshBtn');
const presetList = document.getElementById('presetList');
// 获取预设列表
async function fetchPresets() {
try {
const response = await fetch('/api/presets');
const presets = await response.json();
return presets;
} catch (error) {
console.error('获取预设列表失败:', error);
return [];
}
}
// 加载预设到iframe
function loadPreset(preset) {
const align = alignSelect.value;
// 创建iframe
const iframe = document.createElement('iframe');
iframe.style.width = '100%';
iframe.style.height = '100%';
iframe.style.border = 'none';
iframe.sandbox = 'allow-scripts allow-same-origin';
// 设置iframe内容
const htmlContent = `
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<style>
html, body {
margin: 0;
padding: 0;
width: 100%;
height: 100%;
overflow: hidden;
background: transparent;
}
${preset.extraCss || ''}
</style>
</head>
<body>
${preset.html}
</body>
</html>
`;
// 清空并添加新的iframe
widgetFrame.innerHTML = '';
widgetFrame.appendChild(iframe);
// 写入内容
const iframeDoc = iframe.contentDocument || iframe.contentWindow.document;
iframeDoc.open();
iframeDoc.write(htmlContent);
iframeDoc.close();
}
// 填充预设选择器
async function populatePresetSelect() {
const presets = await fetchPresets();
// 清空选项
presetSelect.innerHTML = '<option value="">请选择预设...</option>';
// 添加预设选项
presets.forEach((preset, index) => {
const option = document.createElement('option');
option.value = index;
option.textContent = preset.name;
presetSelect.appendChild(option);
});
// 显示预设列表
displayPresetList(presets);
}
// 显示预设列表
function displayPresetList(presets) {
presetList.innerHTML = '';
presets.forEach((preset, index) => {
const card = document.createElement('div');
card.className = 'preset-card';
card.innerHTML = `
<div class="preset-name">${preset.name}</div>
<div class="preset-desc">${preset.description}</div>
<div class="preset-meta">
<span>类型: ${preset.kind}</span>
<span>对齐: ${preset.align}</span>
</div>
`;
// 点击卡片加载预设
card.addEventListener('click', () => {
presetSelect.value = index;
loadPreset(preset);
});
presetList.appendChild(card);
});
}
// 事件监听
loadPresetBtn.addEventListener('click', async () => {
const selectedIndex = presetSelect.value;
if (selectedIndex === '') {
alert('请先选择一个预设');
return;
}
const presets = await fetchPresets();
const selectedPreset = presets[selectedIndex];
if (selectedPreset) {
loadPreset(selectedPreset);
}
});
refreshBtn.addEventListener('click', populatePresetSelect);
// 页面加载时初始化
document.addEventListener('DOMContentLoaded', () => {
populatePresetSelect();
// 默认加载几何动画预设
setTimeout(async () => {
const presets = await fetchPresets();
const geometricPreset = presets.find(p => p.name === '几何动画预设');
if (geometricPreset) {
const index = presets.indexOf(geometricPreset);
presetSelect.value = index;
loadPreset(geometricPreset);
}
}, 1000);
});
</script>
</body>
</html>
+453
View File
@@ -0,0 +1,453 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>几何动画预设 - 简单测试</title>
<style>
body {
margin: 0;
padding: 0;
background: #000;
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
font-family: system-ui, sans-serif;
}
.test-container {
width: 800px;
height: 200px;
position: relative;
border: 2px solid #333;
border-radius: 10px;
overflow: hidden;
background: #000;
}
.controls {
position: absolute;
top: 10px;
right: 10px;
z-index: 1000;
background: rgba(0, 0, 0, 0.7);
padding: 10px;
border-radius: 5px;
border: 1px solid #444;
}
button {
background: linear-gradient(135deg, #ff69b4, #00bfff);
border: none;
color: white;
padding: 8px 16px;
border-radius: 4px;
cursor: pointer;
font-weight: 600;
margin: 5px;
}
button:hover {
opacity: 0.9;
}
.status {
position: absolute;
bottom: 10px;
left: 10px;
color: #00ff88;
font-size: 12px;
background: rgba(0, 0, 0, 0.7);
padding: 5px 10px;
border-radius: 4px;
}
</style>
</head>
<body>
<div class="test-container" id="widgetContainer">
<!-- 几何动画预设将在这里加载 -->
</div>
<div class="controls">
<button onclick="loadGeometricPreset()">加载几何动画预设</button>
<button onclick="reloadPreset()">重新加载</button>
<button onclick="toggleAnimation()">暂停/继续动画</button>
</div>
<div class="status" id="status">就绪</div>
<script>
let currentIframe = null;
let animationPaused = false;
// 几何动画预设HTML
const geometricPresetHTML = `<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'/>
<style>
html, body {
margin: 0;
padding: 0;
width: 100%;
height: 100%;
overflow: hidden;
font-family: system-ui, -apple-system, sans-serif;
color: #fff;
background: transparent;
}
.lt-root {
position: relative;
width: 100%;
height: 100%;
padding: 15px 20px;
box-sizing: border-box;
display: flex;
align-items: center;
justify-content: flex-end;
}
/* 几何图形背景 */
.geometric-bg {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 0;
}
.geo-shape {
position: absolute;
opacity: 0.4;
filter: blur(0.5px);
mix-blend-mode: screen;
animation: floatGeo 8s infinite ease-in-out;
}
@keyframes floatGeo {
0%, 100% {
transform: translate(0, 0) rotate(0deg);
}
50% {
transform: translate(10px, -15px) rotate(180deg);
}
}
/* 内容面板 */
.lt-container {
position: relative;
z-index: 1;
background: rgba(15, 20, 30, 0.9);
backdrop-filter: blur(15px);
border-radius: 14px;
padding: 18px 22px;
border: 1px solid rgba(255, 255, 255, 0.15);
box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
max-width: 380px;
min-width: 300px;
transition: all 0.3s ease;
}
.lt-container:hover {
transform: translateY(-2px);
box-shadow: 0 15px 50px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255, 255, 255, 0.2);
}
.lt-header {
display: flex;
align-items: center;
margin-bottom: 12px;
}
.geo-icon {
width: 32px;
height: 32px;
background: linear-gradient(135deg, #ff69b4, #00bfff);
border-radius: 8px;
margin-right: 10px;
display: flex;
align-items: center;
justify-content: center;
font-size: 16px;
animation: rotateIcon 6s infinite linear;
}
.geo-icon span {
transform: rotate(-45deg);
}
@keyframes rotateIcon {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
.lt-title {
font-size: 20px;
font-weight: 700;
background: linear-gradient(90deg, #ff69b4, #00bfff);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
margin-bottom: 2px;
}
.lt-tag {
font-size: 11px;
letter-spacing: 0.08em;
text-transform: uppercase;
color: #00bfff;
font-weight: 600;
}
.lt-description {
font-size: 13px;
line-height: 1.5;
opacity: 0.9;
margin-bottom: 16px;
}
.lt-features {
display: grid;
grid-template-columns: repeat(2, 1fr);
gap: 10px;
margin-bottom: 16px;
}
.lt-feature {
background: rgba(255, 255, 255, 0.05);
border-radius: 8px;
padding: 10px;
border: 1px solid rgba(255, 255, 255, 0.08);
}
.lt-feature-title {
font-size: 12px;
font-weight: 600;
margin-bottom: 4px;
}
.lt-feature-desc {
font-size: 10px;
opacity: 0.7;
line-height: 1.3;
}
.lt-status {
display: flex;
align-items: center;
justify-content: space-between;
padding-top: 12px;
border-top: 1px solid rgba(255, 255, 255, 0.1);
}
.status-dot {
width: 6px;
height: 6px;
background: #00ff88;
border-radius: 50%;
animation: pulseDot 2s infinite;
}
@keyframes pulseDot {
0%, 100% {
opacity: 1;
}
50% {
opacity: 0.5;
}
}
.status-text {
font-size: 11px;
opacity: 0.8;
}
.lt-time {
font-size: 10px;
opacity: 0.6;
}
</style>
</head>
<body>
<div class="lt-root">
<div class="geometric-bg" id="geoContainer"></div>
<div class="lt-container">
<div class="lt-header">
<div class="geo-icon"><span>◈</span></div>
<div>
<div class="lt-title">几何动画预设</div>
<div class="lt-tag">GEOMETRIC PRESET</div>
</div>
</div>
<div class="lt-description">
动态几何图形动画效果,包含多种形状的浮动动画,适合科技展示和创意直播。
</div>
<div class="lt-features">
<div class="lt-feature">
<div class="lt-feature-title">动态图形</div>
<div class="lt-feature-desc">多种几何形状浮动动画</div>
</div>
<div class="lt-feature">
<div class="lt-feature-title">渐变色彩</div>
<div class="lt-feature-desc">彩虹渐变配色方案</div>
</div>
<div class="lt-feature">
<div class="lt-feature-title">3D效果</div>
<div class="lt-feature-desc">CSS 3D变换动画</div>
</div>
<div class="lt-feature">
<div class="lt-feature-title">实时交互</div>
<div class="lt-feature-desc">鼠标悬停响应效果</div>
</div>
</div>
<div class="lt-status">
<div style="display: flex; align-items: center; gap: 6px;">
<div class="status-dot"></div>
<div class="status-text">动画运行中</div>
</div>
<div class="lt-time" id="timeDisplay">15:30</div>
</div>
</div>
</div>
<script>
// 更新时间显示
function updateTime() {
const now = new Date();
const hours = now.getHours().toString().padStart(2, '0');
const minutes = now.getMinutes().toString().padStart(2, '0');
document.getElementById('timeDisplay').textContent = \`\${hours}:\${minutes}\`;
}
// 创建几何图形
function createGeometry() {
const container = document.getElementById('geoContainer');
const shapes = ['circle', 'square', 'triangle'];
const colors = [
'rgba(255,105,180,0.25)',
'rgba(0,191,255,0.25)',
'rgba(50,205,50,0.25)',
'rgba(255,215,0,0.25)',
'rgba(138,43,226,0.25)'
];
// 创建10个几何图形
for (let i = 0; i < 10; i++) {
const shape = document.createElement('div');
shape.className = 'geo-shape';
const shapeType = shapes[Math.floor(Math.random() * shapes.length)];
const color = colors[Math.floor(Math.random() * colors.length)];
const size = Math.random() * 60 + 20;
const left = Math.random() * 100;
const top = Math.random() * 100;
const duration = Math.random() * 6 + 4;
const delay = Math.random() * 2;
shape.style.width = \`\${size}px\`;
shape.style.height = \`\${size}px\`;
shape.style.left = \`\${left}%\`;
shape.style.top = \`\${top}%\`;
shape.style.animationDelay = \`\${delay}s\`;
shape.style.animationDuration = \`\${duration}s\`;
if (shapeType === 'triangle') {
shape.style.width = '0';
shape.style.height = '0';
shape.style.borderLeft = \`\${size/2}px solid transparent\`;
shape.style.borderRight = \`\${size/2}px solid transparent\`;
shape.style.borderBottom = \`\${size}px solid \${color}\`;
shape.style.background = 'none';
} else if (shapeType === 'circle') {
shape.style.borderRadius = '50%';
shape.style.background = \`radial-gradient(circle, \${color}, transparent 70%)\`;
} else {
shape.style.borderRadius = '8px';
shape.style.background = color;
}
container.appendChild(shape);
}
}
// 初始化
document.addEventListener('DOMContentLoaded', function() {
updateTime();
createGeometry();
setInterval(updateTime, 60000);
});
</script>
</body>
</html>`;
function loadGeometricPreset() {
const container = document.getElementById('widgetContainer');
container.innerHTML = '';
const iframe = document.createElement('iframe');
iframe.style.width = '100%';
iframe.style.height = '100%';
iframe.style.border = 'none';
iframe.sandbox = 'allow-scripts allow-same-origin';
container.appendChild(iframe);
currentIframe = iframe;
const iframeDoc = iframe.contentDocument || iframe.contentWindow.document;
iframeDoc.open();
iframeDoc.write(geometricPresetHTML);
iframeDoc.close();
document.getElementById('status').textContent = '几何动画预设已加载';
document.getElementById('status').style.color = '#00ff88';
}
function reloadPreset() {
if (currentIframe) {
const iframeDoc = currentIframe.contentDocument || currentIframe.contentWindow.document;
iframeDoc.open();
iframeDoc.write(geometricPresetHTML);
iframeDoc.close();
document.getElementById('status').textContent = '预设已重新加载';
document.getElementById('status').style.color = '#00bfff';
}
}
function toggleAnimation() {
if (!currentIframe) return;
const iframeDoc = currentIframe.contentDocument || currentIframe.contentWindow.document;
const shapes = iframeDoc.querySelectorAll('.geo-shape');
animationPaused = !animationPaused;
shapes.forEach(shape => {
if (animationPaused) {
shape.style.animationPlayState = 'paused';
} else {
shape.style.animationPlayState = 'running';
}
});
const statusText = animationPaused ? '动画已暂停' : '动画已继续';
document.getElementById('status').textContent = statusText;
document.getElementById('status').style.color = animationPaused ? '#ff69b4' : '#00ff88';
}
// 页面加载时自动加载预设
window.onload = function() {
setTimeout(loadGeometricPreset, 500);
};
</script>
</body>
</html>
+598
View File
@@ -0,0 +1,598 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>验证几何动画预设集成</title>
<style>
body {
font-family: system-ui, sans-serif;
margin: 20px;
background: #1a1a2e;
color: #fff;
}
.container {
max-width: 800px;
margin: 0 auto;
}
h1 {
color: #ff69b4;
text-align: center;
}
.status {
padding: 15px;
border-radius: 8px;
margin: 20px 0;
text-align: center;
font-weight: bold;
}
.success {
background: rgba(0, 255, 136, 0.1);
border: 2px solid #00ff88;
color: #00ff88;
}
.error {
background: rgba(255, 69, 0, 0.1);
border: 2px solid #ff4500;
color: #ff4500;
}
.info {
background: rgba(0, 191, 255, 0.1);
border: 2px solid #00bfff;
color: #00bfff;
}
.preset-preview {
width: 100%;
height: 200px;
border: 2px solid #333;
border-radius: 10px;
overflow: hidden;
background: #000;
margin: 20px 0;
}
.controls {
display: flex;
gap: 10px;
margin: 20px 0;
}
button {
padding: 10px 20px;
border: none;
border-radius: 6px;
background: linear-gradient(135deg, #ff69b4, #00bfff);
color: white;
font-weight: bold;
cursor: pointer;
flex: 1;
}
button:hover {
opacity: 0.9;
}
.preset-info {
background: rgba(255, 255, 255, 0.05);
padding: 20px;
border-radius: 10px;
margin-top: 20px;
}
.preset-info h3 {
color: #ff69b4;
margin-top: 0;
}
.preset-details {
display: grid;
grid-template-columns: repeat(2, 1fr);
gap: 10px;
margin-top: 15px;
}
.detail-item {
background: rgba(255, 255, 255, 0.03);
padding: 10px;
border-radius: 6px;
border: 1px solid rgba(255, 255, 255, 0.1);
}
.detail-label {
font-size: 12px;
opacity: 0.7;
margin-bottom: 5px;
}
.detail-value {
font-size: 14px;
font-weight: 600;
}
</style>
</head>
<body>
<div class="container">
<h1>几何动画预设集成验证</h1>
<div id="serverStatus" class="status info">
正在检查服务器状态...
</div>
<div id="presetStatus" class="status info">
正在检查预设集成...
</div>
<div class="controls">
<button onclick="checkServer()">检查服务器</button>
<button onclick="loadPreset()">加载预设</button>
<button onclick="showPresetInfo()">显示预设信息</button>
</div>
<div class="preset-preview" id="previewFrame">
<!-- 预设将在这里显示 -->
</div>
<div class="preset-info" id="presetInfo" style="display: none;">
<h3>几何动画预设详情</h3>
<div class="preset-details" id="presetDetails">
<!-- 预设详情将在这里显示 -->
</div>
</div>
</div>
<script>
// 几何动画预设的HTML内容(从server.js中提取)
const geometricPresetHTML = `<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'/>
<style>
html, body {
margin: 0;
padding: 0;
width: 100%;
height: 100%;
overflow: hidden;
font-family: system-ui, -apple-system, sans-serif;
color: #fff;
background: transparent;
}
.lt-root {
position: relative;
width: 100%;
height: 100%;
padding: 15px 20px;
box-sizing: border-box;
display: flex;
align-items: center;
justify-content: flex-end;
}
.geometric-bg {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 0;
}
.geo-shape {
position: absolute;
opacity: 0.4;
filter: blur(0.5px);
mix-blend-mode: screen;
animation: floatGeo 8s infinite ease-in-out;
}
@keyframes floatGeo {
0%, 100% {
transform: translate(0, 0) rotate(0deg);
}
50% {
transform: translate(10px, -15px) rotate(180deg);
}
}
.lt-container {
position: relative;
z-index: 1;
background: rgba(15, 20, 30, 0.9);
backdrop-filter: blur(15px);
border-radius: 14px;
padding: 18px 22px;
border: 1px solid rgba(255, 255, 255, 0.15);
box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
max-width: 380px;
min-width: 300px;
transition: all 0.3s ease;
}
.lt-container:hover {
transform: translateY(-2px);
box-shadow: 0 15px 50px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255, 255, 255, 0.2);
}
.lt-header {
display: flex;
align-items: center;
margin-bottom: 12px;
}
.geo-icon {
width: 32px;
height: 32px;
background: linear-gradient(135deg, #ff69b4, #00bfff);
border-radius: 8px;
margin-right: 10px;
display: flex;
align-items: center;
justify-content: center;
font-size: 16px;
animation: rotateIcon 6s infinite linear;
}
.geo-icon span {
transform: rotate(-45deg);
}
@keyframes rotateIcon {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
.lt-title {
font-size: 20px;
font-weight: 700;
background: linear-gradient(90deg, #ff69b4, #00bfff);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
margin-bottom: 2px;
}
.lt-tag {
font-size: 11px;
letter-spacing: 0.08em;
text-transform: uppercase;
color: #00bfff;
font-weight: 600;
}
.lt-description {
font-size: 13px;
line-height: 1.5;
opacity: 0.9;
margin-bottom: 16px;
}
.lt-features {
display: grid;
grid-template-columns: repeat(2, 1fr);
gap: 10px;
margin-bottom: 16px;
}
.lt-feature {
background: rgba(255, 255, 255, 0.05);
border-radius: 8px;
padding: 10px;
border: 1px solid rgba(255, 255, 255, 0.08);
}
.lt-feature-title {
font-size: 12px;
font-weight: 600;
margin-bottom: 4px;
}
.lt-feature-desc {
font-size: 10px;
opacity: 0.7;
line-height: 1.3;
}
.lt-status {
display: flex;
align-items: center;
justify-content: space-between;
padding-top: 12px;
border-top: 1px solid rgba(255, 255, 255, 0.1);
}
.status-dot {
width: 6px;
height: 6px;
background: #00ff88;
border-radius: 50%;
animation: pulseDot 2s infinite;
}
@keyframes pulseDot {
0%, 100% {
opacity: 1;
}
50% {
opacity: 0.5;
}
}
.status-text {
font-size: 11px;
opacity: 0.8;
}
.lt-time {
font-size: 10px;
opacity: 0.6;
}
</style>
</head>
<body>
<div class="lt-root">
<div class="geometric-bg" id="geoContainer"></div>
<div class="lt-container">
<div class="lt-header">
<div class="geo-icon"><span>◈</span></div>
<div>
<div class="lt-title">几何动画预设</div>
<div class="lt-tag">GEOMETRIC PRESET</div>
</div>
</div>
<div class="lt-description">
动态几何图形动画效果,包含多种形状的浮动动画,适合科技展示和创意直播。
</div>
<div class="lt-features">
<div class="lt-feature">
<div class="lt-feature-title">动态图形</div>
<div class="lt-feature-desc">多种几何形状浮动动画</div>
</div>
<div class="lt-feature">
<div class="lt-feature-title">渐变色彩</div>
<div class="lt-feature-desc">彩虹渐变配色方案</div>
</div>
<div class="lt-feature">
<div class="lt-feature-title">3D效果</div>
<div class="lt-feature-desc">CSS 3D变换动画</div>
</div>
<div class="lt-feature">
<div class="lt-feature-title">实时交互</div>
<div class="lt-feature-desc">鼠标悬停响应效果</div>
</div>
</div>
<div class="lt-status">
<div style="display: flex; align-items: center; gap: 6px;">
<div class="status-dot"></div>
<div class="status-text">动画运行中</div>
</div>
<div class="lt-time" id="timeDisplay">15:30</div>
</div>
</div>
</div>
<script>
function updateTime() {
const now = new Date();
const hours = now.getHours().toString().padStart(2, '0');
const minutes = now.getMinutes().toString().padStart(2, '0');
document.getElementById('timeDisplay').textContent = \`\${hours}:\${minutes}\`;
}
function createGeometry() {
const container = document.getElementById('geoContainer');
const shapes = ['circle', 'square', 'triangle'];
const colors = [
'rgba(255,105,180,0.25)',
'rgba(0,191,255,0.25)',
'rgba(50,205,50,0.25)',
'rgba(255,215,0,0.25)',
'rgba(138,43,226,0.25)'
];
for (let i = 0; i < 10; i++) {
const shape = document.createElement('div');
shape.className = 'geo-shape';
const shapeType = shapes[Math.floor(Math.random() * shapes.length)];
const color = colors[Math.floor(Math.random() * colors.length)];
const size = Math.random() * 60 + 20;
const left = Math.random() * 100;
const top = Math.random() * 100;
const duration = Math.random() * 6 + 4;
const delay = Math.random() * 2;
shape.style.width = \`\${size}px\`;
shape.style.height = \`\${size}px\`;
shape.style.left = \`\${left}%\`;
shape.style.top = \`\${top}%\`;
shape.style.animationDelay = \`\${delay}s\`;
shape.style.animationDuration = \`\${duration}s\`;
if (shapeType === 'triangle') {
shape.style.width = '0';
shape.style.height = '0';
shape.style.borderLeft = \`\${size/2}px solid transparent\`;
shape.style.borderRight = \`\${size/2}px solid transparent\`;
shape.style.borderBottom = \`\${size}px solid \${color}\`;
shape.style.background = 'none';
} else if (shapeType === 'circle') {
shape.style.borderRadius = '50%';
shape.style.background = \`radial-gradient(circle, \${color}, transparent 70%)\`;
} else {
shape.style.borderRadius = '8px';
shape.style.background = color;
}
container.appendChild(shape);
}
}
document.addEventListener('DOMContentLoaded', function() {
updateTime();
createGeometry();
setInterval(updateTime, 60000);
});
</script>
</body>
</html>`;
// 检查服务器状态
async function checkServer() {
const statusDiv = document.getElementById('serverStatus');
statusDiv.className = 'status info';
statusDiv.textContent = '正在检查服务器状态...';
try {
const response = await fetch('/health');
if (response.ok) {
statusDiv.className = 'status success';
statusDiv.textContent = '✅ 服务器运行正常';
// 检查预设
checkPresetIntegration();
} else {
statusDiv.className = 'status error';
statusDiv.textContent = '❌ 服务器响应异常';
}
} catch (error) {
statusDiv.className = 'status error';
statusDiv.textContent = '❌ 无法连接到服务器';
console.error('服务器检查失败:', error);
}
}
// 检查预设集成
async function checkPresetIntegration() {
const statusDiv = document.getElementById('presetStatus');
statusDiv.className = 'status info';
statusDiv.textContent = '正在检查预设集成...';
try {
const response = await fetch('/api/presets');
if (response.ok) {
const presets = await response.json();
const geometricPreset = presets.find(p => p.name === '几何动画预设');
if (geometricPreset) {
statusDiv.className = 'status success';
statusDiv.textContent = `✅ 几何动画预设已成功集成 (第${presets.indexOf(geometricPreset) + 1}个预设)`;
} else {
statusDiv.className = 'status error';
statusDiv.textContent = '❌ 未找到几何动画预设';
}
} else {
statusDiv.className = 'status error';
statusDiv.textContent = '❌ 无法获取预设列表';
}
} catch (error) {
statusDiv.className = 'status error';
statusDiv.textContent = '❌ 检查预设集成失败';
console.error('预设检查失败:', error);
}
}
// 加载预设到预览框
function loadPreset() {
const previewFrame = document.getElementById('previewFrame');
previewFrame.innerHTML = '';
const iframe = document.createElement('iframe');
iframe.style.width = '100%';
iframe.style.height = '100%';
iframe.style.border = 'none';
iframe.sandbox = 'allow-scripts allow-same-origin';
previewFrame.appendChild(iframe);
const iframeDoc = iframe.contentDocument || iframe.contentWindow.document;
iframeDoc.open();
iframeDoc.write(geometricPresetHTML);
iframeDoc.close();
// 更新状态
const statusDiv = document.getElementById('presetStatus');
statusDiv.className = 'status success';
statusDiv.textContent = '✅ 几何动画预设已加载到预览框';
}
// 显示预设信息
function showPresetInfo() {
const presetInfo = document.getElementById('presetInfo');
const presetDetails = document.getElementById('presetDetails');
const presetData = {
name: '几何动画预设',
description: '动态几何图形动画,包含多种形状的浮动效果',
kind: 'geometric',
align: 'right',
features: [
'动态几何图形动画',
'多种形状浮动效果',
'渐变色彩方案',
'3D变换动画',
'实时交互效果',
'响应式设计'
],
shapes: ['圆形', '方形', '三角形'],
colors: ['粉色渐变', '蓝色渐变', '绿色渐变', '黄色渐变', '紫色渐变'],
animations: ['浮动动画', '旋转动画', '脉冲效果', '3D变换']
};
// 生成详情HTML
let detailsHTML = '';
detailsHTML += `
<div class="detail-item">
<div class="detail-label">预设名称</div>
<div class="detail-value">${presetData.name}</div>
</div>
<div class="detail-item">
<div class="detail-label">预设类型</div>
<div class="detail-value">${presetData.kind}</div>
</div>
<div class="detail-item">
<div class="detail-label">对齐方式</div>
<div class="detail-value">${presetData.align}</div>
</div>
<div class="detail-item">
<div class="detail-label">几何形状</div>
<div class="detail-value">${presetData.shapes.join(', ')}</div>
</div>
<div class="detail-item">
<div class="detail-label">颜色方案</div>
<div class="detail-value">${presetData.colors.join(', ')}</div>
</div>
<div class="detail-item">
<div class="detail-label">动画效果</div>
<div class="detail-value">${presetData.animations.join(', ')}</div>
</div>
`;
presetDetails.innerHTML = detailsHTML;
presetInfo.style.display = 'block';
// 滚动到详情区域
presetInfo.scrollIntoView({ behavior: 'smooth' });
}
// 页面加载时自动检查
window.onload = function() {
checkServer();
};
</script>
</body>
</html>
+217
View File
@@ -0,0 +1,217 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>OBS Lower Third Widget</title>
<style>
html, body {
margin: 0;
padding: 0;
width: 100%;
height: 100%;
background: transparent;
overflow: hidden;
font-family: system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}
.lt-root {
position: fixed;
inset: 0;
display: flex;
justify-content: flex-end; /* 默认右侧类似晚会信息区 */
align-items: center;
pointer-events: none;
padding: 5vh 6vw;
box-sizing: border-box;
}
.lt-container {
position: relative;
display: inline-block;
min-width: 420px;
max-width: 560px;
color: #fff;
border-radius: 22px;
padding: 16px 26px;
opacity: 0;
transform: translateX(40px) translateY(6px) scale(0.96);
border: 1px solid rgba(255,255,255,0.25);
box-shadow:
0 20px 40px rgba(0, 0, 0, 0.8),
0 0 60px rgba(255, 140, 0, 0.45);
backdrop-filter: blur(18px);
background:
radial-gradient(circle at 0% 0%, rgba(255,255,255,0.34), transparent 55%),
linear-gradient(135deg, rgba(8,8,12,0.92), rgba(20,14,40,0.96));
overflow: hidden;
mask-image: radial-gradient(circle at 0 0, rgba(0,0,0,0.0), rgba(0,0,0,1) 45%),
linear-gradient(to left, transparent 0%, black 20%, black 100%);
-webkit-mask-image: radial-gradient(circle at 0 0, rgba(0,0,0,0.0), rgba(0,0,0,1) 45%),
linear-gradient(to left, transparent 0%, black 20%, black 100%);
}
.lt-container::before {
content: '';
position: absolute;
inset: -40%;
background:
radial-gradient(circle at 120% 0%, rgba(255, 215, 128, 0.35), transparent 45%),
radial-gradient(circle at -10% 100%, rgba(255, 71, 87, 0.45), transparent 55%);
opacity: 0.85;
mix-blend-mode: screen;
pointer-events: none;
}
.lt-container-inner {
position: relative;
z-index: 1;
}
.lt-container.show {
animation: lt-enter 0.7s cubic-bezier(0.18, 0.9, 0.3, 1.2) forwards;
}
.lt-container.hide {
animation: lt-exit 0.55s ease-in forwards;
}
@keyframes lt-enter {
0% {
opacity: 0;
transform: translateX(70px) translateY(10px) scale(0.9);
filter: blur(8px);
}
55% {
opacity: 1;
transform: translateX(-10px) translateY(0) scale(1.03);
filter: blur(0px);
}
100% {
opacity: 1;
transform: translateX(0) translateY(0) scale(1);
filter: blur(0px);
}
}
@keyframes lt-exit {
0% {
opacity: 1;
transform: translateX(0) translateY(0) scale(1);
filter: blur(0px);
}
100% {
opacity: 0;
transform: translateX(40px) translateY(8px) scale(0.95);
filter: blur(4px);
}
}
.lt-title {
font-size: 24px;
font-weight: 800;
line-height: 1.2;
letter-spacing: 0.18em;
text-transform: uppercase;
text-shadow:
0 0 18px rgba(0,0,0,0.9),
0 0 32px rgba(255,180,120,0.6);
}
.lt-subtitle {
margin-top: 8px;
font-size: 15px;
opacity: 0.95;
line-height: 1.45;
}
</style>
</head>
<body>
<div class="lt-root">
<div id="lt" class="lt-container">
<div class="lt-container-inner" id="ltInner">
<div class="lt-title" id="ltTitle"></div>
<div class="lt-subtitle" id="ltSubtitle"></div>
</div>
</div>
</div>
<script>
const lt = document.getElementById('lt');
const ltInner = document.getElementById('ltInner');
const titleEl = document.getElementById('ltTitle');
const subtitleEl = document.getElementById('ltSubtitle');
let iframeEl = null;
function resetAnimation() {
lt.classList.remove('show', 'hide');
// 强制重排让下一次动画生效
void lt.offsetWidth;
}
function applyPreset(preset) {
if (!preset) {
resetAnimation();
lt.classList.add('hide');
return;
}
// 对齐:控制整块在 OBS 画面内的左右位置
const root = lt.parentElement;
if (preset.align === 'center') {
root.style.justifyContent = 'center';
} else if (preset.align === 'left') {
root.style.justifyContent = 'flex-start';
} else {
root.style.justifyContent = 'flex-end';
}
// 外观层额外 CSS(对 .lt-root / .lt-container 做全局修饰)
const existingStyle = document.getElementById('dynamic-style');
if (existingStyle) existingStyle.remove();
if (preset.extraCss) {
const style = document.createElement('style');
style.id = 'dynamic-style';
style.textContent = preset.extraCss;
document.head.appendChild(style);
}
// 纯外观 preset:如果 kind=iframe,则用 iframe srcdoc 完全接管内部内容
if (preset.kind === 'iframe' && preset.html) {
// 清空旧文字容器
titleEl.textContent = '';
subtitleEl.textContent = '';
if (!iframeEl) {
iframeEl = document.createElement('iframe');
iframeEl.setAttribute('sandbox', 'allow-scripts allow-same-origin');
iframeEl.style.border = 'none';
iframeEl.style.width = '100%';
iframeEl.style.height = '100%';
iframeEl.style.display = 'block';
iframeEl.style.background = 'transparent';
ltInner.innerHTML = '';
ltInner.appendChild(iframeEl);
}
iframeEl.srcdoc = preset.html;
}
resetAnimation();
lt.classList.add('show');
}
function connectWs() {
const loc = window.location;
const proto = loc.protocol === 'https:' ? 'wss:' : 'ws:';
const wsUrl = proto + '//' + loc.host;
const ws = new WebSocket(wsUrl);
ws.onmessage = (event) => {
try {
const msg = JSON.parse(event.data);
if (msg.type === 'activePreset') {
applyPreset(msg.preset);
}
} catch (e) {
console.error('WS message parse error', e);
}
};
ws.onclose = () => {
// simple retry
setTimeout(connectWs, 2000);
};
}
connectWs();
</script>
</body>
</html>