recycle.html 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634
  1. <style>
  2. /* 主容器 - 左右布局 */
  3. .user-diagrams-container {
  4. display: flex;
  5. min-height: calc(100vh - 120px); /* 减去导航栏和页脚高度 */
  6. }
  7. /* 左侧菜单样式 */
  8. .sidebar {
  9. width: 200px;
  10. background-color: #fff;
  11. border-right: 1px solid #e8e8e8;
  12. flex-shrink: 0;
  13. }
  14. .menu {
  15. padding: 20px 0;
  16. }
  17. .menu-item {
  18. list-style: none;
  19. }
  20. .menu-item a {
  21. display: block;
  22. padding: 15px 20px;
  23. text-decoration: none;
  24. color: #000000;
  25. font-size: 16px;
  26. transition: all 0.3s ease;
  27. }
  28. .menu-item.active a {
  29. background-color: #f0f7ff;
  30. color: #1890ff;
  31. font-weight: 500;
  32. }
  33. .menu-item:hover a {
  34. background-color: #f5f5f5;
  35. color: #1890ff;
  36. }
  37. /* 右侧内容区域样式 */
  38. .diagrams-content {
  39. flex: 1;
  40. background-color: #fff;
  41. padding: 20px;
  42. }
  43. /* 标签页样式 */
  44. .tabs {
  45. margin-bottom: 20px;
  46. }
  47. .tab-item {
  48. display: inline-block;
  49. margin-right: 20px;
  50. padding: 10px 0;
  51. font-size: 16px;
  52. color: #1890ff;
  53. cursor: pointer;
  54. border-bottom: 2px solid transparent;
  55. transition: all 0.3s ease;
  56. }
  57. .tab-item.active {
  58. font-weight: 500;
  59. border-bottom-color: #1890ff;
  60. }
  61. .tab-item:hover {
  62. color: #40a9ff;
  63. }
  64. /* 内容区域 */
  65. .tab-content {
  66. min-height: 400px;
  67. border: 1px solid #e8e8e8;
  68. border-radius: 4px;
  69. padding: 20px;
  70. }
  71. /* 模板网格样式 */
  72. .template-grid {
  73. display: grid;
  74. grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  75. gap: 20px;
  76. }
  77. .template-card {
  78. border: 1px solid #e8e8e8;
  79. border-radius: 8px;
  80. overflow: hidden;
  81. transition: all 0.3s ease;
  82. cursor: pointer;
  83. }
  84. .template-card:hover {
  85. box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  86. transform: translateY(-2px);
  87. }
  88. .template-thumbnail {
  89. width: 100%;
  90. height: 160px;
  91. overflow: hidden;
  92. background-color: #f5f5f5;
  93. position: relative;
  94. }
  95. /* 审核状态标识样式 */
  96. .examine-status {
  97. position: absolute;
  98. top: 8px;
  99. right: 8px;
  100. padding: 4px 12px;
  101. border-radius: 4px;
  102. font-size: 12px;
  103. font-weight: 500;
  104. color: #fff;
  105. z-index: 10;
  106. }
  107. .examine-status.passed {
  108. background-color: #52c41a;
  109. }
  110. .examine-status.failed {
  111. background-color: #ff4d4f;
  112. }
  113. .examine-status.pending {
  114. background-color: #faad14;
  115. }
  116. .template-thumbnail img,
  117. .template-thumbnail video {
  118. width: 100%;
  119. height: 100%;
  120. object-fit: cover;
  121. transition: transform 0.3s ease;
  122. }
  123. .template-card:hover .template-thumbnail img,
  124. .template-card:hover .template-thumbnail video {
  125. transform: scale(1.05);
  126. }
  127. .template-info {
  128. padding: 15px;
  129. }
  130. .template-name {
  131. font-size: 16px;
  132. font-weight: 500;
  133. margin-bottom: 8px;
  134. white-space: nowrap;
  135. overflow: hidden;
  136. text-overflow: ellipsis;
  137. }
  138. .template-meta {
  139. font-size: 14px;
  140. color: #666;
  141. }
  142. .template-meta span {
  143. margin-right: 15px;
  144. }
  145. /* 删除按钮样式 */
  146. .delete-btn {
  147. color: #ff4d4f;
  148. cursor: pointer;
  149. transition: color 0.3s ease;
  150. margin-left: 10px;
  151. }
  152. .delete-btn:hover {
  153. color: #ff7875;
  154. text-decoration: underline;
  155. }
  156. /* 恢复按钮样式 */
  157. .restore-btn {
  158. color: #52c41a;
  159. cursor: pointer;
  160. transition: color 0.3s ease;
  161. }
  162. .restore-btn:hover {
  163. color: #73d13d;
  164. text-decoration: underline;
  165. }
  166. /* 空提示样式 */
  167. .empty-tip {
  168. grid-column: 1 / -1;
  169. display: flex;
  170. flex-direction: column;
  171. align-items: center;
  172. justify-content: center;
  173. min-height: 400px;
  174. text-align: center;
  175. padding: 40px 20px;
  176. color: #999;
  177. }
  178. .empty-icon {
  179. font-size: 64px;
  180. margin-bottom: 20px;
  181. opacity: 0.5;
  182. }
  183. .empty-text {
  184. font-size: 20px;
  185. font-weight: 500;
  186. margin-bottom: 10px;
  187. color: #666;
  188. }
  189. .empty-subtext {
  190. font-size: 14px;
  191. color: #999;
  192. }
  193. /* 响应式设计 */
  194. @media (max-width: 768px) {
  195. .user-diagrams-container {
  196. flex-direction: column;
  197. }
  198. .sidebar {
  199. width: 100%;
  200. border-right: none;
  201. border-bottom: 1px solid #e8e8e8;
  202. }
  203. .menu {
  204. padding: 0;
  205. }
  206. .menu-item {
  207. display: inline-block;
  208. }
  209. .menu-item a {
  210. padding: 12px 15px;
  211. }
  212. }
  213. </style>
  214. <div class="user-diagrams-container">
  215. <!-- 左侧菜单 -->
  216. <div class="sidebar">
  217. <ul class="menu">
  218. <li class="menu-item">
  219. <a href="{:url('user/diagrams')}">我的模版</a>
  220. </li>
  221. <li class="menu-item active">
  222. <a href="{:url('user/recycle')}">收回站</a>
  223. </li>
  224. </ul>
  225. </div>
  226. <!-- 右侧内容区域 -->
  227. <div class="diagrams-content">
  228. <!-- 标签页 -->
  229. <div class="tabs">
  230. <div class="tab-item active">回收站</div>
  231. </div>
  232. <!-- 内容区域 -->
  233. <div class="tab-content">
  234. <div class="template-grid" id="templateGrid">
  235. <!-- 使用volist标签循环显示模板 -->
  236. {volist name="products" id="template"}
  237. <div class="template-card">
  238. <div class="template-thumbnail">
  239. <!-- 审核状态标识 -->
  240. <div class="examine-status {if condition="$template.toexamine eq '审核通过'"}passed{elseif condition="$template.toexamine eq '未通过'"}failed{else}pending{/if}">
  241. {$template.toexamine}
  242. </div>
  243. {if condition="$template.type eq '文生图'"}
  244. <a href="{:url('user/diagrams_list', ['id' => $template.id])}">
  245. <img src="{$template.template_image_url}" alt="{$template.template_name}" onerror="this.src=''; this.alt='图片加载失败';">
  246. </a>
  247. {elseif condition="$template.type eq '文生视频'"}
  248. <a href="{:url('user/diagrams_list', ['id' => $template.id])}">
  249. <video src="{$template.template_image_url}" alt="{$template.template_name}" controls muted></video>
  250. </a>
  251. {/if}
  252. </div>
  253. <div class="template-info">
  254. <div class="template-name">{$template.template_name}</div>
  255. <div class="template-meta">
  256. <span class="restore-btn" onclick="restoreDiagram({$template.id})">恢复</span>
  257. <span class="delete-btn" onclick="deleteDiagram({$template.id})">彻底删除</span>
  258. </div>
  259. </div>
  260. </div>
  261. {/volist}
  262. <!-- 作品为空时的提示 -->
  263. {empty name="products"}
  264. <div class="empty-tip">
  265. <div class="empty-icon">📄</div>
  266. <div class="empty-text">回收站空的</div>
  267. </div>
  268. {/empty}
  269. </div>
  270. </div>
  271. </div>
  272. <script>
  273. // 标签页切换事件
  274. document.querySelectorAll('.tab-item').forEach(item => {
  275. item.addEventListener('click', function() {
  276. // 移除所有active类
  277. document.querySelectorAll('.tab-item').forEach(tab => {
  278. tab.classList.remove('active');
  279. });
  280. // 为当前点击的标签页添加active类
  281. this.classList.add('active');
  282. // 这里可以添加切换标签页内容的逻辑
  283. const tabText = this.textContent;
  284. console.log('切换到:', tabText);
  285. });
  286. });
  287. // 菜单点击切换事件
  288. document.querySelectorAll('.menu-item a').forEach(item => {
  289. item.addEventListener('click', function(e) {
  290. // 移除所有active类
  291. document.querySelectorAll('.menu-item').forEach(menu => {
  292. menu.classList.remove('active');
  293. });
  294. // 为当前点击的菜单项添加active类
  295. this.parentNode.classList.add('active');
  296. // 这里可以添加切换菜单内容的逻辑
  297. const menuText = this.textContent;
  298. console.log('切换到:', menuText);
  299. });
  300. });
  301. // 媒体显示函数
  302. function showMedia(url, type) {
  303. // 这里可以根据需要实现媒体预览功能
  304. // 例如:打开一个模态框显示大图或视频
  305. console.log('显示媒体:', url, '类型:', type);
  306. // 示例:创建一个简单的模态框
  307. const modal = document.createElement('div');
  308. modal.style.position = 'fixed';
  309. modal.style.top = '0';
  310. modal.style.left = '0';
  311. modal.style.width = '100%';
  312. modal.style.height = '100%';
  313. modal.style.backgroundColor = 'rgba(0, 0, 0, 0.8)';
  314. modal.style.display = 'flex';
  315. modal.style.justifyContent = 'center';
  316. modal.style.alignItems = 'center';
  317. modal.style.zIndex = '10000';
  318. if (type === '文生图') {
  319. const img = document.createElement('img');
  320. img.src = url;
  321. img.style.maxWidth = '90%';
  322. img.style.maxHeight = '90%';
  323. modal.appendChild(img);
  324. } else if (type === '文生视频') {
  325. const video = document.createElement('video');
  326. video.src = url;
  327. video.controls = true;
  328. video.style.maxWidth = '90%';
  329. video.style.maxHeight = '90%';
  330. modal.appendChild(video);
  331. }
  332. // 点击模态框关闭
  333. modal.addEventListener('click', function() {
  334. document.body.removeChild(modal);
  335. });
  336. document.body.appendChild(modal);
  337. }
  338. // 创建并显示自定义确认弹窗
  339. function showConfirmDialog(message, onConfirm, onCancel) {
  340. // 检查是否已存在弹窗,如果存在则移除
  341. let existingDialog = document.getElementById('customConfirmDialog');
  342. if (existingDialog) {
  343. existingDialog.remove();
  344. }
  345. // 创建弹窗容器
  346. const dialog = document.createElement('div');
  347. dialog.id = 'customConfirmDialog';
  348. dialog.style.cssText = `
  349. position: fixed;
  350. top: 0;
  351. left: 0;
  352. width: 100%;
  353. height: 100%;
  354. background-color: rgba(0, 0, 0, 0.5);
  355. display: flex;
  356. justify-content: center;
  357. align-items: center;
  358. z-index: 10000;
  359. `;
  360. // 创建弹窗内容
  361. const dialogContent = document.createElement('div');
  362. dialogContent.style.cssText = `
  363. background-color: white;
  364. border-radius: 8px;
  365. padding: 24px;
  366. min-width: 300px;
  367. box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  368. `;
  369. // 创建消息文本
  370. const dialogMessage = document.createElement('div');
  371. dialogMessage.textContent = message;
  372. dialogMessage.style.cssText = `
  373. font-size: 16px;
  374. color: #333;
  375. margin-bottom: 24px;
  376. text-align: center;
  377. `;
  378. // 创建按钮容器
  379. const dialogButtons = document.createElement('div');
  380. dialogButtons.style.cssText = `
  381. display: flex;
  382. justify-content: center;
  383. gap: 16px;
  384. `;
  385. // 创建取消按钮
  386. const cancelBtn = document.createElement('button');
  387. cancelBtn.textContent = '取消';
  388. cancelBtn.style.cssText = `
  389. padding: 8px 16px;
  390. border: 1px solid #d9d9d9;
  391. background-color: white;
  392. color: #333;
  393. border-radius: 4px;
  394. cursor: pointer;
  395. font-size: 14px;
  396. transition: all 0.3s;
  397. `;
  398. cancelBtn.onmouseover = function() {
  399. this.style.borderColor = '#40a9ff';
  400. this.style.color = '#40a9ff';
  401. };
  402. cancelBtn.onmouseout = function() {
  403. this.style.borderColor = '#d9d9d9';
  404. this.style.color = '#333';
  405. };
  406. cancelBtn.onclick = function() {
  407. dialog.remove();
  408. if (onCancel) onCancel();
  409. };
  410. // 创建确认按钮
  411. const confirmBtn = document.createElement('button');
  412. confirmBtn.textContent = '确定';
  413. confirmBtn.style.cssText = `
  414. padding: 8px 16px;
  415. border: 1px solid #ff4d4f;
  416. background-color: #ff4d4f;
  417. color: white;
  418. border-radius: 4px;
  419. cursor: pointer;
  420. font-size: 14px;
  421. transition: all 0.3s;
  422. `;
  423. confirmBtn.onmouseover = function() {
  424. this.style.backgroundColor = '#ff7875';
  425. this.style.borderColor = '#ff7875';
  426. };
  427. confirmBtn.onmouseout = function() {
  428. this.style.backgroundColor = '#ff4d4f';
  429. this.style.borderColor = '#ff4d4f';
  430. };
  431. confirmBtn.onclick = function() {
  432. dialog.remove();
  433. if (onConfirm) onConfirm();
  434. };
  435. // 组装弹窗
  436. dialogButtons.appendChild(cancelBtn);
  437. dialogButtons.appendChild(confirmBtn);
  438. dialogContent.appendChild(dialogMessage);
  439. dialogContent.appendChild(dialogButtons);
  440. dialog.appendChild(dialogContent);
  441. // 添加到页面
  442. document.body.appendChild(dialog);
  443. // 点击弹窗外部关闭
  444. dialog.onclick = function(e) {
  445. if (e.target === dialog) {
  446. dialog.remove();
  447. if (onCancel) onCancel();
  448. }
  449. };
  450. }
  451. // 创建并显示自定义提示框
  452. function showAlert(message, type = 'info', duration = 3000) {
  453. // 检查是否已存在提示框容器,如果不存在则创建
  454. let alertElement = document.getElementById('customAlert');
  455. if (alertElement) {
  456. alertElement.remove();
  457. }
  458. // 创建提示框元素
  459. alertElement = document.createElement('div');
  460. alertElement.id = 'customAlert';
  461. // 设置不同类型的样式
  462. let backgroundColor;
  463. switch (type) {
  464. case 'success':
  465. backgroundColor = '#52c41a';
  466. break;
  467. case 'error':
  468. backgroundColor = '#ff4d4f';
  469. break;
  470. case 'warning':
  471. backgroundColor = '#faad14';
  472. break;
  473. default:
  474. backgroundColor = '#1890ff';
  475. }
  476. // 设置样式
  477. alertElement.style.cssText = `
  478. position: fixed;
  479. top: 20px;
  480. left: 50%;
  481. transform: translateX(-50%);
  482. padding: 12px 20px;
  483. background-color: ${backgroundColor};
  484. color: white;
  485. border-radius: 4px;
  486. box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  487. z-index: 10001;
  488. font-size: 14px;
  489. max-width: 80%;
  490. text-align: center;
  491. `;
  492. // 设置文本内容
  493. alertElement.textContent = message;
  494. // 添加到页面
  495. document.body.appendChild(alertElement);
  496. // 自动关闭
  497. setTimeout(() => {
  498. if (alertElement.parentNode) {
  499. alertElement.remove();
  500. }
  501. }, duration);
  502. }
  503. // 恢复作品函数
  504. function restoreDiagram(id) {
  505. showConfirmDialog('确定要恢复该作品吗?', function() {
  506. // 发送Ajax请求到恢复接口
  507. fetch('{:url("user/diagrams_restore")}', {
  508. method: 'POST',
  509. headers: {
  510. 'Content-Type': 'application/x-www-form-urlencoded',
  511. },
  512. body: 'id=' + id
  513. })
  514. .then(response => response.json())
  515. .then(data => {
  516. if (data.code === 0) {
  517. // 恢复成功后显示提示并刷新页面
  518. showAlert('恢复成功', 'success', 1500);
  519. setTimeout(() => {
  520. location.reload();
  521. }, 1500);
  522. } else {
  523. showAlert('恢复失败: ' + data.msg, 'error');
  524. }
  525. })
  526. .catch(error => {
  527. console.error('恢复请求失败:', error);
  528. showAlert('恢复请求失败,请重试', 'error');
  529. });
  530. });
  531. }
  532. // 删除作品函数 - 彻底删除
  533. function deleteDiagram(id) {
  534. showConfirmDialog('确定要彻底删除该作品吗?删除后将无法恢复!', function() {
  535. // 发送Ajax请求到删除接口
  536. fetch('{:url("user/diagrams_delete")}', {
  537. method: 'POST',
  538. headers: {
  539. 'Content-Type': 'application/x-www-form-urlencoded',
  540. },
  541. body: 'id=' + id
  542. })
  543. .then(response => response.json())
  544. .then(data => {
  545. if (data.code === 0) {
  546. // 删除成功后显示提示并刷新页面
  547. showAlert('删除成功', 'success', 1500);
  548. setTimeout(() => {
  549. location.reload();
  550. }, 1500);
  551. } else {
  552. showAlert('删除失败: ' + data.msg, 'error');
  553. }
  554. })
  555. .catch(error => {
  556. console.error('删除请求失败:', error);
  557. showAlert('删除请求失败,请重试', 'error');
  558. });
  559. });
  560. }
  561. </script>