243 lines
8.1 KiB
HTML
243 lines
8.1 KiB
HTML
|
<!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: 900px;
|
||
|
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;
|
||
|
}
|
||
|
.image-container {
|
||
|
display: flex;
|
||
|
justify-content: center;
|
||
|
margin: 30px 0;
|
||
|
min-height: 400px;
|
||
|
align-items: center;
|
||
|
background-color: #f8f9fa;
|
||
|
border-radius: 6px;
|
||
|
padding: 20px;
|
||
|
}
|
||
|
#previewImage {
|
||
|
max-width: 100%;
|
||
|
max-height: 600px;
|
||
|
border-radius: 6px;
|
||
|
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
|
||
|
}
|
||
|
.loading {
|
||
|
text-align: center;
|
||
|
font-size: 18px;
|
||
|
color: #666;
|
||
|
}
|
||
|
.btn-group {
|
||
|
display: flex;
|
||
|
justify-content: center;
|
||
|
margin-top: 30px;
|
||
|
gap: 20px;
|
||
|
}
|
||
|
.btn {
|
||
|
padding: 12px 25px;
|
||
|
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;
|
||
|
}
|
||
|
.btn-secondary:hover {
|
||
|
background-color: #7f8c8d;
|
||
|
}
|
||
|
.btn-danger {
|
||
|
background-color: #e74c3c;
|
||
|
color: white;
|
||
|
}
|
||
|
.btn-danger:hover {
|
||
|
background-color: #c0392b;
|
||
|
}
|
||
|
/* 添加遮罩动画样式 */
|
||
|
.mask {
|
||
|
position: fixed;
|
||
|
top: 0;
|
||
|
left: 0;
|
||
|
width: 100%;
|
||
|
height: 100%;
|
||
|
background-color: rgba(0, 0, 0, 0.7);
|
||
|
display: flex;
|
||
|
justify-content: center;
|
||
|
align-items: center;
|
||
|
z-index: 1000;
|
||
|
opacity: 0;
|
||
|
visibility: hidden;
|
||
|
transition: opacity 0.3s, visibility 0.3s;
|
||
|
}
|
||
|
.mask.active {
|
||
|
opacity: 1;
|
||
|
visibility: visible;
|
||
|
}
|
||
|
.loader {
|
||
|
width: 50px;
|
||
|
height: 50px;
|
||
|
border: 5px solid rgba(255, 255, 255, 0.3);
|
||
|
border-radius: 50%;
|
||
|
border-top-color: #3498db;
|
||
|
animation: spin 1s ease-in-out infinite;
|
||
|
}
|
||
|
@keyframes spin {
|
||
|
to { transform: rotate(360deg); }
|
||
|
}
|
||
|
.mask-text {
|
||
|
color: white;
|
||
|
margin-top: 20px;
|
||
|
text-align: center;
|
||
|
font-size: 18px;
|
||
|
}
|
||
|
.mask-content {
|
||
|
display: flex;
|
||
|
flex-direction: column;
|
||
|
align-items: center;
|
||
|
}
|
||
|
</style>
|
||
|
</head>
|
||
|
<body>
|
||
|
<div class="container">
|
||
|
<h1>首帧预览</h1>
|
||
|
<div class="image-container">
|
||
|
<div class="loading" id="loading">加载中...</div>
|
||
|
<img id="previewImage" style="display: none;">
|
||
|
</div>
|
||
|
<div class="btn-group">
|
||
|
<button class="btn btn-danger" id="backBtn">返回修改</button>
|
||
|
<button class="btn btn-secondary" id="regenerateBtn">重新生成</button>
|
||
|
<button class="btn btn-primary" id="confirmBtn">确认满意</button>
|
||
|
</div>
|
||
|
</div>
|
||
|
|
||
|
<!-- 添加遮罩层 -->
|
||
|
<div class="mask" id="mask">
|
||
|
<div class="mask-content">
|
||
|
<div class="loader"></div>
|
||
|
<div class="mask-text" id="maskText">正在生成图片,请稍候...</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
|
||
|
<script>
|
||
|
document.addEventListener('DOMContentLoaded', function() {
|
||
|
const imageUrl = sessionStorage.getItem('generatedImageUrl');
|
||
|
const prompt = sessionStorage.getItem('lastPrompt');
|
||
|
const previewImage = document.getElementById('previewImage');
|
||
|
const loading = document.getElementById('loading');
|
||
|
const backBtn = document.getElementById('backBtn');
|
||
|
const regenerateBtn = document.getElementById('regenerateBtn');
|
||
|
const confirmBtn = document.getElementById('confirmBtn');
|
||
|
const mask = document.getElementById('mask');
|
||
|
const maskText = document.getElementById('maskText');
|
||
|
|
||
|
if (!imageUrl) {
|
||
|
alert('没有找到生成的图片,请返回重新生成');
|
||
|
window.location.href = 'prompt_input.html';
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
// 加载图片
|
||
|
previewImage.onload = function() {
|
||
|
loading.style.display = 'none';
|
||
|
previewImage.style.display = 'block';
|
||
|
};
|
||
|
previewImage.onerror = function() {
|
||
|
loading.textContent = '图片加载失败';
|
||
|
};
|
||
|
previewImage.src = imageUrl;
|
||
|
|
||
|
// 返回修改按钮
|
||
|
backBtn.addEventListener('click', function() {
|
||
|
window.location.href = 'prompt_input.html';
|
||
|
});
|
||
|
|
||
|
// 重新生成按钮
|
||
|
regenerateBtn.addEventListener('click', function() {
|
||
|
// 显示遮罩动画
|
||
|
mask.classList.add('active');
|
||
|
maskText.textContent = '正在重新生成图片,请稍候...';
|
||
|
|
||
|
// 调用 API 重新生成图片
|
||
|
fetch('/api/jimeng/prompt_input', {
|
||
|
method: 'POST',
|
||
|
headers: {
|
||
|
'Content-Type': 'application/json'
|
||
|
},
|
||
|
body: JSON.stringify({ prompt: prompt })
|
||
|
})
|
||
|
.then(response => {
|
||
|
if (!response.ok) {
|
||
|
throw new Error('网络响应异常');
|
||
|
}
|
||
|
return response.json();
|
||
|
})
|
||
|
.then(data => {
|
||
|
// 隐藏遮罩动画
|
||
|
mask.classList.remove('active');
|
||
|
|
||
|
if (data.code === 200) {
|
||
|
// 更新图片 URL
|
||
|
const newImageUrl = data.data.image_url;
|
||
|
sessionStorage.setItem('generatedImageUrl', newImageUrl);
|
||
|
previewImage.src = newImageUrl;
|
||
|
} else {
|
||
|
alert('图片生成失败: ' + data.message);
|
||
|
loading.style.display = 'none';
|
||
|
previewImage.style.display = 'block';
|
||
|
}
|
||
|
})
|
||
|
.catch(error => {
|
||
|
// 隐藏遮罩动画
|
||
|
mask.classList.remove('active');
|
||
|
|
||
|
console.error('生成图片时出错:', error);
|
||
|
alert('生成图片时出错: ' + error.message);
|
||
|
loading.style.display = 'none';
|
||
|
previewImage.style.display = 'block';
|
||
|
});
|
||
|
});
|
||
|
|
||
|
// 确认满意按钮
|
||
|
confirmBtn.addEventListener('click', function() {
|
||
|
alert('首帧确认成功!即将进入下一环节');
|
||
|
// 这里可以添加跳转到下一步的逻辑
|
||
|
// window.location.href = 'next_step.html';
|
||
|
});
|
||
|
});
|
||
|
</script>
|
||
|
</body>
|
||
|
</html>
|