{"id":268,"date":"2026-05-25T22:15:06","date_gmt":"2026-05-25T22:15:06","guid":{"rendered":"https:\/\/mist.onmypc.info\/?page_id=268"},"modified":"2026-06-11T00:06:34","modified_gmt":"2026-06-10T16:06:34","slug":"gallery","status":"publish","type":"page","link":"https:\/\/mist.onmypc.info\/index.php\/gallery\/","title":{"rendered":"\u56fe\u5e93"},"content":{"rendered":"<p><!-- \u5c06\u6b64\u4ee3\u7801\u66ff\u6362\u5230\u56fe\u5e93\u9875\u9762\uff08ID: 268\uff09--><\/p>\n<div id=\"gallery-container\" class=\"gallery-upgrade-container\">\n<div class=\"gallery-header\">\n<h2 class=\"gallery-title\">\u590f\u70df\u56fe\u5e93<\/h2>\n<p class=\"gallery-description\">\u8fd9\u91cc\u662f\u590f\u70df\u7684\u58c1\u7eb8\u548c\u56fe\u7247\u5408\u96c6~ \u66f4\u591a\u56fe\u7247\u6301\u7eed\u66f4\u65b0\u4e2d<\/p>\n<div class=\"gallery-controls\">\n      <label for=\"gallery-sort\" class=\"sort-label\">\u6392\u5e8f\u65b9\u5f0f:<\/label><\/p>\n<p>        \u65f6\u95f4\u6392\u5e8f (\u65e7\u2192\u65b0)<br \/>\n        \u65f6\u95f4\u6392\u5e8f (\u65b0\u2192\u65e7)<br \/>\n        \u70ed\u5ea6\u6392\u5e8f (\u70b9\u8d5e\u6700\u591a)<br \/>\n        \u70ed\u5ea6\u6392\u5e8f (\u70b9\u8d5e\u6700\u5c11)<\/p><\/div>\n<\/p><\/div>\n<div id=\"gallery-grid\" class=\"gallery-grid\">\n    <!-- \u56fe\u7247\u7f51\u683c\u5c06\u5728\u8fd9\u91cc\u6e32\u67d3 -->\n  <\/div>\n<p class=\"gallery-footer\">\u66f4\u591a\u56fe\u7247\u656c\u8bf7\u671f\u5f85~<\/p>\n<\/div>\n<p><!-- \u706f\u7bb1\u6a21\u6001\u7a97\u53e3 --><\/p>\n<div id=\"lightbox-modal\" class=\"lightbox-modal\" style=\"display: none\">\n  <span class=\"lightbox-close\">&times;<\/span><br \/>\n  <img decoding=\"async\" class=\"lightbox-image\" src=\"\" alt=\"\"><\/p>\n<div class=\"lightbox-caption\"><\/div>\n<\/div>\n<p>.gallery-upgrade-container { max-width: 1200px; margin: 0 auto; padding: 40px 20px; font-family: -apple-system, BlinkMacSystemFont, &#8216;Segoe UI&#8217;, Roboto, &#8216;Helvetica Neue&#8217;, Arial, sans-serif; }<br \/>\n.gallery-header { text-align: center; margin-bottom: 50px; }<br \/>\n.gallery-title { font-size: 36px; font-weight: 700; color: #e91e8c; margin: 0 0 15px 0; }<br \/>\n.gallery-description { font-size: 16px; color: #9c27b0; margin: 0 0 30px 0; }<br \/>\n.gallery-controls { display: flex; align-items: center; justify-content: center; gap: 15px; margin-bottom: 30px; }<br \/>\n.sort-label { font-weight: 600; color: #333; font-size: 14px; }<br \/>\n.sort-select { padding: 10px 15px; border: 2px solid #e91e8c; border-radius: 6px; background-color: #fff; color: #333; font-size: 14px; font-weight: 500; cursor: pointer; transition: all 0.3s ease; }<br \/>\n.sort-select:hover { background-color: #f5f5f5; border-color: #ad1457; }<br \/>\n.sort-select:focus { outline: none; box-shadow: 0 0 0 3px rgba(233, 30, 140, 0.1); }<br \/>\n.gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 25px; margin-bottom: 50px; }<br \/>\n@media (max-width: 1024px) { .gallery-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 20px; } }<br \/>\n@media (max-width: 768px) { .gallery-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 15px; } .gallery-title { font-size: 28px; } .gallery-description { font-size: 14px; } }<br \/>\n@media (max-width: 480px) { .gallery-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px; } .gallery-upgrade-container { padding: 20px 15px; } }<br \/>\n.gallery-card { position: relative; overflow: hidden; border-radius: 12px; background: #f5f5f5; cursor: pointer; transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); aspect-ratio: auto; }<br \/>\n.gallery-card:hover { transform: translateY(-8px) scale(1.02); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15); }<br \/>\n.gallery-card-image { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform 0.4s ease; }<br \/>\n.gallery-card:hover .gallery-card-image { transform: scale(1.08); }<br \/>\n.gallery-card-overlay { position: absolute; bottom: 0; left: 0; right: 0; background: linear-gradient(to top, rgba(0, 0, 0, 0.8), rgba(0, 0, 0, 0.3), transparent); padding: 20px 15px 15px 15px; transform: translateY(60px); transition: transform 0.3s ease; display: flex; align-items: center; justify-content: space-between; }<br \/>\n.gallery-card:hover .gallery-card-overlay { transform: translateY(0); }<br \/>\n.gallery-card-info { flex: 1; min-width: 0; }<br \/>\n.gallery-card-alt { color: #fff; font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin: 0; }<br \/>\n.gallery-like-btn { background: none; border: none; cursor: pointer; padding: 8px; display: flex; align-items: center; justify-content: center; transition: all 0.2s ease; position: relative; flex-shrink: 0; margin-left: 10px; }<br \/>\n.gallery-like-btn:hover { transform: scale(1.15); }<br \/>\n.like-icon { width: 24px; height: 24px; display: flex; align-items: center; justify-content: center; font-size: 20px; transition: all 0.3s ease; }<br \/>\n.gallery-like-btn.liked .like-icon { color: #e91e8c; animation: heartBeat 0.3s ease; }<br \/>\n.gallery-like-btn:not(.liked) .like-icon { color: #fff; }<br \/>\n.gallery-like-count { color: #fff; font-size: 12px; font-weight: 600; min-width: 25px; text-align: center; margin-left: 5px; }<br \/>\n@keyframes heartBeat { 0%, 100% { transform: scale(1); } 10%, 30% { transform: scale(0.9); } 20%, 40%, 60%, 80% { transform: scale(1.1); } 50%, 70% { transform: scale(1.05); } }<br \/>\n.lightbox-modal { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.95); z-index: 1000; display: flex; align-items: center; justify-content: center; animation: fadeIn 0.3s ease; }<br \/>\n.lightbox-modal.open { display: flex; }<br \/>\n.lightbox-image { max-width: 90vw; max-height: 90vh; object-fit: contain; animation: zoomIn 0.3s ease; }<br \/>\n.lightbox-caption { position: absolute; bottom: 20px; left: 20px; right: 20px; color: #fff; text-align: center; font-size: 14px; background: rgba(0, 0, 0, 0.5); padding: 10px 15px; border-radius: 6px; max-width: 600px; margin: 0 auto; }<br \/>\n.lightbox-close { position: absolute; top: 20px; right: 30px; font-size: 40px; color: #fff; cursor: pointer; transition: all 0.2s ease; font-weight: 300; line-height: 1; z-index: 1001; }<br \/>\n.lightbox-close:hover { transform: scale(1.2) rotate(90deg); }<br \/>\n@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }<br \/>\n@keyframes zoomIn { from { opacity: 0; transform: scale(0.8); } to { opacity: 1; transform: scale(1); } }<br \/>\n.gallery-footer { text-align: center; color: #ad1457; font-size: 14px; margin-top: 40px; }<br \/>\n.gallery-loading { text-align: center; padding: 40px 20px; font-size: 16px; color: #999; }<br \/>\n.loading-spinner { display: inline-block; width: 40px; height: 40px; border: 4px solid #f3f3f3; border-top: 4px solid #e91e8c; border-radius: 50%; animation: spin 1s linear infinite; margin-bottom: 20px; }<br \/>\n@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }<br \/>\n.gallery-error { text-align: center; padding: 40px 20px; color: #d32f2f; font-size: 16px; }<\/p>\n<p>class GalleryManager {<br \/>\n  constructor(containerSelector = &#8216;#gallery-container&#8217;, apiUrl = &#8216;\/wp-json\/gallery\/v1&#8217;) {<br \/>\n    this.container = document.querySelector(containerSelector);<br \/>\n    this.grid = document.getElementById(&#8216;gallery-grid&#8217;);<br \/>\n    this.sortSelect = document.getElementById(&#8216;gallery-sort&#8217;);<br \/>\n    this.lightbox = document.getElementById(&#8216;lightbox-modal&#8217;);<br \/>\n    this.lightboxImage = document.querySelector(&#8216;.lightbox-image&#8217;);<br \/>\n    this.lightboxCaption = document.querySelector(&#8216;.lightbox-caption&#8217;);<br \/>\n    this.lightboxClose = document.querySelector(&#8216;.lightbox-close&#8217;);<br \/>\n    this.apiUrl = apiUrl;<br \/>\n    this.images = [];<br \/>\n    this.likedImages = new Set(this.getLikedFromStorage());<br \/>\n    this.init();<br \/>\n  }<br \/>\n  async init() {<br \/>\n    await this.loadImages();<br \/>\n    this.sortSelect.addEventListener(&#8216;change&#8217;, () =&gt; this.handleSortChange());<br \/>\n    this.lightboxClose.addEventListener(&#8216;click&#8217;, () =&gt; this.closeLightbox());<br \/>\n    this.lightbox.addEventListener(&#8216;click&#8217;, (e) =&gt; {<br \/>\n      if (e.target === this.lightbox) this.closeLightbox();<br \/>\n    });<br \/>\n  }<br \/>\n  async loadImages() {<br \/>\n    try {<br \/>\n      this.showLoading();<br \/>\n      const response = await fetch(`${this.apiUrl}\/images?sort=sort_order&amp;order=ASC`);<br \/>\n      if (!response.ok) throw new Error(&#8216;Failed to load images&#8217;);<br \/>\n      this.images = await response.json();<br \/>\n      this.render();<br \/>\n    } catch (error) {<br \/>\n      console.error(&#8216;Load images error:&#8217;, error);<br \/>\n      this.showError(&#8216;\u52a0\u8f7d\u56fe\u7247\u5931\u8d25\uff0c\u8bf7\u5237\u65b0\u91cd\u8bd5&#8217;);<br \/>\n    }<br \/>\n  }<br \/>\n  render() {<br \/>\n    if (this.images.length === 0) {<br \/>\n      this.grid.innerHTML = &#8216;<\/p>\n<p class=\"gallery-loading\">\u6682\u65e0\u56fe\u7247<\/p>\n<p>&#8216;;<br \/>\n      return;<br \/>\n    }<br \/>\n    this.grid.innerHTML = this.images.map(image =&gt; `<\/p>\n<div class=\"gallery-card\" data-id=\"${image.id}\">\n        <img decoding=\"async\" class=\"gallery-card-image\" src=\"${this.escapeHtml(image.image_url)}\" alt=\"${this.escapeHtml(image.alt_text)}\"><\/p>\n<div class=\"gallery-card-overlay\">\n<div class=\"gallery-card-info\">\n<p class=\"gallery-card-alt\">${this.escapeHtml(image.alt_text)}<\/p>\n<\/p><\/div>\n<p>          <button class=\"gallery-like-btn ${this.likedImages.has(image.id) ? &apos;liked&apos; : &apos;&apos;}\" data-image-id=\"${image.id}\"><br \/>\n            <span class=\"like-icon\">\u2665<\/span><br \/>\n            <span class=\"gallery-like-count\">${image.likes_count}<\/span><br \/>\n          <\/button>\n        <\/div>\n<\/p><\/div>\n<p>    `).join(&#8221;);<br \/>\n    this.grid.querySelectorAll(&#8216;.gallery-card-image&#8217;).forEach(img =&gt; {<br \/>\n      img.addEventListener(&#8216;click&#8217;, (e) =&gt; {<br \/>\n        const card = e.target.closest(&#8216;.gallery-card&#8217;);<br \/>\n        const imageId = card.dataset.id;<br \/>\n        const image = this.images.find(img =&gt; img.id == imageId);<br \/>\n        this.openLightbox(image.image_url, image.alt_text);<br \/>\n      });<br \/>\n    });<br \/>\n    this.grid.querySelectorAll(&#8216;.gallery-like-btn&#8217;).forEach(btn =&gt; {<br \/>\n      btn.addEventListener(&#8216;click&#8217;, (e) =&gt; {<br \/>\n        e.stopPropagation();<br \/>\n        this.toggleLike(btn);<br \/>\n      });<br \/>\n    });<br \/>\n  }<br \/>\n  async toggleLike(button) {<br \/>\n    const imageId = button.dataset.imageId;<br \/>\n    try {<br \/>\n      const response = await fetch(`${this.apiUrl}\/images\/${imageId}\/like`, {<br \/>\n        method: &#8216;POST&#8217;,<br \/>\n        headers: {&#8216;Content-Type&#8217;: &#8216;application\/json&#8217;},<br \/>\n        body: JSON.stringify({user_id: this.getUserIdentifier()})<br \/>\n      });<br \/>\n      if (!response.ok) throw new Error(&#8216;Like action failed&#8217;);<br \/>\n      const data = await response.json();<br \/>\n      if (data.liked) {<br \/>\n        this.likedImages.add(parseInt(imageId));<br \/>\n        button.classList.add(&#8216;liked&#8217;);<br \/>\n      } else {<br \/>\n        this.likedImages.delete(parseInt(imageId));<br \/>\n        button.classList.remove(&#8216;liked&#8217;);<br \/>\n      }<br \/>\n      const likeCount = button.querySelector(&#8216;.gallery-like-count&#8217;);<br \/>\n      likeCount.textContent = data.likes_count;<br \/>\n      this.saveLikedToStorage();<br \/>\n    } catch (error) {<br \/>\n      console.error(&#8216;Toggle like error:&#8217;, error);<br \/>\n      alert(&#8216;\u64cd\u4f5c\u5931\u8d25\uff0c\u8bf7\u91cd\u8bd5&#8217;);<br \/>\n    }<br \/>\n  }<br \/>\n  async handleSortChange() {<br \/>\n    const [sortField, sortOrder] = this.sortSelect.value.split(&#8216;:&#8217;);<br \/>\n    try {<br \/>\n      this.showLoading();<br \/>\n      const response = await fetch(`${this.apiUrl}\/images?sort=${sortField}&amp;order=${sortOrder}`);<br \/>\n      if (!response.ok) throw new Error(&#8216;Failed to load images&#8217;);<br \/>\n      this.images = await response.json();<br \/>\n      this.render();<br \/>\n    } catch (error) {<br \/>\n      console.error(&#8216;Sort error:&#8217;, error);<br \/>\n      this.showError(&#8216;\u6392\u5e8f\u5931\u8d25\uff0c\u8bf7\u91cd\u8bd5&#8217;);<br \/>\n    }<br \/>\n  }<br \/>\n  openLightbox(imageUrl, altText) {<br \/>\n    this.lightboxImage.src = imageUrl;<br \/>\n    this.lightboxCaption.textContent = altText;<br \/>\n    this.lightbox.style.display = &#8216;flex&#8217;;<br \/>\n    this.lightbox.classList.add(&#8216;open&#8217;);<br \/>\n    document.body.style.overflow = &#8216;hidden&#8217;;<br \/>\n  }<br \/>\n  closeLightbox() {<br \/>\n    this.lightbox.style.display = &#8216;none&#8217;;<br \/>\n    this.lightbox.classList.remove(&#8216;open&#8217;);<br \/>\n    document.body.style.overflow = &#8221;;<br \/>\n  }<br \/>\n  getUserIdentifier() {<br \/>\n    let identifier = localStorage.getItem(&#8216;gallery-user-id&#8217;);<br \/>\n    if (!identifier) {<br \/>\n      identifier = &#8216;user-&#8216; + Math.random().toString(36).substr(2, 9);<br \/>\n      localStorage.setItem(&#8216;gallery-user-id&#8217;, identifier);<br \/>\n    }<br \/>\n    return identifier;<br \/>\n  }<br \/>\n  getLikedFromStorage() {<br \/>\n    try {<br \/>\n      const data = localStorage.getItem(&#8216;gallery-liked-images&#8217;);<br \/>\n      return data ? JSON.parse(data) : [];<br \/>\n    } catch (e) {<br \/>\n      return [];<br \/>\n    }<br \/>\n  }<br \/>\n  saveLikedToStorage() {<br \/>\n    localStorage.setItem(&#8216;gallery-liked-images&#8217;, JSON.stringify(Array.from(this.likedImages)));<br \/>\n  }<br \/>\n  showLoading() {<br \/>\n    this.grid.innerHTML = `<\/p>\n<div class=\"gallery-loading\">\n<div class=\"loading-spinner\"><\/div>\n<p>\u52a0\u8f7d\u4e2d&#8230;<\/p>\n<\/div>\n<p>`;<br \/>\n  }<br \/>\n  showError(message) {<br \/>\n    this.grid.innerHTML = `<\/p>\n<div class=\"gallery-error\">${this.escapeHtml(message)}<\/div>\n<p>`;<br \/>\n  }<br \/>\n  escapeHtml(text) {<br \/>\n    const map = {&#8216;&amp;&#8217;: &#8216;&amp;&#8217;, &#8221;: &#8216;&gt;&#8217;, &#8216;&#8221;&#8216;: &#8216;&quot;&#8217;, &#8220;&#8216;&#8221;: &#8216;&#039;&#8217;};<br \/>\n    return text.replace(\/[&amp;&#8221;&#8216;]\/g, m =&gt; map[m]);<br \/>\n  }<br \/>\n}<br \/>\ndocument.addEventListener(&#8216;DOMContentLoaded&#8217;, function() {<br \/>\n  new GalleryManager();<br \/>\n});<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u590f\u70df\u56fe\u5e93 \u8fd9\u91cc\u662f\u590f\u70df\u7684\u58c1\u7eb8\u548c\u56fe\u7247\u5408\u96c6~ \u66f4\u591a\u56fe\u7247\u6301\u7eed\u66f4\u65b0\u4e2d \u6392\u5e8f\u65b9\u5f0f: \u65f6\u95f4\u6392\u5e8f (\u65e7\u2192\u65b0) \u65f6\u95f4\u6392\u5e8f (\u65b0\u2192 &#8230; <a title=\"\u56fe\u5e93\" class=\"read-more\" href=\"https:\/\/mist.onmypc.info\/index.php\/gallery\/\" aria-label=\"\u9605\u8bfb \u56fe\u5e93\">\u9605\u8bfb\u66f4\u591a<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"open","template":"","meta":{"footnotes":""},"class_list":["post-268","page","type-page","status-publish"],"_links":{"self":[{"href":"https:\/\/mist.onmypc.info\/index.php\/wp-json\/wp\/v2\/pages\/268","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mist.onmypc.info\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/mist.onmypc.info\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/mist.onmypc.info\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mist.onmypc.info\/index.php\/wp-json\/wp\/v2\/comments?post=268"}],"version-history":[{"count":5,"href":"https:\/\/mist.onmypc.info\/index.php\/wp-json\/wp\/v2\/pages\/268\/revisions"}],"predecessor-version":[{"id":292,"href":"https:\/\/mist.onmypc.info\/index.php\/wp-json\/wp\/v2\/pages\/268\/revisions\/292"}],"wp:attachment":[{"href":"https:\/\/mist.onmypc.info\/index.php\/wp-json\/wp\/v2\/media?parent=268"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}