holidays.ejs 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <!doctype html>
  2. <html lang="zh-CN">
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1">
  6. <title><%= title %></title>
  7. <link rel="stylesheet" href="/styles.css">
  8. </head>
  9. <body>
  10. <%- include('partials/nav') %>
  11. <main>
  12. <section class="hero tile-light compact page-intro">
  13. <p class="eyebrow">Mainland China Calendar</p>
  14. <h1>节假日导入</h1>
  15. <p class="lead">复制提示词给大模型,生成 JSON 后粘贴导入。</p>
  16. </section>
  17. <% if (message) { %><div class="notice"><%= message %></div><% } %>
  18. <% if (error) { %><div class="notice notice-error"><%= error %></div><% } %>
  19. <section class="tile-parchment compact two-col holiday-import-grid">
  20. <article class="utility-card holiday-card">
  21. <div class="holiday-card-header">
  22. <h2>生成节假日数据</h2>
  23. </div>
  24. <textarea class="holiday-textarea" id="prompt" readonly><%= prompt %></textarea>
  25. <button class="button-primary holiday-action" type="button" onclick="copyPrompt()">复制提示词</button>
  26. </article>
  27. <article class="utility-card holiday-card">
  28. <div class="holiday-card-header">
  29. <h2>粘贴并导入 JSON</h2>
  30. </div>
  31. <form method="post" action="/holidays/import" class="holiday-form">
  32. <textarea class="holiday-textarea" name="holiday_json" placeholder="把大模型生成的 JSON 粘贴到这里"></textarea>
  33. <button class="button-primary holiday-action">导入节假日</button>
  34. </form>
  35. </article>
  36. </section>
  37. <section class="tile-light compact">
  38. <div class="table-wrap utility-card wide">
  39. <div class="table-card-header">
  40. <h2>已导入数据</h2>
  41. <% if (rows.length) { %>
  42. <form method="post" action="/holidays/clear" onsubmit="return confirm('确定清空所有已导入的节假日数据吗?')">
  43. <button class="button-secondary small">清空数据</button>
  44. </form>
  45. <% } %>
  46. </div>
  47. <table>
  48. <thead><tr><th>年份</th><th>日期</th><th>名称</th><th>类型</th></tr></thead>
  49. <tbody>
  50. <% rows.forEach((row) => { %>
  51. <tr><td><%= row.year %></td><td><%= row.date %></td><td><%= row.name %></td><td><%= holidayTypeLabel(row.type) %></td></tr>
  52. <% }) %>
  53. </tbody>
  54. </table>
  55. </div>
  56. </section>
  57. </main>
  58. <script>
  59. async function copyPrompt() {
  60. const prompt = document.getElementById('prompt');
  61. try {
  62. await navigator.clipboard.writeText(prompt.value);
  63. } catch {
  64. prompt.select();
  65. document.execCommand('copy');
  66. }
  67. }
  68. </script>
  69. </body>
  70. </html>