diagrams.html 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588
  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. }
  151. .delete-btn:hover {
  152. color: #ff7875;
  153. text-decoration: underline;
  154. }
  155. /* 空提示样式 */
  156. .empty-tip {
  157. grid-column: 1 / -1;
  158. display: flex;
  159. flex-direction: column;
  160. align-items: center;
  161. justify-content: center;
  162. min-height: 400px;
  163. text-align: center;
  164. padding: 40px 20px;
  165. color: #999;
  166. }
  167. .empty-icon {
  168. font-size: 64px;
  169. margin-bottom: 20px;
  170. opacity: 0.5;
  171. }
  172. .empty-text {
  173. font-size: 20px;
  174. font-weight: 500;
  175. margin-bottom: 10px;
  176. color: #666;
  177. }
  178. .empty-subtext {
  179. font-size: 14px;
  180. color: #999;
  181. }
  182. /* 响应式设计 */
  183. @media (max-width: 768px) {
  184. .user-diagrams-container {
  185. flex-direction: column;
  186. }
  187. .sidebar {
  188. width: 100%;
  189. border-right: none;
  190. border-bottom: 1px solid #e8e8e8;
  191. }
  192. .menu {
  193. padding: 0;
  194. }
  195. .menu-item {
  196. display: inline-block;
  197. }
  198. .menu-item a {
  199. padding: 12px 15px;
  200. }
  201. }
  202. </style>
  203. <div class="user-diagrams-container">
  204. <!-- 左侧菜单 -->
  205. <div class="sidebar">
  206. <ul class="menu">
  207. <li class="menu-item active">
  208. <a href="{:url('user/diagrams')}">我的模版</a>
  209. </li>
  210. <li class="menu-item">
  211. <a href="{:url('user/recycle')}">收回站</a>
  212. </li>
  213. </ul>
  214. </div>
  215. <!-- 右侧内容区域 -->
  216. <div class="diagrams-content">
  217. <!-- 标签页 -->
  218. <div class="tabs">
  219. <div class="tab-item active">全部模版</div>
  220. </div>
  221. <!-- 内容区域 -->
  222. <div class="tab-content">
  223. <div class="template-grid" id="templateGrid">
  224. <!-- 使用volist标签循环显示模板 -->
  225. {volist name="products" id="template"}
  226. <div class="template-card">
  227. <div class="template-thumbnail">
  228. <!-- 审核状态标识 -->
  229. <div class="examine-status {if condition="$template.toexamine eq '审核通过'"}passed{elseif condition="$template.toexamine eq '未通过'"}failed{else}pending{/if}">
  230. {$template.toexamine}
  231. </div>
  232. {if condition="$template.type eq '文生图'"}
  233. <a href="{:url('user/diagrams_list', ['id' => $template.id])}">
  234. <img src="{$template.template_image_url}" alt="{$template.template_name}" onerror="this.src=''; this.alt='图片加载失败';">
  235. </a>
  236. {elseif condition="$template.type eq '文生视频'"}
  237. <a href="{:url('user/diagrams_list', ['id' => $template.id])}">
  238. <video src="{$template.template_image_url}" alt="{$template.template_name}" controls muted></video>
  239. </a>
  240. {/if}
  241. </div>
  242. <div class="template-info">
  243. <div class="template-name">{$template.template_name}</div>
  244. <div class="template-meta">
  245. <span class="delete-btn" onclick="deleteDiagram({$template.id})">删除</span>
  246. </div>
  247. </div>
  248. </div>
  249. {/volist}
  250. <!-- 作品为空时的提示 -->
  251. {empty name="products"}
  252. <div class="empty-tip">
  253. <div class="empty-icon">📄</div>
  254. <div class="empty-text">您还没有作品</div>
  255. <div class="empty-subtext">快去发布您的第一个作品吧!</div>
  256. </div>
  257. {/empty}
  258. </div>
  259. </div>
  260. </div>
  261. </div>
  262. <script>
  263. // 标签页切换事件
  264. document.querySelectorAll('.tab-item').forEach(item => {
  265. item.addEventListener('click', function() {
  266. // 移除所有active类
  267. document.querySelectorAll('.tab-item').forEach(tab => {
  268. tab.classList.remove('active');
  269. });
  270. // 为当前点击的标签页添加active类
  271. this.classList.add('active');
  272. // 这里可以添加切换标签页内容的逻辑
  273. const tabText = this.textContent;
  274. console.log('切换到:', tabText);
  275. });
  276. });
  277. // 菜单点击事件处理
  278. document.querySelectorAll('.menu-item a').forEach(item => {
  279. item.addEventListener('click', function() {
  280. // 移除所有active类
  281. document.querySelectorAll('.menu-item').forEach(menu => {
  282. menu.classList.remove('active');
  283. });
  284. // 为当前点击的菜单项添加active类
  285. this.parentNode.classList.add('active');
  286. });
  287. });
  288. // 媒体显示函数
  289. function showMedia(url, type) {
  290. // 这里可以根据需要实现媒体预览功能
  291. // 例如:打开一个模态框显示大图或视频
  292. console.log('显示媒体:', url, '类型:', type);
  293. // 示例:创建一个简单的模态框
  294. const modal = document.createElement('div');
  295. modal.style.position = 'fixed';
  296. modal.style.top = '0';
  297. modal.style.left = '0';
  298. modal.style.width = '100%';
  299. modal.style.height = '100%';
  300. modal.style.backgroundColor = 'rgba(0, 0, 0, 0.8)';
  301. modal.style.display = 'flex';
  302. modal.style.justifyContent = 'center';
  303. modal.style.alignItems = 'center';
  304. modal.style.zIndex = '10000';
  305. if (type === '文生图') {
  306. const img = document.createElement('img');
  307. img.src = url;
  308. img.style.maxWidth = '90%';
  309. img.style.maxHeight = '90%';
  310. modal.appendChild(img);
  311. } else if (type === '文生视频') {
  312. const video = document.createElement('video');
  313. video.src = url;
  314. video.controls = true;
  315. video.style.maxWidth = '90%';
  316. video.style.maxHeight = '90%';
  317. modal.appendChild(video);
  318. }
  319. // 点击模态框关闭
  320. modal.addEventListener('click', function() {
  321. document.body.removeChild(modal);
  322. });
  323. document.body.appendChild(modal);
  324. }
  325. // 创建并显示自定义确认弹窗
  326. function showConfirmDialog(message, onConfirm, onCancel) {
  327. // 检查是否已存在弹窗,如果存在则移除
  328. let existingDialog = document.getElementById('customConfirmDialog');
  329. if (existingDialog) {
  330. existingDialog.remove();
  331. }
  332. // 创建弹窗容器
  333. const dialog = document.createElement('div');
  334. dialog.id = 'customConfirmDialog';
  335. dialog.style.cssText = `
  336. position: fixed;
  337. top: 0;
  338. left: 0;
  339. width: 100%;
  340. height: 100%;
  341. background-color: rgba(0, 0, 0, 0.5);
  342. display: flex;
  343. justify-content: center;
  344. align-items: center;
  345. z-index: 10000;
  346. `;
  347. // 创建弹窗内容
  348. const dialogContent = document.createElement('div');
  349. dialogContent.style.cssText = `
  350. background-color: white;
  351. border-radius: 8px;
  352. padding: 24px;
  353. min-width: 300px;
  354. box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  355. `;
  356. // 创建消息文本
  357. const dialogMessage = document.createElement('div');
  358. dialogMessage.textContent = message;
  359. dialogMessage.style.cssText = `
  360. font-size: 16px;
  361. color: #333;
  362. margin-bottom: 24px;
  363. text-align: center;
  364. `;
  365. // 创建按钮容器
  366. const dialogButtons = document.createElement('div');
  367. dialogButtons.style.cssText = `
  368. display: flex;
  369. justify-content: center;
  370. gap: 16px;
  371. `;
  372. // 创建取消按钮
  373. const cancelBtn = document.createElement('button');
  374. cancelBtn.textContent = '取消';
  375. cancelBtn.style.cssText = `
  376. padding: 8px 16px;
  377. border: 1px solid #d9d9d9;
  378. background-color: white;
  379. color: #333;
  380. border-radius: 4px;
  381. cursor: pointer;
  382. font-size: 14px;
  383. transition: all 0.3s;
  384. `;
  385. cancelBtn.onmouseover = function() {
  386. this.style.borderColor = '#40a9ff';
  387. this.style.color = '#40a9ff';
  388. };
  389. cancelBtn.onmouseout = function() {
  390. this.style.borderColor = '#d9d9d9';
  391. this.style.color = '#333';
  392. };
  393. cancelBtn.onclick = function() {
  394. dialog.remove();
  395. if (onCancel) onCancel();
  396. };
  397. // 创建确认按钮
  398. const confirmBtn = document.createElement('button');
  399. confirmBtn.textContent = '确定';
  400. confirmBtn.style.cssText = `
  401. padding: 8px 16px;
  402. border: 1px solid #ff4d4f;
  403. background-color: #ff4d4f;
  404. color: white;
  405. border-radius: 4px;
  406. cursor: pointer;
  407. font-size: 14px;
  408. transition: all 0.3s;
  409. `;
  410. confirmBtn.onmouseover = function() {
  411. this.style.backgroundColor = '#ff7875';
  412. this.style.borderColor = '#ff7875';
  413. };
  414. confirmBtn.onmouseout = function() {
  415. this.style.backgroundColor = '#ff4d4f';
  416. this.style.borderColor = '#ff4d4f';
  417. };
  418. confirmBtn.onclick = function() {
  419. dialog.remove();
  420. if (onConfirm) onConfirm();
  421. };
  422. // 组装弹窗
  423. dialogButtons.appendChild(cancelBtn);
  424. dialogButtons.appendChild(confirmBtn);
  425. dialogContent.appendChild(dialogMessage);
  426. dialogContent.appendChild(dialogButtons);
  427. dialog.appendChild(dialogContent);
  428. // 添加到页面
  429. document.body.appendChild(dialog);
  430. // 点击弹窗外部关闭
  431. dialog.onclick = function(e) {
  432. if (e.target === dialog) {
  433. dialog.remove();
  434. if (onCancel) onCancel();
  435. }
  436. };
  437. }
  438. // 创建并显示自定义提示框
  439. function showAlert(message, type = 'info', duration = 3000) {
  440. // 检查是否已存在提示框容器,如果不存在则创建
  441. let alertElement = document.getElementById('customAlert');
  442. if (alertElement) {
  443. alertElement.remove();
  444. }
  445. // 创建提示框元素
  446. alertElement = document.createElement('div');
  447. alertElement.id = 'customAlert';
  448. // 设置不同类型的样式
  449. let backgroundColor;
  450. switch (type) {
  451. case 'success':
  452. backgroundColor = '#52c41a';
  453. break;
  454. case 'error':
  455. backgroundColor = '#ff4d4f';
  456. break;
  457. case 'warning':
  458. backgroundColor = '#faad14';
  459. break;
  460. default:
  461. backgroundColor = '#1890ff';
  462. }
  463. // 设置样式
  464. alertElement.style.cssText = `
  465. position: fixed;
  466. top: 20px;
  467. left: 50%;
  468. transform: translateX(-50%);
  469. padding: 12px 20px;
  470. background-color: ${backgroundColor};
  471. color: white;
  472. border-radius: 4px;
  473. box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  474. z-index: 10001;
  475. font-size: 14px;
  476. max-width: 80%;
  477. text-align: center;
  478. `;
  479. // 设置文本内容
  480. alertElement.textContent = message;
  481. // 添加到页面
  482. document.body.appendChild(alertElement);
  483. // 自动关闭
  484. setTimeout(() => {
  485. if (alertElement.parentNode) {
  486. alertElement.remove();
  487. }
  488. }, duration);
  489. }
  490. // 删除作品函数
  491. function deleteDiagram(id) {
  492. showConfirmDialog('确定要删除该作品吗?', function() {
  493. // 发送Ajax请求到删除接口
  494. fetch('{:url("user/diagrams_del")}', {
  495. method: 'POST',
  496. headers: {
  497. 'Content-Type': 'application/x-www-form-urlencoded',
  498. },
  499. body: 'id=' + id
  500. })
  501. .then(response => response.json())
  502. .then(data => {
  503. if (data.code === 0) {
  504. // 删除成功后显示提示并刷新页面
  505. showAlert('删除成功', 'success', 1500);
  506. setTimeout(() => {
  507. location.reload();
  508. }, 1500);
  509. } else {
  510. showAlert('删除失败: ' + data.msg, 'error');
  511. }
  512. })
  513. .catch(error => {
  514. console.error('删除请求失败:', error);
  515. showAlert('删除请求失败,请重试', 'error');
  516. });
  517. });
  518. }
  519. </script>