myworks.ejs 5.6 KB

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