278 lines
28 KiB
HTML
278 lines
28 KiB
HTML
<!DOCTYPE html><html lang="zh-CN"> <head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="description" content="Personal blog by biss."><link rel="icon" href="/images/Bi.ico"><script defer src="https://umami.biss.click/script.js" data-website-id="3d97b310-b241-4fc6-bc9c-68e317fc7d42"></script><script>window.SITE_CONFIG = {"site":{"url":"https://blog.biss.click","name":"Bi's Blog","description":"Personal blog by biss.","language":"zh-CN","domain":"blog.biss.click","slogan":"好奇心转化为代码的空间。","startTime":"2025-01-01T00:00:00+08:00","copyrightStartYear":2025,"license":"内容采用 CC BY-NC-SA 4.0 协议"},"author":{"name":"biss","email":"bishsh2006@gmail.com","github":"https://github.com/bishshi","avatar":"https://free.picui.cn/free/2025/08/10/689845496a283.png"},"comments":{"envId":"https://comment.biss.click","region":"","script":"https://cdn.jsdelivr.net/npm/twikoo@1.7.7/dist/twikoo.min.js"},"analytics":{"umami":{"script":"https://umami.biss.click/script.js","websiteId":"3d97b310-b241-4fc6-bc9c-68e317fc7d42","statsEndpoint":"https://blogumami.biss.click"}},"talks":{"apiUrl":"https://mm.biss.click/api/echo/page","pageSize":30,"homeLimit":6,"cacheKey":"talksCache","cacheTimeKey":"talksCacheTime","cacheDurationMs":1800000,"fallbackAvatar":"https://free.picui.cn/free/2025/08/10/689845496a283.png"},"search":{"apiKey":"2uxQzk7eD2GBCljdSmIiuU3ause7UK9n","server":{"host":"typesense.biss.click","port":"443","protocol":"https"},"indexName":"blogs","searchParams":{"query_by":"title,content","highlight_full_fields":"title,content","per_page":8,"num_typos":1,"typo_tokens_threshold":1,"prefix":true},"ui":{"maxRetries":10,"retryDelay":100,"animationDuration":300,"maxInitRetries":30,"placeholder":"输入关键词寻找故事..."}},"externalLinks":{"waitSeconds":10,"whitelist":["blog.biss.click","biss.click","github.com","localhost","127.0.0.1"]}};</script><script>
|
|
(() => {
|
|
const storageKey = 'site-theme';
|
|
const savedTheme = localStorage.getItem(storageKey);
|
|
const systemTheme = window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
|
|
document.documentElement.dataset.theme = savedTheme || systemTheme;
|
|
})();
|
|
</script><link rel="stylesheet" href="https://cdn.jsdmirror.com/npm/instantsearch.css/themes/reset-min.css"><link rel="stylesheet" href="https://cdn.jsdmirror.com/npm/@fancyapps/ui@5.0/dist/fancybox/fancybox.css"><link rel="stylesheet" href="https://cdn.jsdmirror.com/npm/@fortawesome/fontawesome-free@6.7.2/css/all.min.css"><title>归档 | Bi's Blog</title><link rel="stylesheet" href="/_astro/BaseLayout.D7kFxpxP.css"></head> <body> <header class="site-header"> <nav class="nav"> <a class="brand" href="/">Bi's Blog</a> <button class="nav-menu-toggle" type="button" aria-label="打开菜单" aria-expanded="false" data-nav-toggle> <i class="fa-solid fa-bars nav-menu-open" aria-hidden="true"></i> <i class="fa-solid fa-xmark nav-menu-close" aria-hidden="true"></i> </button> <div class="nav-menu" data-nav-menu> <div class="nav-links nav-center"> <a href="/archives/"><i class="fa-solid fa-box-archive nav-icon" aria-hidden="true"></i><span>归档</span></a><a href="/categories/"><i class="fa-solid fa-folder-open nav-icon" aria-hidden="true"></i><span>分类</span></a><a href="/tags/"><i class="fa-solid fa-tags nav-icon" aria-hidden="true"></i><span>标签</span></a><a href="/shuoshuo/"><i class="fa-regular fa-comments nav-icon" aria-hidden="true"></i><span>说说</span></a><a href="/about/"><i class="fa-solid fa-heart nav-icon" aria-hidden="true"></i><span>关于</span></a><a href="/link/"><i class="fa-solid fa-link nav-icon" aria-hidden="true"></i><span>友链</span></a> </div> <div class="nav-links nav-actions"> <button class="nav-random" type="button" onclick="randomPost()" aria-label="前往随机文章" title="前往随机文章"> <i class="fa-solid fa-shuffle nav-icon" aria-hidden="true"></i> <span>随机文章</span> </button> <button class="nav-search search-typesense-trigger" type="button" aria-label="搜索" title="搜索"> <i class="fa-solid fa-magnifying-glass nav-icon" aria-hidden="true"></i> <span>搜索</span> </button> <button class="theme-toggle" type="button" aria-label="切换夜间模式" title="切换夜间模式" data-theme-toggle> <i class="fa-solid fa-sun theme-toggle-sun nav-icon" aria-hidden="true"></i> <i class="fa-solid fa-moon theme-toggle-moon nav-icon" aria-hidden="true"></i> </button> </div> </div> </nav> </header> <main> <section class="content-wrap narrow"> <header class="page-header-card"> <p class="page-header-eyebrow">Bi's Blog</p> <h1>归档</h1> <p class="page-header-subtitle">共 43 篇文章</p> </header> <section class="stats-chart stats-chart-line" aria-labelledby="line-chart-title"> <div class="stats-chart-head"> <h2 id="line-chart-title">归档发布趋势</h2> <p>按月份统计文章发布数量</p> </div> <div class="line-chart-wrap"> <svg class="line-chart" viewBox="0 0 640 240" role="img" aria-label="归档发布趋势" preserveAspectRatio="none"> <line class="line-chart-axis" x1="40" y1="198" x2="616" y2="198"></line> <line class="line-chart-axis" x1="40" y1="24" x2="40" y2="198"></line> <line class="line-chart-grid" x1="40" y1="198" x2="616" y2="198"></line> <text class="line-chart-y-label" x="28" y="202" text-anchor="end"> 0 </text> <line class="line-chart-grid" x1="40" y1="111" x2="616" y2="111"></line> <text class="line-chart-y-label" x="28" y="115" text-anchor="end"> 9 </text> <line class="line-chart-grid" x1="40" y1="24" x2="616" y2="24"></line> <text class="line-chart-y-label" x="28" y="28" text-anchor="end"> 17 </text> <polygon class="line-chart-area" points="40,198 40,24 112,167.2941176470588 184,177.52941176470588 256,167.2941176470588 328,126.3529411764706 400,167.2941176470588 472,136.58823529411765 544,187.76470588235293 616,187.76470588235293 616,198"></polygon> <polyline class="line-chart-line" points="40,24 112,167.2941176470588 184,177.52941176470588 256,167.2941176470588 328,126.3529411764706 400,167.2941176470588 472,136.58823529411765 544,187.76470588235293 616,187.76470588235293"></polyline> <circle class="line-chart-dot" cx="40" cy="24" r="4"></circle> <title>2025-08: 17 篇</title> <text class="line-chart-x-label" x="40" y="228" text-anchor="middle"> 2025-08 </text> <circle class="line-chart-dot" cx="112" cy="167.2941176470588" r="4"></circle> <title>2025-09: 3 篇</title> <circle class="line-chart-dot" cx="184" cy="177.52941176470588" r="4"></circle> <title>2025-10: 2 篇</title> <text class="line-chart-x-label" x="184" y="228" text-anchor="middle"> 2025-10 </text> <circle class="line-chart-dot" cx="256" cy="167.2941176470588" r="4"></circle> <title>2026-01: 3 篇</title> <circle class="line-chart-dot" cx="328" cy="126.3529411764706" r="4"></circle> <title>2026-02: 7 篇</title> <text class="line-chart-x-label" x="328" y="228" text-anchor="middle"> 2026-02 </text> <circle class="line-chart-dot" cx="400" cy="167.2941176470588" r="4"></circle> <title>2026-03: 3 篇</title> <circle class="line-chart-dot" cx="472" cy="136.58823529411765" r="4"></circle> <title>2026-04: 6 篇</title> <text class="line-chart-x-label" x="472" y="228" text-anchor="middle"> 2026-04 </text> <circle class="line-chart-dot" cx="544" cy="187.76470588235293" r="4"></circle> <title>2026-05: 1 篇</title> <circle class="line-chart-dot" cx="616" cy="187.76470588235293" r="4"></circle> <title>2026-06: 1 篇</title> <text class="line-chart-x-label" x="616" y="228" text-anchor="middle"> 2026-06 </text> </svg> </div> </section> <div class="archive-list"> <a href="/posts/4c91a8f2/"> <time datetime="2026-06-19T08:58:00.000Z">2026/06/19</time> <span>用 Umami 分享链接给网站信息卡提供统计数据</span> </a><a href="/posts/efe1e805/"> <time datetime="2026-05-29T18:09:40.000Z">2026/05/30</time> <span>把普通的一天过成自己的节奏</span> </a><a href="/posts/3f8de22/"> <time datetime="2026-04-25T15:00:00.000Z">2026/04/25</time> <span>GPT Image2 初试</span> </a><a href="/posts/8712baaa/"> <time datetime="2026-04-19T13:46:25.000Z">2026/04/19</time> <span>电子价签玩法</span> </a><a href="/posts/9b2ef00a/"> <time datetime="2026-04-15T19:34:23.000Z">2026/04/16</time> <span>OpenGL- Cohen-Sutherland 编码裁剪算法</span> </a><a href="/posts/7207243b/"> <time datetime="2026-04-11T19:01:02.000Z">2026/04/12</time> <span>OpenGL-直线的扫描转换</span> </a><a href="/posts/437a5198/"> <time datetime="2026-04-11T18:20:34.000Z">2026/04/12</time> <span>OpenGL-基础程序</span> </a><a href="/posts/c4477b0c/"> <time datetime="2026-04-02T04:52:16.000Z">2026/04/02</time> <span>配置OpenGL环境</span> </a><a href="/posts/b559997d/"> <time datetime="2026-03-17T13:13:08.000Z">2026/03/17</time> <span>opencv应用-算术运算</span> </a><a href="/posts/e8f95ead/"> <time datetime="2026-03-15T09:56:51.000Z">2026/03/15</time> <span>opencv应用-基础操作</span> </a><a href="/posts/6e3332b/"> <time datetime="2026-03-14T11:48:36.000Z">2026/03/14</time> <span>配置opencv</span> </a><a href="/posts/7baa41fc/"> <time datetime="2026-02-25T11:09:23.000Z">2026/02/25</time> <span>自建bitwarden服务</span> </a><a href="/posts/56f57c0b/"> <time datetime="2026-02-23T10:49:17.000Z">2026/02/23</time> <span>自建renovate-bot</span> </a><a href="/posts/5785bd01/"> <time datetime="2026-02-14T06:56:18.000Z">2026/02/14</time> <span>新年快乐!</span> </a><a href="/posts/7e921903/"> <time datetime="2026-02-10T07:11:14.000Z">2026/02/10</time> <span>添加网站左上角菜单</span> </a><a href="/posts/d2c8521/"> <time datetime="2026-02-07T12:30:39.000Z">2026/02/07</time> <span>将博客仓库转移到gitea</span> </a> </div> <nav class="pagination" aria-label="分页导航"><span class="pagination-link pagination-prev is-disabled" aria-disabled="true">
|
|
上一页
|
|
</span><div class="pagination-pages" aria-label="第 1 页,共 3 页"><span class="pagination-number is-current" aria-current="page">1</span><a class="pagination-number" href="/archives/page/2/">2</a><a class="pagination-number" href="/archives/page/3/">3</a></div><a class="pagination-link pagination-next" href="/archives/page/2/" aria-label="下一页">
|
|
下一页
|
|
</a></nav> </section> </main> <footer class="site-footer" aria-label="站点页脚"> <div class="footer-inner"> <section class="footer-top" aria-label="站点信息"> <a class="footer-brand" href="/" aria-label="Bi's Blog 首页"> <img src="/images/Bi.ico" alt="" loading="lazy"> <span>Bi's Blog</span> </a> <p class="footer-slogan">好奇心转化为代码的空间。</p> </section> <section class="footer-contact" aria-label="联系方式"> <p>联系方式</p> <div class="footer-socials"> <a href="mailto:bishsh2006@gmail.com" aria-label="发送邮件" title="发送邮件"> <i class="fa-solid fa-envelope" aria-hidden="true"></i> </a><a href="/rss.xml" aria-label="订阅 RSS" title="订阅 RSS"> <i class="fa-solid fa-rss" aria-hidden="true"></i> </a><a href="https://github.com/bishshi" target="_blank" rel="noreferrer" aria-label="GitHub" title="GitHub"> <i class="fa-brands fa-github" aria-hidden="true"></i> </a> </div> <nav class="footer-contact-links" aria-label="页脚链接"> <a href="/archives/">发展历程</a> <span aria-hidden="true">|</span><a href="/privacy/">隐私政策</a> </nav> </section> <section class="footer-bottom" aria-label="版权信息"> <div> <p>© 2025 - 2026 Bi's Blog</p> <p>blog.biss.click | 内容采用 CC BY-NC-SA 4.0 协议</p> </div> <div class="footer-meta"> <p>本站已运行:<span id="site-runtime">计算中...</span></p> <p> <a href="https://fastly.com/" target="_blank" rel="noreferrer">Fastly</a> <span aria-hidden="true">|</span><a href="https://astro.build/" target="_blank" rel="noreferrer">ASTRO</a> </p> </div> </section> </div> </footer> <aside class="hitokoto-card" aria-label="一言" data-hitokoto-card data-astro-cid-4cgfuthx> <div class="hitokoto-card__head" data-astro-cid-4cgfuthx> <button class="hitokoto-card__toggle" type="button" aria-label="展开一言" aria-expanded="true" title="一言" data-hitokoto-toggle data-astro-cid-4cgfuthx> <i class="fa-solid fa-quote-left" aria-hidden="true" data-astro-cid-4cgfuthx></i> <span data-astro-cid-4cgfuthx>一言</span> </button> <div class="hitokoto-card__actions" data-astro-cid-4cgfuthx> <button class="hitokoto-card__refresh" type="button" aria-label="换一句" title="换一句" data-hitokoto-refresh data-astro-cid-4cgfuthx> <i class="fa-solid fa-rotate" aria-hidden="true" data-astro-cid-4cgfuthx></i> </button> <button class="hitokoto-card__collapse" type="button" aria-label="收起一言" title="收起" data-hitokoto-collapse data-astro-cid-4cgfuthx> <i class="fa-solid fa-chevron-down" aria-hidden="true" data-astro-cid-4cgfuthx></i> </button> </div> </div> <a class="hitokoto-card__text" href="https://hitokoto.cn/" target="_blank" rel="noreferrer" data-hitokoto-text data-astro-cid-4cgfuthx>
|
|
获取中...
|
|
</a> <p class="hitokoto-card__from" data-hitokoto-from data-astro-cid-4cgfuthx>来自 Hitokoto</p> </aside> <script type="module">(()=>{const o=document.querySelector("[data-hitokoto-card]"),s=o?.querySelector("[data-hitokoto-toggle]"),r=o?.querySelector("[data-hitokoto-text]"),l=o?.querySelector("[data-hitokoto-from]"),k=o?.querySelector("[data-hitokoto-refresh]"),m=o?.querySelector("[data-hitokoto-collapse]");if(!(o instanceof HTMLElement)||!(s instanceof HTMLButtonElement)||!(r instanceof HTMLAnchorElement)||!(l instanceof HTMLElement))return;const g="https://yiyan.biss.click/api?encode=json",u="hitokoto-card-cache",y=360*60*1e3,d={sentence:"生活明朗,万物可爱。",source:"本地缓存",url:"https://hitokoto.cn/"},L=["/","/index.html"].includes(window.location.pathname);function c(t){o.classList.toggle("is-collapsed",!t),s.setAttribute("aria-expanded",String(t)),s.setAttribute("aria-label",t?"收起一言":"展开一言")}function f(){try{const t=localStorage.getItem(u);if(!t)return null;const e=JSON.parse(t);return!e||typeof e.expiresAt!="number"||e.expiresAt<=Date.now()?null:e.data}catch{return null}}function x(t){try{localStorage.setItem(u,JSON.stringify({data:t,expiresAt:Date.now()+y}))}catch{}}function i(t){r.textContent=t.sentence,r.href=t.url||"https://hitokoto.cn/",l.textContent=t.source?`出自 ${t.source}`:"来自 Hitokoto"}async function h({force:t=!1}={}){if(!t){const e=f();if(e){i(e);return}}o.classList.add("is-loading"),r.textContent="获取中...";try{const e=await fetch(g);if(!e.ok)throw new Error(`Hitokoto request failed: ${e.status}`);const n=await e.json(),a=n.hitokoto||n.content||n.sentence||n.text,S=typeof a=="string"&&a.trim()?a.trim():d.sentence,E=typeof n.from=="string"&&n.from.trim()?n.from.trim():"Hitokoto",w=n.uuid?`https://hitokoto.cn/?uuid=${encodeURIComponent(n.uuid)}`:"https://hitokoto.cn/",p={sentence:S,source:E,url:w};x(p),i(p)}catch(e){console.error(e),i(f()||d)}finally{o.classList.remove("is-loading")}}c(L),s.addEventListener("click",()=>{c(o.classList.contains("is-collapsed"))}),k?.addEventListener("click",t=>{t.stopPropagation(),c(!0),h({force:!0})}),m?.addEventListener("click",t=>{t.stopPropagation(),c(!1)}),o.addEventListener("click",t=>{o.classList.contains("is-collapsed")&&(t.target instanceof Element&&t.target.closest("a, button")||c(!0))}),h()})();</script> <div class="custom-context-menu" data-context-menu role="menu" aria-hidden="true"> <div class="context-menu-nav" aria-label="页面导航"> <button type="button" data-context-action="back" aria-label="后退上一页" title="后退上一页"> <i class="fa-solid fa-arrow-left" aria-hidden="true"></i> </button> <button type="button" data-context-action="forward" aria-label="前进下一页" title="前进下一页"> <i class="fa-solid fa-arrow-right" aria-hidden="true"></i> </button> <button type="button" data-context-action="reload" aria-label="刷新页面" title="刷新页面"> <i class="fa-solid fa-rotate-right" aria-hidden="true"></i> </button> <a href="/" aria-label="返回首页" title="返回首页"> <i class="fa-solid fa-house" aria-hidden="true"></i> </a> </div> <div class="context-menu-group" data-selection-group hidden> <button type="button" data-context-action="copy-selection" data-selection-item> <i class="fa-regular fa-copy" aria-hidden="true"></i> <span>复制选中文字</span> </button> <button type="button" data-context-action="search-selection" data-selection-item> <i class="fa-brands fa-microsoft" aria-hidden="true"></i> <span>用 Bing 搜索</span> </button> <button type="button" data-context-action="quote-selection" data-selection-item data-comments-item> <i class="fa-regular fa-comment-dots" aria-hidden="true"></i> <span>引用到评论区</span> </button> </div> <div class="context-menu-group" data-image-group hidden> <button type="button" data-context-action="copy-image"> <i class="fa-regular fa-image" aria-hidden="true"></i> <span>复制图片</span> </button> <button type="button" data-context-action="open-image"> <i class="fa-solid fa-up-right-from-square" aria-hidden="true"></i> <span>新页面打开图片</span> </button> <button type="button" data-context-action="copy-image-url"> <i class="fa-solid fa-link" aria-hidden="true"></i> <span>复制图片地址</span> </button> </div> <div class="context-menu-group"> <a href="/archives/"> <i class="fa-solid fa-box-archive" aria-hidden="true"></i> <span>时间线</span> </a> <a href="/categories/"> <i class="fa-solid fa-folder" aria-hidden="true"></i> <span>分类</span> </a> <a href="/tags/"> <i class="fa-solid fa-hashtag" aria-hidden="true"></i> <span>标签</span> </a> <button type="button" data-context-action="comments" data-comments-item> <i class="fa-regular fa-comment-dots" aria-hidden="true"></i> <span>跳转评论区</span> </button> <button type="button" data-context-action="print"> <i class="fa-solid fa-print" aria-hidden="true"></i> <span>打印页面</span> </button> <a href="/cc/"> <i class="fa-solid fa-circle-info" aria-hidden="true"></i> <span>网站版权</span> </a> </div> </div> <script>
|
|
(() => {
|
|
const menu = document.querySelector('[data-context-menu]');
|
|
if (!menu) return;
|
|
|
|
const selectionItems = [...menu.querySelectorAll('[data-selection-item]')];
|
|
const selectionGroup = menu.querySelector('[data-selection-group]');
|
|
const commentsItems = [...menu.querySelectorAll('[data-comments-item]')];
|
|
const imageGroup = menu.querySelector('[data-image-group]');
|
|
const focusableSelector = 'a[href], button:not([disabled])';
|
|
let lastSelectionText = '';
|
|
let lastImage = null;
|
|
|
|
const isNativeContextTarget = (target) =>
|
|
target instanceof Element &&
|
|
Boolean(target.closest('input, textarea, select, [contenteditable="true"], [contenteditable=""]'));
|
|
|
|
const getCommentsTarget = () =>
|
|
document.querySelector('.twikoo-comments, #twikoo-wrap, #twikoo, .tk-comments-container');
|
|
|
|
const getSelectionText = () => String(window.getSelection?.() || '').trim();
|
|
|
|
const getImageTarget = (target) => {
|
|
if (!(target instanceof Element)) return null;
|
|
const image = target.closest('img');
|
|
return image instanceof HTMLImageElement ? image : null;
|
|
};
|
|
|
|
const getImageUrl = () => {
|
|
if (!lastImage) return '';
|
|
return lastImage.currentSrc || lastImage.src || lastImage.getAttribute('src') || '';
|
|
};
|
|
|
|
const copyText = async (text) => {
|
|
if (navigator.clipboard?.writeText) {
|
|
await navigator.clipboard.writeText(text);
|
|
return;
|
|
}
|
|
|
|
const textarea = document.createElement('textarea');
|
|
textarea.value = text;
|
|
textarea.setAttribute('readonly', '');
|
|
textarea.style.position = 'fixed';
|
|
textarea.style.inset = '0 auto auto -9999px';
|
|
document.body.appendChild(textarea);
|
|
textarea.select();
|
|
document.execCommand('copy');
|
|
textarea.remove();
|
|
};
|
|
|
|
const setMenuState = () => {
|
|
const hasSelection = lastSelectionText.length > 0;
|
|
const hasComments = Boolean(getCommentsTarget());
|
|
const hasImage = Boolean(getImageUrl());
|
|
|
|
selectionItems.forEach((item) => {
|
|
item.hidden = !hasSelection;
|
|
});
|
|
if (selectionGroup) selectionGroup.hidden = !hasSelection;
|
|
|
|
commentsItems.forEach((item) => {
|
|
item.hidden = !hasComments || (item.hasAttribute('data-selection-item') && !hasSelection);
|
|
});
|
|
|
|
if (imageGroup) imageGroup.hidden = !hasImage;
|
|
};
|
|
|
|
const closeMenu = () => {
|
|
menu.classList.remove('is-open');
|
|
menu.setAttribute('aria-hidden', 'true');
|
|
};
|
|
|
|
const openMenu = (x, y) => {
|
|
setMenuState();
|
|
menu.classList.add('is-open');
|
|
menu.setAttribute('aria-hidden', 'false');
|
|
|
|
const rect = menu.getBoundingClientRect();
|
|
const gap = 10;
|
|
const left = Math.min(Math.max(gap, x), window.innerWidth - rect.width - gap);
|
|
const top = Math.min(Math.max(gap, y), window.innerHeight - rect.height - gap);
|
|
|
|
menu.style.left = `${left}px`;
|
|
menu.style.top = `${top}px`;
|
|
};
|
|
|
|
const jumpToComments = () => {
|
|
const target = getCommentsTarget();
|
|
target?.scrollIntoView({ behavior: 'smooth', block: 'start' });
|
|
};
|
|
|
|
const quoteToComments = () => {
|
|
jumpToComments();
|
|
window.setTimeout(() => {
|
|
const textarea = document.querySelector('#twikoo textarea, .twikoo-comments textarea, .tk-input textarea');
|
|
if (!(textarea instanceof HTMLTextAreaElement) || !lastSelectionText) return;
|
|
|
|
const quote = lastSelectionText
|
|
.split(/\r?\n/)
|
|
.map((line) => `> ${line}`)
|
|
.join('\n');
|
|
const current = textarea.value.trim();
|
|
textarea.value = current ? `${current}\n\n${quote}\n` : `${quote}\n`;
|
|
textarea.dispatchEvent(new Event('input', { bubbles: true }));
|
|
textarea.focus();
|
|
}, 500);
|
|
};
|
|
|
|
const searchSelection = () => {
|
|
if (!lastSelectionText) return;
|
|
const url = `https://www.bing.com/search?q=${encodeURIComponent(lastSelectionText)}`;
|
|
window.open(url, '_blank', 'noopener,noreferrer');
|
|
};
|
|
|
|
const copyImage = async () => {
|
|
const imageUrl = getImageUrl();
|
|
if (!imageUrl) return;
|
|
|
|
try {
|
|
if (!navigator.clipboard?.write || typeof ClipboardItem === 'undefined') {
|
|
throw new Error('Image clipboard is not available.');
|
|
}
|
|
|
|
const response = await fetch(imageUrl, { mode: 'cors' });
|
|
const blob = await response.blob();
|
|
await navigator.clipboard.write([
|
|
new ClipboardItem({ [blob.type || 'image/png']: blob }),
|
|
]);
|
|
} catch {
|
|
await copyText(new URL(imageUrl, window.location.href).toString());
|
|
}
|
|
};
|
|
|
|
const openImage = () => {
|
|
const imageUrl = getImageUrl();
|
|
if (!imageUrl) return;
|
|
window.open(new URL(imageUrl, window.location.href).toString(), '_blank', 'noopener,noreferrer');
|
|
};
|
|
|
|
document.addEventListener('contextmenu', (event) => {
|
|
if (isNativeContextTarget(event.target)) return;
|
|
|
|
lastSelectionText = getSelectionText();
|
|
lastImage = getImageTarget(event.target);
|
|
event.preventDefault();
|
|
openMenu(event.clientX, event.clientY);
|
|
});
|
|
|
|
document.addEventListener('click', (event) => {
|
|
const actionTarget = event.target instanceof Element ? event.target.closest('[data-context-action]') : null;
|
|
if (!actionTarget || !menu.contains(actionTarget)) {
|
|
closeMenu();
|
|
return;
|
|
}
|
|
|
|
const action = actionTarget.dataset.contextAction;
|
|
closeMenu();
|
|
|
|
if (action === 'back') history.back();
|
|
if (action === 'forward') history.forward();
|
|
if (action === 'reload') location.reload();
|
|
if (action === 'copy-selection' && lastSelectionText) copyText(lastSelectionText);
|
|
if (action === 'search-selection') searchSelection();
|
|
if (action === 'quote-selection') quoteToComments();
|
|
if (action === 'copy-image') copyImage();
|
|
if (action === 'open-image') openImage();
|
|
if (action === 'copy-image-url') copyText(new URL(getImageUrl(), window.location.href).toString());
|
|
if (action === 'comments') jumpToComments();
|
|
if (action === 'print') window.print();
|
|
});
|
|
|
|
document.addEventListener('keydown', (event) => {
|
|
if (event.key === 'Escape') closeMenu();
|
|
if (event.key === 'Tab' && menu.classList.contains('is-open')) {
|
|
const items = [...menu.querySelectorAll(focusableSelector)].filter((item) => !item.closest('[hidden]'));
|
|
if (items.length === 0) return;
|
|
const first = items[0];
|
|
const last = items[items.length - 1];
|
|
|
|
if (event.shiftKey && document.activeElement === first) {
|
|
event.preventDefault();
|
|
last.focus();
|
|
} else if (!event.shiftKey && document.activeElement === last) {
|
|
event.preventDefault();
|
|
first.focus();
|
|
}
|
|
}
|
|
});
|
|
|
|
window.addEventListener('scroll', closeMenu, { passive: true });
|
|
window.addEventListener('resize', closeMenu);
|
|
})();
|
|
</script> <script src="https://cdn.jsdmirror.com/npm/instantsearch.js@4.56.0"></script> <script src="https://cdn.jsdmirror.com/npm/typesense-instantsearch-adapter@2.7.0/dist/typesense-instantsearch-adapter.min.js"></script> <script src="https://cdn.jsdmirror.com/npm/@fancyapps/ui@5.0/dist/fancybox/fancybox.umd.js"></script> <script src="/js/random.js"></script> <script src="/js/search/typesense-search.js"></script> <script src="/js/external-links.js"></script> <script>
|
|
(() => {
|
|
const nav = document.querySelector('.nav');
|
|
const toggle = document.querySelector('[data-nav-toggle]');
|
|
const menu = document.querySelector('[data-nav-menu]');
|
|
if (!nav || !toggle || !menu) return;
|
|
|
|
function setMenu(open) {
|
|
nav.classList.toggle('is-open', open);
|
|
toggle.setAttribute('aria-expanded', String(open));
|
|
toggle.setAttribute('aria-label', open ? '关闭菜单' : '打开菜单');
|
|
}
|
|
|
|
toggle.addEventListener('click', () => {
|
|
setMenu(!nav.classList.contains('is-open'));
|
|
});
|
|
|
|
menu.addEventListener('click', (event) => {
|
|
if (event.target instanceof Element && event.target.closest('a')) setMenu(false);
|
|
});
|
|
|
|
window.addEventListener('resize', () => {
|
|
if (window.innerWidth > 720) setMenu(false);
|
|
});
|
|
})();
|
|
|
|
(() => {
|
|
const storageKey = 'site-theme';
|
|
const root = document.documentElement;
|
|
const button = document.querySelector('[data-theme-toggle]');
|
|
const media = window.matchMedia('(prefers-color-scheme: dark)');
|
|
const getSystemTheme = () => (media.matches ? 'dark' : 'light');
|
|
const getTheme = () => localStorage.getItem(storageKey) || getSystemTheme();
|
|
|
|
function applyTheme(theme) {
|
|
root.dataset.theme = theme;
|
|
button?.setAttribute('aria-label', theme === 'dark' ? '切换到日间模式' : '切换到夜间模式');
|
|
button?.setAttribute('title', theme === 'dark' ? '切换到日间模式' : '切换到夜间模式');
|
|
}
|
|
|
|
applyTheme(getTheme());
|
|
|
|
button?.addEventListener('click', () => {
|
|
const nextTheme = root.dataset.theme === 'dark' ? 'light' : 'dark';
|
|
localStorage.setItem(storageKey, nextTheme);
|
|
applyTheme(nextTheme);
|
|
});
|
|
|
|
media.addEventListener('change', () => {
|
|
if (!localStorage.getItem(storageKey)) applyTheme(getSystemTheme());
|
|
});
|
|
})();
|
|
|
|
(() => {
|
|
const runtime = document.getElementById('site-runtime');
|
|
if (!runtime) return;
|
|
|
|
const start = new Date(window.SITE_CONFIG.site.startTime).getTime();
|
|
const pad = (value) => String(value).padStart(2, '0');
|
|
|
|
function updateRuntime() {
|
|
const diff = Math.max(0, Date.now() - start);
|
|
const days = Math.floor(diff / 86400000);
|
|
const hours = Math.floor((diff / 3600000) % 24);
|
|
const minutes = Math.floor((diff / 60000) % 60);
|
|
const seconds = Math.floor((diff / 1000) % 60);
|
|
runtime.textContent = `${days} 天 ${pad(hours)} 时 ${pad(minutes)} 分 ${pad(seconds)} 秒`;
|
|
}
|
|
|
|
updateRuntime();
|
|
window.setInterval(updateRuntime, 1000);
|
|
})();
|
|
</script> </body> </html> |