myworks.ejs 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <link rel="icon" href="/assets/icon/favicon.ico" type="image/x-icon">
  7. <title>My Coloring Page Works | Art Color</title>
  8. <meta name="description"
  9. content="Explore our massive collection of over 20,000 free coloring pages! Find endless printable designs from animals to mandalas, cartoons, and more. Perfect for kids and adults – start your creative journey today!">
  10. <link rel="stylesheet" href="/stylesheets/v2/styles.css">
  11. <style>
  12. /* 标签导航样式 */
  13. .tab-nav {
  14. display: flex;
  15. border-bottom: 2px solid #eee;
  16. }
  17. .tab-button {
  18. padding: 1rem 2rem;
  19. border: none;
  20. background: none;
  21. cursor: pointer;
  22. font-size: 1.2rem;
  23. color: var(--text-color);
  24. transition: all 0.3s ease;
  25. position: relative;
  26. }
  27. .tab-button.active {
  28. color: var(--secondary-color);
  29. font-weight: 600;
  30. }
  31. .tab-button.active::after {
  32. content: '';
  33. position: absolute;
  34. bottom: -2px;
  35. left: 0;
  36. width: 100%;
  37. height: 3px;
  38. background: var(--secondary-color);
  39. }
  40. /* 内容区域样式 */
  41. .tab-content {
  42. display: none;
  43. }
  44. .tab-content.active {
  45. margin-top: 20px;
  46. display: flex;
  47. flex-direction: column;
  48. justify-content: center;
  49. animation: fadeIn 0.3s ease;
  50. }
  51. @keyframes fadeIn {
  52. from {
  53. opacity: 0;
  54. transform: translateY(10px);
  55. }
  56. to {
  57. opacity: 1;
  58. transform: translateY(0);
  59. }
  60. }
  61. /* 响应式设计, 如果是手机屏幕 */
  62. @media (max-width: 768px) {
  63. .tab-button {
  64. font-size: 1.0rem;
  65. padding: 1rem 1rem;
  66. }
  67. }
  68. </style>
  69. </head>
  70. <!-- Google tag (gtag.js) -->
  71. <script async src="https://www.googletagmanager.com/gtag/js?id=G-JBGGVGLHTP"></script>
  72. <script>
  73. window.dataLayer = window.dataLayer || [];
  74. function gtag() { dataLayer.push(arguments); }
  75. gtag('js', new Date());
  76. gtag('config', 'G-JBGGVGLHTP');
  77. </script>
  78. <body>
  79. <%- include('header') %>
  80. <main class="container">
  81. <section>
  82. <!-- 标签导航 -->
  83. <nav class="tab-nav">
  84. <button class="tab-button active" data-tab="ongoing">In Progress</button>
  85. <button class="tab-button" data-tab="completed">Completed</button>
  86. <button class="tab-button" data-tab="favorite">Favorite</button>
  87. </nav>
  88. <!-- 进行中内容 -->
  89. <div id="ongoing" class="tab-content active">
  90. <div class="coloring-grid">
  91. </div>
  92. </div>
  93. <!-- 已完成内容 -->
  94. <div id="completed" class="tab-content">
  95. <div class="coloring-grid">
  96. </div>
  97. </div>
  98. <!-- 收藏内容 -->
  99. <div id="favorite" class="tab-content">
  100. <div class="coloring-grid">
  101. </div>
  102. </div>
  103. </section>
  104. </main>
  105. <script src="/scripts/script.js"></script>
  106. <script>
  107. const host = '<%= host %>';
  108. // 标签切换功能
  109. const tabButtons = document.querySelectorAll('.tab-button');
  110. const tabContents = document.querySelectorAll('.tab-content');
  111. tabButtons.forEach(button => {
  112. button.addEventListener('click', () => {
  113. const targetTab = button.dataset.tab;
  114. // 移除所有激活状态
  115. tabButtons.forEach(btn => btn.classList.remove('active'));
  116. tabContents.forEach(content => content.classList.remove('active'));
  117. // 添加当前激活状态
  118. button.classList.add('active');
  119. document.getElementById(targetTab).classList.add('active');
  120. });
  121. });
  122. // 加载
  123. const loadWorks = (tabType) => {
  124. let data = {};
  125. if (tabType === 'favorite') {
  126. const raw = localStorage.getItem('_storage_collection__') || '{}';
  127. data = JSON.parse(raw);
  128. } else {
  129. const rawMeta = localStorage.getItem('__storage_metadata__') || '{}';
  130. const metaData = JSON.parse(rawMeta);
  131. data = Object.entries(metaData).filter(([_, item]) =>
  132. tabType === 'ongoing' ? item.progress < 100 : item.progress >= 100
  133. ).reduce((acc, [id, item]) => ({ ...acc, [id]: item }), {});
  134. }
  135. return Object.entries(data).map(([id, item]) => ({
  136. id,
  137. uri: `/coloring-page/${id}`,
  138. thumbnail: `${host}/thumbs/coloring-page/${item.progress >= 100 ? 'work' : 'page'}/480/${id}.png`, // 缩略图拼接规则‌:ml-citation{ref="7" data="citationList"}
  139. progress: item.progress,
  140. timestamp: item.timestamp
  141. })).sort((a, b) => b.timestamp - a.timestamp); // 时间倒序排列
  142. };
  143. // 动态渲染
  144. const renderWorks = (container, items) => {
  145. container.innerHTML = '';
  146. items.forEach(item => {
  147. const card = document.createElement('div');
  148. card.className = 'coloring-card';
  149. card.innerHTML = `
  150. <div data-content-id="${item.id}" class="coloring-image">
  151. <a href="${item.uri}"><img src="${item.thumbnail}"></a>
  152. <div class="progress-badge" style="background-color: ${item.progress >= 100 ? 'var(--secondary-color)' : 'var(--primary-color)'}; transition: background-color 0.3s ease; ">
  153. <span>${item.progress >= 100 ? '✓' : item.progress + '%'}</span>
  154. </div>
  155. </div>
  156. `;
  157. container.appendChild(card);
  158. });
  159. };
  160. document.querySelectorAll('.tab-content').forEach(container => {
  161. const tabType = container.id;
  162. const works = loadWorks(tabType);
  163. const grid = container.querySelector('.coloring-grid');
  164. renderWorks(grid, works);
  165. });
  166. </script>
  167. </body>
  168. </html>