|
|
@@ -330,7 +330,7 @@
|
|
|
<!-- 菜单功能区 -->
|
|
|
<div class="menu-container">
|
|
|
<div class="menu-item">
|
|
|
- <a href="{:url('user/index')}">
|
|
|
+ <a href="{:url('user/text_to_image')}">
|
|
|
<i class="fas fa-image"></i>
|
|
|
文生图
|
|
|
</a>
|
|
|
@@ -348,6 +348,7 @@
|
|
|
<!-- 左侧输入区域 -->
|
|
|
<div class="input-section">
|
|
|
<h3 style="font-size: 18px; font-weight: bold; margin-bottom: 15px; color: #333;">文生视频生成参数设置</h3>
|
|
|
+ <input type="text" value="{$user.id}" id="user_id" disabled style="display: none">
|
|
|
|
|
|
<!-- 提示词示例 -->
|
|
|
<div class="prompt-examples">
|
|
|
@@ -461,6 +462,7 @@
|
|
|
const videoSize = document.getElementById('videoSize').value;
|
|
|
const videoResultDiv = document.getElementById('videoResult');
|
|
|
|
|
|
+
|
|
|
// 检查是否有提示词
|
|
|
if (!promptText) {
|
|
|
alert('请先输入视频描述');
|
|
|
@@ -506,12 +508,12 @@
|
|
|
if (response.code === 0 && response.data && response.data.web_url) {
|
|
|
// 视频生成完成
|
|
|
let videoUrl = response.data.web_url;
|
|
|
-
|
|
|
+
|
|
|
// 确保web_url格式正确,添加根路径前缀
|
|
|
if (videoUrl && !videoUrl.startsWith('/')) {
|
|
|
videoUrl = '/' + videoUrl;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// 显示生成的视频
|
|
|
videoResultDiv.innerHTML = `
|
|
|
<div class="video-container">
|
|
|
@@ -529,7 +531,7 @@
|
|
|
web_url: videoUrl,
|
|
|
video_id: response.data.video_id || response.data.id || ''
|
|
|
};
|
|
|
-
|
|
|
+
|
|
|
// 启用下载按钮和保存模板按钮
|
|
|
document.getElementById('downloadBtn').disabled = false;
|
|
|
document.getElementById('saveBtn').disabled = false;
|
|
|
@@ -605,7 +607,7 @@
|
|
|
const videoId = response.data.video_id;
|
|
|
const status = response.data.status;
|
|
|
const progress = response.data.progress || 0;
|
|
|
-
|
|
|
+
|
|
|
// 显示接口返回的message信息
|
|
|
const message = response.msg || response.data.message || '';
|
|
|
// <p style="font-size: 12px; margin-top: 10px; color: #999;">视频ID: ${videoId}</p>
|
|
|
@@ -621,7 +623,7 @@
|
|
|
<p style="font-size: 12px; margin-top: 5px; color: #999;">系统正在自动检查视频生成状态...</p>
|
|
|
</div>
|
|
|
`;
|
|
|
-
|
|
|
+
|
|
|
// 开始轮询检查视频状态
|
|
|
startVideoPolling(videoId, videoStyle, videoDuration, videoSize);
|
|
|
} else {
|
|
|
@@ -658,7 +660,7 @@
|
|
|
$('.clear-btn').click(clearPrompt);
|
|
|
// 绑定一键优化按钮点击事件
|
|
|
$('.optimize-btn').click(optimizePrompt);
|
|
|
-
|
|
|
+
|
|
|
// 键盘ESC键关闭模态框事件
|
|
|
document.addEventListener('keydown', function(event) {
|
|
|
if (event.key === 'Escape') {
|
|
|
@@ -742,7 +744,7 @@
|
|
|
let pollingCount = 0;
|
|
|
const maxPollingCount = 60; // 最大轮询次数 (30次 * 5秒 = 2.5分钟)
|
|
|
const pollingInterval = 6000; // 轮询间隔 (5秒)
|
|
|
-
|
|
|
+
|
|
|
// 轮询检查视频状态
|
|
|
const pollingTimer = setInterval(function() {
|
|
|
$.ajax({
|
|
|
@@ -756,15 +758,15 @@
|
|
|
if (response.code === 0 && response.data && response.data.web_url) {
|
|
|
// 视频生成完成
|
|
|
clearInterval(pollingTimer);
|
|
|
-
|
|
|
+
|
|
|
const videoResultDiv = document.getElementById('videoResult');
|
|
|
let videoUrl = response.data.web_url;
|
|
|
-
|
|
|
+
|
|
|
// 确保web_url格式正确,添加根路径前缀
|
|
|
if (videoUrl && !videoUrl.startsWith('/')) {
|
|
|
videoUrl = '/' + videoUrl;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// 显示生成的视频
|
|
|
videoResultDiv.innerHTML = `
|
|
|
<div class="video-container">
|
|
|
@@ -773,7 +775,7 @@
|
|
|
</video>
|
|
|
</div>
|
|
|
`;
|
|
|
-
|
|
|
+
|
|
|
// 更新视频信息到全局变量
|
|
|
videoInfo = {
|
|
|
style: videoStyle,
|
|
|
@@ -782,11 +784,11 @@
|
|
|
web_url: videoUrl,
|
|
|
video_id: response.data.video_id || videoId
|
|
|
};
|
|
|
-
|
|
|
+
|
|
|
// 启用下载按钮和保存模板按钮
|
|
|
document.getElementById('downloadBtn').disabled = false;
|
|
|
document.getElementById('saveBtn').disabled = false;
|
|
|
-
|
|
|
+
|
|
|
// 添加视频放大模态框(如果还不存在)
|
|
|
if (!document.getElementById('videoModal')) {
|
|
|
const modal = document.createElement('div');
|
|
|
@@ -857,11 +859,11 @@
|
|
|
// 视频仍在生成中,更新状态信息
|
|
|
const status = response.data.status;
|
|
|
const progress = response.data.progress || 0;
|
|
|
-
|
|
|
+
|
|
|
const progressBar = videoResultDiv.querySelector('.progress-bar');
|
|
|
const statusText = videoResultDiv.querySelector('.video-processing p:nth-child(3)');
|
|
|
const progressText = videoResultDiv.querySelector('.video-processing p:nth-child(4)');
|
|
|
-
|
|
|
+
|
|
|
if (progressBar) {
|
|
|
progressBar.style.width = `${progress}%`;
|
|
|
}
|
|
|
@@ -901,7 +903,7 @@
|
|
|
`;
|
|
|
}
|
|
|
});
|
|
|
-
|
|
|
+
|
|
|
// 检查是否达到最大轮询次数
|
|
|
pollingCount++;
|
|
|
if (pollingCount >= maxPollingCount) {
|
|
|
@@ -919,7 +921,7 @@
|
|
|
}
|
|
|
}, pollingInterval);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// 手动检查视频状态函数
|
|
|
function checkVideoStatus(videoId) {
|
|
|
$.ajax({
|
|
|
@@ -934,12 +936,12 @@
|
|
|
// 视频生成完成,直接显示结果
|
|
|
const videoResultDiv = document.getElementById('videoResult');
|
|
|
let videoUrl = response.data.web_url;
|
|
|
-
|
|
|
+
|
|
|
// 确保web_url格式正确,添加根路径前缀
|
|
|
if (videoUrl && !videoUrl.startsWith('/')) {
|
|
|
videoUrl = '/' + videoUrl;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// 显示生成的视频
|
|
|
videoResultDiv.innerHTML = `
|
|
|
<div class="video-container">
|
|
|
@@ -948,17 +950,17 @@
|
|
|
</video>
|
|
|
</div>
|
|
|
`;
|
|
|
-
|
|
|
+
|
|
|
// 更新视频信息到全局变量
|
|
|
videoInfo = {
|
|
|
video_id: response.data.video_id || videoId,
|
|
|
web_url: videoUrl
|
|
|
};
|
|
|
-
|
|
|
+
|
|
|
// 启用下载按钮和保存模板按钮
|
|
|
document.getElementById('downloadBtn').disabled = false;
|
|
|
document.getElementById('saveBtn').disabled = false;
|
|
|
-
|
|
|
+
|
|
|
// 添加视频放大模态框(如果还不存在)
|
|
|
if (!document.getElementById('videoModal')) {
|
|
|
const modal = document.createElement('div');
|
|
|
@@ -1066,24 +1068,26 @@
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// 保存模板函数
|
|
|
function saveTemplate() {
|
|
|
// 获取模板名称
|
|
|
const templateName = document.getElementById('templateName').value.trim();
|
|
|
const textarea = document.getElementById('prompt');
|
|
|
+ const user_id = document.getElementById('user_id');
|
|
|
+
|
|
|
// 验证模板名称
|
|
|
if (!templateName) {
|
|
|
showAlert('模板名称不能为空');
|
|
|
return;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// 检查是否有视频信息
|
|
|
if (!videoInfo || !videoInfo.web_url) {
|
|
|
showAlert('请先生成视频');
|
|
|
return;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// 构建请求参数
|
|
|
const params = {
|
|
|
chinese_description: textarea.value.trim(),
|
|
|
@@ -1092,11 +1096,11 @@
|
|
|
size: videoInfo.size,
|
|
|
style: videoInfo.style,
|
|
|
type: "文生视频",
|
|
|
- sys_id:"管理员",
|
|
|
+ user_id:user_id,
|
|
|
seconds: videoInfo.duration,
|
|
|
video_id: videoInfo.video_id
|
|
|
};
|
|
|
-
|
|
|
+
|
|
|
// 发送请求保存模板
|
|
|
$.ajax({
|
|
|
url: '/index.php/api/work_order/Add_Product_Template',
|