This commit is contained in:
2025-08-21 07:53:15 +08:00
parent 05f15b3948
commit 1ccc4c207c
4 changed files with 1332 additions and 0 deletions

View File

@@ -0,0 +1,353 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>智能视频生成 - 提示词输入</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: 'PingFang SC', 'Microsoft YaHei', sans-serif;
}
body {
background-color: #f5f7fa;
color: #333;
line-height: 1.6;
padding: 20px;
}
.container {
max-width: 800px;
margin: 0 auto;
background: white;
border-radius: 10px;
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
padding: 30px;
}
h1 {
text-align: center;
margin-bottom: 20px;
color: #2c3e50;
}
.form-group {
margin-bottom: 20px;
}
label {
display: block;
margin-bottom: 8px;
font-weight: bold;
color: #555;
}
input[type="text"], textarea {
width: 100%;
padding: 12px;
border: 1px solid #ddd;
border-radius: 6px;
font-size: 16px;
transition: border 0.3s;
}
input[type="text"]:focus, textarea:focus {
border-color: #3498db;
outline: none;
}
.required::after {
content: ' *';
color: red;
}
.tag-container {
display: flex;
flex-wrap: wrap;
margin-top: 10px;
padding: 10px;
border: 1px dashed #ccc;
border-radius: 6px;
min-height: 50px;
}
.tag {
background-color: #3498db;
color: white;
padding: 5px 10px;
border-radius: 20px;
margin-right: 10px;
margin-bottom: 10px;
display: flex;
align-items: center;
}
.tag span {
margin-right: 5px;
}
.tag button {
background: none;
border: none;
color: white;
cursor: pointer;
font-size: 14px;
}
.add-tag {
display: flex;
margin-top: 10px;
}
.add-tag input {
flex: 1;
margin-right: 10px;
}
.btn {
padding: 12px 20px;
border: none;
border-radius: 6px;
cursor: pointer;
font-size: 16px;
transition: background 0.3s;
}
.btn-primary {
background-color: #3498db;
color: white;
}
.btn-primary:hover {
background-color: #2980b9;
}
.btn-secondary {
background-color: #95a5a6;
color: white;
margin-left: 10px;
}
.btn-secondary:hover {
background-color: #7f8c8d;
}
.btn-group {
display: flex;
justify-content: center;
margin-top: 30px;
}
.placeholder {
color: #999;
font-style: italic;
}
.example-tip {
background-color: #f8f9fa;
padding: 15px;
border-radius: 6px;
margin-top: 5px;
font-size: 14px;
color: #666;
}
.sample-container {
margin-top: 10px;
padding: 15px;
background-color: #f8f9fa;
border-radius: 6px;
border-left: 4px solid #3498db;
}
.sample-title {
font-weight: bold;
margin-bottom: 10px;
}
</style>
</head>
<body>
<div class="container">
<h1>智能视频生成 - 提示词输入</h1>
<form id="promptForm">
<div class="form-group">
<label for="timeWeatherLight" class="required">时间-天气-光</label>
<input type="text" id="timeWeatherLight" placeholder="例如:傍晚小雨,路灯刚亮" required>
<div class="example-tip">请描述时间、天气状况和光线条件,这将影响画面的整体感觉</div>
</div>
<div class="form-group">
<label for="sceneLocation" class="required">场景-地点</label>
<input type="text" id="sceneLocation" placeholder="例如:老城区石板路" required>
<div class="example-tip">请描述具体的场景和地点,帮助构建画面背景</div>
</div>
<div class="form-group">
<label for="subjects">主体列表 (可选)</label>
<div class="tag-container" id="tagContainer">
<div class="placeholder" id="placeholder">点击下方添加主体(人/动物/物体),或留空</div>
</div>
<div class="add-tag">
<input type="text" id="subjectInput" placeholder="例如:工人父亲(背)">
<button type="button" class="btn btn-primary" id="addTagBtn">添加</button>
</div>
<div class="example-tip">多个主体用逗号分隔,括号内可描述动作或姿态</div>
</div>
<div class="form-group">
<label for="atmosphere" class="required">氛围-情绪</label>
<input type="text" id="atmosphere" placeholder="例如:温馨" required>
<div class="example-tip">请描述画面想要传达的整体氛围或情绪</div>
</div>
<div class="form-group">
<button type="button" class="btn btn-secondary" id="randomSampleBtn">随机示例</button>
<div class="sample-container" id="sampleContainer" style="display: none;">
<div class="sample-title">示例提示词:</div>
<div id="sampleContent"></div>
</div>
</div>
<div class="btn-group">
<button type="submit" class="btn btn-primary">生成首帧图片</button>
<button type="reset" class="btn btn-secondary">重置</button>
</div>
</form>
</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
const tagContainer = document.getElementById('tagContainer');
const subjectInput = document.getElementById('subjectInput');
const addTagBtn = document.getElementById('addTagBtn');
const placeholder = document.getElementById('placeholder');
const randomSampleBtn = document.getElementById('randomSampleBtn');
const sampleContainer = document.getElementById('sampleContainer');
const sampleContent = document.getElementById('sampleContent');
const promptForm = document.getElementById('promptForm');
// 检查标签容器是否为空
function checkTagContainer() {
if (tagContainer.children.length === 1 && tagContainer.contains(placeholder)) {
placeholder.style.display = 'block';
} else {
placeholder.style.display = 'none';
}
}
// 添加标签
function addTag(text) {
if (!text.trim()) return;
const tag = document.createElement('div');
tag.className = 'tag';
tag.innerHTML = `<span>${text}</span><button type="button">×</button>`;
// 删除标签
tag.querySelector('button').addEventListener('click', function() {
tagContainer.removeChild(tag);
checkTagContainer();
});
tagContainer.appendChild(tag);
subjectInput.value = '';
checkTagContainer();
}
// 添加标签按钮点击事件
addTagBtn.addEventListener('click', function() {
addTag(subjectInput.value);
});
// 按Enter键添加标签
subjectInput.addEventListener('keypress', function(e) {
if (e.key === 'Enter') {
e.preventDefault();
addTag(subjectInput.value);
}
});
// 随机示例数据
const samples = [
{
timeWeatherLight: '傍晚小雨,路灯刚亮',
sceneLocation: '老城区石板路',
subjects: ['戴斗笠的老奶奶(牵)', '穿红雨鞋的小女孩'],
atmosphere: '温暖'
},
{
timeWeatherLight: '清晨薄雾,侧逆光',
sceneLocation: '空旷高速公路',
subjects: [],
atmosphere: '寂静'
},
{
timeWeatherLight: '深夜暴雨,城市广场灯光',
sceneLocation: '城市广场',
subjects: ['一只黑伞(被风吹翻)', '一辆倒地的外卖车', '散落的黄色外卖箱'],
atmosphere: '慌乱'
},
{
timeWeatherLight: '晴天午后,阳光明媚',
sceneLocation: '公园草坪',
subjects: ['穿白色连衣裙的女孩(奔跑)', '棕色小狗(追逐)'],
atmosphere: '欢快'
}
];
// 随机示例按钮点击事件
randomSampleBtn.addEventListener('click', function() {
const randomIndex = Math.floor(Math.random() * samples.length);
const sample = samples[randomIndex];
// 填充表单
document.getElementById('timeWeatherLight').value = sample.timeWeatherLight;
document.getElementById('sceneLocation').value = sample.sceneLocation;
document.getElementById('atmosphere').value = sample.atmosphere;
// 清空现有标签
while (tagContainer.firstChild) {
tagContainer.removeChild(tagContainer.firstChild);
}
tagContainer.appendChild(placeholder);
// 添加示例标签
sample.subjects.forEach(subject => {
addTag(subject);
});
// 显示示例容器
sampleContent.textContent = `${sample.timeWeatherLight}${sample.sceneLocation}${sample.subjects.length ? '' + sample.subjects.join('与') : ''},氛围${sample.atmosphere}`;
sampleContainer.style.display = 'block';
});
// 表单提交事件
promptForm.addEventListener('submit', function(e) {
e.preventDefault();
// 收集表单数据
const formData = {
timeWeatherLight: document.getElementById('timeWeatherLight').value,
sceneLocation: document.getElementById('sceneLocation').value,
subjects: [],
atmosphere: document.getElementById('atmosphere').value
};
// 收集标签数据
const tags = tagContainer.querySelectorAll('.tag');
tags.forEach(tag => {
formData.subjects.push(tag.querySelector('span').textContent);
});
// 构建提示词
let prompt = `${formData.timeWeatherLight}${formData.sceneLocation}`;
if (formData.subjects.length > 0) {
prompt += '' + formData.subjects.join('与');
}
prompt += `,氛围${formData.atmosphere}`;
// 在实际应用中,这里应该发送数据到后端
console.log('生成的提示词:', prompt);
alert('提示词已生成:\n' + prompt + '\n\n下一步将生成首帧图片');
// 这里可以添加跳转到图片生成页面的逻辑
// window.location.href = 'image_generation.html?prompt=' + encodeURIComponent(prompt);
});
// 表单重置事件
promptForm.addEventListener('reset', function() {
// 清空标签
while (tagContainer.firstChild) {
tagContainer.removeChild(tagContainer.firstChild);
}
tagContainer.appendChild(placeholder);
checkTagContainer();
sampleContainer.style.display = 'none';
});
// 初始化检查
checkTagContainer();
});
</script>
</body>
</html>