1 line
228 KiB
JSON
1 line
228 KiB
JSON
[{"title":"新年快乐!","url":"/posts/5785bd01/","content":"\n各位亲朋好友、合作伙伴及屏幕前的你:\n\n值此二〇二六年蛇年来临之际,为贯彻落实“快乐至上”的核心价值观,进一步提升全体人员的幸福指数,现将有关事项通知如下:\n\n一、各单位要切实做好“吃好喝好”保障工作,严禁在假期期间进行任何形式的emo。\n\n二、请各有关人员在收到本通知后,务必在下方留言区留下你的新年愿望,由后台系统统一收集并祝愿其实现。\n\n三、祝大家在新的一年里,身体健康,万事如意,所得皆所愿,所行化坦途!","tags":["生活"]},{"title":"添加网站左上角菜单","url":"/posts/7e921903/","content":"\n看到柳神的网站有这种菜单,但是没有写魔改教程,只好自己慢慢摸索了。\n\n{% link liushen,liushen,https://blog.liushen.fun %}\n\n预计做好后是这种效果:\n\n\n\n首先,修改```\\themes\\butterfly\\layout\\includes\\header\\nav.pug```:\n```pug\nnav#nav\n //- 左侧区域:包含指纹菜单和网站名\n span#blog-info\n #ls-menu-container\n i.fas.fa-fingerprint\n #ls-menu-panel\n .ls-section\n .ls-title 😀 个人网站\n .ls-grid\n a(href=\"/\") #[i.fas.fa-rss] 个人博客\n a(href=\"https://github.com/bishshi\") #[i.fab.fa-github] Github\n .ls-section\n .ls-title 😎 常用服务\n .ls-grid\n a(href=\"https://git.biss.click/biss\") #[i.fas.fa-code] 代码仓库\n a(href=\"https://mm.biss.click\") #[i.fas.fa-pen-nib] 日常yy\n a(href=\"https://statstic.biss.click\") #[i.fas.fa-users] 访客统计\n a(href=\"https://pic.biss.click\") #[i.fas.fa-image] 图床\n a(href=\"https://chat.biss.click\") #[i.fas.fa-robot] AI网站\n .ls-section\n .ls-title 🛸 实用工具\n .ls-grid\n a(href=\"https://cover.biss.click\") #[i.fas.fa-palette] 封面设计\n\n a.nav-site-title(href=url_for('/'))\n if theme.nav.logo\n img.site-icon(src=url_for(theme.nav.logo) alt='Logo')\n if theme.nav.display_title\n span.site-name=config.title\n\n //- 中间区域:关键!必须在 nav 下一级,以便 JS 切换类名\n if globalPageType === 'post' && theme.nav.display_post_title\n a.nav-page-title(href='javascript:void(0);' onclick='btf.scrollToDest(0, 500)')\n span.site-name=(page.title || config.title)\n\n //- 右侧区域\n #nav-right\n if theme.menu\n #menus\n != partial('includes/header/menu_item', {}, {cache: true})\n \n if theme.search.use || true\n #random-post-button\n a.site-page.social-icon#random-post-link(href='javascript:void(0);' onclick='randomPost()')\n i.fas.fa-solid.fa-shuffle\n #search-button\n a.site-page.social-icon.search-typesense-trigger\n i.fas.fa-search.fa-fw\n #toggle-menu\n span.site-page\n i.fas.fa-bars.fa-fw\n```\n\n在合适的目录下新建```nav.css```(例如```\\themes\\butterfly\\source\\css\\nav.css```),这份css是磨砂玻璃的样式:\n\n```css\n#nav-right{\n flex:1 1 auto;\n justify-content: flex-end;\n margin-left: auto;\n display: flex;\n flex-wrap:nowrap;\n}\n \n/* 导航栏居中 */\n\n#sidebar #sidebar-menus .menus_items .menus_item {\n margin: 10px 0;\n}\n#sidebar #sidebar-menus .menus_items a.site-page {\n padding-left: 0;\n}\n#sidebar #sidebar-menus .menus_items .site-page {\n position: relative;\n display: block;\n padding: 6px 30px 6px 22px;\n color: var(--font-color);\n font-size: 1.15em;\n border: var(--style-border-always);\n background: var(--icat-card-bg);\n font-size: 14px;\n border-radius: 12px;\n}\n#sidebar #sidebar-menus .menus_items .site-page i:first-child {\n text-align: left;\n padding-left: 10px;\n}\n\n#nav #menus {\n display: flex;\n justify-content: center;\n width: 100%;\n position: absolute;\n left: 0;\n margin: 0;\n transform: translateZ(0);\n}\n#nav #blog-info {\n flex-wrap: nowrap;\n display: flex;\n align-items: center;\n z-index: 102;\n max-width: fit-content;\n}\n@media screen and (max-width: 900px) {\n #nav {\n padding: 0 15px;\n }\n #nav-group {\n padding: 0 0.2rem;\n }\n #rightside {\n right: -42px;\n }\n}\n/* IPAD菜单栏调整 */\n\n/* 1. 容器溢出穿透 */\n#nav, #blog-info, #nav-group {\n overflow: visible !important;\n}\n\n#ls-menu-container {\n position: relative !important;\n display: inline-flex !important;\n align-items: center;\n height: 100%;\n padding: 0 15px;\n cursor: pointer !important;\n z-index: 2000 !important;\n}\n\n/* 2. 悬浮面板:宽大且高不透明度 */\n#ls-menu-panel {\n position: absolute !important;\n top: 100% !important;\n left: 0 !important;\n margin-top: 15px !important;\n width: 420px; \n padding: 24px;\n border-radius: 18px;\n \n /* 高不透明度磨砂玻璃 (0.9) */\n background: rgba(255, 255, 255, 0.95) !important;\n backdrop-filter: blur(20px) saturate(180%) !important;\n -webkit-backdrop-filter: blur(20px) saturate(180%) !important;\n \n border: 1px solid rgba(255, 255, 255, 0.5) !important;\n box-shadow: 0 20px 50px rgba(0, 0, 0, 0.18) !important;\n\n opacity: 0 !important;\n visibility: hidden !important;\n transform: translateY(12px) !important;\n transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;\n z-index: 999999 !important;\n cursor: default;\n}\n\n/* 3. 透明感应桥梁 */\n#ls-menu-panel::before {\n content: \"\";\n position: absolute;\n top: -20px;\n left: 0;\n right: 0;\n height: 25px;\n background: transparent !important;\n}\n\n/* 4. 触发效果 */\n#ls-menu-container:hover #ls-menu-panel {\n opacity: 1 !important;\n visibility: visible !important;\n transform: translateY(0) !important;\n}\n\n#ls-menu-container:hover i.fa-fingerprint {\n color: #49b1f5;\n transform: scale(1.1);\n}\n\n/* 5. 内部网格:保持两列 */\n.ls-section { margin-bottom: 22px; }\n.ls-section:last-child { margin-bottom: 0; }\n.ls-title { \n color: #333; \n font-weight: 800; \n font-size: 15px; \n margin-bottom: 12px; \n opacity: 0.9;\n}\n\n.ls-grid { \n display: grid !important; \n grid-template-columns: repeat(2, 1fr); /* 恢复为两列 */\n gap: 10px; \n}\n\n.ls-grid a { \n color: #444 !important; \n font-size: 14px !important; \n padding: 10px 12px; \n border-radius: 12px;\n display: flex;\n align-items: center;\n transition: all 0.2s ease;\n background: rgba(0, 0, 0, 0.02);\n}\n\n.ls-grid a:hover { \n background: #49b1f5 !important; \n color: #fff !important; \n transform: translateX(4px); /* 悬停时轻微右移,增加动感 */\n}\n\n.ls-grid a i { \n margin-right: 12px; \n width: 20px; \n text-align: center; \n font-size: 15px;\n}\n\n/* 6. 深色模式适配 */\n[data-theme='dark'] #ls-menu-panel {\n background: rgba(30, 30, 30, 0.95) !important;\n border-color: rgba(255, 255, 255, 0.1) !important;\n}\n[data-theme='dark'] .ls-title { color: #eee; }\n[data-theme='dark'] .ls-grid a { \n color: #ccc !important; \n background: rgba(255, 255, 255, 0.05); \n}\n\n#nav.show-title .nav-page-title {\n display: flex !important;\n opacity: 1 !important;\n visibility: visible !important;\n position: absolute !important;\n left: 50% !important;\n transform: translateX(-50%) !important;\n white-space: nowrap !important;\n z-index: 1000 !important;\n}\n\n#nav.show-title #menus,\n#nav.show-title .nav-site-title {\n opacity: 0 !important;\n visibility: hidden !important;\n pointer-events: none !important;\n}\n\n#nav .nav-page-title {\n display: none; \n transition: opacity 0.3s ease;\n}\n\n#nav #blog-info {\n overflow: visible !important;\n}\n```\n\n然后在```_config.butterfly.yml```里面引用该css\n\n```yml\n- <link rel=\"stylesheet\" href=\"/css/nav.css\">\n```\n\n然后重新构建应该就可以看到效果了。","tags":["网站"],"categories":["建站手札"]},{"title":"将博客仓库转移到gitea","url":"/posts/d2c8521/","content":"\n在上一篇文章中已经完成了gitea的安装\n那么博客源码迁移倒是没问题,直接```git remote add origin```就行,但是action文件就有些变更。\n这是我修改的action文件:\n\n```yaml\nname: 自动部署\non:\n push:\n branches:\n - master\n release:\n types:\n - published\n workflow_dispatch:\nenv:\n TZ: Asia/Shanghai\njobs:\n deploy:\n runs-on: ubuntu-latest\n steps:\n - name: 检查分支\n uses: actions/checkout@v4\n with:\n ref: master\n - name: 缓存项目 npm 包\n id: cache-node-modules\n uses: actions/cache@v3\n with:\n path: node_modules\n key: ${{ runner.os }}-nodeModules-${{ hashFiles('package-lock.json') }}-${{ hashFiles('package.json') }}\n restore-keys: |\n ${{ runner.os }}-nodeModules-\n - name: 安装 Node\n uses: actions/setup-node@v4\n with:\n node-version: \"22.x\"\n - name: 安装 Hexo\n run: |\n npm install hexo-cli --global\n - name: 安装依赖\n if: steps.cache-node-modules.outputs.cache-hit != 'true'\n run: |\n npm install\n - name: 清理文件树\n run: |\n npm run clean\n - name: 生成静态文件并压缩\n run: |\n npm run build\n - name: 部署\n run: |\n cd ./public\n git init\n git config user.name \"${{ gitea.actor }}\"\n git config user.email \"${{ gitea.actor }}@noreply.gitea.io\"\n git add .\n git commit -m \"${{ gitea.event.head_commit.message }}··[$(date +\"%Z %Y-%m-%d %A %H:%M:%S\")]\"\n git push --force --quiet \"https://${{ gitea.actor }}:${{ secrets.DEPLOY_TOKEN }}@git.biss.click/biss/blog.git\" master:page\n - name: Deploy to Server\n run: |\n curl -k -X POST \n```\n仅供参考吧,最后面是webhook,可以自己改改。","tags":["gitea"],"categories":["技术"]},{"title":"安装gitea","url":"/posts/34725d47/","content":"\n今天想把网站的源码转移到自建git仓,所以先来安装gitea吧(gitlab过于庞大,服务器配置不够)\nPS:我的服务器为2C2G\n\n# 安装gitea\n这里用二进制文件安装\n## 获取二进制文件:\n```bash\nwget -O gitea https://dl.gitea.com/gitea/1.25.4/gitea-1.25.4-linux-amd64\nchmod +x gitea\ncp gitea /usr/local/bin/gitea\n```\n\n## 创建用户\n这一步不是必须的,但是推荐这样,用root用户很容易出问题。\n\n```bash\n# On Ubuntu/Debian:\nadduser \\\n --system \\\n --shell /bin/bash \\\n --gecos 'Git Version Control' \\\n --group \\\n --disabled-password \\\n --home /home/git \\\n git\n\n# On Fedora/RHEL/CentOS:\ngroupadd --system git\nadduser \\\n --system \\\n --shell /bin/bash \\\n --comment 'Git Version Control' \\\n --gid git \\\n --home-dir /home/git \\\n --create-home \\\n git\n```\n\n## 创建工作目录\n\n```bash\nmkdir -p /var/lib/gitea/{custom,data,log}\nchown -R git:git /var/lib/gitea/\nchmod -R 750 /var/lib/gitea/\nmkdir /etc/gitea\nchown root:git /etc/gitea\nchmod 770 /etc/gitea\nchmod 750 /etc/gitea\nchmod 640 /etc/gitea/app.ini\n```\n\n## 创建系统服务\n\n直接把github上面的挪过来就可以\n\n{% link service文件,github,https://github.com/go-gitea/gitea/blob/release/v1.25/contrib/systemd/gitea.service %}\n\n然后注册服务并启动\n```bash\nsudo systemctl enable gitea\nsudo systemctl start gitea\n```\n\n## 创建数据库\n可以用MySQL数据库或者PostgreSQL,创建一个数据库在web页面填写进去就行。\n\n反向代理略过,和普通网站的反向代理配置没有什么区别。\n\n# 安装runner\n这个runner也不是必须的,是为了实现github的action功能;在2C2G服务器上我看运行的还可以,当然,只是这个hexo博客的自动构建,占用资源也少;\n使用doker,这也是官方建议。以下是compose文件:\n\n```yaml\n\nservices:\n runner:\n image: gitea/act_runner:latest\n ports:\n - 8088:8088\n environment:\n - CONFIG_FILE=/config.yaml\n - GITEA_INSTANCE_URL=https://git.biss.click\n - GITEA_RUNNER_REGISTRATION_TOKEN= #替换成自己的token\n volumes:\n - ./config.yaml:/config.yaml\n - ./data:/data\n - /var/run/docker.sock:/var/run/docker.sock # 允许 Runner 调用宿主机 Docker\n\n```\ntoken在管理后台 工作流-运行器-新建运行器获取\nconfig文件需要这样生成\n\n```bash\ndocker run --entrypoint=\"\" --rm -it docker.io/gitea/act_runner:latest act_runner generate-config > config.yaml\n```\n\n在后台工作流运行器可以看见就没问题了。","tags":["gitea"],"categories":["技术"]},{"title":"添加typesense搜索","url":"/posts/f287c563/","content":"\n最近在构建班级博客,用```ghost cms```,在构建搜索时发现了typesense,所以把他移植到这个博客上。\n\n# 安装typesense\n\n直接用```docker-compose```:\n\n```yaml\n\nservices:\n typesense:\n image: typesense/typesense:30.1\n restart: always\n ports:\n - \"8108:8108\"\n volumes:\n - ./typesense-data:/data\n command: '--data-dir /data --api-key=填写key --enable-cors'\n\n```\n\n然后就是反向代理之类的,不过多写了。\n\n# 添加数据集\n\n```bash\n# 先安装库\nnpm install hexo-generator-search\nnpm install typesense xml2js\n```\n然后在```config.yml```配置(就是把文章生成json):\n\n```yml\nsearch:\n path: search.json\n field: post\n content: true\n```\n\n创建一个数据同步脚本```sync_typesense.js```:\n\n```js\nconst Typesense = require('typesense');\nconst fs = require('fs');\nconst xml2js = require('xml2js');\n\n// --- 配置区域 ---\nconst CONFIG = {\n apiKey: '你的Admin-API-Key', // 必须是 Admin Key\n host: '你的Typesense主机地址', \n port: 443,\n protocol: 'https',\n collectionName: 'blogs'\n};\n\nconst client = new Typesense.Client({\n 'nodes': [{ 'host': CONFIG.host, 'port': CONFIG.port, 'protocol': CONFIG.protocol }],\n 'apiKey': CONFIG.apiKey,\n 'connectionTimeoutSeconds': 5\n});\n\nasync function sync() {\n try {\n // 1. 读取并解析 XML\n const xml = fs.readFileSync('./public/search.xml', 'utf8');\n const parser = new xml2js.Parser({ explicitArray: false });\n const result = await parser.parseStringPromise(xml);\n \n // 提取文章列表 (处理单篇文章和多篇文章的情况)\n let entries = result.search.entry;\n if (!Array.isArray(entries)) entries = [entries];\n\n // 格式化数据以适配 Typesense\n const documents = entries.map(post => ({\n title: post.title,\n url: post.url,\n content: post.content,\n categories: post.categories ? (Array.isArray(post.categories.category) ? post.categories.category : [post.categories.category]) : [],\n tags: post.tags ? (Array.isArray(post.tags.tag) ? post.tags.tag : [post.tags.tag]) : [],\n }));\n\n // 2. 检查或创建 Collection (Schema)\n try {\n await client.collections(CONFIG.collectionName).retrieve();\n } catch (err) {\n const schema = {\n name: CONFIG.collectionName,\n fields: [\n { name: 'title', type: 'string', locale: 'zh'},\n { name: 'content', type: 'string', locale: 'zh'},\n { name: 'url', type: 'string' },\n { name: 'categories', type: 'string[]', facet: true },\n { name: 'tags', type: 'string[]', facet: true }\n ]\n };\n await client.collections().create(schema);\n console.log('Collection created!');\n }\n\n // 3. 导入数据 (使用 upsert 模式:存在则更新,不存在则创建)\n console.log(`Syncing ${documents.length} posts to Typesense...`);\n await client.collections(CONFIG.collectionName).documents().import(documents, { action: 'upsert' });\n console.log('Sync complete!');\n\n } catch (error) {\n console.error('Sync failed:', error);\n }\n}\n\nsync();\n```\n然后运行```node sync_typesense.js```\n\n# 创建只读key\n把下面代码存储成js,node运行就行。\n```js\nconst http = require('https');\n\nconst data = JSON.stringify({\n \"description\": \"Public search only key\",\n \"actions\": [\"documents:search\"],\n \"collections\": [\"blogs\"]\n});\n\nconst options = {\n hostname: '', // 不要带 https://\n port: 443,\n path: '/keys',\n method: 'POST',\n headers: {\n 'X-TYPESENSE-API-KEY': '你的admin key',\n 'Content-Type': 'application/json',\n 'Content-Length': data.length\n }\n};\n\nconst req = http.request(options, res => {\n res.on('data', d => { process.stdout.write(d); });\n});\n\nreq.on('error', error => { console.error(error); });\nreq.write(data);\nreq.end();\n```\n\n# 博客添加搜索\n\n在```config.yaml```inject bottom添加:\n\n```yaml\n - <script src=\"https://cdn.jsdmirror.com/npm/instantsearch.js@4.56.0\"></script>\n - <script src=\"https://cdn.jsdmirror.com/npm/typesense-instantsearch-adapter@2.7.0/dist/typesense-instantsearch-adapter.min.js\"></script>\n```\n\n为了方便,我直接修改了```\\themes\\butterfly\\source\\js\\search\\local_search.js```\n\n```js\n(function () {\n 'use strict';\n\n // ============================================================================\n // 配置区域 - 请根据实际情况修改\n // ============================================================================\n const CONFIG = {\n apiKey: \"\", // ⚠️ 建议使用 Search-Only API Key\n server: {\n host: \"host\",\n port: \"443\",\n protocol: \"https\"\n },\n indexName: \"blogs\",\n searchParams: {\n query_by: \"title,content\",\n highlight_full_fields: \"title,content\",\n per_page: 8,\n num_typos: 1,\n typo_tokens_threshold: 1,\n prefix: true\n },\n ui: {\n maxRetries: 10,\n retryDelay: 100,\n animationDuration: 300\n }\n };\n\n // ============================================================================\n // 状态管理\n // ============================================================================\n let searchInstance = null;\n let isInitialized = false;\n let isSearchOpen = false;\n let initRetryCount = 0;\n const MAX_INIT_RETRIES = 30; // 最多重试30次 (3秒)\n\n // ============================================================================\n // 错误提示函数\n // ============================================================================\n function showErrorMessage() {\n const hitsContainer = document.getElementById('hits');\n if (!hitsContainer) return;\n \n hitsContainer.innerHTML = \n '<div class=\"ts-empty\">' +\n '<div style=\"color: #f44336;\"><i class=\"fas fa-exclamation-triangle\" style=\"font-size: 3rem;\"></i></div>' +\n '<div style=\"font-size: 1.1rem; font-weight: bold; margin: 15px 0;\">搜索服务加载失败</div>' +\n '<div style=\"font-size: 0.9rem; color: #666; line-height: 1.8;\">' +\n '<p>依赖库未能正确加载,请检查以下配置:</p>' +\n '<ol style=\"text-align: left; max-width: 500px; margin: 15px auto;\">' +\n '<li>确认已在 <code>_config.butterfly.yml</code> 中正确引入依赖</li>' +\n '<li>检查 JS 文件加载顺序(先 instantsearch.js,再 adapter)</li>' +\n '<li>尝试更换 CDN 或使用本地文件</li>' +\n '<li>打开浏览器控制台查看详细错误信息</li>' +\n '</ol>' +\n '</div>' +\n '<div style=\"margin-top: 20px;\">' +\n '<button onclick=\"location.reload()\" style=\"padding: 10px 20px; background: #49b1f5; color: white; border: none; border-radius: 5px; cursor: pointer;\">重新加载页面</button>' +\n '</div>' +\n '</div>';\n }\n\n // ============================================================================\n // 1. 动态插入 HTML 结构\n // ============================================================================\n const searchHTML = `\n <div id=\"typesense-search-mask\" class=\"ts-mask\" style=\"display:none;\">\n <div id=\"typesense-search-container\" class=\"ts-container\">\n <div class=\"ts-header\">\n <span class=\"ts-title\">\n <i class=\"fas fa-search\"></i> 本站搜索\n </span>\n <span id=\"close-typesense\" class=\"ts-close\" aria-label=\"关闭搜索\">×</span>\n </div>\n <div id=\"searchbox\"></div>\n <div id=\"stats\" class=\"ts-stats\"></div>\n <div id=\"hits\" class=\"ts-hits\"></div>\n <div id=\"pagination\" class=\"ts-pagination\"></div>\n <div class=\"ts-footer\">\n <small>Search powered by <strong>Typesense</strong></small>\n </div>\n </div>\n </div>\n\n <style>\n .ts-mask {\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n background: rgba(0, 0, 0, 0.7);\n z-index: 10000;\n backdrop-filter: blur(5px);\n -webkit-backdrop-filter: blur(5px);\n opacity: 0;\n transition: opacity 300ms ease;\n }\n .ts-mask.active { opacity: 1; }\n .ts-container {\n margin: 5% auto;\n width: 90%;\n max-width: 650px;\n background: var(--search-bg, var(--card-bg, #fff));\n padding: 25px;\n border-radius: 12px;\n box-shadow: 0 15px 35px rgba(0, 0, 0, 0.3);\n position: relative;\n z-index: 10001;\n transform: translateY(-50px);\n opacity: 0;\n transition: all 300ms ease;\n }\n .ts-mask.active .ts-container {\n transform: translateY(0);\n opacity: 1;\n }\n .ts-header {\n display: flex;\n justify-content: space-between;\n align-items: center;\n margin-bottom: 20px;\n border-bottom: 2px solid var(--text-highlight-color, #49b1f5);\n padding-bottom: 10px;\n }\n .ts-title {\n font-size: 1.2rem;\n font-weight: bold;\n color: var(--text-highlight-color, #49b1f5);\n }\n .ts-close {\n cursor: pointer;\n font-size: 28px;\n color: var(--font-color, #333);\n line-height: 1;\n transition: color 0.2s, transform 0.2s;\n }\n .ts-close:hover {\n color: var(--text-highlight-color, #49b1f5);\n transform: scale(1.1);\n }\n .ais-SearchBox-input {\n position: relative;\n z-index: 10002;\n cursor: text;\n padding: 12px 40px 12px 15px !important;\n border-radius: 8px !important;\n border: 2px solid #eee !important;\n width: 100%;\n outline: none;\n transition: border-color 0.3s, box-shadow 0.3s;\n background: var(--card-bg, #fff);\n color: var(--font-color, #333);\n font-size: 1rem;\n }\n .ais-SearchBox-input:focus {\n border-color: var(--text-highlight-color, #49b1f5) !important;\n box-shadow: 0 0 0 3px rgba(73, 177, 245, 0.1);\n }\n .ts-stats {\n margin: 10px 0;\n font-size: 0.85rem;\n color: var(--font-color, #666);\n opacity: 0.8;\n }\n .ts-hits {\n max-height: 55vh;\n overflow-y: auto;\n margin-top: 15px;\n padding-right: 5px;\n }\n .ts-hits::-webkit-scrollbar { width: 6px; }\n .ts-hits::-webkit-scrollbar-track {\n background: var(--card-bg, #f1f1f1);\n border-radius: 10px;\n }\n .ts-hits::-webkit-scrollbar-thumb {\n background: var(--text-highlight-color, #49b1f5);\n border-radius: 10px;\n }\n .ts-empty {\n text-align: center;\n padding: 40px 20px;\n color: var(--font-color, #999);\n }\n .ts-empty i {\n font-size: 3rem;\n margin-bottom: 15px;\n opacity: 0.3;\n }\n .ts-empty code {\n background: #f5f5f5;\n padding: 2px 6px;\n border-radius: 3px;\n font-family: monospace;\n color: #e91e63;\n }\n .ts-empty ol {\n padding-left: 20px;\n }\n .ts-empty li {\n margin: 8px 0;\n }\n .ts-result-item {\n border-radius: 8px;\n transition: all 0.2s ease;\n margin-bottom: 10px;\n padding: 15px;\n border: 1px solid transparent;\n text-decoration: none;\n display: block;\n background: var(--card-bg, #fff);\n }\n .ts-result-item:hover {\n background: var(--text-bg-hover, rgba(73, 177, 245, 0.05));\n border-color: var(--text-highlight-color, #49b1f5);\n transform: translateX(5px);\n box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);\n }\n .ts-result-title {\n font-weight: bold;\n color: var(--text-highlight-color, #49b1f5);\n font-size: 1.1rem;\n margin-bottom: 8px;\n display: block;\n line-height: 1.4;\n }\n .ts-result-content {\n font-size: 0.9rem;\n color: var(--font-color, #666);\n line-height: 1.6;\n opacity: 0.85;\n display: -webkit-box;\n -webkit-line-clamp: 2;\n -webkit-box-orient: vertical;\n overflow: hidden;\n }\n .ts-result-item mark {\n background: #ffeb3b;\n color: #000;\n padding: 2px 4px;\n border-radius: 3px;\n font-weight: 500;\n }\n .ts-pagination {\n margin-top: 20px;\n display: flex;\n justify-content: center;\n gap: 5px;\n }\n .ais-Pagination-list {\n display: flex;\n list-style: none;\n padding: 0;\n margin: 0;\n gap: 5px;\n }\n .ais-Pagination-link {\n display: block;\n padding: 8px 12px;\n border: 1px solid #ddd;\n border-radius: 5px;\n color: var(--font-color, #333);\n text-decoration: none;\n transition: all 0.2s;\n background: var(--card-bg, #fff);\n }\n .ais-Pagination-link:hover {\n background: var(--text-highlight-color, #49b1f5);\n color: #fff;\n }\n .ais-Pagination-item--selected .ais-Pagination-link {\n background: var(--text-highlight-color, #49b1f5);\n color: #fff;\n }\n .ts-footer {\n text-align: right;\n margin-top: 15px;\n border-top: 1px solid var(--border-color, #eee);\n padding-top: 10px;\n }\n @media (max-width: 768px) {\n .ts-container {\n margin: 10px;\n width: calc(100% - 20px);\n padding: 20px 15px;\n }\n .ts-hits { max-height: 50vh; }\n }\n [data-theme=\"dark\"] .ts-mask,\n .dark-mode .ts-mask {\n background: rgba(0, 0, 0, 0.85);\n }\n </style>\n `;\n\n document.body.insertAdjacentHTML('beforeend', searchHTML);\n\n const mask = document.getElementById('typesense-search-mask');\n const closeBtn = document.getElementById('close-typesense');\n const container = document.getElementById('typesense-search-container');\n\n // ============================================================================\n // 搜索控制\n // ============================================================================\n function openSearch() {\n if (isSearchOpen) return;\n isSearchOpen = true;\n mask.style.display = 'block';\n void mask.offsetWidth;\n mask.classList.add('active');\n document.body.style.overflow = 'hidden';\n\n if (!isInitialized) {\n initTypesense();\n }\n focusSearchInput();\n }\n\n function closeSearch() {\n if (!isSearchOpen) return;\n isSearchOpen = false;\n mask.classList.remove('active');\n setTimeout(function() {\n mask.style.display = 'none';\n document.body.style.overflow = '';\n }, CONFIG.ui.animationDuration);\n }\n\n function focusSearchInput(retryCount) {\n retryCount = retryCount || 0;\n const input = document.querySelector('.ais-SearchBox-input');\n if (input) {\n input.focus();\n input.select();\n } else if (retryCount < CONFIG.ui.maxRetries) {\n setTimeout(function() {\n focusSearchInput(retryCount + 1);\n }, CONFIG.ui.retryDelay);\n }\n }\n\n // ============================================================================\n // 事件监听\n // ============================================================================\n document.addEventListener('click', function(e) {\n if (e.target.closest('.search-typesense-trigger')) {\n e.preventDefault();\n openSearch();\n }\n });\n\n closeBtn.addEventListener('click', closeSearch);\n mask.addEventListener('click', function(e) {\n if (e.target === mask) closeSearch();\n });\n container.addEventListener('click', function(e) {\n e.stopPropagation();\n });\n window.addEventListener('keydown', function(e) {\n if (e.key === 'Escape' && isSearchOpen) {\n closeSearch();\n }\n if ((e.ctrlKey || e.metaKey) && e.key === 'k') {\n e.preventDefault();\n openSearch();\n }\n });\n\n // ============================================================================\n // Typesense 初始化(带重试限制)\n // ============================================================================\n function initTypesense() {\n if (isInitialized || searchInstance) {\n console.warn('Typesense 搜索已初始化');\n return;\n }\n\n var instantsearchLoaded = typeof instantsearch !== 'undefined';\n var adapterLoaded = typeof TypesenseInstantSearchAdapter !== 'undefined' || \n typeof window.TypesenseInstantSearchAdapter !== 'undefined';\n \n console.log('📦 依赖库检查 (' + (initRetryCount + 1) + '/' + MAX_INIT_RETRIES + '):');\n console.log(' instantsearch.js:', instantsearchLoaded ? '✅ 已加载' : '❌ 未加载');\n console.log(' TypesenseAdapter:', adapterLoaded ? '✅ 已加载' : '❌ 未加载');\n \n if (!instantsearchLoaded || !adapterLoaded) {\n initRetryCount++;\n \n if (initRetryCount >= MAX_INIT_RETRIES) {\n console.error('');\n console.error('❌ Typesense 依赖库加载失败!');\n console.error('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');\n console.error('');\n console.error('🔧 请检查 _config.butterfly.yml 配置:');\n console.error('');\n console.error('inject:');\n console.error(' bottom: # ⚠️ 使用 bottom 而不是 head');\n console.error(' - <script src=\"https://cdn.jsdelivr.net/npm/instantsearch.js@4.56.0\"></script>');\n console.error(' - <script src=\"https://cdn.jsdelivr.net/npm/typesense-instantsearch-adapter@2.7.0/dist/typesense-instantsearch-adapter.min.js\"></script>');\n console.error(' - <script src=\"/js/typesense-search-fixed.js\"></script>');\n console.error('');\n console.error('💡 或在控制台手动检查:');\n console.error(' typeof instantsearch');\n console.error(' typeof TypesenseInstantSearchAdapter');\n console.error('');\n console.error('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');\n \n showErrorMessage();\n return;\n }\n \n console.warn('⏳ 100ms 后重试...');\n setTimeout(initTypesense, 100);\n return;\n }\n \n initRetryCount = 0;\n console.log('🚀 开始初始化 Typesense...');\n\n try {\n const typesenseAdapter = new TypesenseInstantSearchAdapter({\n server: {\n apiKey: CONFIG.apiKey,\n nodes: [{\n host: CONFIG.server.host,\n port: CONFIG.server.port,\n protocol: CONFIG.server.protocol\n }],\n cacheSearchResultsForSeconds: 120\n },\n additionalSearchParameters: CONFIG.searchParams\n });\n\n searchInstance = instantsearch({\n searchClient: typesenseAdapter.searchClient,\n indexName: CONFIG.indexName,\n routing: false\n });\n\n searchInstance.addWidgets([\n instantsearch.widgets.searchBox({\n container: '#searchbox',\n placeholder: '输入关键词寻找故事...',\n autofocus: true,\n showReset: true,\n showSubmit: false,\n showLoadingIndicator: true\n }),\n instantsearch.widgets.stats({\n container: '#stats',\n templates: {\n text: function(data) {\n if (!data.query) return '';\n return '找到 <strong>' + data.nbHits + '</strong> 条结果 (' + data.processingTimeMS + 'ms)';\n }\n }\n }),\n instantsearch.widgets.hits({\n container: '#hits',\n templates: {\n empty: function(results) {\n return '<div class=\"ts-empty\">' +\n '<div><i class=\"fas fa-search\"></i></div>' +\n '<div>找不到与 \"<strong>' + results.query + '</strong>\" 相关的内容</div>' +\n '<div style=\"margin-top: 10px;\">试试其他关键词吧 (´·ω·`)</div>' +\n '</div>';\n },\n item: function(hit) {\n // 使用 _highlightResult 获取高亮文本\n var titleHighlight = hit._highlightResult && hit._highlightResult.title \n ? hit._highlightResult.title.value \n : (hit.title || '');\n \n var contentHighlight = hit._highlightResult && hit._highlightResult.content \n ? hit._highlightResult.content.value \n : (hit.content || '');\n \n // 截取内容长度\n if (contentHighlight.length > 200) {\n contentHighlight = contentHighlight.substring(0, 200) + '...';\n }\n \n return '<a href=\"' + hit.url + '\" class=\"ts-result-item\">' +\n '<div class=\"ts-result-title\">' + titleHighlight + '</div>' +\n '<div class=\"ts-result-content\">' + contentHighlight + '</div>' +\n '</a>';\n }\n }\n }),\n instantsearch.widgets.pagination({\n container: '#pagination',\n padding: 2,\n showFirst: false,\n showLast: false\n })\n ]);\n\n searchInstance.start();\n isInitialized = true;\n \n console.log('✅ Typesense 初始化成功!');\n\n searchInstance.on('render', function() {\n if (isSearchOpen) {\n const input = document.querySelector('.ais-SearchBox-input');\n if (input && document.activeElement !== input) {\n input.focus();\n }\n }\n });\n\n } catch (error) {\n console.error('❌ 初始化失败:', error);\n showErrorMessage();\n }\n }\n\n // ============================================================================\n // 初始化\n // ============================================================================\n function init() {\n console.log('🔍 Typesense 搜索已准备就绪');\n console.log('💡 快捷键: Ctrl/Cmd + K');\n }\n\n if (document.readyState === 'loading') {\n document.addEventListener('DOMContentLoaded', init);\n } else {\n init();\n }\n\n // ============================================================================\n // 全局接口\n // ============================================================================\n window.TypesenseSearch = {\n open: openSearch,\n close: closeSearch,\n isOpen: function() { return isSearchOpen; },\n getInstance: function() { return searchInstance; }\n };\n\n})();\n```\n\n# 注意\n\n{% note red %}\nindexName: \"blogs\" 和 collectionName: 'posts' 要一致!!!\n{% endnote %}","categories":["技术","建站手札"]},{"title":"自定义字体","url":"/posts/b5601a7e/","content":"\n今天感觉网站的字体有些不好看,想换一下,搜索发现网站用woff或者woff2字体,在手机端和电脑都能完美显示\n{% note no-icon %}\n2026年2月3日更新:好像谷歌字体库可以在大陆直连了,速度也很快,所以这篇文章好像没什么必要了。\n{% endnote %}\n# 选择字体\n\n首先在网上查找自己喜欢的字体,这里有一个网站\n{% link 中文开源字体集 Open Source Fonts Collection for Chinese,开源字体,https://drxie.github.io/OSFCC/ %}\n找到一个自己喜欢的,如果有woff或者woff2格式下载下载保存。没有也没关系,转换网站:\n{% link 转换网站,ttf2woff2,https://products.groupdocs.app/zh/conversion/ttf-to-woff2 %}\n利用这个网站把下载的ttf字体文件转换成woff2格式。\n\n# 添加字体\n\n新建一个css文件\n\n```css\n@font-face {\n font-family: 'CascadiaCodePL';\n font-display: swap;\n src: url('/butterflyChange/fonts/font.woff2') format(\"woff2\");\n}\n```\n\n其中 `font.woff2`改成自己的文件名。\n其他字体格式参考\n\n```css\n@font-face {\n font-family: 'webfont';\n font-display: swap;\n src: url('.eot'); /*IE9*/\n src: url('.eot') format('embedded-opentype'), /* IE6-IE8 */\n url('.woff2') format('woff2'),\n url('.woff') format('woff'), /*chrome、firefox */\n url('.ttf') format('truetype'), /* chrome、firefox、opera、Safari, Android, iOS 4.2+*/\n url('.svg') format('svg'); /* iOS 4.1- */\n}```\n然后在`_config.butterfly.yml`里面引用这个css\n```yml\n- <link rel=\"stylesheet\" href=\"/css/font.css\">\n```\n\n在主题文件的font配置区域修改字体:\n\n```yml\nfont:\n global_font_size: 110%\n code_font_size: 100%\n font_family: # ,全局字体,不带后缀名\n code_font_family: # 这是代码使用的字体\n```\n\n# 参考链接\n\n{% link Ordis的博客,ordis,https://blog.imbhj.com/archives/0rIzmBIn %}","tags":["网站"],"categories":["建站手札"]},{"title":"在侧边栏添加日历和倒计时","url":"/posts/5ed2f1e6/","content":"突然看到某个网站侧边栏有日历和倒计时,就研究了一下,抄下来了(🤭)\n效果图:\n\n<center><img src=\"https://pic.biss.click/image/b9819d72-3496-4204-9b7d-07d82e2e2f1b.webp\" alt=\"效果图\"></center>\n\n# 添加js\n\n```js\ndocument.addEventListener(\"DOMContentLoaded\", () => {\n initializeCard();\n});\n\ndocument.addEventListener(\"pjax:complete\", () => {\n initializeCard();\n});\n\nfunction initializeCard() {\n cardTimes();\n cardRefreshTimes();\n}\n\nlet year, month, week, date, dates, weekStr, monthStr, asideTime, asideDay, asideDayNum, animalYear, ganzhiYear, lunarMon, lunarDay;\nconst now = new Date();\n\nfunction cardRefreshTimes() {\n const e = document.getElementById(\"card-widget-schedule\");\n if (e) {\n asideDay = (now - asideTime) / 1e3 / 60 / 60 / 24;\n e.querySelector(\"#pBar_year\").value = asideDay;\n e.querySelector(\"#p_span_year\").innerHTML = (asideDay / 365 * 100).toFixed(1) + \"%\";\n e.querySelector(\".schedule-r0 .schedule-d1 .aside-span2\").innerHTML = `还剩<a> ${(365 - asideDay).toFixed(0)} </a>天`;\n e.querySelector(\"#pBar_month\").value = date;\n e.querySelector(\"#pBar_month\").max = dates;\n e.querySelector(\"#p_span_month\").innerHTML = (date / dates * 100).toFixed(1) + \"%\";\n e.querySelector(\".schedule-r1 .schedule-d1 .aside-span2\").innerHTML = `还剩<a> ${(dates - date)} </a>天`;\n e.querySelector(\"#pBar_week\").value = week === 0 ? 7 : week;\n e.querySelector(\"#p_span_week\").innerHTML = ((week === 0 ? 7 : week) / 7 * 100).toFixed(1) + \"%\";\n e.querySelector(\".schedule-r2 .schedule-d1 .aside-span2\").innerHTML = `还剩<a> ${(7 - (week === 0 ? 7 : week))} </a>天`;\n }\n}\n\nfunction cardTimes() {\n year = now.getFullYear();\n month = now.getMonth();\n week = now.getDay();\n date = now.getDate();\n\n const e = document.getElementById(\"card-widget-calendar\");\n if (e) {\n const isLeapYear = year % 4 === 0 && year % 100 !== 0 || year % 400 === 0;\n weekStr = [\"周日\", \"周一\", \"周二\", \"周三\", \"周四\", \"周五\", \"周六\"][week];\n const monthData = [\n { month: \"1月\", days: 31 },\n { month: \"2月\", days: isLeapYear ? 29 : 28 },\n { month: \"3月\", days: 31 },\n { month: \"4月\", days: 30 },\n { month: \"5月\", days: 31 },\n { month: \"6月\", days: 30 },\n { month: \"7月\", days: 31 },\n { month: \"8月\", days: 31 },\n { month: \"9月\", days: 30 },\n { month: \"10月\", days: 31 },\n { month: \"11月\", days: 30 },\n { month: \"12月\", days: 31 }\n ];\n monthStr = monthData[month].month;\n dates = monthData[month].days;\n\n const t = (week + 8 - date % 7) % 7;\n let n = \"\", d = false, s = 7 - t;\n const o = (dates - s) % 7 === 0 ? Math.floor((dates - s) / 7) + 1 : Math.floor((dates - s) / 7) + 2;\n const c = e.querySelector(\"#calendar-main\");\n const l = e.querySelector(\"#calendar-date\");\n\n l.style.fontSize = [\"64px\", \"48px\", \"36px\"][Math.min(o - 3, 2)];\n\n for (let i = 0; i < o; i++) {\n if (!c.querySelector(`.calendar-r${i}`)) {\n c.innerHTML += `<div class='calendar-r${i}'></div>`;\n }\n for (let j = 0; j < 7; j++) {\n if (i === 0 && j === t) {\n n = 1;\n d = true;\n }\n const r = n === date ? \" class='now'\" : \"\";\n if (!c.querySelector(`.calendar-r${i} .calendar-d${j} a`)) {\n c.querySelector(`.calendar-r${i}`).innerHTML += `<div class='calendar-d${j}'><a${r}>${n}</a></div>`;\n }\n if (n >= dates) {\n n = \"\";\n d = false;\n }\n if (d) {\n n += 1;\n }\n }\n }\n\n const lunarDate = chineseLunar.solarToLunar(new Date(year, month, date));\n animalYear = chineseLunar.format(lunarDate, \"A\");\n ganzhiYear = chineseLunar.format(lunarDate, \"T\").slice(0, -1);\n lunarMon = chineseLunar.format(lunarDate, \"M\");\n lunarDay = chineseLunar.format(lunarDate, \"d\");\n\n const newYearDate = new Date(\"2026/02/16 00:00:00\");\n const daysUntilNewYear = Math.floor((newYearDate - now) / 1e3 / 60 / 60 / 24);\n asideTime = new Date(`${new Date().getFullYear()}/01/01 00:00:00`);\n asideDay = (now - asideTime) / 1e3 / 60 / 60 / 24;\n asideDayNum = Math.floor(asideDay);\n const weekNum = week - asideDayNum % 7 >= 0 ? Math.ceil(asideDayNum / 7) : Math.ceil(asideDayNum / 7) + 1;\n\n e.querySelector(\"#calendar-week\").innerHTML = `第${weekNum}周 ${weekStr}`;\n e.querySelector(\"#calendar-date\").innerHTML = date.toString().padStart(2, \"0\");\n e.querySelector(\"#calendar-solar\").innerHTML = `${year}年${monthStr} 第${asideDay.toFixed(0)}天`;\n e.querySelector(\"#calendar-lunar\").innerHTML = `${ganzhiYear}${animalYear}年 ${lunarMon}${lunarDay}`;\n document.getElementById(\"schedule-days\").innerHTML = daysUntilNewYear;\n }\n}\n```\n\n# 添加css\n\n在主题文件 `source/css/`新建 `calendar.css`。\n\n```css\n/* 浅色主题变量覆盖 -------------------------------- */\n:root {\n --anzhiyu-main: #a0d2eb; /* 主强调色:柔和天空蓝 */\n --anzhiyu-main-op: rgba(160, 210, 235, 0.6);\n --anzhiyu-main-op-deep: rgba(160, 210, 235, 0.4);\n --anzhiyu-main-op-light: rgba(160, 210, 235, 0.2);\n\n --efu-card-bg: #fdfdfd; /* 卡片背景:几乎白 */\n --efu-fontcolor: #444; /* 主文本:深灰 */\n --efu-secondtext: #999; /* 次级文本:浅灰 */\n}\n.card-widget {\n padding: 10px!important;\n max-height: calc(100vh - 100px);\n}\n.card-times a, .card-times div {\n color: var(--efu-fontcolor);\n}\n\n#card-widget-calendar .item-content {\n display: flex;\n}\n\n#calendar-area-left {\n width: 45%;\n}\n\n#calendar-area-right {\n width: 55%;\n}\n\n#calendar-area-left, #calendar-area-right {\n height: 100%;\n padding: 8px;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: flex-start;\n}\n\n#calendar-main {\n width: 100%;\n}\n\n#calendar-week {\n height: 1.2rem;\n font-size: 14px;\n letter-spacing: 1px;\n font-weight: 700;\n align-items: center;\n display: flex;\n}\n\n#calendar-date {\n height: 3rem;\n line-height: 1.3;\n font-size: 64px;\n letter-spacing: 3px;\n color: var(--anzhiyu-main);\n font-weight: 700;\n align-items: center;\n display: flex;\n position: relative;\n top: calc(50% - 2.1rem);\n}\n\n#calendar-lunar, #calendar-solar {\n height: 1rem;\n font-size: 12px;\n align-items: center;\n display: flex;\n position: absolute;\n}\n\n#calendar-solar {\n bottom: 2.1rem;\n}\n\n#calendar-lunar {\n bottom: 1rem;\n color: var(--efu-secondtext);\n}\n\n#calendar-main a {\n height: 1rem;\n width: 1rem;\n border-radius: 50%;\n font-size: 12px;\n line-height: 12px;\n display: flex;\n justify-content: center;\n align-items: center;\n}\n\n#calendar-main a.now {\n background: var(--anzhiyu-main);\n color: var(--efu-card-bg);\n}\n\n#calendar-main .calendar-rh a {\n color: var(--efu-secondtext);\n}\n\n.calendar-r0, .calendar-r1, .calendar-r2, .calendar-r3, .calendar-r4, .calendar-r5, .calendar-rh {\n height: 1.2rem;\n display: flex;\n}\n\n.calendar-d0, .calendar-d1, .calendar-d2, .calendar-d3, .calendar-d4, .calendar-d5, .calendar-d6 {\n width: calc(100% / 7);\n display: flex;\n justify-content: center;\n align-items: center;\n}\n\n#card-widget-schedule .item-content {\n display: flex;\n}\n\n#schedule-area-left, #schedule-area-right {\n height: 100px;\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n}\n\n#schedule-area-left {\n width: 30%;\n}\n\n#schedule-area-right {\n width: 70%;\n padding: 0 5px;\n}\n\n.schedule-r0, .schedule-r1, .schedule-r2 {\n height: 2rem;\n width: 100%;\n align-items: center;\n display: flex;\n}\n\n.schedule-d0 {\n width: 30px;\n margin-right: 5px;\n text-align: center;\n font-size: 12px;\n}\n\n.schedule-d1 {\n width: calc(100% - 35px);\n height: 1.5rem;\n align-items: center;\n display: flex;\n}\n\nprogress::-webkit-progress-bar {\n background: linear-gradient(to right, var(--anzhiyu-main-op-deep), var(--anzhiyu-main-op), var(--anzhiyu-main-op-light));\n border-radius: 5px;\n overflow: hidden;\n}\n\nprogress::-webkit-progress-value {\n background: var(--anzhiyu-main);\n border-radius: 5px;\n}\n\n.aside-span1, .aside-span2 {\n height: 1rem;\n font-size: 12px;\n z-index: 1;\n display: flex;\n align-items: center;\n position: absolute;\n}\n\n.aside-span1 {\n margin-left: 5px;\n}\n\n.aside-span2 {\n right: 20px;\n color: var(--efu-secondtext);\n}\n\n.aside-span2 a {\n margin: 0 3px;\n}\n\n#pBar_month, #pBar_week, #pBar_year {\n width: 100%;\n border-radius: 5px;\n height: 100%;\n}\n\n#schedule-date, #schedule-days, #schedule-title {\n display: flex;\n align-items: center;\n}\n\n#schedule-title {\n height: 25px;\n line-height: 1;\n font-size: 14px;\n font-weight: 700;\n}\n\n#schedule-days {\n height: 40px;\n line-height: 1;\n font-size: 30px;\n font-weight: 900;\n color: var(--anzhiyu-main);\n}\n\n#schedule-date {\n height: 20px;\n line-height: 1;\n font-size: 12px;\n color: var(--efu-secondtext);\n}\n```\n\n# 引入\n\n新增+号后面内容\n\n```yml\ninject:\n head:\n # 自定义css\n+ - <link rel=\"stylesheet\" href=\"/css/calendar.css\">\n\n bottom:\n # 自定义js\n+ - <script src=\"/js/calendar.js\"></script>\n+ - <script src=\"https://unpkg.com/chinese-lunar@0.1.4/lib/chinese-lunar.js\"></script>\n```\n\n在 `blogroot/source/_data` 文件夹下创建 `widget.yml` 文件,并添加以下内容:\n\n```yml\nbottom:\n - class_name: calendar\n id_name: card-widget-calendar\n name:\n icon:\n order: -1\n html: |\n <div id=\"calendar-area-left\">\n <div id=\"calendar-week\"></div>\n <div id=\"calendar-date\" style=\"font-size: 48px;\"></div>\n <div id=\"calendar-solar\"></div>\n <div id=\"calendar-lunar\"></div>\n </div>\n <div id=\"calendar-area-right\">\n <div id=\"calendar-main\">\n </div>\n </div>\n\n - class_name: schedule\n id_name: card-widget-schedule\n name:\n icon:\n order: -1\n html: |\n <div id=\"schedule-area-left\">\n <div id=\"schedule-title\">距离除夕</div>\n <div id=\"schedule-days\"></div>\n <div id=\"schedule-date\">2025-01-28</div>\n </div>\n <div id=\"schedule-area-right\">\n <div class=\"schedule-r0\">\n <div class=\"schedule-d0\">本年</div>\n <div class=\"schedule-d1\">\n <span id=\"p_span_year\" class=\"aside-span1\"></span>\n <span class=\"aside-span2\">还剩<a></a>天</span>\n <progress max=\"365\" id=\"pBar_year\"></progress>\n </div>\n </div>\n <div class=\"schedule-r1\">\n <div class=\"schedule-d0\">本月</div>\n <div class=\"schedule-d1\">\n <span id=\"p_span_month\" class=\"aside-span1\"></span>\n <span class=\"aside-span2\">还剩<a></a>天</span>\n <progress max=\"30\" id=\"pBar_month\"></progress>\n </div>\n </div>\n <div class=\"schedule-r2\">\n <div class=\"schedule-d0\">本周</div>\n <div class=\"schedule-d1\">\n <span id=\"p_span_week\" class=\"aside-span1\"></span>\n <span class=\"aside-span2\">还剩<a></a>天</span>\n <progress max=\"7\" id=\"pBar_week\"></progress>\n </div>\n </div>\n </div>\n```\n\n# 参考\n\n{% link 乐活星球,lohas,https://blog.lohas.fun/hc/jc005/ %}\n","tags":["网站"],"categories":["建站手札"]},{"title":"和朋友们的故事","url":"/posts/a31d95d9/","content":"\n最近一直忙于学习(~~虽然也没怎么好好学~~),所以一直忘了网站的更新;现在闲下来了,又不知道该写点什么;就写写我和朋友们的故事吧。\n因为一次偶然的突发奇想,解锁了挂号信这种奇奇怪怪的通信方式,虽然现在网络发达,但感觉这种方式有一种独特的魅力。所以从去年开始就断断续续地给朋友们写信,这是一些挂号信收据:\n<center><img src=\"https://pic.biss.click/i/2026/01/05/y08m0d.jpg\" alt=\"一些挂号信收据\" /></center>\n这应该是去年上半年的一张图片,下半年也在零散的发,只不过下半年比较忙,没发多少。到年底的时候呢又想着写一点贺年信,当然感觉自己的水平下降,写不出什么好的文章。于是开始着手准备电子版贺卡,当然完全使用了AI工具,自己写太麻烦,也没什么精力去写,于是就有了下面的电子贺卡:\n<center><img src=\"https://pic.biss.click/i/2026/01/05/ys91t1.png\" alt=\"电子贺卡\" /></center>\n之后呢,又写了其他一些有趣的功能,但好像不是这篇文章的重点;\n再写信和创作电子贺卡是感慨万分,进入大学之后时间似乎变得十分快,感觉除了几个天天联系的好友之外,其他人都慢慢疏远了,不过这也是必然的事情,也没什么可悲伤的,只是感慨罢了。\n怎么说,就这样吧,下次有时间再在这篇文章里更新。","tags":["生活"],"categories":["杂谈"]},{"title":"Adguard和Openclash共存","url":"/posts/66e66374/","content":"\n在之前已经安装了`Openwrt`系统,并且也配置了`OpenClash`和`AdguardHome`,两者的原理简单看都是劫持`DNS`,所以两者要同时运行,必须经过一定的配置。\n无非就这两种方式:\n\n<center><img src=\"https://pic.biss.click/i/2025/10/05/qyl83t.png\" alt=\"image\" /></center>\n\n左边的方式更简单一些,只需要修改`AdguardHome`的上游DNS服务器为`127.0.0.1:7874` 即可;\n右边的方式需要将`OpenClash`里的`DNS`指向`AdguardHome`,但是可能有拦截失败的情况(好像没有遇到过)。","tags":["AdguardHome","Openclash","Openwrt"],"categories":["技术"]},{"title":"Adguard规则分享","url":"/posts/69b16001/","content":"\n众所周知,`Adguardhome`是用于拦截广告的工具,搭配好的规则,拦截效果才会更好,下面来分享一些规则:\n1. 一个综合的过滤规则\n {% link adblockfilters,adblockfilters,https://github.com/217heidai/adblockfilters %}\n2. 广告过滤规则订阅中心\n {% link 广告过滤规则订阅中心,广告过滤规则订阅中心,https://adguardfilters-chinese.pages.dev/ %}\n 集成了许多规则,可以挑选一下加入。\n\n<center><img src=\"https://pic.biss.click/i/2025/10/05/lndn18.png\" alt=\"image\" /></center>\n这是我添加的规则,在这些规则下,用Adblocktester可以达到74分,基本够用\n<center><img src=\"https://pic.biss.click/i/2025/10/05/lqfc7z.png\" alt=\"image\" /></center>","tags":["AdguardHome","Openwrt"],"categories":["技术"]},{"title":"在Openwrt上安装AdguardHome","url":"/posts/b57500e9/","content":"\n接续前言,`AdguardHome`是一款广告拦截软件,有了一台小软路由后就开始折腾了。\n\n# 安装\n\n首先要下载软件包,但是经过尝试,软件源里面的`luci-app-adguardhome`不太好用~~(也可能是我不会用)~~ ,所以我用的下面的包:\n\n{% link luci-app-adguardhome,rufengsuixing,https://github.com/rufengsuixing/luci-app-adguardhome %}\n\n虽然好几年没更新了,但还是能用。下载之后上传到路由器,使用`opkg install`命令安装,或者可以直接通过网页安装:\n\n<center><img src=\"https://pic.biss.click/i/2025/10/05/rek0qq.png\" alt=\"image\" /></center>\n\n# 配置\n\n如下图所示进行操作,如果更新核心版本失败,考虑更换`升级用的下载链接`,使用镜像源,或者科学上网,错号框内的非必要不修改;\n<center><img src=\"https://pic.biss.click/i/2025/10/05/s46k8g.png\" alt=\"Screenshot of the AdGuard Home configuration page in the OpenWrt web interface. The left sidebar menu is expanded to highlight the Services section and AdGuard Home submenu. The main panel displays configuration options including enable checkbox, web management port, update core version button, executable file path, compressed file option, configuration file path, working directory, and log file path. A large red X marks the configuration file path field, indicating it should not be modified. Visible text includes AdGuard Home, OpenClash, miniDLNA, UPnP IGD and PCP, enable, update core version, executable file path, configuration file path, working directory, log file path, and other related options. The interface is clean and instructional, with a neutral tone.\" /></center>\n\n最后点击“保存并应用”,然后点击`AdGuardHome Web:3000`,进行安装,建议关闭路由器自带DNS/DHCP服务器,`AdguardHome`直接替代\n\n<center><img src=\"https://pic.biss.click/i/2025/10/05/s8livw.png\" alt=\"Screenshot of the OpenWrt web interface showing the DHCP/DNS settings page. The left sidebar menu is expanded to highlight the network section and DHCP/DNS submenu. The main panel displays the General tab with options for enabling exclusive authorization and DNS redirect, both with checkboxes. The interface is clean and organized, with navigation tabs for additional settings such as DNS records, filters, logs, and PXE/TFTP. The overall tone is neutral and instructional. Visible text includes DHCP/DNS, 常规, 唯一授权, DNS redirect, 本地解析这些项目, 本地域名, and other configuration options.\" /></center>\n\n<center><img src=\"https://pic.biss.click/i/2025/10/05/sa99dn.png\" alt=\"alt=Screenshot of the OpenWrt web interface focused on DHCP/DNS settings. The left sidebar menu highlights the network section and DHCP/DNS submenu. Red arrows guide the user through selecting DHCP/DNS, then the settings and port tab, and finally entering 5353 in the DNS server port field. The main panel displays options for specifying interface addresses, listening interfaces, excluded interfaces, and DNS server port. Visible text includes DHCP/DNS, 设置及端口, 5353, 监听接口, 排除接口, DNS服务器端口, DNS查询端口, and related configuration options. The interface is clean and instructional, with a neutral and helpful tone.\" /></center>\n\n然后,设置AdguardHome的DHCP服务器,注意要先检查配置,再启用\n<center><img src=\"https://pic.biss.click/i/2025/10/05/scj0h4.png\" alt=\"image\" /></center>","tags":["AdguardHome","Openwrt"],"categories":["技术"]},{"title":"在Openwrt中安装OpenClash","url":"/posts/2b2fb1a7/","content":"\n# 前言\n因为一直想要实现从软路由上进行代理,所以买到了一个Cudy Tr3000刷系统折腾。用这篇文章记录一下安装的过程。\n# 安装\n可以通过web管理页面安装,搜索openclash。\n\n<center><img src=\"https://pic.biss.click/i/2025/09/02/z5y0d1.png\" alt=\"image\" /></center>\n\n当然也可以在终端中执行命令:\n\n```bash\nopkg update\nopkg install bash iptables dnsmasq-full curl ca-bundle ipset ip-full iptables-mod-tproxy iptables-mod-extra ruby ruby-yaml kmod-tun kmod-inet-diag unzip luci-compat luci luci-base\nopkg install luci-app-openclash\n```\n# 配置\n首先需要下载内核,推荐启用Smart内核。\n\n<center><img src=\"https://pic.biss.click/i/2025/09/02/zcllg4.png\" alt=\"image\" /></center>\n\n然后导入配置:\n\n<center><img src=\"https://pic.biss.click/i/2025/09/02/zdut38.png\" alt=\"image\" /></center>\n\n然后就可以开心使用啦!\n感觉zashboard简洁好看一些,看自己感觉啦\n<center><img src=\"https://pic.biss.click/i/2025/09/02/zfix7i.png\" alt=\"image\" /></center>","tags":["Openclash","Openwrt"],"categories":["技术"]},{"title":"Cudy TR3000刷入Openwrt系统","url":"/posts/8802e397/","content":"\n最近搞到了一台`Cudy-TR3000`路由器,用来进行科学上网(小猫咪),先记录一下刷写`Openwrt`系统的过程。\n# 下载固件\n1. 中间固件\n中间固件可以在`Cudy`官方网站上下载\n\n{% link Cudy固件下载,Cudy,https://www.cudy.com/zh-cn/pages/download-center/tr3000-1-0 %}\n\n<center><img src=\"https://pic.biss.click/i/2025/08/31/xjk7op.png\" alt=\"image\" /></center>\n2. Openwrt固件\n在下面的网站中下载,下载最新的就行\n\n{% link Openwrt固件,Openwrt.ai,https://openwrt.ai/?target=mediatek%2Ffilogic&id=cudy_tr3000-256mb-v1 %}\n\n# 刷写固件\n访问`192.168.10.1`先刷入中间固件\n\n<center><img src=\"https://pic.biss.click/i/2025/08/31/xl9zvk.png\" alt=\"image\" /></center>\n\n然后访问`192.168.1.1`,刷入`Openwrt`插件\n\n<center><img src=\"https://pic.biss.click/i/2025/08/31/xnr3bb.png\" alt=\"image\" /></center>\n\n然后访问`10.0.0.1`,就可以看到openwrt登录页面了,默认密码是`root`。\n\n<center><img src=\"https://pic.biss.click/i/2025/08/31/xp14em.png\" alt=\"image\" /></center>","tags":["Cudy-TR3000"],"categories":["技术"]},{"title":"搭建Owncloud并集成Onlyoffice","url":"/posts/59c8572a/","content":"\n# 引言\n因为正好有云存储的需求,恰好又有服务器,所以决定自建一个Owncloud网盘服务,集成一个Onlyoffice。\n# 安装网盘\n## 建站\n在官网下载最新的安装包\n{% link Owncloud,Owncloud,https://owncloud.com/ %}\n因为使用1panel,所以搭网站很简单,选择`php7.3`运行环境,添加必要的`php`扩展,新建一个`Mysql`数据库,按照正常步骤安装就行了。\n## 调优\n1. 配置Redis缓存\n 在1panel安装Redis,\n在config/config.php中添加\n```php\n 'filelocking.enabled' => true,\n 'memcache.local' => '\\OC\\Memcache\\Redis',\n 'memcache.locking' => '\\OC\\Memcache\\Redis',\n 'redis' => [\n 'host' => '容器名', // For a Unix domain socket, use '/var/run/redis/redis.sock'\n 'port' => 6379, // Set to 0 when using a Unix socket\n 'timeout' => 0, // Optional, keep connection open forever\n 'password' => 'password', // Optional, if not defined no password will be used.\n 'dbindex' => 0, // Optional, if undefined SELECT will not run and will\n // use Redis Server's default DB Index.\n ],\n```\n2. 添加Cron任务\n首先在Owncloud的配置页面把计划任务调整为`Cron`。\n在1panel的计划任务中添加,容器选择`php7.3`的容器,用户必须为`www-data`,时间为每15分钟。\n```bash\nphp sites/cloud.biss.click/index/occ system:cron\n```\n# 集成Onlyoffice\n在1panel应用商店直接安装Onlyoffice,并反向代理到自己的域名\n在Owncloud中搜索Onlyoffice插件,然后填写自己的域名、密钥(在参数中可以查到)","tags":["网站"],"categories":["技术"]},{"title":"为博客添加CMS系统","url":"/posts/3a26a97a/","content":"# 序言\n\n因为喜欢wordpress之类动态博客的在线编辑功能,但是又不想抛弃hexo,特别是这个花里胡哨的模板,所以想着给博客添加一个cms系统,在搜索一番后发现这种CMS系统叫无头CMS,然后找到一个很好的系统:sveltia-cms\n\n\n{% link sveltia-cms,sveltia,https://github.com/sveltia/sveltia-cms %}\n\n# 安装\n\n## 安装包\n\n在博客根目录下运行`npm i @sveltia/cms`\n\n## 创建必要文件\n\n然后在博客`source`目录下创建`admin`目录\n并在其下新建`index.html`\n\n```html\n<!doctype html>\n<html>\n<head>\n <meta charset=\"utf-8\" />\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />\n <meta name=\"robots\" content=\"noindex\" />\n <title>博客管理</title>\n</head>\n<body>\n <script src=\"https://unpkg.com/netlify-cms@^2.0.0/dist/netlify-cms.js\"></script>\n</body>\n</html>\n```\n\n新建`config.yml`\n\n```yml\n# https://decapcms.org/docs/configuration-options/\nbackend:\n name: github\n repo: #博客存储库\n branch: #分支\n auth_type: \n app_id: \nmedia_folder: \"folder\"\npublic_folder: \"folder\"\nsite_url: \"\"\nlogo_url: \"\"\nlocale: \"zh_Hans\"\ncommon_col_conf: &common_col_conf\n create: true\n slug: \"{{fields.filename}}\"\n sortable_fields:\n - \"commit_date\"\n - \"title\"\n - \"date\"\n - \"updated\"\n # https://decapcms.org/docs/widgets/\n fields:\n - label: \"文件名\"\n name: \"filename\"\n widget: \"string\"\n - label: \"标题\"\n name: \"title\"\n widget: \"string\"\n - label: \"发表日期\"\n name: \"date\"\n widget: \"datetime\"\n format: \"YYYY-MM-DD HH:mm:ss\"\n date_format: \"YYYY-MM-DD\"\n time_format: \"HH:mm:ss\"\n - label: \"更新日期\"\n name: \"updated\"\n widget: \"datetime\"\n format: \"YYYY-MM-DD HH:mm:ss\"\n date_format: \"YYYY-MM-DD\"\n time_format: \"HH:mm:ss\"\n required: false\n - label: \"封面\"\n name: \"cover\"\n widget: \"image\"\n required: false\n - label: \"标签\"\n name: \"tags\"\n widget: \"select\"\n multiple: true\n required: false\n options:\n - \"amazon\"\n - \"android\"\n - \"angularjs\"\n - \"azure\"\n - \"cdn\"\n - \"chartjs\"\n - \"chrome\"\n - \"csharp\"\n - \"css\"\n - \"devops\"\n - \"diary\"\n - \"docker\"\n - \"edge\"\n - \"git\"\n - \"github\"\n - \"hexo\"\n - \"html\"\n - \"icarus\"\n - \"java\"\n - \"js\"\n - \"life\"\n - \"material\"\n - \"mysql\"\n - \"nodejs\"\n - \"onedrive\"\n - \"oneindex\"\n - \"php\"\n - \"restapi\"\n - \"security\"\n - \"serverless\"\n - \"shadowdefender\"\n - \"tool\"\n - \"twikoo\"\n - \"ubuntu\"\n - \"vagrant\"\n - \"vb\"\n - \"vite\"\n - \"vue\"\n - \"webpack\"\n - \"windows\"\n - \"xlsx\"\n - \"小程序\"\n - label: \"分类\"\n name: \"categories\"\n widget: \"select\"\n multiple: true\n required: false\n options:\n - \"Diary\"\n - \"Tool\"\n - \"Tech\"\n - \"FrontEnd\"\n - \"BackEnd\"\n - \"Windows\"\n - \"Android\"\n - \"Linux\"\n - \"Serverless\"\n - label: \"正文\"\n name: \"body\"\n widget: \"markdown\"\n - label: \"原创\"\n name: \"toc\"\n widget: \"boolean\"\n default: true\n - label: \"评论\"\n name: \"comments\"\n widget: \"boolean\"\n default: true\ncollections:\n - name: \"2023\"\n label: \"2023\"\n folder: \"source/_posts/2023\"\n preview_path: \"2023/{{filename}}/\"\n <<: *common_col_conf\n - name: \"pages\"\n label: \"Pages\"\n files:\n - name: \"friends\"\n label: \"友链\"\n file: \"source/friends/index.md\"\n preview_path: \"friends/\"\n <<: *common_col_conf\n - name: \"about\"\n label: \"关于\"\n file: \"source/about/index.md\"\n preview_path: \"about/\"\n <<: *common_col_conf\n```\n\n需要自己修改一些配置;\n一般到这一步就可以了,但是因为我使用自己的服务器,没办法用官方的auth系统,所以还要进一步配置。\n\n## 创建auth系统、授权\n\n{% link Sveltia CMS Authenticator,Sveltia CMS Authenticator,https://github.com/sveltia/sveltia-cms-auth %}\n比较简单,直接Cloudflare一键部署就可以\n然后要在github新建一个oauth应用,就不写了,可以自己查找。\n然后在cloudflare新建环境变量:\n`GITHUB_CLIENT_ID`: \n`GITHUB_CLIENT_SECRET`:\n然后在`config.yml`添加\n\n```yml\n backend:\n name: github # or gitlab\n repo: username/repo\n branch: main\n base_url: <YOUR_WORKER_URL>\n```\n\n# 大功告成\n\n访问博客的admin就可以了","tags":["网站"],"categories":["建站手札"]},{"title":"为1Panel添加自己想要的应用","url":"/posts/bb18d851/","content":"记录一下自己为1Panel贡献自己应用的经历\n\n# 预准备\n1. Fork仓库\n {% link 1Panel appstore 仓库,1panel appstore,https://github.com/1Panel-dev/appstore %}\n 把仓库fork到自己的仓库\n2. pull\n ```bash\n git clone -b dev https://<your-github-username>/appstore\n ```\n 创建新分支\n ```bash\n cd appstore\n git checkout -b app/<app-name>\n ```\n# 创建文件\n\n## 文件目录\n```\n├──halo // 以 halo 的 key 命名 ,下面解释什么是 key \n\t├── logo.png // 应用 logo , 最好是 180 * 180 px 不要超过 10 KB \n\t├── data.yml // 应用声明文件\n\t├── README.md // 应用的 README\n\t├── 2.2.0 // 应用版本 注意不要以 v 开头\n\t│ ├── data.yml // 应用的参数配置,下面有详细介绍\n\t│ ├── data // 挂载出来的目录 \n\t| ├── scripts // 脚本目录 存放 init.sh upgrade.sh uninstall.sh\n\t│ └── docker-compose.yml // docker-compose 文件\n\t└── 2.3.2\n\t ├── data.yml\n\t ├── data\n\t └── docker-compose.yml\n```\n## 应用声明文件`data.yml`\n\n本文件主要用于声明应用的一些信息\n```yml\nadditionalProperties: #固定参数\n key: halo #应用的 key ,仅限英文,用于在 Linux 创建文件夹\n name: Halo #应用名称\n tags: \n - WebSite #应用标签,可以有多个,请参照下方的标签列表 \n\tdescription: \n\t en: Powerful and easy-to-use open source website builder\n\t zh: 强大易用的开源建站工具 #应用中文描述,不要超过30个字\n\t zh-Hant:\n\t ja: \n\t ms: \n\t pt-br: \n\t ru: \n\t ko: \n type: website #应用类型,区别于应用分类,只能有一个,请参照下方的类型列表\n crossVersionUpdate: true #是否可以跨大版本升级\n limit: 0 #应用安装数量限制,0 代表无限制\n website: https://halo.run/ #官网地址\n github: https://github.com/halo-dev/halo #github 地址 \n document: https://docs.halo.run/ #文档地址\n```\n## 应用标签 - tags 字段\n| key | name |\n|----------|----------|\n| WebSite | 建站 |\n| Server | Web 服务器 |\n| Runtime | 运行环境 |\n| Database | 数据库 |\n| Tool | 工具 |\n| CI/CD | CI/CD |\n| Local | 本地 |\n\n# 应用类型 - type 字段\n\n| type | 说明 |\n|---------|---------------------------------------------------------|\n| website | website 类型在 1Panel 中支持在网站中一键部署,wordpress halo 都是此 type |\n| runtime | mysql openresty redis 等类型的应用 |\n| tool | phpMyAdmin redis-commander jenkins 等类型的应用 |\n\n# 应用参数配置文件 data.yml \n(注意区分于应用主目录下面的 `data.yaml`)\n\n本文件主要用于生成安装时要填写的 form 表单,在应用版本文件夹下面 可以无表单,但是需要有这个 data.yml文件,并且包含 formFields 字段\n\n以安装 halo 时的 form 表单 为例\n\n如果要生成上面的表单,需要这么填写 `data.yml`\n```yml\n\tadditionalProperties: #固定参数\n\t formFields: \n\t - default: \"\" \n\t envKey: PANEL_DB_HOST #docker-compose 文件中的参数\n\t key: mysql #依赖应用的 key , 例如 mysql\n\t\t label: \n\t\t en: Database Service \n\t ja: データベースサービス \n\t\t ms: Perkhidmatan Pangkalan Data \n\t\t pt-br: Serviço de Banco de Dados \n\t\t ru: Сервис базы данных \n\t\t ko: 데이터베이스 서비스 \n\t\t zh: 数据库服务 \n\t\t zh-Hant: 數據庫 服務\n\t\t required: true #是否必填\n\t type: service #如果需要依赖其他应用,例如数据库,使用此 type \n\t - default: halo \n\t envKey: PANEL_DB_NAME \n\t label: \n\t en: Database \n\t\t ja: データベース \n\t\t ms: Pangkalan Data \n\t\t pt-br: Banco de Dados \n\t\t ru: База данных \n\t\t ko: 데이터베이스 \n\t\t zh: 数据库名 \n\t\t zh-Hant: 資料庫名稱\n\t random: true #是否在 default 文字后面,增加随机字符串\n\t required: true \n\t rule: paramCommon #校验规则\n\t type: text #需要手动填写的,使用此 type\n\t - default: halo \n\t envKey: PANEL_DB_USER \n\t\t label: \n\t\t en: User \n\t\t ja: ユーザー \n\t\t ms: Pengguna \n\t\t pt-br: Usuário \n\t\t ru: Пользователь \n\t\t ko: 사용자 \n\t\t zh: 数据库用户 \n\t\t zh-Hant: 資料庫使用者\n\t random: true \n\t required: true \n\t rule: paramCommon \n\t type: text \n\t - default: halo \n\t envKey: PANEL_DB_USER_PASSWORD \n\t\t label: \n\t\t en: Password \n\t\t ja: パスワード \n\t\t ms: Kata laluan \n\t\t pt-br: Senha \n\t\t ru: Пароль \n\t\t ko: 비밀번호 \n\t\t zh: 数据库用户密码 \n\t\t zh-Hant: 資料庫使用者密碼 \n\t random: true \n\t required: true \n\t rule: paramComplexity \n\t type: password #密码字段使用此 type\n\t - default: admin \n\t envKey: HALO_ADMIN \n\t labelEn: Admin Username \n\t labelZh: 超级管理员用户名 \n\t required: true \n\t rule: paramCommon \n\t type: text \n\t - default: http://localhost:8080 \n\t edit: true \n\t envKey: HALO_EXTERNAL_URL \n\t\t label: \n\t\t en: External URL \n\t\t ja: 外部URL \n\t\t ms: URL Luaran \n\t\t pt-br: URL Externa \n\t\t ru: Внешний URL \n\t\t ko: 외부 URL \n\t\t zh: 外部访问地址 \n\t\t zh-Hant: 外部訪問地址 \n\t required: true \n\t rule: paramExtUrl \n\t type: text \n\t - default: 8080 \n\t edit: true \n\t envKey: PANEL_APP_PORT_HTTP \n\t\t label: \n\t\t en: Port \n\t\t ja: ポート \n\t\t ms: Port \n\t\t pt-br: Porta \n\t\t ru: Порт \n\t\t ko: 포트 \n\t\t zh: 端口 \n\t\t zh-Hant: 埠\n\t required: true \n\t rule: paramPort \n\t type: number #端口使用此 type \n```\n## 关于端口字段:\n`PANEL_APP_PORT_HTTP` 有 `web` 访问端口的优先使用此 `envKey`\n`envKey` 中包含 `PANEL_APP_PORT` 前缀会被认定为端口类型,并且用于安装前的端口占用校验。注意:端口需要是外部端口\n## 关于 type 字段:\n| type | 说明 |\n|----------|-----------------------------------------------------------------------------------------|\n| service | type: service 如果该应用需要依赖其他组件,如 mysql redis 等,可以通过 key: mysql 定义依赖的名称,在创建应用时会要求先创建依赖的应用。 |\n| password | type: password 敏感信息,如密码相关的字段会默认不显示明文。 |\n| text | type: text 一般内容,比如数据库名称,默认明文显示。 |\n| number | type: number 一般用在端口相关的配置上,只允许输入数字。 |\n\n简单的例子\n```yml\n# type: service,定义一个 mysql 的 service 依赖。\n- child: \n default: \"\" \n envKey: PANEL_DB_HOST \n required: true \n type: service \n default: mysql \n envKey: PANEL_DB_TYPE \n label: \n en: Database Service \n ja: データベースサービス \n ms: Perkhidmatan Pangkalan Data \n pt-br: Serviço de Banco de Dados \n ru: Сервис баз данных \n ko: 데이터베이스 서비스 \n zh-hant: 資料庫服務 \n zh: 数据库服务 \n required: true \n type: apps \n values: \n - label: MySQL \n value: mysql \n - label: MariaDB \n value: mariadb\n\n# type: password\n- default: word \n envKey: PANEL_DB_USER_PASSWORD \n labelEn: Database Password \n labelZh: 数据库密码 \n label: \n en: Database Password \n ja: データベースのパスワード \n ms: Kata Laluan Pangkalan Data \n pt-br: Senha do Banco de Dados \n ru: Пароль базы данных \n ko: 데이터베이스 비밀번호 \n zh-hant: 資料庫密碼 \n zh: 数据库密码 \n random: true \n required: true \n type: password\n\n# type: text\n- default: \"\" \n edit: true \n envKey: REDIS_HOST \n key: redis \n required: true \n type: service \n label: \n en: Redis Service \n ja: Redis サービス \n ms: Perkhidmatan Redis \n pt-br: Serviço Redis \n ru: Сервис Redis \n ko: Redis 서비스 \n zh-Hant: Redis 服務 \n zh: Redis 服务\n \n# type: number\n- default: \"\" \n edit: true \n envKey: DBHUB_DB_PORT \n required: true \n type: text \n label: \n en: Database Port \n ja: データベースのポート \n ms: Pangkalan Data Port \n pt-br: Porta do Banco de Dados \n ru: Порт базы данных \n ko: 데이터베이스 포트 \n zh-hant: 資料庫端口 \n zh: 数据库端口\n\n# type: select\n- default: \"ERROR\" \n envKey: LOG_LEVEL \n required: true \n type: select \n values: \n - label: DEBUG \n value: \"DEBUG\" \n - label: INFO \n value: \"INFO\" \n - label: WARNING \n value: \"WARNING\" \n - label: ERROR \n value: \"ERROR\" \n - label: CRITICAL \n value: \"CRITICAL\"\n```\nrule 字段目前支持的几种校验\n| rule | 规则 |\n|-----------------|------------------------------------|\n| paramPort | 用于限制端口范围为 1-65535 |\n| paramExtUrl | 格式为 http(s)://(域名/ip):(端口) |\n| paramCommon | 英文、数字、.-和_,长度2-30 |\n| paramComplexity | 支持英文、数字、.%@$!&~_-,长度6-30,特殊字符不能在首尾 |\n\n应用 `docker-compose.yml` 文件\n\n`${PANEL_APP_PORT_HTTP} `类型的参数,都在 `data.yml` 中有声明\n\n```yml\nversion: \"3\" \nservices: \n halo: \n image: halohub/halo:2.2.0 \n container_name: ${CONTAINER_NAME} // 固定写法,勿改\n restart: always \n networks: \n - 1panel-network // 1Panel 创建的应用都在此网络下\n volumes: \n - ./data:/root/.halo2 \n ports: \n - ${PANEL_APP_PORT_HTTP}:8090 \n command: \n - --spring.r2dbc.url=r2dbc:pool:${HALO_PLATFORM}://${PANEL_DB_HOST}:${HALO_DB_PORT}/${PANEL_DB_NAME} \n - --spring.r2dbc.username=${PANEL_DB_USER} \n - --spring.r2dbc.password=${PANEL_DB_USER_PASSWORD} \n - --spring.sql.init.platform=${HALO_PLATFORM} \n - --halo.external-url=${HALO_EXTERNAL_URL} \n - --halo.security.initializer.superadminusername=${HALO_ADMIN} \n - --halo.security.initializer.superadminpassword=${HALO_ADMIN_PASSWORD} \n labels: \n createdBy: \"Apps\" \n \nnetworks: \n 1panel-network: \n external: true\n```\n## 脚本\n1Panel 在 安装之前、升级之前、卸载之后支持执行 .sh 脚本\n分别对应 init.sh upgrade.sh uninstall.sh\n存放目录(以halo为例) : halo/2.2.0/scripts\n\n# 本地测试\n将应用目录上传到 1Panel 的 /opt/1panel/resource/apps/local 文件夹下\n注意:/opt 为 1Panel 默认安装目录,请根据自己的实际情况修改\n上传完成后,目录结构如下\n```\n├──halo \n\t├── logo.png \n\t├── data.yml\n\t├── README.md \n\t├── 2.2.0 \n\t ├── data.yml \n\t ├── data \n\t └── docker-compose.yml\n```\n在 1Panel 应用商店中,点击更新应用列表按钮同步本地应用\n\nv1.2 版本及之前版本的本地应用,请参考这个文档修改\n\n# 提交文件\n```bash\ngit add .\ngit commit -m \"Add my-app\"\ngit push origin dev\n```\n# 提交 Pull Request\n在你的仓库点击 Pull requests 菜单\n点击 New pull request ,填写标题和描述\n选择由你的分支提交到 1Panel-dev/appstore","tags":["1panel"],"categories":["技术"]},{"title":"使用GitHub推送Hexo到服务器","url":"/posts/ce1ec3fe/","content":"\n1panel没有宝塔的webhook功能,之前一直使用在服务器上建立裸仓库,直接推送到服务器的方法。现在找到一种新的方法。\n# 建立GitHub仓库\n因为服务器部署在香港,可以直连GitHub,国内可以使用gitee或者GitHub镜像加速。\n1. 在本地安装git\n2. 打开git bash配置用户名和邮箱\n ```bash\n git config --global user.name \"yourname\"\n git config --global user.email \"youremail\"\n ```\n 可以使用 git config --list查看当前所有的配置\n\n3. 在github上创建自己的账号(在自己的电脑和服务器上)\n4. 创建SSH Key\n a:打开Git Bash,输入pwd查看当前路径\n b.输入`ssh-keygen -t rsa –C “youremail@example.com”`\n (输入完毕后程序同时要求输入一个密语字符串(passphrase),空表示没有密语。接着会让输入2次口令(password),空表示没有口令。3次回车即可完成当前步骤)\n <center>\n <img src=\"https://pic.biss.click/i/2025/08/18/924058.webp\" alt=\"924058.webp\">\n </center>\n5. 在GitHub上传自己的公钥\n <center><img src=\"https://pic.biss.click/i/2025/08/18/946620.webp\" alt=\"946620.webp\"></center>\n6. 新建一个私有仓库\n\n# 上传文件到仓库\n在自己hexo根目录下使用`powershell`,输入`git init`,然后git push到之前自己新建的仓库。\n\n# 创建Action\n## 创建Action\n\n```yml\nname: 自动部署\n\non:\n push:\n branches:\n - main \n\n release:\n types:\n - published\n\n workflow_dispatch:\n\nenv:\n TZ: Asia/Shanghai\n\njobs:\n deploy:\n runs-on: ubuntu-latest\n steps:\n - name: 检查分支\n uses: actions/checkout@v3\n with:\n ref: main\n\n - name: 缓存项目 npm 包\n id: cache-node-modules\n uses: actions/cache@v3\n with:\n path: node_modules\n key: ${{ runner.os }}-nodeModules-${{ hashFiles('package-lock.json') }}-${{ hashFiles('package.json') }}\n restore-keys: |\n ${{ runner.os }}-nodeModules-\n\n - name: 安装 Node\n uses: actions/setup-node@v3\n with:\n node-version: \"20.x\"\n\n - name: 安装 Hexo\n run: |\n npm install hexo-cli --global\n\n - name: 安装依赖\n if: steps.cache-node-modules.outputs.cache-hit != 'true'\n run: |\n npm install\n\n - name: 清理文件树\n run: |\n npm run clean\n\n - name: 生成静态文件并压缩\n run: |\n npm run build\n\n - name: 部署\n run: |\n cd ./public\n git init\n git config user.name \"${{ github.actor }}\"\n git config user.email \"${{ github.actor }}@users.noreply.github.com\"\n git add .\n git commit -m \"${{ github.event.head_commit.message }}··[$(date +\"%Z %Y-%m-%d %A %H:%M:%S\")]\"\n git push --force --quiet \"https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git\" master:page\n - name: 服务器执行拉取命令\n uses: appleboy/ssh-action@v1\n with:\n host: ${{ secrets.SERVER_IP }}\n username: ${{ secrets.USERNAME }}\n key: ${{ secrets.KEY }}\n passphrase: ${{ secrets.PASSPHRASE }}\n port: ${{ secrets.PORT }}\n script: |\n cd /opt/1panel/apps/openresty/openresty/www/sites/blog.liushen.fun/index/\n git config --global --add safe.directory \"$(pwd)\"\n git fetch --all --depth=1\n git reset --hard origin/main\n git pull --depth=1\n echo \"✅ 已拉取 page 分支最新内容\"\n```\n## 环境变量\n此次添加变量较多,有:`SERVER_IP`,`USERNAME`,`PASSPHRASE`,`KEY`,`PORT`五个变量,如下:\n\n`SERVER_IP`:服务器IP\n`USERNAME`:SSH链接用户名,一般为root\n`PASSPHRASE`:密钥密码,用来提升强度用\n`KEY`:密钥(私钥)\n`PORT`:SSH登录端口,一般为22\n# 测试\n运行一下这个Action无报错即可。","tags":["网站"],"categories":["建站手札"]},{"title":"C# 基本语法","url":"/posts/e9a8e898/","content":"# 简介\nC# 是一种面向对象的编程语言。在面向对象的程序设计方法中,程序由各种相互交互的对象组成。相同种类的对象通常具有相同的类型,或者说,是在相同的 class 中。\n\n例如,以 Rectangle(矩形)对象为例。它具有 length 和 width 属性。根据设计,它可能需要接受这些属性值、计算面积和显示细节。\n\n实例\n```c#\nusing System;\nnamespace RectangleApplication\n{\n class Rectangle\n {\n // 成员变量\n double length;\n double width;\n public void Acceptdetails()\n {\n length = 4.5; \n width = 3.5;\n }\n public double GetArea()\n {\n return length * width;\n }\n public void Display()\n {\n Console.WriteLine(\"Length: {0}\", length);\n Console.WriteLine(\"Width: {0}\", width);\n Console.WriteLine(\"Area: {0}\", GetArea());\n }\n }\n \n class ExecuteRectangle\n {\n static void Main(string[] args)\n {\n Rectangle r = new Rectangle();\n r.Acceptdetails();\n r.Display();\n Console.ReadLine();\n }\n }\n}\n```\n尝试一下 »\n当上面的代码被编译和执行时,它会产生下列结果:\n```\nLength: 4.5\nWidth: 3.5\nArea: 15.75\n```\n# using 关键字\n在任何 C# 程序中的第一条语句都是:\n\nusing System;\nusing 关键字用于在程序中包含命名空间。一个程序可以包含多个 using 语句。\n\n# class 关键字\nclass 关键字用于声明一个类。\n\n# C# 中的注释\n注释是用于解释代码。编译器会忽略注释的条目。在 C# 程序中,多行注释以 /* 开始,并以字符 */ 终止,如下所示:\n```c#\n/* 这个程序演示\nC# 的注释\n使用 */\n```\n单行注释是用 // 符号表示。例如:\n```c#\n// 这一行是注释 \n```\n# 成员变量\n变量是类的属性或数据成员,用于存储数据。在上面的程序中,Rectangle 类有两个成员变量,名为 length 和 width。\n\n成员函数\n函数是一系列执行指定任务的语句。类的成员函数是在类内声明的。我们举例的类 Rectangle 包含了三个成员函数: AcceptDetails、GetArea 和 Display。\n\n实例化一个类\n在上面的程序中,类 ExecuteRectangle 是一个包含 Main() 方法和实例化 Rectangle 类的类。\n\n# 标识符\n标识符是用来识别类、变量、函数或任何其它用户定义的项目。在 C# 中,类的命名必须遵循如下基本规则:\n\n* 标识符必须以字母、下划线或 @ 开头,后面可以跟一系列的字母、数字( 0 - 9 )、下划线( _ )、@。\n* 标识符中的第一个字符不能是数字。\n* 标识符必须不包含任何嵌入的空格或符号,比如 ? - +! # % ^ & * ( ) [ ] { } . ; : \" ' / \\。\n* 标识符不能是 C# 关键字。除非它们有一个 @ 前缀。 例如,@if 是有效的标识符,但 if 不是,因为 if 是关键字。\n* 标识符必须区分大小写。大写字母和小写字母被认为是不同的字母。\n* 不能与C#的类库名称相同。\n# C# 关键字\n关键字是 C# 编译器预定义的保留字。这些关键字不能用作标识符,但是,如果您想使用这些关键字作为标识符,可以在关键字前面加上 @ 字符作为前缀。\n\n在 C# 中,有些关键字在代码的上下文中有特殊的意义,如 get 和 set,这些被称为上下文关键字(contextual keywords)。\n\n# 顶级语句(Top-Level Statements)\n在 C# 9.0 版本中,引入了顶级语句(Top-Level Statements)的概念,这是一种新的编程范式,允许开发者在文件的顶层直接编写语句,而不需要将它们封装在方法或类中。\n\n## 特点:\n\n无需类或方法:顶级语句允许你直接在文件的顶层编写代码,无需定义类或方法。\n\n文件作为入口点:包含顶级语句的文件被视为程序的入口点,类似于 C# 之前的 Main 方法。\n\n自动 Main 方法:编译器会自动生成一个 Main 方法,并将顶级语句作为 Main 方法的主体。\n\n支持局部函数:尽管不需要定义类,但顶级语句的文件中仍然可以定义局部函数。\n\n更好的可读性:对于简单的脚本或工具,顶级语句提供了更好的可读性和简洁性。\n\n适用于小型项目:顶级语句非常适合小型项目或脚本,可以快速编写和运行代码。\n\n与现有代码兼容:顶级语句可以与现有的 C# 代码库一起使用,不会影响现有代码。\n\n传统 C# 代码 - 在使用顶级语句之前,你必须像这样编写一个 C# 程序:\n\n实例\n```c#\nusing System;\n\nnamespace MyApp\n{\n class Program\n {\n static void Main(string[] args)\n {\n Console.WriteLine(\"Hello, World!\");\n }\n }\n}\n```\n使用顶级语句的 C# 代码 - 使用顶级语句,可以简化为:\n\n实例\n```c#\nusing System;\n\nConsole.WriteLine(\"Hello, World!\");\n```\n顶级语句支持所有常见的 C# 语法,包括声明变量、定义方法、处理异常等。\n\n实例\n```c#\nusing System;\nusing System.Linq;\n\n// 顶级语句中的变量声明\nint number = 42;\nstring message = \"The answer to life, the universe, and everything is\";\n\n// 输出变量\nConsole.WriteLine($\"{message} {number}.\");\n\n// 定义和调用方法\nint Add(int a, int b) => a + b;\nConsole.WriteLine($\"Sum of 1 and 2 is {Add(1, 2)}.\");\n\n// 使用 LINQ\nvar numbers = new[] { 1, 2, 3, 4, 5 };\nvar evens = numbers.Where(n => n % 2 == 0).ToArray();\nConsole.WriteLine(\"Even numbers: \" + string.Join(\", \", evens));\n\n// 异常处理\ntry\n{\n int zero = 0;\n int result = number / zero;\n}\ncatch (DivideByZeroException ex)\n{\n Console.WriteLine(\"Error: \" + ex.Message);\n}\n```","tags":["C#"],"categories":["学习"]},{"title":"C# 入门","url":"/posts/bc56f789/","content":"今天开始学习C#\n# 环境安装\n下载Visual Studio,社区版就可以\n{% link Visual Studio,Visual Studio,https://visualstudio.microsoft.com/zh-hans/downloads/ %}\n下载的是安装器选择.Net桌面开发,注意修改安装位置\n<center><img src=\"https://pic.biss.click/i/2025/08/15/776813.webp\" alt=\".Net 桌面开发\"></center>\n\n# 第一个程序\n```c#\nusing System;\nnamespace HelloWorldApplication\n{\n /* 类名为 HelloWorld */\n class HelloWorld\n {\n /* main函数 */\n static void Main(string[] args)\n {\n /* 我的第一个 C# 程序 */\n Console.WriteLine(\"Hello World!\");\n Console.ReadKey();\n }\n }\n}\n```\n这也是一个默认的格式","tags":["C#"],"categories":["学习"]},{"title":"自定义页脚(新)","url":"/posts/c6143ad3/","content":"\n# 添加CSS\n{% note warning 1 %}\n修改有风险,注意备份\n{% endnote %}\n```css\n/*https://codepen.io/poojanahelia/pen/Exabvdy*/\n\n#footer {\n background-color: rgba(0, 0, 0, 0); /* 修改透明色 */\n color: #fff;\n padding: 0;\n}\n\n#footer .footer-other {\n padding: 0;\n}\n\n.footer-copyright{\n padding: 0;\n}\n\n.my-footer-logo {\n color: white;\n}\n\n.my-footer-wave-svg {\n height: 50px;\n width: 100%;\n transform: scale(-1, -1) translateY(-10px); /*;*/\n}\n\n.my-footer-wave-path {\n fill: #177ecd;\n}\n\n.my-footer-content {\n margin-left: auto;\n margin-right: auto;\n max-width: 1230px;\n padding: 40px 15px 450px;\n position: relative;\n}\n\n.my-footer-content-column {\n box-sizing: border-box;\n float: left;\n padding-left: 15px;\n padding-right: 15px;\n width: 100%;\n color: #fff;\n}\n\n.my-footer-content-column ul li a {\n color: #fff;\n text-decoration: none;\n}\n\n.my-footer-logo-link {\n display: inline-block;\n}\n\n.my-footer-menu {\n margin-top: 15px;\n}\n\n.my-footer-menu-name {\n color: #fffff2;\n font-size: 15px;\n font-weight: 900;\n letter-spacing: .1em;\n line-height: 18px;\n margin-bottom: 0;\n margin-top: 0;\n text-transform: uppercase;\n}\n\n.my-footer-menu-list {\n list-style: none;\n margin-bottom: 0;\n margin-top: 10px;\n padding-left: 0;\n}\n\n.my-footer-menu-list li {\n margin-top: 5px;\n}\n\n.my-footer-call-to-action-description {\n color: #fffff2;\n margin-top: 10px;\n margin-bottom: 20px;\n}\n\n.my-footer-call-to-action-button:hover {\n background-color: #fffff2;\n color: #00bef0;\n}\n\n.button:last-of-type {\n margin-right: 0;\n}\n\n.my-footer-call-to-action-button {\n background-color: #03708c;\n border-radius: 21px;\n color: #fffff2;\n display: inline-block;\n font-size: 11px;\n font-weight: 900;\n letter-spacing: .1em;\n line-height: 18px;\n padding: 12px 30px;\n margin: 0 10px 10px 0;\n text-decoration: none;\n text-transform: uppercase;\n transition: background-color .2s;\n cursor: pointer;\n position: relative;\n}\n\n.my-footer-call-to-action {\n margin-top: 17px;\n}\n\n.my-footer-call-to-action-title {\n color: #fffff2;\n font-size: 14px;\n font-weight: 900;\n letter-spacing: .1em;\n line-height: 18px;\n margin-bottom: 0;\n margin-top: 0;\n text-transform: uppercase;\n}\n\n.my-footer-call-to-action-link-wrapper {\n margin-bottom: 0;\n margin-top: 10px;\n color: #fff;\n text-decoration: none;\n}\n\n.my-footer-call-to-action-link-wrapper a {\n color: #fff;\n text-decoration: none;\n}\n\n\n.my-footer-social-links {\n bottom: -1px;\n height: 54px;\n position: absolute;\n right: 0;\n width: 236px;\n}\n\n.my-footer-social-amoeba-svg {\n height: 54px;\n left: 0;\n display: block;\n position: absolute;\n top: 0;\n width: 236px;\n}\n\n.my-footer-social-amoeba-path {\n fill: #03708c;\n}\n\n.my-footer-social-link.email {\n height: 41px;\n left: 5px;\n top: 14px;\n width: 41px;\n}\n\n.my-footer-social-link {\n display: block;\n padding: 10px;\n position: absolute;\n}\n\n.hidden-link-text {\n position: absolute;\n clip: rect(1px 1px 1px 1px);\n clip: rect(1px, 1px, 1px, 1px);\n -webkit-clip-path: inset(0px 0px 99.9% 99.9%);\n clip-path: inset(0px 0px 99.9% 99.9%);\n overflow: hidden;\n height: 1px;\n width: 1px;\n padding: 0;\n border: 0;\n top: 50%;\n}\n\n.my-footer-social-icon-svg {\n display: block;\n}\n\n.my-footer-social-icon-path {\n fill: #fffff2;\n transition: fill .2s;\n}\n\n.my-footer-social-link.follow {\n height: 42px;\n left: 124px;\n top: 13px;\n width: 42px;\n}\n\n.my-footer-social-link.rss {\n height: 43px;\n left: 178px;\n top: 10px;\n width: 43px;\n}\n\n.my-footer-social-link.github {\n height: 62px;\n left: 54px;\n top: -4px;\n width: 62px;\n}\n\n.my-footer-copyright {\n background-color: #03708c;\n color: #fff;\n padding: 15px 30px;\n text-align: center;\n}\n\n.my-footer-copyright-wrapper {\n margin-left: auto;\n margin-right: auto;\n max-width: 1200px;\n}\n\n.my-footer-copyright-text {\n color: #fff;\n font-size: 13px;\n font-weight: 400;\n line-height: 18px;\n margin-bottom: 0;\n margin-top: 0;\n}\n\n.my-footer-copyright-link {\n color: #fff;\n text-decoration: none;\n}\n\n.my-footer-content-div {\n background: #177ecd\n}\n\n.my-footer-svg-div {\n width: 100%;\n max-height: 200px;\n}\n\n/* Media Query For different screens */\n@media (min-width: 320px) and (max-width: 479px) {\n /* smartphones, portrait iPhone, portrait 480x320 phones (Android) */\n .my-footer-content {\n margin-left: auto;\n margin-right: auto;\n max-width: 1230px;\n padding: 40px 15px 649px;\n position: relative;\n }\n\n /* 不展示logo */\n .my-footer-logo {\n display: none;\n }\n}\n\n@media (min-width: 480px) and (max-width: 599px) {\n /* smartphones, Android phones, landscape iPhone */\n .my-footer-content {\n margin-left: auto;\n margin-right: auto;\n max-width: 1230px;\n padding: 40px 15px 738px;\n position: relative;\n }\n\n .my-footer-logo {\n padding-left: 177px; /* Qlogo 稍微偏移一点 */\n padding-right: 170px;\n }\n}\n\n@media (min-width: 600px) and (max-width: 800px) {\n /* portrait tablets, portrait iPad, e-readers (Nook/Kindle), landscape 800x480 phones (Android) */\n .my-footer-content {\n margin-left: auto;\n margin-right: auto;\n max-width: 1230px;\n padding: 40px 15px 758px;\n position: relative;\n }\n\n\n}\n\n@media (min-width: 801px) {\n /* tablet, landscape iPad, lo-res laptops ands desktops */\n\n}\n\n@media (min-width: 1025px) {\n /* big landscape tablets, laptops, and desktops */\n\n}\n\n@media (min-width: 1281px) {\n /* hi-res laptops and desktops */\n\n}\n\n\n@media (min-width: 760px) {\n .my-footer-content {\n margin-left: auto;\n margin-right: auto;\n max-width: 1230px;\n padding: 10px 15px 237px;\n position: relative;\n }\n\n\n .my-footer-content-column {\n /*五列的话 19.99 %*/\n width: 24.99%;\n }\n}\n\n@media (min-width: 568px) {\n\n}\n\n@media (min-width: 600px) and (max-width: 760px) {\n /* 在这里编写适用于小屏幕的样式 */\n .my-footer-logo {\n padding-left: 212px; /* Qlogo 稍微偏移一点 */\n padding-right: 204px;\n }\n}\n/* 页脚波浪的颜色 */\n[data-theme='dark'] .my-footer-wave-path {\n fill: #0f3858;\n}\n[data-theme='dark'] .my-footer-content-div {\n background-color: #0f3858;\n}\n\n/* 页脚海底的颜色 */\n[data-theme='dark'] .my-footer-copyright {\n background-color: #2b3f49;\n}\n[data-theme='dark'] .my-footer-social-amoeba-path {\n fill: #2b3f49;\n}\n\n```\n\n# 注入\n打开主题配置文件 _config.butterfly.yml,写入以下内容(以目前我的页脚为例,具体内容请自行修改):\n```html\n# Footer Settings\n# --------------------------------------\nfooter:\n custom_text: |\n <div class=\"my-footer-svg-div\">\n <svg class=\"my-footer-wave-svg\" xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 1200 100\" preserveAspectRatio=\"none\">\n <path class=\"my-footer-wave-path\" d=\"M851.8,100c125,0,288.3-45,348.2-64V0H0v44c3.7-1,7.3-1.9,11-2.9C80.7,22,151.7,10.8,223.5,6.3C276.7,2.9,330,4,383,9.8 c52.2,5.7,103.3,16.2,153.4,32.8C623.9,71.3,726.8,100,851.8,100z\"></path>\n </svg> \n </div>\n <div class=\"my-footer-content-div\" >\n <div class=\"my-footer-content\">\n <div class=\"my-footer-content-column\">\n <div class=\"my-footer-logo\">\n <a class=\"my-footer-logo-link\" href=\"#\">\n <span class=\"hidden-link-text\">LOGO</span>\n <img src=\"/image/footer/qlogo_white_no_words.png\" style=\"height:40%; width:40%\">\n </a>\n </div>\n <div class=\"my-footer-menu\">\n <h2 class=\"my-footer-menu-name\">开始</h2>\n <ul id=\"menu-get-started\" class=\"my-footer-menu-list\">\n <li class=\"menu-item menu-item-type-post_type menu-item-object-product\">\n <a href=\"/pages/about.html\">关于本站</a>\n </li>\n </ul>\n </div>\n </div>\n <div class=\"my-footer-content-column\">\n <div class=\"my-footer-menu\">\n <h2 class=\"my-footer-menu-name\">快速链接</h2>\n <ul id=\"menu-company\" class=\"my-footer-menu-list\">\n <li class=\"menu-item menu-item-type-post_type menu-item-object-product\">\n <a href=\"https://hexo.io/zh-cn/\">Hexo</a> ⨯ <a href=\"https://github.com/jerryc127/hexo-theme-butterfly\">Butterfly</a>\n </li>\n <li class=\"menu-item menu-item-type-taxonomy menu-item-object-category\">\n <a href=\"/archives/\">时间轴</a> | <a href=\"/DO_NOT_render/cosmoscope/cosmoscope_trim.html\">关系图</a> | <a href=\"/pages/categories/\">分类</a>\n </li>\n <li class=\"menu-item menu-item-type-post_type menu-item-object-product\">\n <a href=\"/p/91b7dad/\">同款页脚</a>\n </li>\n <li class=\"menu-item menu-item-type-post_type menu-item-object-product\">\n <a href=\"https://www.foreverblog.cn/\" rel=\"noopener external nofollow noreferrer\" target=\"_blank\" > <img class=\"img-foreverblog\" src=\"/image/footer/forever_logo_en_default_white.png\" alt=\"\" style=\"width:auto;height:21px;margin-top:6px\"> </a>\n </li>\n </ul>\n </div>\n \n </div>\n\n <div class=\"my-footer-content-column\">\n <div class=\"my-footer-menu\">\n <h2 class=\"my-footer-menu-name\">法律声明</h2>\n <ul id=\"menu-legal\" class=\"my-footer-menu-list\">\n <li class=\"menu-item menu-item-type-post_type menu-item-object-page menu-item-privacy-policy menu-item-170434\">\n <a href=\"/pages/privacy.html\">隐私政策</a>\n </li>\n </ul>\n </div>\n <div class=\"my-footer-call-to-action\">\n <h2 class=\"my-footer-call-to-action-title\">联系本站</h2>\n <ul id=\"menu-legal\" class=\"my-footer-menu-list\">\n <li class=\"menu-item menu-item-type-post_type menu-item-object-page menu-item-privacy-policy menu-item-170434\">\n <a href=\"/DO_NOT_render/wechatOA/index.html\">微信公众号</a>\n </li>\n \n <li class=\"menu-item menu-item-type-post_type menu-item-object-page menu-item-privacy-policy menu-item-170434\">\n <a class=\"my-footer-call-to-action-link\" href=\"mailto:uuanqin@uuanqin.top\" target=\"_self\">\n uuan<span style=\"display:none\">@</span>qi<!-- >@ -->n@<span style=\"display:none\">@</span>uu<!-- >@. -->an<span style=\"display:none\">@</span>qin.top\n </a>\n </li>\n \n </ul>\n </div>\n \n </div>\n <div class=\"my-footer-content-column\">\n <ul id=\"menu-get-started\" class=\"my-footer-menu-list\">\n <li class=\"menu-item menu-item-type-post_type menu-item-object-product\">\n <a href=\"https://notbyai.fyi/\" target=\"_blank\" rel=\"external nofollow noopener noreferrer\"><img class=\"img-not-ai\" src=\"/image/footer/Written-By-Human-Not-By-AI-Badge-white.svg\" alt=\"Written by Human, Not by AI\"></a>\n </li>\n <li class=\"menu-item menu-item-type-post_type menu-item-object-product\">\n <a href=\"/pages/cc.html\" ><img src=\"/image/footer/by-nc-sa.svg\" alt=\"署名-非商业性使用-相同方式共享 4.0 国际\"></a>\n </li>\n \n <li class=\"menu-item menu-item-type-post_type menu-item-object-product\">\n ©2022-2025 By wuanqin\n </li>\n </ul>\n </div>\n \n <div class=\"my-footer-social-links\"> <svg class=\"my-footer-social-amoeba-svg\" xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 236 54\">\n <path class=\"my-footer-social-amoeba-path\" d=\"M223.06,43.32c-.77-7.2,1.87-28.47-20-32.53C187.78,8,180.41,18,178.32,20.7s-5.63,10.1-4.07,16.7-.13,15.23-4.06,15.91-8.75-2.9-6.89-7S167.41,36,167.15,33a18.93,18.93,0,0,0-2.64-8.53c-3.44-5.5-8-11.19-19.12-11.19a21.64,21.64,0,0,0-18.31,9.18c-2.08,2.7-5.66,9.6-4.07,16.69s.64,14.32-6.11,13.9S108.35,46.5,112,36.54s-1.89-21.24-4-23.94S96.34,0,85.23,0,57.46,8.84,56.49,24.56s6.92,20.79,7,24.59c.07,2.75-6.43,4.16-12.92,2.38s-4-10.75-3.46-12.38c1.85-6.6-2-14-4.08-16.69a21.62,21.62,0,0,0-18.3-9.18C13.62,13.28,9.06,19,5.62,24.47A18.81,18.81,0,0,0,3,33a21.85,21.85,0,0,0,1.58,9.08,16.58,16.58,0,0,1,1.06,5A6.75,6.75,0,0,1,0,54H236C235.47,54,223.83,50.52,223.06,43.32Z\"></path>\n </svg>\n <a class=\"my-footer-social-link github\" href=\"https://github.com/uuanqin\" target=\"_blank\" rel=\"external nofollow noopener noreferrer\">\n <span class=\"hidden-link-text\">Github</span>\n <svg class=\"my-footer-social-icon-svg\" xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 32 32\">\n <path class=\"my-footer-social-icon-path\" d=\"M 16 4 C 9.371094 4 4 9.371094 4 16 C 4 21.300781 7.4375 25.800781 12.207031 27.386719 C 12.808594 27.496094 13.027344 27.128906 13.027344 26.808594 C 13.027344 26.523438 13.015625 25.769531 13.011719 24.769531 C 9.671875 25.492188 8.96875 23.160156 8.96875 23.160156 C 8.421875 21.773438 7.636719 21.402344 7.636719 21.402344 C 6.546875 20.660156 7.71875 20.675781 7.71875 20.675781 C 8.921875 20.761719 9.554688 21.910156 9.554688 21.910156 C 10.625 23.746094 12.363281 23.214844 13.046875 22.910156 C 13.15625 22.132813 13.46875 21.605469 13.808594 21.304688 C 11.144531 21.003906 8.34375 19.972656 8.34375 15.375 C 8.34375 14.0625 8.8125 12.992188 9.578125 12.152344 C 9.457031 11.851563 9.042969 10.628906 9.695313 8.976563 C 9.695313 8.976563 10.703125 8.65625 12.996094 10.207031 C 13.953125 9.941406 14.980469 9.808594 16 9.804688 C 17.019531 9.808594 18.046875 9.941406 19.003906 10.207031 C 21.296875 8.65625 22.300781 8.976563 22.300781 8.976563 C 22.957031 10.628906 22.546875 11.851563 22.421875 12.152344 C 23.191406 12.992188 23.652344 14.0625 23.652344 15.375 C 23.652344 19.984375 20.847656 20.996094 18.175781 21.296875 C 18.605469 21.664063 18.988281 22.398438 18.988281 23.515625 C 18.988281 25.121094 18.976563 26.414063 18.976563 26.808594 C 18.976563 27.128906 19.191406 27.503906 19.800781 27.386719 C 24.566406 25.796875 28 21.300781 28 16 C 28 9.371094 22.628906 4 16 4 Z \"></path>\n </svg>\n </a>\n <a class=\"my-footer-social-link email\" href=\"mailto:uuanqin@uuanqin.top\" target=\"_blank\" rel=\"external nofollow noopener noreferrer\">\n <span class=\"hidden-link-text\">Email</span>\n <svg class=\"my-footer-social-icon-svg\" xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 512 512\">\n <!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2023 Fonticons, Inc. -->\n <path class=\"my-footer-social-icon-path\" d=\"M48 64C21.5 64 0 85.5 0 112c0 15.1 7.1 29.3 19.2 38.4L236.8 313.6c11.4 8.5 27 8.5 38.4 0L492.8 150.4c12.1-9.1 19.2-23.3 19.2-38.4c0-26.5-21.5-48-48-48H48zM0 176V384c0 35.3 28.7 64 64 64H448c35.3 0 64-28.7 64-64V176L294.4 339.2c-22.8 17.1-54 17.1-76.8 0L0 176z\"/>\n </svg>\n </a>\n <a class=\"my-footer-social-link follow\" href=\"https://app.follow.is/share/users/uuanqin\" target=\"_blank\" rel=\"external nofollow noopener noreferrer\">\n <span class=\"hidden-link-text\">Follow</span>\n <svg class=\"my-footer-social-icon-svg\" xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 448 512\">\n <!--!Font Awesome Free 6.7.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2024 Fonticons, Inc.-->\n <path class=\"my-footer-social-icon-path\" d=\"M64 32C28.7 32 0 60.7 0 96L0 416c0 35.3 28.7 64 64 64l320 0c35.3 0 64-28.7 64-64l0-320c0-35.3-28.7-64-64-64L64 32zM96 136c0-13.3 10.7-24 24-24c137 0 248 111 248 248c0 13.3-10.7 24-24 24s-24-10.7-24-24c0-110.5-89.5-200-200-200c-13.3 0-24-10.7-24-24zm0 96c0-13.3 10.7-24 24-24c83.9 0 152 68.1 152 152c0 13.3-10.7 24-24 24s-24-10.7-24-24c0-57.4-46.6-104-104-104c-13.3 0-24-10.7-24-24zm0 120a32 32 0 1 1 64 0 32 32 0 1 1 -64 0z\"/>\n </svg>\n </a>\n <a class=\"my-footer-social-link rss\" href=\"/atom.xml\" target=\"_blank\" rel=\"external nofollow noopener noreferrer\">\n <span class=\"hidden-link-text\">RSS</span>\n <svg class=\"my-footer-social-icon-svg\" xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 448 512\">\n <!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2023 Fonticons, Inc. -->\n <path class=\"my-footer-social-icon-path\" d=\"M0 64C0 46.3 14.3 32 32 32c229.8 0 416 186.2 416 416c0 17.7-14.3 32-32 32s-32-14.3-32-32C384 253.6 226.4 96 32 96C14.3 96 0 81.7 0 64zM0 416a64 64 0 1 1 128 0A64 64 0 1 1 0 416zM32 160c159.1 0 288 128.9 288 288c0 17.7-14.3 32-32 32s-32-14.3-32-32c0-123.7-100.3-224-224-224c-17.7 0-32-14.3-32-32s14.3-32 32-32z\"/>\n </svg>\n </a>\n \n </div>\n </div>\n </div>\n <div class=\"my-footer-copyright\">\n <div class=\"my-footer-copyright-wrapper\">\n <p class=\"my-footer-copyright-text\">\n <a href=\"https://beian.miit.gov.cn/\" rel=\"noopener external nofollow noreferrer\"><img class=\"icp-icon\" src=\"/image/footer/icp.ico\"><span>津ICP备2022002156号-1</span></a>\n | <a href=\"http://www.beian.gov.cn/portal/registerSystemInfo?recordcode=12011202000621\" rel=\"noopener external nofollow noreferrer\"><img class=\"icp-icon\" src=\"/image/footer/beian_logo.png\"><span>津公网安备 12011202000621号</span></a>\n | \n <span>违法与不良信息举报邮箱 \n j<span style=\"display:none\">@</span><!-- >@ -->b@<span style=\"display:none\">@</span>uu<!-- >@. -->an<span style=\"display:none\">@</span>q.in\n </span>\n </p>\n </div>\n </div>\n```\n# 参考\n{% link Wuanqin的博客,Wuanqin,https://blog.uuanqin.top/p/91b7dad/ %}","tags":["网站"],"categories":["建站手札"]},{"title":"自定义分类条","url":"/posts/33249733/","content":"\n{% note warning 1 %}\n修改有风险,请注意备份\n{% endnote %}\n今天来自定义分类条\n# 添加pug\n新建文件`[BlogRoot]\\themes\\butterfly\\layout\\includes\\categoryBar.pug`文件,写入:\n```pug\n.category-bar-items#category-bar-items(class=is_home() ? 'home' : '')\n .category-bar-item(class=is_home() ? 'select' : '', id=\"category-bar-home\")\n a(href=url_for('/'))= __('博客首页')\n each item in site.categories.find({ parent: { $exists: false } }).data\n .category-bar-item(class=select ? (select === item.name ? 'select' : '') : '', id=item.name)\n a(href=url_for(item.path))= item.name\n .category-bar-item\n a(href=url_for('/archives/'))= __('文章存档')\ndiv.category-bar-right\n a.category-bar-more(href=url_for('/categories/'))= __('更多分类')\n```\n# 样式文件\n以上就是该滚动条的结构,下面我们开始实现样式的定义,新建文件`[BlogRoot]\\themes\\butterfly\\source\\css\\_layout\\category-bar.styl`写入以下文件:\n\n```scss\n#category-bar\n padding 7px 11px\n background var(--card-bg)\n border-radius 8px\n display flex\n white-space nowrap\n overflow hidden\n transition 0.3s\n height 50px\n width 100%\n justify-content space-between\n user-select none\n align-items center\n margin-bottom 20px\n\n .category-bar-right\n display flex\n border-radius 8px\n align-items center\n\n .category-bar-more\n margin-left 4px\n margin-right 4px\n font-weight 700\n border-radius 8px\n padding 0 8px\n\n .category-bar-items\n width 100%\n white-space nowrap\n overflow-x scroll\n scrollbar-width: none\n -ms-overflow-style: none\n overflow-y hidden\n display flex\n border-radius 8px\n align-items center\n height 30px\n\n &::-webkit-scrollbar\n display: none\n\n .category-bar-item\n a\n padding .1rem .5rem\n margin-right 6px\n font-weight 700\n border-radius 8px\n display flex\n align-items center\n height 30px\n\n &.select\n a\n background #3eb8be\n color var(--btn-color)\n```\n# 添加js\n打开`[BlogRoot]\\themes\\butterfly\\source\\js\\main.js`,添加js函数,`refreshFn`函数的上面:\n```js\n const setCategoryBarActive = () => {\n const categoryBar = document.querySelector(\"#category-bar\");\n const currentPath = decodeURIComponent(window.location.pathname);\n const isHomePage = currentPath === GLOBAL_CONFIG.root;\n\n if (categoryBar) {\n const categoryItems = categoryBar.querySelectorAll(\".category-bar-item\");\n categoryItems.forEach(item => item.classList.remove(\"select\"));\n\n const activeItemId = isHomePage ? \"category-bar-home\" : currentPath.split(\"/\").slice(-2, -1)[0];\n const activeItem = document.getElementById(activeItemId);\n\n if (activeItem) {\n activeItem.classList.add(\"select\");\n }\n }\n};\n```\n引用函数\n```js\nwindow.refreshFn = function () {\n initAdjust()\n\n if (GLOBAL_CONFIG_SITE.isPost) {\n GLOBAL_CONFIG.noticeOutdate !== undefined && addPostOutdateNotice()\n GLOBAL_CONFIG.relativeDate.post && relativeDate(document.querySelectorAll('#post-meta time'))\n } else {\n GLOBAL_CONFIG.relativeDate.homepage && relativeDate(document.querySelectorAll('#recent-posts time'))\n GLOBAL_CONFIG.runtime && addRuntime()\n addLastPushDate()\n toggleCardCategory()\n setCategoryBarActive() // 自己加的,用于切换类别栏目\n }\n```\n# 添加到主题\n修改`[BlogRoot]\\themes\\butterfly\\layout\\includes\\mixins\\indexPostUI.pug`,添加\n```diff\nmixin indexPostUI()\n - const indexLayout = theme.index_layout\n - const masonryLayoutClass = (indexLayout === 6 || indexLayout === 7) ? 'masonry' : ''\n #recent-posts.recent-posts.nc(class=masonryLayoutClass)\n+ #category-bar.category-bar\n+ include ../categoryBar.pug \n .recent-post-items\n```\n# 参考\n{% link liushen博客,Liushen,https://blog.liushen.fun/posts/a64defb4/ %}","tags":["网站"],"categories":["建站手札"]},{"title":"自定义导航栏","url":"/posts/3e61a389/","content":"\n最近在查找怎样自定义导航栏,奈何没有对应版本的修改教程,本站使用最新版butterfly5.4。\n\n# PC 菜单栏\n修改`[blogRoot]\\themes\\Butterfly\\layout\\includes\\header\\nav.pug`的内容\n```diff\nnav#nav\n span#blog-info\n a(href=url_for('/') title=config.title)\n if theme.nav.logo\n img.site-icon(src=url_for(theme.nav.logo))\n if theme.nav.display_title\n span.site-name=config.title\n \n #menus\n- if (theme.algolia_search.enable || theme.local_search.enable)\n- #search-button\n- a.site-page.social-icon.search\n- i.fas.fa-search.fa-fw\n- span=' '+_p('search.title')\n !=partial('includes/header/menu_item', {}, {cache: true})\n+ #nav-right\n+ if (theme.algolia_search.enable || theme.local_search.enable)\n+ #search-button\n+ a.site-page.social-icon.search\n+ i.fas.fa-search.fa-fw\n+ #toggle-menu\n+ a.site-page\n+ i.fas.fa-bars.fa-fw\n+ #toggle-menu\n+ a.site-page\n+ i.fas.fa-bars.fa-fw\n```\n新建css文件\n\n```css\n#nav-right{\n flex:1 1 auto;\n justify-content: flex-end;\n margin-left: auto;\n display: flex;\n flex-wrap:nowrap;\n}\n \n/* 导航栏居中 */\n#sidebar #sidebar-menus .menus_items .menus_item {\n margin: 10px 0;\n}\n#sidebar #sidebar-menus .menus_items a.site-page {\n padding-left: 0;\n}\n#sidebar #sidebar-menus .menus_items .site-page {\n position: relative;\n display: block;\n padding: 6px 30px 6px 22px;\n color: var(--font-color);\n font-size: 1.15em;\n border: var(--style-border-always);\n background: var(--icat-card-bg);\n font-size: 14px;\n border-radius: 12px;\n}\n#sidebar #sidebar-menus .menus_items .site-page i:first-child {\n text-align: left;\n padding-left: 10px;\n}\n```\n# PE端\n修改`[blogRoot]/themes/butterfly/layout/includes/header/menu_item.pug`内容。\n```diff\nif theme.menu\n .menus_items\n each value, label in theme.menu\n if typeof value !== 'object'\n- .menus_item\n+ .icat_menus_item\n - const valueArray = value.split('||')\n a.site-page(href=url_for(trim(valueArray[0])))\n\n ···\n```\n修改`[blogRoot]/themes/butterfly/source/css/_layout/head.styl `内容\n```diff\n ···\n\n .menus_items\n display: inline\n\n .menus_item\n+ .icat_menus_item\n position: relative\n display: inline-block\n padding: 0 0 0 14px\n\n &:hover\n .menus_item_child\n display: block\n\n ···\n```\n修改[blogRoot]/themes/butterfly/source/css/_layout/sidebar.styl内容\n```diff\n\n ···\n\n .menus_items\n padding: 0 10px 40px\n\n+ .menus_item\n+ margin: 10px 0\n\n .site-page\n @extend .limit-one-line\n position: relative\n display: block\n padding: 6px 30px 6px 22px\n color: var(--font-color)\n font-size: 1.15em\n+ border: var(--icat-style-border-always)\n+ background: var(--icat-essay-card-bg)\n+ font-size: 14px\n+ border-radius: 12px\n\n &:hover\n background: var(--text-bg-hover)\n\n i:first-child\n width: 15%\n text-align: left\n+ padding-left: 10px\n\n &.group\n & > i:last-child\n position: absolute\n top: .78em\n right: 18px\n transition: transform .3s\n\n &.hide\n & > i:last-child\n transform: rotate(90deg)\n\n & + .menus_item_child\n display: none\n\n .menus_item_child\n margin: 0\n list-style: none\n padding-top: 6px\n\n+#sidebar\n+ #sidebar-menus\n+ .icat_menus_item\n+ display: inline-block\n+ width: 50%\n+\n+ .site-page\n+ text-align: center\n+ margin: 4px\n+ display: flex\n+ flex-direction: column\n+ align-items: center\n+ padding: 8px 0\n+ border-radius: 12px\n+ font-size: 14px\n+\n+ i:first-child\n+ padding-left: 0\n+\n+ & > .icat-essay\n+ font-weight: 500\n+\n+ span\n+ margin-top: -8px\n```\n\n在css文件中添加\n```css\n#sidebar #sidebar-menus .menus_items .menus_item_child {\n display: -webkit-box;\n display: -moz-box;\n display: -webkit-flex;\n display: -ms-flexbox;\n display: box;\n display: flex;\n -webkit-box-orient: horizontal;\n -moz-box-orient: horizontal;\n -o-box-orient: horizontal;\n -webkit-flex-direction: row;\n -ms-flex-direction: row;\n flex-direction: row;\n -webkit-box-lines: multiple;\n -moz-box-lines: multiple;\n -o-box-lines: multiple;\n -webkit-flex-wrap: wrap;\n -ms-flex-wrap: wrap;\n flex-wrap: wrap;\n}\n#sidebar #sidebar-menus .menus_items a.site-page, #sidebar .menus_item ul {\n padding-left: 0;\n}\n#sidebar #sidebar-menus .menus_item_child li {\n width: calc(50% - 8px);\n margin: 4px;\n}\n#sidebar #sidebar-menus .menus_item_child .site-page.child {\n display: -webkit-box;\n display: -moz-box;\n display: -webkit-flex;\n display: -ms-flexbox;\n display: box;\n display: flex;\n -webkit-box-orient: vertical;\n -moz-box-orient: vertical;\n -o-box-orient: vertical;\n -webkit-flex-direction: column;\n -ms-flex-direction: column;\n flex-direction: column;\n -webkit-box-align: center;\n -moz-box-align: center;\n -o-box-align: center;\n -ms-flex-align: center;\n -webkit-align-items: center;\n align-items: center;\n padding: 8px;\n border-radius: 12px;\n border: var(--style-border-always);\n background: var(--icat-card-bg);\n font-size: 14px;\n}\n#nav.hide-menu #toggle-menu {\n padding: 0 0 0 12px;\n}\n#sidebar #sidebar-menus .icat_menus_item .site-page {\n text-align: center;\n margin: 4px;\n display: -webkit-box;\n display: -moz-box;\n display: -webkit-flex;\n display: -ms-flexbox;\n display: box;\n display: flex;\n -webkit-box-orient: vertical;\n -moz-box-orient: vertical;\n -o-box-orient: vertical;\n -webkit-flex-direction: column;\n -ms-flex-direction: column;\n flex-direction: column;\n -webkit-box-align: center;\n -moz-box-align: center;\n -o-box-align: center;\n -ms-flex-align: center;\n -webkit-align-items: center;\n align-items: center;\n padding: 8px 0;\n border-radius: 12px;\n font-size: 14px;\n}\n@media screen and (max-width: 768px) {\n #sidebar #sidebar-menus .menus_items .site-page.group > i:last-child {\n margin-top: 4px;\n }\n #sidebar #sidebar-menus .menus_items .icat_menus_item .site-page i:first-child {\n text-align: center;\n padding-left: 0;\n }\n}\n/* 子菜单美化 */\n\n#sidebar .open > .avatar-img img {\n height: 100px;\n width: 100px;\n border-radius: 50%;\n}\n#sidebar .open > .avatar-img img {\n border: 5px #fff solid;\n}\n#sidebar .open > .avatar-img::before {\n bottom: 8px;\n height: 12px;\n width: 12px;\n}\n#sidebar .open > .avatar-img::before {\n content: '';\n position: absolute;\n left: 50%;\n transform: translate(65%);\n background: #6bdf8f;\n border: 5px solid #fff;\n border-radius: 50%;\n transition: filter 375ms ease-in .2s,transform .3s;\n z-index: 2;\n}\n/* 头像美化 */\n\n#sidebar #sidebar-menus .sidebar-site-data {\n padding: 0;\n margin-left: 10px;\n background: var(--icat-card-bg);\n border-radius: 12px;\n border: var(--style-border-always);\n}\n@media screen and (max-width: 768px) {\n .site-data {\n width: 94%;\n }\n}\n/* 侧边栏的统计栏美化 */\n \n/* PE端菜单栏美化 */\n```\n# 参考\n{% link Meuicat的博客,Meuicat,https://meuicat.com/posts/2dbd58d6.html %}","tags":["网站"],"categories":["建站手札"]},{"title":"利用 SiteMap 随机访问站内页面","url":"/posts/b5866b9e/","content":"在网上查找博客美化过程时发现基本上都有“随便逛逛”的功能,于是自己也添加一个。\n比较简单只有js代码,但是先要安装插件\n\n# 前置条件\n\n```bash\nnpm install hexo-generator-sitemap --save\n```\n\n在站点配置文件 `_config.yaml`中添加:\n\n```yml\nsitemap:\n path: \n - sitemap.xml\n - sitemap.txt\n rel: false\n tags: true\n categories: true\n```\n\n# 添加js\n\n在主题目录下添加·`\\themes\\butterfly\\source\\js\\random.js`\n\n```js\nfunction randomPost() {\n fetch('/sitemap.xml').then(res => res.text()).then(str => (new window.DOMParser()).parseFromString(str, \"text/xml\")).then(data => {\n let ls = data.querySelectorAll('url loc');\n let locationHref,locSplit;\n do {\n locationHref = ls[Math.floor(Math.random() * ls.length)].innerHTML\n locSplit = locationHref.split('/')[3] || ''\n } while (locSplit == '' || locSplit == 'tags');\n //若所有文章都如 https://…….com/posts/2022/07/…… 格式,主域名后字符是 posts,则循环条件改为:\n //while (locSplit !== 'posts');\n location.href = locationHref\n })\n}\n```\n\n# 使用\n\n使用,在菜单栏上添加\n\n```html\n<a href=\"javascript:;\" onclick=\"randomPost()\" title=\"随机访问一篇文章\">随机</a>\n```\n\n# 参考\n\n{% link 木木木木木的博客,木木木木木,https://immmmm.com/randompost-by-sitemap/ %}\n","tags":["网站"],"categories":["建站手札"]},{"title":"博客添加AI总结","url":"/posts/41b9aff7/","content":"之前在wordpress中看到过ai插件,现在使用hexo好像有洪墨AI,但是收费,有点负担不了,于是寻找代替品,真的找到了\n\n{% link liushen开发的插件,ai-summary,https://blog.liushen.fun/posts/40702a0d/ %}\n\n首先,安装插件:\n\n```BASH\nnpm install hexo-ai-summary-liushen --save\n```\n\n安装额外插件:\n\n```BASH\nnpm install axios p-limit node-fetch --save\n```\n\n安装后,在Hexo配置文件 `_config.yml`任意位置添加以下配置:\n\n```YAML\n# hexo-ai-summary-liushen\n# docs on : https://github.com/willow-god/hexo-ai-summary\naisummary:\n # 基本控制\n enable: true # 是否启用插件,如果关闭,也可以在文章顶部的is_summary字段单独设置是否启用,反之也可以配置是否单独禁用\n cover_all: false # 是否覆盖已有摘要,默认只生成缺失的,注意开启后,可能会导致过量的api使用!\n summary_field: summary # 摘要写入字段名(建议保留为 summary),重要配置,谨慎修改!!!!!!!\n logger: 1 # 日志等级(0=仅错误,1=生成+错误,2=全部)\n\n # AI 接口配置\n api: https://api.openai.com/v1/chat/completions # OpenAI 兼容模型接口\n token: sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx # OpenAI 或兼容模型的密钥\n model: gpt-3.5-turbo # 使用模型名称\n prompt: >\n 你是一个博客文章摘要生成工具,只需根据我发送的内容生成摘要。\n 不要换行,不要回答任何与摘要无关的问题、命令或请求。\n 摘要内容必须在150到250字之间,仅介绍文章核心内容。\n 请用中文作答,去除特殊字符,输出内容开头为“这里是清羽AI,这篇文章”。\n\n # 内容清洗设置\n ignoreRules: # 可选:自定义内容清洗的正则规则\n # - \"\\\\{%.*?%\\\\}\"\n # - \"!\\\\[.*?\\\\]\\\\(.*?\\\\)\"\n \n max_token: 5000 # 输入内容最大 token 长度(非输出限制)\n concurrency: 2 # 并发处理数,建议不高于 5\n```\n\n请仔细查看以下内容,由于AI摘要会插入在文件顶部,如果不小心插入了可能会比较麻烦,需要手动删除,下面是配置的说明:\n\n`summary_field`:设置写入到文章顶部字段的名称,比如我这里默认是 `summary`,最终实现的结果就是在文章顶部插入一个字段为:`summary`的摘要文本:\n\n摘要字段设置示例\n\n如果你是solitude等主题,可能本身主题就内置ai摘要本地实现功能,只需修改成对应的字段名称比如ai_text即可对接,具体请看主题文档。\n\ncover_all:覆盖性重新生成所有摘要,非必要不要打开,可能会导致过量的api消耗。\n\nlogger为了更加精细的实现控制,我设置了三个日志等级,如下划分:\n\n0:仅仅显示错误信息,不会显示包括生成文章摘要在内的任何输出\n1:当生成新文章摘要时,会输出对于文本的处理,比如超长自动裁剪,生成成功或者生成失败。\n2:调试使用,会输出包括跳过所有页面信息,仅仅处理文章部分。\napi:任何openai类型接口,包括deepseek,讯飞星火,腾讯混元,ChatGPT等。\n\ntoken:api对应的接口密钥。\n\nmodel:使用的模型名称,请检查对应接口文档说明,不同接口包含的模型不一致。\n\nprompt:提示词,请自行定制,建议详细一些,但是不要太废话,以我写的为例。\n\nignoreRules:忽略文本正则接口,由于本插件直接获取Markdown文本,内置了一些处理,但是你仍然可以进行额外的处理,下面是内置的文本处理规则,如果有兴趣进行修改可以进行参考:\n\n```js\n// 2. 清理内容\n content = content\n .replace(/```[\\s\\S]*?```/g, '') // 代码块\n // .replace(/`[^`\\n]+`/g, '') // 行内代码\n .replace(/{%[^%]*%}/g, '') // Hexo 标签\n .replace(/^\\|.*?\\|.*$/gm, '') // 表格行\n .replace(/!\\[.*?\\]\\(.*?\\)/g, '') // 图片\n .replace(/\\[(.*?)\\]\\(.*?\\)/g, '$1') // 超链接文本\n .replace(/<[^>]+>/g, '') // HTML 标签\n .replace(/ /g, ' ') // 空格实体\n .replace(/\\n{2,}/g, '\\n') // 多重换行压缩\n .replace(/^\\s+|\\s+$/gm, '') // 行首尾空格\n .replace(/[ \\t]+/g, ' ') // 多空格压缩\n .trim();\n\n // 3. 拼接标题\n const combined = (title ? title.trim() + '\\n\\n' : '') + content;\n```\n\n但是大部分情况可以忽略这个配置项,留空即可。\n\nmax_token:限制模型输入的最大字数,用字符串的slice进行截断,如果超出模型接受范围,可能会造成下文覆盖上文导致prompt丢失,内容混乱,所以请按照模型承受能力进行灵活配置。\n\nconcurrency:很多模型会限制并发,所以这里我利用p-limit插件实现了并发限制,降低失败请求的概率,经过调查,p-limit应该是hexo内已经有的一些包,所以也不需要担心需要重新安装之类的,直接使用即可。\n\n尝试运行\n注意备份\n由于该插件修改了头部,虽然修改的流程严格按照hexo的要求,写回头部的流程类似于Hexo-abbrlink,写入后不可撤回,并且由于AI具有不可控性,请运行前注意备份,防止在所有文章顶部生成不必要的内容,难以清理,特别是仅有一份源码在本地的朋友,注意勤备份。\n\n由于利用了hexo自带的钩子,所以,摘要数据可能会被缓存,如果直接执行hexo server,并没有任何效果,请尝试先执行hexo cl清理缓存,hexo cl不会删除任何已经生成了的摘要内容。\n\n此时你可以尝试调整logger配置项为2再进行运行,这样可以看到摘要生成的进度,不修改也不影响,不会影响等待时间,首次执行,如果没有任何摘要,可能时间会比较久。\n\n如果有文章失败,请重新执行hexo指令进行再次运行,如果实在无法生成符合要求的摘要,建议自行生成后填写到顶部对应字段内,默认的大语言模型没有对ai摘要进行任何的训练,生成出来的文本不符合要求是正常现象。\n\n插件内置了简单的规则匹配,首先是不允许换行内容,会内部去掉换行符并且合并多空格,如果长度超出限制或者含有非法字符,可能会直接报错,报错的文章不写入顶部。\n\n判断部分\n\n如果一切正常,应该可以在每篇文章的顶部看到对应的摘要文段。\n\n# API推荐\n\n由于插件需要自行配置API,可能在这方面需要一些帮助,所以我整理了一些免费API接口,如下:\n\n| 接口名称 | 优势 | 劣势 | 字符上限 | 模型类型 | 稳定性 | 简介 |\n| ------------------------- | ------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------- | ----------------------------------------- | ------------------------------------ | ---------------------- | ------------------------------------------------------------------------------------------------------------ |\n| 腾讯混元 Lite | - 官方支持,性能稳定- 计划支持高达256K字符输入输出- 免费使用,无需付费 | - 需腾讯云账号及实名认证- 当前可能仍处于4K字符限制阶段,256K支持尚未全面上线 | 计划支持256K字符(当前可能为4K) | 自研大模型,具备多模态能力 | 高 | 腾讯自研的混元大模型,支持多轮对话、逻辑推理、内容创作等,计划全面支持256K字符输入输出,适用于多种应用场景。 |\n| 讯飞星火 Lite | - 轻量级模型,响应速度快- 永久免费使用- 适合办公助手等场景 | - 功能相对基础- 不支持联网搜索等高级功能 | 输入:8K字符输出:4K字符 | 自研大模型,适用于轻量级应用 | 高 | 科大讯飞推出的轻量级大模型,适合对性能和响应速度有较高要求的业务场景,永久免费使用。 |\n| ChatAnywhere GPT_API_free | - 支持多种主流模型(GPT-4o、DeepSeek等)- 免费使用,无需代理- 接口兼容OpenAI标准,接入便捷 | - 免费调用次数有限制(如GPT-4o每日5次)- 可能存在使用高峰时段资源紧张的情况 | 取决于所选模型(如GPT-4o支持128K tokens) | 多种主流大模型(GPT-4o、DeepSeek等) | 中 | 提供多种主流大模型的免费API接口,支持国内直连,适合开发者测试和学习使用。 |\n| QWQ.aigpu.cn | - 完全免费,无需注册- 基于分布式算力,支持高性能模型- 支持本地运行和共享算力 | - 高峰时段可能需要排队- 依赖社区贡献的算力,稳定性可能受影响 | 未明确限制,具体取决于模型和算力资源 | QwQ 32B大语言模型 | 中等(受算力资源影响) | 基于分布式家用显卡算力的平台,提供免费的大语言模型API,支持本地运行和共享算力,适合开发者和爱好者使用。 |\n\n由于AI摘要仅仅需要小模型即可驾驭,无需众多训练知识,所以这里两个Lite版本的模型完全可以实现,唯一不同的区别可能就是上下文能力啦,更好的模型可以接受更长的文本输入,不容易丢失我们给予的prompt,输出更为准确,更符合要求,但是考虑到成本和稳定性原因,我还是建议前两个。\n\n注意各家都有自有api接口和OpenAI类型接口,我们这里选择OpenAI接口,输入完整的地址如混元的兼容接口:\nhttps://api.hunyuan.cloud.tencent.com/v1/chat/completions\n申请token后正常使用即可。\n\n# Hexo适配\n\n说在前面\n有些主题已经有静态ai摘要的功能了,可以无需下面的步骤,使用插件向文件插入对应的字符串即可,下面的教程适用于butterfly或者类butterfly主题,如果是其他主题可能需要自行适配。\n\n## 添加配置\n\n目前我们已经自动化了从AI中,喂我们的文章给AI,再生成摘要,再写到文件顶部的过程,下面我们开始进行从文件顶部渲染到网站页面上。\n\n首先在主题配置文件 `_config.butterfly.yml`文件中写入配置,方便我们进行控制摘要是否开启:\n\n```yml\n# --------------------------------------\n# 文章设置\n# --------------------------------------\n# 文章AI摘要是否开启,会自动检索文章色summary字段,若没有则不显示\nai_summary:\n enable: true\n title: 清羽のAI摘要\n loadingText: 清羽AI正在绞尽脑汁想思路ING···\n modelName: HunYuan-Lite\n```\n\n这里的内容均为装饰性内容,除了enable选项,其他没有任何控制效果,都是装饰,所以无需担心,可以先按照我的写,后面再根据效果修改。\n\n## 添加模板\n\n下面找到主题文件下的 `/root/theme/butterfly/layout/post.pug`文件,添加文件中指出来的两行内容:\n\n```diff\nextends includes/layout.pug\n\nblock content\n #post\n if top_img === false\n include includes/header/post-info.pug\n\n article#article-container.post-content\n+ if page.summary && theme.ai_summary.enable\n+ include includes/post/post-summary.pug\n !=page.content\n include includes/post/post-copyright.pug\n .tag_share\n if (page.tags.length > 0 && theme.post_meta.post.tags)\n .post-meta__tag-list\n each item, index in page.tags.data\n a(href=url_for(item.path)).post-meta__tags #[=item.name]\n include includes/third-party/share/index.pug\n\n if theme.reward.enable && theme.reward.QR_code\n !=partial('includes/post/reward', {}, {cache: true})\n\n //- ad\n if theme.ad && theme.ad.post\n .ads-wrap!=theme.ad.post\n\n if theme.post_pagination\n include includes/pagination.pug\n if theme.related_post && theme.related_post.enable\n != related_posts(page,site.posts)\n\n if page.comments !== false && theme.comments.use\n - var commentsJsLoad = true\n !=partial('includes/third-party/comments/index', {}, {cache: true})\n```\n\n注意缩进,pug作为预编译语言,对缩进的要求极为严格,在该文件中,应该是两个空格一缩进。\n\n下面添加组件,创建文件 `/root/theme/butterfly/layout/includes/post/post-summary.pug`,写入以下内容:\n\n```pug\n.ai-summary\n .ai-explanation(style=\"display: block;\" data-summary=page.summary)=theme.ai_summary.loadingText\n .ai-title \n .ai-title-left \n i.fa-brands.fa-slack\n .ai-title-text=theme.ai_summary.title\n .ai-tag#ai-tag= theme.ai_summary.modelName\n```\n\n## 添加样式\n\n下面我们添加样式部分,创建文件 `/root/theme/butterfly/source/css/_layout/ai-summary.styl`文件,写入:\n\n```\n// ===================\n// 🌗 主题变量定义(仅使用项)\n// ===================\n\n:root\n // ai_summary\n --liushen-title-font-color: #0883b7\n --liushen-maskbg: rgba(255, 255, 255, 0.85)\n --liushen-ai-bg: conic-gradient(from 1.5708rad at 50% 50%, #d6b300 0%, #42A2FF 54%, #d6b300 100%)\n\n // card 背景\n --liushen-card-secondbg: #f1f3f8\n\n // text\n --liushen-text: #4c4948\n --liushen-secondtext: #3c3c43cc\n\n[data-theme='dark']\n // ai_summary\n --liushen-title-font-color: #0883b7\n --liushen-maskbg: rgba(0, 0, 0, 0.85)\n --liushen-ai-bg: conic-gradient(from 1.5708rad at 50% 50%, rgba(214, 178, 0, 0.46) 0%, rgba(66, 161, 255, 0.53) 54%, rgba(214, 178, 0, 0.49) 100%)\n\n // card 背景\n --liushen-card-secondbg: #3e3f41\n\n // text\n --liushen-text: #ffffffb3\n --liushen-secondtext: #a1a2b8\n\n// ===================\n// 📘 AI 摘要模块样式\n// ===================\n\nif hexo-config('ai_summary.enable')\n .ai-summary\n background-color var(--liushen-maskbg)\n background var(--liushen-card-secondbg)\n border-radius 12px\n padding 8px 8px 12px 8px\n line-height 1.3\n flex-direction column\n margin-bottom 16px\n display flex\n gap 5px\n position relative\n\n &::before\n content ''\n position absolute\n top 0\n left 0\n width 100%\n height 100%\n z-index 1\n filter blur(8px)\n opacity .4\n background-image var(--liushen-ai-bg)\n transform scaleX(1) scaleY(.95) translateY(2px)\n \n &::after\n content: '';\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n z-index: 2;\n border-radius: 12px;\n background: var(--liushen-maskbg);\n\n .ai-explanation\n z-index 10\n padding 8px 12px\n font-size 15px\n line-height 1.4\n color var(--liushen-text)\n text-align justify\n\n // ✅ 打字机光标动画\n &::after\n content ''\n display inline-block\n width 8px\n height 2px\n margin-left 2px\n background var(--liushen-text)\n vertical-align bottom\n animation blink-underline 1s ease-in-out infinite\n transition all .3s\n position relative\n bottom 3px\n\n // 平滑滚动动画\n // .char\n // display inline-block\n // opacity 0\n // animation chat-float .5s ease forwards\n \n .ai-title\n z-index 10\n font-size 14px\n display flex\n border-radius 8px\n align-items center\n position relative\n padding 0 12px\n cursor default\n user-select none\n\n .ai-title-left\n display flex\n align-items center\n color var(--liushen-title-font-color)\n\n i\n margin-right 3px\n display flex\n color var(--liushen-title-font-color)\n border-radius 20px\n justify-content center\n align-items center\n\n .ai-title-text\n font-weight 500\n\n .ai-tag\n color var(--liushen-secondtext)\n font-weight 300\n margin-left auto\n display flex\n align-items center\n justify-content center\n transition .3s\n\n // 平滑滚动动画\n // @keyframes chat-float\n // 0% \n // opacity 0\n // transform translateY(20px)\n // 100% \n // opacity 1\n // transform translateY(0)\n \n // ✅ 打字机光标闪烁动画\n @keyframes blink-underline\n 0%, 100%\n opacity 1\n 50%\n opacity 0\n```\n\n样式也实现啦!目前就差将我们的摘要插入到我们的网站就大功告成啦,为了实现的更加逼真,我这里实现了两种样式一个是打字机效果,一个是平滑显示效果,可以按需引入:\n\n## 添加核心JS\n\n介绍两种动效,可以按照自己的需求在任意js文件中选择一个引入即可,两个的区别是,打字机效果更加的节省性能,而平滑显示,因为每个文本为一个span,所以会比较耗费性能。\n\n### 打字机\n\n```js\n// 打字机效果\nfunction typeTextMachineStyle(text, targetSelector, options = {}) {\n const {\n delay = 50,\n startDelay = 2000,\n onComplete = null,\n clearBefore = true,\n eraseBefore = true, // 新增:是否以打字机方式清除原文本\n eraseDelay = 30, // 新增:删除每个字符的间隔\n } = options;\n\n const el = document.querySelector(targetSelector);\n if (!el || typeof text !== \"string\") return;\n\n setTimeout(() => {\n const startTyping = () => {\n let index = 0;\n function renderChar() {\n if (index <= text.length) {\n el.textContent = text.slice(0, index++);\n setTimeout(renderChar, delay);\n } else {\n onComplete && onComplete(el);\n }\n }\n renderChar();\n };\n\n if (clearBefore) {\n if (eraseBefore && el.textContent.length > 0) {\n let currentText = el.textContent;\n let eraseIndex = currentText.length;\n\n function eraseChar() {\n if (eraseIndex > 0) {\n el.textContent = currentText.slice(0, --eraseIndex);\n setTimeout(eraseChar, eraseDelay);\n } else {\n startTyping(); // 删除完毕后开始打字\n }\n }\n\n eraseChar();\n } else {\n el.textContent = \"\";\n startTyping();\n }\n } else {\n startTyping();\n }\n }, startDelay);\n}\n\nfunction renderAISummary() {\n const summaryEl = document.querySelector('.ai-summary .ai-explanation');\n if (!summaryEl) return;\n\n const summaryText = summaryEl.getAttribute('data-summary');\n if (summaryText) {\n typeTextMachineStyle(summaryText, \".ai-summary .ai-explanation\"); // 如果需要切换,在这里调用另一个函数即可\n }\n}\n\ndocument.addEventListener('pjax:complete', renderAISummary);\ndocument.addEventListener('DOMContentLoaded', renderAISummary);\n```\n\n本站使用的就是打字机效果,可以自行查看。\n\n### 平滑\n\n这个没有样图,如果好奇可以自行部署并尝试:\n\n```js\n // 平滑弹出效果\n function typeText(text, targetSelector, options = {}) {\n const {\n delay = 50, // 每个字符之间的延迟(毫秒)\n startDelay = 2000, // 开始打字前的延迟(默认 3 秒)\n onComplete = null, // 动画完成后的回调\n clearBefore = true // 是否在开始前清空原有内容\n } = options;\n\n const targetEl = document.querySelector(targetSelector);\n if (!targetEl || typeof text !== \"string\") return;\n\n // if (clearBefore) targetEl.textContent = \"\";\n\n let index = 0;\n let frameId = null;\n\n function renderChar() {\n if (index < text.length) {\n const span = document.createElement(\"span\");\n span.textContent = text[index++];\n span.className = \"char\";\n targetEl.appendChild(span);\n frameId = requestAnimationFrame(() => setTimeout(renderChar, delay));\n } else {\n cancelAnimationFrame(frameId);\n onComplete && onComplete(targetEl);\n }\n }\n\n setTimeout(() => {\n if (clearBefore) targetEl.textContent = \"\";\n renderChar();\n }, startDelay);\n }\n\nfunction renderAISummary() {\n const summaryEl = document.querySelector('.ai-summary .ai-explanation');\n if (!summaryEl) return;\n\n const summaryText = summaryEl.getAttribute('data-summary');\n if (summaryText) {\n typeText(summaryText, \".ai-summary .ai-explanation\"); // 如果需要切换,在这里调用另一个函数即可\n }\n}\n\ndocument.addEventListener('pjax:complete', renderAISummary);\ndocument.addEventListener('DOMContentLoaded', renderAISummary);\n```\n\n注意,平滑滚动部分的css,默认注释掉了\n\n好的,设置完毕!\n","tags":["网站"],"categories":["建站手札"]},{"title":"利用插件自定义页脚菜单","url":"/posts/a6ab0925/","content":"\n# 安装\n\n安装插件,在博客根目录[Blogroot]下打开终端,运行以下指令:\n\n```bash\nnpm install hexo-butterfly-footer-marcus --save\n```\n\n如果需要随机友链接的话,再运行以下指令:\n\n```bash\nnpm i yamljs --save\n```\n\n# 添加配置信息\n\n以下为写法示例 在站点配置文件_config.yml或者主题配置文件_config.butterfly.yml中添加\n\n```yml\n#hexo-butterfly-footer-marcus\n#see https://blog.marcus233.top/p/footer.html\nfooter_beautify:\n enable: true\n priority: 5 #过滤器优先权\n enable_page: all # 应用页面\n layout: # 挂载容器类型\n type: id\n name: footer\n index: 1\n footer_icons:\n enable: true\n left:\n - icon: fa-solid fa-compass\n link: https://www.marcus233.top/\n desrc: 个人主页\n class: out\n - icon: fa-brands fa-qq\n link: https://res.abeim.cn/api/qq/?qq=3105950984\n desrc: 联系QQ\n class: out\n - icon: fa-brands fa-weixin\n link: /wechat/\n desrc: 联系微信\n class: in\n - icon: fa-solid fa-envelope\n link: mailto:marcus@marcus233.top\n desrc: 发送邮件\n class: out\n right:\n - icon: fa-brands fa-github\n link: https://github.com/Marcusyyds\n desrc: Github主页\n class: out\n - icon: fa-brands fa-bilibili\n link: https://space.bilibili.com/1024450661\n desrc: 哔哩哔哩主页\n class: out\n - icon: fa-solid fa-star\n link: /stars/\n desrc: 藏宝阁\n class: in\n - icon: fa-solid fa-comment\n link: /message/\n desrc: 留言\n class: in\n footer_logo:\n enable: true\n url: https://img01.anheyu.com/useruploads/8/2022/12/15/639adf5b8806a.png\n footer_group:\n enable: true\n footer_group_link:\n - group_title: 直达\n footer_links: \n - text: 藏宝阁\n link: /stars/\n class: in\n - text: 优秀句子\n link: /sentence/\n class: in\n - text: 空间说说\n link: /zone/\n class: in\n - text: 友链订阅\n link: /fcircle/\n class: in\n - text: 切换背景\n link: /bg/\n class: in\n - group_title: 关于\n footer_links: \n - text: 关于我\n link: /about/\n class: in\n - text: RSS订阅\n link: /atom.xml\n class: in\n - text: 站点监控\n link: https://uptime.marcus233.top/\n class: out\n - text: 更新记录\n link: /timeline/\n class: in\n - text: 我的相册\n link: /picture/\n class: in\n - group_title: 分类\n footer_links: \n - text: 博客相关\n link: /categories/博客相关\n class: in\n - text: 生活点滴\n link: /categories/生活点滴\n class: in \n - text: 资源分享\n link: /categories/资源分享\n class: in\n - text: 学习笔记\n link: /categories/学习笔记\n class: in \n - text: 实用教程\n link: /categories/实用教程\n class: in \n - text: 查看全部\n link: /categories/\n class: in \n footer_friend_links:\n enable: true\n number: 5\n footer_bottom:\n copyright:\n enable: true\n author: Marcus\n link: https://marcus233.top/\n time: 2022\n left:\n - text: 雨云\n desrc: 本站CDN支持\n link: https://rainyun.com/\n - text: 网盾星球\n desrc: 本站CDN防护主要提供商:网盾星球\n link: https://www.netdun.net/\n - text: 萌ICP备20230221\n desrc: 萌ICP备20230221\n link: https://icp.gov.moe/?keyword=20230221\n - text: 萌ICP备20236688\n desrc: 萌ICP备20236688\n link: https://icp.gov.moe/?keyword=20236688\n - text: 萌ICP备20230002\n desrc: 萌ICP备20230002\n link: https://icp.gov.moe/?keyword=20230002\n right:\n - text: Hexo\n desrc: 框架\n link: https://hexo.io/zh-cn/\n - text: Butterfly\n desrc: 主题\n link: https://butterfly.js.org/\n runtime:\n enable: true\n time: 2022/08/09 00:00:00\n footer_css: https://cdn1.tianli0.top/npm/hexo-butterfly-footer-marcus/lib/footer.min.css\n footer_js: https://cdn1.tianli0.top/npm/hexo-butterfly-footer-marcus/lib/footer.min.js\n```\n\n请自行下载footer_js修改建站日期\n如果开启了随机友联,根目录下却没有link.json,请参考(页脚的随机友链)[https://blog.shineyu.cn/footer-random-flink.html]\n\n# 参数释义\n\n| 参数 | 备选值/类型 | 释义 |\n| ------------------------------ | ----------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| enable | true/false | 【必选】控制开关 |\n| priority | number | 【可选】过滤器优先级,数值越小,执行越早,默认为10,选填 |\n| enable_page | path/all | 【可选】填写想要应用的页面的相对路径(即路由地址),如根目录就填’/‘,分类页面就填’/categories/‘。若要应用于所有页面,就填’all’,默认为all |\n| exclude | path | 【可选】填写想要屏蔽的页面,可以多个。仅当enable_page为’all’时生效。写法见示例。原理是将屏蔽项的内容逐个放到当前路径去匹配,若当前路径包含任一屏蔽项,则不会挂载。 |\n| layout.type | id/class | 【可选】挂载容器类型,填写id或class,不填则默认为id |\n| layout.name | text | 【必选】挂载容器名称 |\n| layout.index | 0和正整数 | 【可选】前提是layout.type为class,因为同一页面可能有多个class,此项用来确认究竟排在第几个顺位 |\n| insertposition | text | ‘beforebegin’:元素自身的前面。’afterbegin’:插入元素内部的第一个子节点之前。’beforeend’:插入元素内部的最后一个子节点之后。’afterend’:插入元素自身的后面。 |\n| footer_icons.enable | true/false | 【必选】icon控制开关 |\n| *.text | text | 【必选】显示文字 |\n| *.icon | class | 【必选】icon(例:fa-solid fa-commet) |\n| *.desrc | text | 【必选】a标签内的title选项 |\n| *.class | in/out | 【必选】站内/外链接(站内:in,站外:out) |\n| *.link | url | 【必选】链接 |\n| footer_logo.enable | true/false | 【必选】icon内logo控制开关 |\n| footer_group.enable | true/false | 【必选】group控制开关 |\n| footer_friend_links.enable | true/false | 【必选】随机友联开关 |\n| footer_friend_link.number | 正整数 | 【可选】随机友联数量 |\n| footer_bottom.copyright.enable | true/false | 【必选】copyright开关 |\n| footer_bottom.runtime.enable | true/false | 【必选】网站运行时间开关 |\n| footer_css | url | 【必选】css链接 |\n| footer_js | url | 【必选】js链接 |\n\n使用方法\n填写配置项\n需改动源码的地方\n\n在 `themes\\butterfly\\layout\\includes\\layout.pug`43行(修改页脚背景色的bug)\n\n```pug\n else\n - var footer_bg = ''\n\n- footer#footer(style=footer_bg)\n\n+ footer#footer(style='background: transparent')\n !=partial('includes/footer', {}, {cache: true})\n\n else\n include ./404.pug\n```\n\n 去掉+号\n 在 `themes\\butterfly\\source\\css\\_mode\\darkmode.styl`43行(修改黑暗模式按钮层级的bug)\n\n```\n #web_bg:before,\n\n- #footer:before,\n #page-header:before\n position: absolute\n width: 100%\n height: 100%\n background-color: alpha($dark-black, .7)\n content: ''\n```\n\n# 参考\n\n{%link Marcus的博客,Marcus,https://blog.marcus233.top/p/footer.html%}\n{%link GitHub开源,github@sysicon,https://github.com/sysiocn/hexo-butterfly-footer-marcus%}","tags":["网站"],"categories":["建站手札"]},{"title":"英语文章分享-去奋力生活吧,就好像死亡近在咫尺","url":"/posts/f0a1a1f4/","content":"\nAs a hospice doctor, I often have the privilege of being at the bedside of dying patients.Over the years, I've had countless conversations about lives well lived, and more often, about regrets.Many of my patients express a strikingly similar sentiment:\nI really regret that I never had the energy or time to…\nThe rest of the sentence varies.For one, it might be writing a book.For another, traveling to a far-off land.For someone else, maybe it's training for a favorite sport.The specifics change, but the underlying theme is always the same: they missed out on what I call little p purpose — the process-oriented kind of purpose that comes from doing things that light us up from within.\nThe heartbreaking truth about these deathbed epiphanies is that the dying no longer have the agency to make things right.They've run out of time, or strength, or both.What they once could have done, they no longer can.\nA large part of my work, and of the books I write, is trying to convince the living to adopt this mindset before it's too late.To offer the lens of the dying as a kind of instruction manual for how to live now.\nWe must live as if death is just a breath away.\nAnd yet, again and again, I hear the same explanations for why people don't prioritize purpose in their daily lives.\nI Don't Have Enough Energy\nThis one comes up often, especially among young people, busy with careers and raising children.They feel completely depleted by the demands of work and family.The idea of mustering up extra energy to pursue something just for them seems laughable.\nBut research tells us something interesting.Studies on motivation and physical activity have shown that people with a stronger sense of purpose are actually more likely to feel energized.They experience fewer barriers to action and develop more intrinsic motivation to engage with life.\nIn other words, energy isn't necessarily a finite pie.It can grow, especially when we're engaging with activities that matter to us.\nAnd \"purpose\" doesn't have to mean starting a nonprofit or launching a million-dollar business.Little p purpose is smaller.Simpler.It could be reading a good book, taking a walk by the lake, or tinkering with a hobby you loved as a kid.It's not about the size of the act, it's about the spark.\nI Don't Have Enough Time\nThis one may feel especially true.We're busier than ever, no doubt bombarded by the demands of work, family, texts, emails, and social media.It's one of the most common objections I hear.\nBut data paints a different picture.\nThe Bureau of Labor Statistics conducts the American Time Use Survey every year, collecting insights from thousands of participants.The most recent findings?Americans spend an average of five hours a day on leisure and sports activities.That's across all socioeconomic backgrounds.Rich or poor, employed or not — most people have more discretionary time than they realize.\nSo, if we do have the time, the question becomes: what's really stopping us?\nPurpose Demands Courage\nIn my years of working with the dying, I've learned something unexpected.The true barrier to purpose isn't energy, money, or time.\nIt's courage.\nNot bravery in the way we typically define it.I've had this conversation with war heroes and daredevil athletes.It's not about fearlessness.It's not about skill either.I've cared for world-class artisans and bestselling authors.It's not about knowledge — most of them knew what mattered to them.\nWhat they lacked was the courage to choose those things.(他们缺乏的是选择那些的勇气)\nIt's easier to focus on building wealth, pursuing a career, or raising kids.Those are important, yes, but they're also the low-hanging fruit.They come with clear milestones and societal validation.\nTurning toward what lights you up is a much scarier proposition.\nWhat if I'm not good enough?\nWhat if I fail?\nWhat if it doesn't turn out how I hoped?\nWhat if people laugh at me?\nThe list of reasons not to pursue your purpose is long.\nBut there's one reason that matters more than all the rest:\nYou might regret it on your deathbed if you don't.","tags":["英语"],"categories":["学习"]},{"title":"自定义右键菜单","url":"/posts/8bdb35fb/","content":"\n# 演示\n\n本站右键即可查看,和原有菜单相比比较美观\n\n# 新建pug文件\n\n在 `\\themes\\butterfly\\layout\\includes`新建 `rightmenu.pug`\n\n```pug\n#rightMenu.js-pjax\n .rightMenu-group.rightMenu-small\n a.rightMenu-item(href=\"javascript:window.history.back();\")\n i.fa.fa-arrow-left\n a.rightMenu-item(href=\"javascript:window.history.forward();\")\n i.fa.fa-arrow-right\n a.rightMenu-item(href=\"javascript:window.location.reload();\")\n i.fa.fa-refresh\n a.rightMenu-item(href=\"javascript:window.scrollTo(0, 0);\")\n i.fa.fa-arrow-up\n .rightMenu-group.rightMenu-line.hide#menu-text\n a.rightMenu-item(href=\"javascript:rmf.copySelect();\")\n i.fa.fa-copy\n span='复制'\n a.rightMenu-item(href=\"javascript:rmf.searchinThisPage();\")\n i.fas.fa-search\n span='站内搜索'\n .rightMenu-group.rightMenu-line.hide#menu-too\n a.rightMenu-item(href=\"javascript:window.open(window.getSelection().toString());window.location.reload();\")\n i.fa.fa-link\n span='转到链接'\n .rightMenu-group.rightMenu-line.hide#menu-paste\n a.rightMenu-item(href='javascript:rmf.paste()')\n i.fa.fa-copy\n span='粘贴'\n .rightMenu-group.rightMenu-line.hide#menu-post\n a.rightMenu-item(href=\"javascript:rmf.copyWordsLink()\")\n i.fa.fa-link\n span='复制本文地址'\n .rightMenu-group.rightMenu-line.hide#menu-to\n a.rightMenu-item(href=\"javascript:rmf.openWithNewTab()\")\n i.fa.fa-window-restore\n span='新窗口打开'\n a.rightMenu-item(href=\"javascript:rmf.open()\")\n i.fa.fa-link\n span='转到链接'\n a.rightMenu-item(href=\"javascript:rmf.copyLink()\")\n i.fa.fa-copy\n span='复制链接'\n .rightMenu-group.rightMenu-line.hide#menu-img\n a.rightMenu-item(href=\"javascript:rmf.saveAs()\")\n i.fa.fa-download\n span='保存图片'\n a.rightMenu-item(href=\"javascript:rmf.openWithNewTab()\")\n i.fa.fa-window-restore\n span='在新窗口打开'\n a.rightMenu-item(href=\"javascript:rmf.click()\")\n i.fa.fa-arrows-alt\n span='全屏显示'\n a.rightMenu-item(href=\"javascript:rmf.copyLink()\")\n i.fa.fa-copy\n span='复制图片链接'\n .rightMenu-group.rightMenu-line\n a.rightMenu-item(href=\"javascript:randomPost()\")\n i.fa.fa-paper-plane\n span='随便逛逛'\n a.rightMenu-item(href=\"javascript:rmf.switchDarkMode();\")\n i.fa.fa-moon\n span='昼夜切换'\n a.rightMenu-item(href=\"javascript:rmf.translate();\")\n i.iconfont.icon-fanti\n span='繁简转换'\n if is_post()||is_page()\n a.rightMenu-item(href=\"javascript:rmf.switchReadMode();\")\n i.fa.fa-book\n span='阅读模式'\n a.rightMenu-item(href=\"javascript:pjax.loadUrl(\\\"/privacy/\\\");\")\n i.fa.fa-info-circle\n span='隐私声明'\n a.rightMenu-item(href=\"javascript:pjax.loadUrl(\\\"/cookie/\\\");\")\n i.fa.fa-info-circle\n span='Cookie协议'\n a.rightMenu-item(href=\"javascript:pjax.loadUrl(\\\"/cc/\\\");\")\n i.fa.fa-info-circle\n span='版权声明'\n```\n\n# 新建js文件\n\n创建 `\\themes\\butterfly\\source\\js\\rightmenu.js`\n\n```js\nfunction setMask() {//设置遮罩层\n if (document.getElementsByClassName(\"rmMask\")[0] !== undefined) {\n return document.getElementsByClassName(\"rmMask\")[0];\n }\n mask = document.createElement('div');\n mask.className = \"rmMask\";\n mask.style.width = window.innerWidth + 'px';\n mask.style.height = window.innerHeight + 'px';\n mask.style.background = '#fff';\n mask.style.opacity = '.0';\n mask.style.position = 'fixed';\n mask.style.top = '0';\n mask.style.left = '0';\n mask.style.zIndex = 998;\n document.body.appendChild(mask);\n document.getElementById(\"rightMenu\").style.zIndex = 19198;\n return mask;\n}\n\nfunction insertAtCursor(myField, myValue) {\n\n //IE 浏览器\n if (document.selection) {\n myField.focus();\n sel = document.selection.createRange();\n sel.text = myValue;\n sel.select();\n }\n\n //FireFox、Chrome等\n else if (myField.selectionStart || myField.selectionStart === '0') {\n var startPos = myField.selectionStart;\n var endPos = myField.selectionEnd;\n\n // 保存滚动条\n var restoreTop = myField.scrollTop;\n myField.value = myField.value.substring(0, startPos) + myValue + myField.value.substring(endPos, myField.value.length);\n\n if (restoreTop > 0) {\n myField.scrollTop = restoreTop;\n }\n\n myField.focus();\n myField.selectionStart = startPos + myValue.length;\n myField.selectionEnd = startPos + myValue.length;\n } else {\n myField.value += myValue;\n myField.focus();\n }\n}\n\nlet rmf = {};\nrmf.showRightMenu = function (isTrue, x = 0, y = 0) {\n let $rightMenu = $('#rightMenu');\n $rightMenu.css('top', x + 'px').css('left', y + 'px');\n\n if (isTrue) {\n $rightMenu.show();\n } else {\n $rightMenu.hide();\n }\n}\nrmf.switchDarkMode = function () {\n const nowMode = document.documentElement.getAttribute('data-theme') === 'dark' ? 'dark' : 'light'\n if (nowMode === 'light') {\n activateDarkMode()\n saveToLocal.set('theme', 'dark', 2)\n GLOBAL_CONFIG.Snackbar !== undefined && btf.snackbarShow(GLOBAL_CONFIG.Snackbar.day_to_night)\n } else {\n activateLightMode()\n saveToLocal.set('theme', 'light', 2)\n GLOBAL_CONFIG.Snackbar !== undefined && btf.snackbarShow(GLOBAL_CONFIG.Snackbar.night_to_day)\n }\n // handle some cases\n typeof utterancesTheme === 'function' && utterancesTheme()\n typeof FB === 'object' && window.loadFBComment()\n window.DISQUS && document.getElementById('disqus_thread').children.length && setTimeout(() => window.disqusReset(), 200)\n switchPostChart();\n};\n\nrmf.copyWordsLink = function () {\n const decodedUrl = decodeURIComponent(window.location.href); // 解码 URL\n navigator.clipboard.writeText(decodedUrl)\n .then(() => {\n Snackbar.show({\n text: '链接复制成功!快去分享吧!',\n pos: 'top-right',\n showAction: false\n });\n })\n};\n\nrmf.switchReadMode = function () {\n const $body = document.body\n $body.classList.add('read-mode')\n const newEle = document.createElement('button')\n newEle.type = 'button'\n newEle.className = 'fas fa-sign-out-alt exit-readmode'\n $body.appendChild(newEle)\n\n function clickFn() {\n $body.classList.remove('read-mode')\n newEle.remove()\n newEle.removeEventListener('click', clickFn)\n }\n\n newEle.addEventListener('click', clickFn)\n}\n\n//复制选中文字\nrmf.copySelect = function () {\n navigator.clipboard.writeText(document.getSelection().toString()).then(() => {\n Snackbar.show({\n text: '已复制选中文字!',\n pos: 'top-right',\n showAction: false,\n });\n });\n}\n\n//回到顶部\nrmf.scrollToTop = function () {\n document.getElementsByClassName(\"menus_items\")[1].setAttribute(\"style\", \"\");\n document.getElementById(\"name-container\").setAttribute(\"style\", \"display:none\");\n btf.scrollToDest(0, 500);\n}\nrmf.translate = function () {\n document.getElementById(\"translateLink\").click();\n}\nrmf.searchinThisPage = () => {\n let mask = setMask(); // 确保 mask 元素存在于 document.body 中\n document.getElementsByClassName(\"local-search-box--input\")[0].value = window.getSelection().toString();\n document.getElementsByClassName(\"search\")[0].click();\n var evt = document.createEvent(\"HTMLEvents\");\n evt.initEvent(\"input\", false, false);\n document.getElementsByClassName(\"local-search-box--input\")[0].dispatchEvent(evt);\n\n // 在尝试移除 mask 元素之前检查它是否存在于 document.body 中\n if (document.body.contains(mask)) {\n document.body.removeChild(mask);\n }\n}\n\ndocument.body.addEventListener('touchmove', function (e) {\n\n}, {passive: false});\n\nfunction popupMenu() {\n //window.oncontextmenu=function(){return false;}\n window.oncontextmenu = function (event) {\n Snackbar.show({\n text: '按住 Ctrl 再点击右键,即可恢复原界面哦',\n pos: 'bottom-left',\n showAction: false\n });\n if (event.ctrlKey || document.body.clientWidth < 900) return true;\n $('.rightMenu-group.hide').hide();\n if (document.getSelection().toString()) {\n $('#menu-text').show();\n }\n if (document.getElementById('post')) {\n $('#menu-post').show();\n } else {\n if (document.getElementById('page')) {\n $('#menu-post').show();\n }\n }\n var el = window.document.body;\n el = event.target;\n var a = /^(?:http(s)?:\\/\\/)?[\\w.-]+(?:\\.[\\w.-]+)+[\\w\\-._~:\\/?#[\\]@!$&'*+,;=]+$/\n if (a.test(window.getSelection().toString()) && el.tagName !== \"A\") {\n $('#menu-too').show()\n }\n if (el.tagName === 'A') {\n $('#menu-to').show()\n rmf.open = function () {\n if (el.href.indexOf(\"http://\") === -1 && el.href.indexOf(\"https://\") === -1 || el.href.indexOf(\"blog.june-pj.cn\") !== -1) {\n pjax.loadUrl(el.href)\n } else {\n location.href = el.href\n }\n }\n rmf.openWithNewTab = function () {\n window.open(el.href);\n // window.location.reload();\n }\n rmf.copyLink = function () {\n const url = el.href;\n navigator.clipboard.writeText(url);\n Snackbar.show({\n text: '链接复制成功!快去分享吧!',\n pos: 'top-right',\n showAction: false\n });\n };\n }\n if (el.tagName === 'IMG') {\n $('#menu-img').show()\n rmf.openWithNewTab = function () {\n window.open(el.src);\n // window.location.reload();\n }\n rmf.click = function () {\n el.click()\n }\n rmf.copyLink = function () {\n const url = el.src\n navigator.clipboard.writeText(url);\n Snackbar.show({\n text: '链接复制成功!快去分享吧!',\n pos: 'top-right',\n showAction: false\n });\n }\n rmf.saveAs = function () {\n var a = document.createElement('a');\n a.href = el.src;\n // 获取图片的文件名部分\n a.download = el.src.split('/').pop(); // 使用图片的文件名作为下载文件名\n a.style.display = 'none'; // 隐藏下载链接\n document.body.appendChild(a);\n a.click();\n document.body.removeChild(a);\n }\n } else if (el.tagName === \"TEXTAREA\" || el.tagName === \"INPUT\") {\n $('#menu-paste').show();\n // rmf.paste=function(){\n // input.addEventListener('paste', async event => {\n // event.preventDefault();\n // const text = await navigator.clipboard.readText();\n // el.value+=text;\n // });\n // }\n rmf.paste = function () {\n navigator.permissions\n .query({\n name: 'clipboard-read'\n })\n .then(result => {\n if (result.state === 'granted' || result.state === 'prompt') {\n //读取剪贴板\n navigator.clipboard.readText().then(text => {\n console.log(text)\n insertAtCursor(el, text)\n })\n } else {\n Snackbar.show({\n text: '请允许读取剪贴板!',\n pos: 'top-center',\n showAction: false,\n })\n }\n })\n }\n }\n let pageX = event.clientX + 10;\n let pageY = event.clientY;\n let rmWidth = $('#rightMenu').width();\n let rmHeight = $('#rightMenu').height();\n if (pageX + rmWidth > window.innerWidth) {\n pageX -= rmWidth + 10;\n }\n if (pageY + rmHeight > window.innerHeight) {\n pageY -= pageY + rmHeight - window.innerHeight;\n }\n mask = setMask();\n window.onscroll = () => {\n rmf.showRightMenu(false);\n window.onscroll = () => {\n }\n if (document.body.contains(mask)) {\n document.body.removeChild(mask);\n }\n }\n\n $(\".rightMenu-item\").click(() => {\n if (document.body.contains(mask)) {\n document.body.removeChild(mask);\n }\n });\n\n $(window).resize(() => {\n rmf.showRightMenu(false);\n if (document.body.contains(mask)) {\n document.body.removeChild(mask);\n }\n });\n\n mask.onclick = () => {\n if (document.body.contains(mask)) {\n document.body.removeChild(mask);\n }\n };\n\n rmf.showRightMenu(true, pageY, pageX);\n return false;\n };\n\n window.addEventListener('click', function () {\n rmf.showRightMenu(false);\n });\n}\n\nif (!(navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i))) {\n popupMenu()\n}\nconst box = document.documentElement\n\nfunction addLongtabListener(target, callback) {\n let timer = 0 // 初始化timer\n\n target.ontouchstart = () => {\n timer = 0 // 重置timer\n timer = setTimeout(() => {\n callback();\n timer = 0\n }, 380) // 超时器能成功执行,说明是长按\n }\n\n target.ontouchmove = () => {\n clearTimeout(timer) // 如果来到这里,说明是滑动\n timer = 0\n }\n\n target.ontouchend = () => { // 到这里如果timer有值,说明此触摸时间不足380ms,是点击\n if (timer) {\n clearTimeout(timer)\n }\n }\n}\n\naddLongtabListener(box, popupMenu)\n```\n\n# 创建css\n\n创建 `\\themes\\butterfly\\source\\css\\rightmenu.css`\n\n```css\n/* rightMenu */\n[data-theme='light'] #rightMenu{\n display: none;\n position: fixed;\n width: 160px;\n height: fit-content;\n top: 10%;\n left: 10%;\n background-color: var(--card-bg);\n border: 1px solid rgb(210,210,210);;\n border-radius: 8px;\n z-index: 100;\n box-shadow: 3px 3px 5px #88888894;\n background-color: var(--june-white-acrylic1);\n backdrop-filter: blur(30px);\n}\n[data-theme='dark'] #rightMenu{\n display: none;\n position: fixed;\n width: 160px;\n height: fit-content;\n top: 10%;\n left: 10%;\n background-color: var(--card-bg);\n border: 1px solid rgb(210,210,210);;\n border-radius: 8px;\n z-index: 100;\n box-shadow: 3px 3px 5px #88888894;\n background-color: var(--june-black-acrylic1);\n backdrop-filter: blur(30px);\n}\n#rightMenu .rightMenu-group{\n padding: 7px 6px;\n}\n#rightMenu .rightMenu-group:not(:nth-last-child(1)){\n border-bottom: 1px solid rgb(180,180,180);\n}\n#rightMenu .rightMenu-group.rightMenu-small{\n display: flex;\n justify-content: space-between;\n}\n#rightMenu .rightMenu-group .rightMenu-item{\n height: 30px;\n line-height: 30px;\n border-radius: 8px;\n transition: 0.3s;\n color: var(--font-color);\n}\n#rightMenu .rightMenu-group.rightMenu-line .rightMenu-item{\n display: flex;\n height: 40px;\n line-height: 40px;\n padding: 0 4px;\n}\n#rightMenu .rightMenu-group .rightMenu-item:hover{\n background-color: var(--text-bg-hover);\n box-shadow: 0px 0px 5px var(--june-border);\n}\n#rightMenu .rightMenu-group .rightMenu-item i{\n display: inline-block;\n text-align: center;\n line-height: 30px;\n width: 30px;\n height: 30px;\n padding: 0 5px;\n}\n#rightMenu .rightMenu-group .rightMenu-item span{\n line-height: 30px;\n}\n#rightMenu:hover{\n border: 1px solid var(--june-theme);\n}\n#rightMenu .rightMenu-group.rightMenu-line .rightMenu-item *{\n height: 40px;\n line-height: 40px;\n}\n.rightMenu-group.hide{\n display: none;\n}\n.rightMenu-item:hover{\n color:white!important;\n background-color:var(--june-theme)!important;\n}\n```\n\n# 引入\n\n```yml\n- <script type=\"text/javascript\" src=\"/js/rightmenu.js\"></script>\n- <link rel=\"stylesheet\" href=\"/css/rightmenu.css\">\n```","tags":["网站"],"categories":["建站手札"]},{"title":"在侧边栏中添加欢迎信息","url":"/posts/da17d00/","content":"# 效果展示\n\n<center><img src=\"https://pic.biss.click/image/e37d7241-ed48-4595-ba18-c4de11289adf.webp\" alt=\"效果展示\"></center>\n\n# 开始折腾\n\n## 申请腾讯地图的api key\n\n{% link 腾讯地图,Tencent,https://lbs.qq.com/dev/console/application/mine %}\n自行查看文档,要注意在填写信任域名时不填 `https://`\n\n## 添加js\n\n在主题 `/source/js/`目录下添加 `txmap.js`\n\n有一个更完善的js脚本\n\n{% link txmap.js,github,https://github.com/bishshi/welcomemessage %}\n```js\n//get请求\n$.ajax({\n type: 'get',\n url: 'https://apis.map.qq.com/ws/location/v1/ip',\n data: {\n key: '你的key',\n output: 'jsonp',\n callback: '?',\n },\n dataType: 'jsonp',\n success: function (res) {\n window.ipLocation = res;\n }\n})\nfunction getDistance(e1, n1, e2, n2) {\n const R = 6371\n const { sin, cos, asin, PI, hypot } = Math\n let getPoint = (e, n) => {\n e *= PI / 180\n n *= PI / 180\n return { x: cos(n) * cos(e), y: cos(n) * sin(e), z: sin(n) }\n }\n\n let a = getPoint(e1, n1)\n let b = getPoint(e2, n2)\n let c = hypot(a.x - b.x, a.y - b.y, a.z - b.z)\n let r = asin(c / 2) * 2 * R\n return Math.round(r);\n}\n\nfunction showWelcome() {\n\n let dist = getDistance(112.92358, 35.79807, ipLocation.result.location.lng, ipLocation.result.location.lat); //这里记得换成自己的经纬度\n let pos = ipLocation.result.ad_info.nation;\n let ip;\n let posdesc;\n //根据国家、省份、城市信息自定义欢迎语\n switch (ipLocation.result.ad_info.nation) {\n case \"日本\":\n posdesc = \"よろしく,一起去看樱花吗\";\n break;\n case \"美国\":\n posdesc = \"Let us live in peace!\";\n break;\n case \"英国\":\n posdesc = \"想同你一起夜乘伦敦眼\";\n break;\n case \"俄罗斯\":\n posdesc = \"干了这瓶伏特加!\";\n break;\n case \"法国\":\n posdesc = \"C'est La Vie\";\n break;\n case \"德国\":\n posdesc = \"Die Zeit verging im Fluge.\";\n break;\n case \"澳大利亚\":\n posdesc = \"一起去大堡礁吧!\";\n break;\n case \"加拿大\":\n posdesc = \"拾起一片枫叶赠予你\";\n break;\n case \"中国\":\n pos = ipLocation.result.ad_info.province + \" \" + ipLocation.result.ad_info.city + \" \" + ipLocation.result.ad_info.district;\n ip = ipLocation.result.ip;\n switch (ipLocation.result.ad_info.province) {\n case \"北京市\":\n posdesc = \"北——京——欢迎你~~~\";\n break;\n case \"天津市\":\n posdesc = \"讲段相声吧\";\n break;\n case \"河北省\":\n posdesc = \"山势巍巍成壁垒,天下雄关铁马金戈由此向,无限江山\";\n break;\n case \"山西省\":\n switch (ipLocation.result.ad_info.city) {\n case \"太原市\":\n posdesc = \"秋叶蓝不城\";\n break;\n case \"晋城市\":\n posdesc = \"一方水土养一方人,晋城话说给晋城人...\";\n break;\n default:\n posdesc = \"展开坐具长三尺,已占山河五百余\";\n break;\n }\n break;\n case \"内蒙古自治区\":\n posdesc = \"天苍苍,野茫茫,风吹草低见牛羊\";\n break;\n case \"辽宁省\":\n posdesc = \"我想吃烤鸡架!\";\n break;\n case \"吉林省\":\n posdesc = \"状元阁就是东北烧烤之王\";\n break;\n case \"黑龙江省\":\n posdesc = \"很喜欢哈尔滨大剧院\";\n break;\n case \"上海市\":\n posdesc = \"众所周知,中国只有两个城市\";\n break;\n case \"江苏省\":\n switch (ipLocation.result.ad_info.city) {\n case \"南京市\":\n posdesc = \"这是我挺想去的城市啦\";\n break;\n case \"苏州市\":\n posdesc = \"上有天堂,下有苏杭\";\n break;\n default:\n posdesc = \"散装是必须要散装的\";\n break;\n }\n break;\n case \"浙江省\":\n posdesc = \"东风渐绿西湖柳,雁已还人未南归\";\n break;\n case \"河南省\":\n switch (ipLocation.result.ad_info.city) {\n case \"郑州市\":\n posdesc = \"豫州之域,天地之中\";\n break;\n case \"南阳市\":\n posdesc = \"臣本布衣,躬耕于南阳此南阳非彼南阳!\";\n break;\n case \"驻马店市\":\n posdesc = \"峰峰有奇石,石石挟仙气嵖岈山的花很美哦!\";\n break;\n case \"开封市\":\n posdesc = \"刚正不阿包青天\";\n break;\n case \"洛阳市\":\n posdesc = \"洛阳牡丹甲天下\";\n break;\n default:\n posdesc = \"可否带我品尝河南烩面啦?\";\n break;\n }\n break;\n case \"安徽省\":\n posdesc = \"蚌埠住了,芜湖起飞\";\n break;\n case \"福建省\":\n posdesc = \"井邑白云间,岩城远带山\";\n break;\n case \"江西省\":\n posdesc = \"落霞与孤鹜齐飞,秋水共长天一色\";\n break;\n case \"山东省\":\n posdesc = \"遥望齐州九点烟,一泓海水杯中泻\";\n break;\n case \"湖北省\":\n switch (ipLocation.result.ad_info.city) {\n case \"黄冈市\":\n posdesc = \"红安将军县!辈出将才!\";\n break;\n default:\n posdesc = \"来碗热干面~\";\n break;\n }\n break;\n case \"湖南省\":\n posdesc = \"74751,长沙斯塔克\";\n break;\n case \"广东省\":\n switch (ipLocation.result.ad_info.city) {\n case \"广州市\":\n posdesc = \"看小蛮腰,喝早茶了嘛~\";\n break;\n case \"深圳市\":\n posdesc = \"今天你逛商场了嘛~\";\n break;\n case \"阳江市\":\n posdesc = \"阳春合水!博主家乡~ 欢迎来玩~\";\n break;\n default:\n posdesc = \"来两斤福建人~\";\n break;\n }\n break;\n case \"广西壮族自治区\":\n posdesc = \"桂林山水甲天下\";\n break;\n case \"海南省\":\n posdesc = \"朝观日出逐白浪,夕看云起收霞光\";\n break;\n case \"四川省\":\n posdesc = \"康康川妹子\";\n break;\n case \"贵州省\":\n posdesc = \"茅台,学生,再塞200\";\n break;\n case \"云南省\":\n posdesc = \"玉龙飞舞云缠绕,万仞冰川直耸天\";\n break;\n case \"西藏自治区\":\n posdesc = \"躺在茫茫草原上,仰望蓝天\";\n break;\n case \"陕西省\":\n posdesc = \"来份臊子面加馍\";\n break;\n case \"甘肃省\":\n posdesc = \"羌笛何须怨杨柳,春风不度玉门关\";\n break;\n case \"青海省\":\n posdesc = \"牛肉干和老酸奶都好好吃\";\n break;\n case \"宁夏回族自治区\":\n posdesc = \"大漠孤烟直,长河落日圆\";\n break;\n case \"新疆维吾尔自治区\":\n posdesc = \"驼铃古道丝绸路,胡马犹闻唐汉风\";\n break;\n case \"台湾省\":\n posdesc = \"我在这头,大陆在那头\";\n break;\n case \"香港特别行政区\":\n posdesc = \"永定贼有残留地鬼嚎,迎击光非岁玉\";\n break;\n case \"澳门特别行政区\":\n posdesc = \"性感荷官,在线发牌\";\n break;\n default:\n posdesc = \"带我去你的城市逛逛吧!\";\n break;\n }\n break;\n default:\n posdesc = \"带我去你的国家逛逛吧\";\n break;\n }\n\n //根据本地时间切换欢迎语\n let timeChange;\n let date = new Date();\n if (date.getHours() >= 5 && date.getHours() < 11) timeChange = \"<span>🌤️ 早上好,一日之计在于晨</span>\";\n else if (date.getHours() >= 11 && date.getHours() < 13) timeChange = \"<span>☀️ 中午好,记得午休喔~</span>\";\n else if (date.getHours() >= 13 && date.getHours() < 17) timeChange = \"<span>🕞 下午好,饮茶先啦!</span>\";\n else if (date.getHours() >= 17 && date.getHours() < 19) timeChange = \"<span>🚶♂️ 即将下班,记得按时吃饭~</span>\";\n else if (date.getHours() >= 19 && date.getHours() < 24) timeChange = \"<span>🌙 晚上好,夜生活嗨起来!</span>\";\n else timeChange = \"夜深了,早点休息,少熬夜\";\n\n// 新增ipv6显示为指定内容\n if (ip.includes(\":\")) {\n ip = \"<br>好复杂,咱看不懂~(ipv6)\";\n }\n try {\n //自定义文本和需要放的位置\n document.getElementById(\"welcome-info\").innerHTML =\n `欢迎来自 <b><span style=\"color: var(--kouseki-ip-color);font-size: var(--kouseki-gl-size)\">${pos}</span></b> 的小友💖<br>${posdesc}🍂<br>当前位置距博主约 <b><span style=\"color: var(--kouseki-ip-color)\">${dist}</span></b> 公里!<br>您的IP地址为:<b><span class=\"ip-mask\">${ip}</span></b><br>${timeChange} <br>`;\n } catch (err) {\n console.log(\"Pjax无法获取元素\")\n }\n}\nwindow.onload = showWelcome;\n// 如果使用了pjax在加上下面这行代码\ndocument.addEventListener('pjax:complete', showWelcome);\n```\n\n## 添加css文件\n\n在主题文件夹/source/css/在这里我添加了模糊IP地址。\n\n```css\n#welcome-info {\n overflow: hidden;\n border-radius: 14px;\n --kouseki-welcome-color: #49B1F5;\n --kouseki-ip-color: #49B1F5;\n --kouseki-gl-size: 16px!important;\n }\n/* 给 IP 地址的 span 再包一层,便于选择器定位 */\n/* JS 原文已经生成 <b><span>IP</span></b>,这里我们给这个 span 加类名 ip-mask */\n/* 如果你不方便改 HTML,可直接用属性选择器:#welcome-info b span:nth-child(1) */\n#welcome-info b span.ip-mask {\n display: inline-block;\n filter: blur(6px);\n transition: filter .3s ease;\n cursor: pointer;\n user-select: none; /* 防止复制到模糊文本 */\n}\n\n/* 鼠标悬停或点击时(:active)立即清晰 */\n#welcome-info b span.ip-mask:hover,\n#welcome-info b span.ip-mask:active {\n filter: blur(0);\n}\n\n/* 如果想做成「必须点一下才永久清晰」,把 :hover 去掉即可 */\n```\n\n# 引用\n\n在主题配置文件中添加\n\n```yml\ninject: \n bottom: \n+ - <script src=\"https://cdn.staticfile.org/jquery/3.6.3/jquery.min.js\"></script> # jQuery\n+ - <script async data-pjax src=\"/js/txmap.js\"></script> # 腾讯位置API\n```\n\n在需要展示文本的容器上添加相应id(`welcome-info`)就可以了,例如我想添加在网站公告栏信息的下方,于是就在 `[BlogRoot]\\themes\\butterfly\\layout\\includes\\widget\\card_announcement.pug`的最后一行加上这个,缩进与上一行相同即可\n\n```pug\n .announcement_content!= theme.aside.card_announcement.content\n //- 添加欢迎访客的信息\n+ #welcome-info\n```\n\n# 参考内容\n\n{% link Ganzhe的博文,Ganzhe,https://ganzhe2028.github.io/posts/14542 %}\n","tags":["网站"],"categories":["建站手札"]},{"title":"配置说说页面","url":"/posts/ad244066/","content":"又开始折腾啦,这次把说说页面加上,改用moments项目的api\n{% link Moments 极简朋友圈,githun@kingwrcy,https://github.com/kingwrcy/moments %}\n\n# 前期要求\n\n## 硬件要求\n\n1. 一台服务器\n2. 一个可自主解析的域名\n\n## 软件要求\n\n1. docker环境\n2. 反向代理工具(本文以Nginx为例)\n\n# 介绍与展示\n\n这里先给大家展示一下最终的效果,注意该教程可能仅适合部分主题,如果出现主题不适配的情况请自行适配,这里以本站主题 `Hexo-theme-butterfly`为基础进行修改:\n\n1. 说说页面:\n {% link 我的说说,胡言乱语ing。。。,https://blog.biss.click %}\n2. 轻量朋友圈\n {% link 朋友圈,依旧胡言乱语,https://mm.biss.blog %}\n3. 功能说明\n\nMoments作为一个轻量朋友圈,其功能都是分享上的部分,如下所示:\n\n* 分享:链接,图片,音乐,视频,书籍,电影\n* 信息:自定义位置,自定义标签,是否公开\n* 页面:Markdown渲染,编辑说说,删除说说,暗夜模式,自定义图标,信息,CSS及JS代码\n* 功能:S3存储,文件查询,多用户注册,点赞,评论,API\n\n简单介绍完毕,下面我就来教大家如何进行部署!\n\n# 部署教程\n\n## Moments部署\n\n### Compose部署\n\n官方给予了很完善的教程,这里我仅仅简单介绍一下 `docker-compose`部署的方式,如果你想以源码等其他方式进行部署,请查看文章开头部分的 `github`地址进行查阅。\n\n首先,在服务器任意位置创建文件:`docker-compose.yaml`,填入以下内容:\n\n```bash\nversion: '3'\nservices:\n moments:\n image: kingwrcy/moments:latest\n container_name: moments\n restart: always\n environment:\n port: 3000\n JWT_KEY: \"自己随便生成点字符串\"\n ENABLE_SWAGGER: \"true\"\n CORS_ORIGIN: # 填写跨域域名\n ports:\n - \"3000:3000\" # 自行换端口,换前面的,后面的3000不要动\n volumes:\n - ./opt/data:/app/data\n # - ./data/localtime:/etc/localtime:ro\n # - ./data/timezone:/etc/timezone:ro\n```\n\n注意文件,我将 `/opt/`文件夹(当然可以改成其他的)下的 `/data`文件夹挂载了进去,数据都会在里面,迁移时仅需整体打包到新服务器即可。然后执行以下两条命令,后续需要升级也仅需要执行这两个命令:\n\n```bash\ndocker-compose pull\ndocker-compose up -d\n```\n\n如果网络环境不佳,可尝试替换 `docker`源,可以自行查找\n\n通过反向代理将其添加到某个域名中,这里就不再多说了,各大面板都有极其完备的反代文档。\n\n### Nginx修改\n\n`Moments`在跨域 `docker-compose`文件中可以配置,所以不必进行此步\n\n网站目录\n\n返回到上一级目录,也就是域名名称的文件夹下,找到 `Proxy`文件夹,编辑里面的 `root.conf`文件为如下内容:\n\n```bash\n#代理配置\n\nlocation / {\n # 跨域设置\n add_header Access-Control-Allow-Origin *; # 允许所有域名访问,你也可以指定具体域名\n add_header Access-Control-Allow-Methods 'GET, POST, PUT, DELETE, OPTIONS'; # 允许的 HTTP 方法\n add_header Access-Control-Allow-Headers 'Origin, X-Requested-With, Content-Type, Accept, Authorization'; # 允许的请求头\n\n # 处理 OPTIONS 请求,预检请求\n if ($request_method = 'OPTIONS') {\n add_header Access-Control-Allow-Origin *;\n add_header Access-Control-Allow-Methods 'GET, POST, PUT, DELETE, OPTIONS';\n add_header Access-Control-Allow-Headers 'Origin, X-Requested-With, Content-Type, Accept, Authorization';\n add_header Access-Control-Max-Age 1728000;\n add_header Content-Type 'text/plain charset=UTF-8';\n add_header Content-Length 0;\n return 204;\n }\n\n # 原代理设置\n proxy_pass http://127.0.0.1:3003;\n proxy_set_header Host $host;\n proxy_set_header X-Real-IP $remote_addr;\n proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\n proxy_set_header REMOTE-HOST $remote_addr;\n proxy_set_header Upgrade $http_upgrade;\n proxy_set_header Connection $http_connection;\n proxy_set_header X-Forwarded-Proto $scheme;\n proxy_http_version 1.1;\n add_header X-Cache $upstream_cache_status;\n add_header Cache-Control no-cache;\n proxy_ssl_server_name off;\n proxy_ssl_name $proxy_host;\n add_header Strict-Transport-Security \"max-age=31536000\";\n}\n```\n\n下面是原代理设置,可以仅仅复制上面部分内容,下面保持不变,注意端口不要出问题。\n\n## 前端实现\n\n由于该项目利用了MetingJS和APlayer,所以请提前引入这两个包,Hexo-theme-butterfly中虽然有内置的两个包,仅需修改配置文件即可开启,但是版本比较老,这里我建议自行引入最新版本,在配置中引入以下文件,注意css和js应该是分开引入的:\n\n```bash\n<link rel=\"stylesheet\" href=\"https://fastly.jsdelivr.net/npm/aplayer/dist/APlayer.min.css\" media=\"all\" onload=\"this.media=\"all\"\">\n<script src=\"https://fastly.jsdelivr.net/npm/aplayer/dist/APlayer.min.js\"></script>\n<script src=\"https://fastly.jsdelivr.net/npm/meting/dist/Meting.min.js\"></script>\n```\n\n新建页面shuoshuo,在文件内写入一下内容:\n\n```bash\n---\ntitle: 日常哔哔,键盘侠的日常吐槽\naside: false\n---\n<div id=\"talk\"></div>\n<div class=\"limit\">- 只展示最近30条说说 -</div>\n<script src=\"/js/shuoshuo.js\" no-pjax></script>\n```\n\n其中的JS文件地址清自行修改,放在主题目录 `/script/`目录,自行创建,并写入以下内容:\n\n```js\nfunction renderTalks() {\n const talkContainer = document.querySelector('#talk');\n const domain = 'https://mm.biss.click'; \n if (!talkContainer) return;\n talkContainer.innerHTML = '';\n const generateIconSVG = () => {\n return `<svg viewBox=\"0 0 512 512\"xmlns=\"http://www.w3.org/2000/svg\"class=\"is-badge icon\"><path d=\"m512 268c0 17.9-4.3 34.5-12.9 49.7s-20.1 27.1-34.6 35.4c.4 2.7.6 6.9.6 12.6 0 27.1-9.1 50.1-27.1 69.1-18.1 19.1-39.9 28.6-65.4 28.6-11.4 0-22.3-2.1-32.6-6.3-8 16.4-19.5 29.6-34.6 39.7-15 10.2-31.5 15.2-49.4 15.2-18.3 0-34.9-4.9-49.7-14.9-14.9-9.9-26.3-23.2-34.3-40-10.3 4.2-21.1 6.3-32.6 6.3-25.5 0-47.4-9.5-65.7-28.6-18.3-19-27.4-42.1-27.4-69.1 0-3 .4-7.2 1.1-12.6-14.5-8.4-26-20.2-34.6-35.4-8.5-15.2-12.8-31.8-12.8-49.7 0-19 4.8-36.5 14.3-52.3s22.3-27.5 38.3-35.1c-4.2-11.4-6.3-22.9-6.3-34.3 0-27 9.1-50.1 27.4-69.1s40.2-28.6 65.7-28.6c11.4 0 22.3 2.1 32.6 6.3 8-16.4 19.5-29.6 34.6-39.7 15-10.1 31.5-15.2 49.4-15.2s34.4 5.1 49.4 15.1c15 10.1 26.6 23.3 34.6 39.7 10.3-4.2 21.1-6.3 32.6-6.3 25.5 0 47.3 9.5 65.4 28.6s27.1 42.1 27.1 69.1c0 12.6-1.9 24-5.7 34.3 16 7.6 28.8 19.3 38.3 35.1 9.5 15.9 14.3 33.4 14.3 52.4zm-266.9 77.1 105.7-158.3c2.7-4.2 3.5-8.8 2.6-13.7-1-4.9-3.5-8.8-7.7-11.4-4.2-2.7-8.8-3.6-13.7-2.9-5 .8-9 3.2-12 7.4l-93.1 140-42.9-42.8c-3.8-3.8-8.2-5.6-13.1-5.4-5 .2-9.3 2-13.1 5.4-3.4 3.4-5.1 7.7-5.1 12.9 0 5.1 1.7 9.4 5.1 12.9l58.9 58.9 2.9 2.3c3.4 2.3 6.9 3.4 10.3 3.4 6.7-.1 11.8-2.9 15.2-8.7z\"fill=\"#1da1f2\"></path></svg>`;\n }\n const waterfall = (a) => {\n function b(a, b) {\n var c = window.getComputedStyle(b);\n return parseFloat(c[\"margin\" + a]) || 0\n }\n\n function c(a) {\n return a + \"px\"\n }\n\n function d(a) {\n return parseFloat(a.style.top)\n }\n\n function e(a) {\n return parseFloat(a.style.left)\n }\n\n function f(a) {\n return a.clientWidth\n }\n\n function g(a) {\n return a.clientHeight\n }\n\n function h(a) {\n return d(a) + g(a) + b(\"Bottom\", a)\n }\n\n function i(a) {\n return e(a) + f(a) + b(\"Right\", a)\n }\n\n function j(a) {\n a = a.sort(function (a, b) {\n return h(a) === h(b) ? e(b) - e(a) : h(b) - h(a)\n })\n }\n\n function k(b) {\n f(a) != t && (b.target.removeEventListener(b.type, arguments.callee), waterfall(a))\n }\n \"string\" == typeof a && (a = document.querySelector(a));\n var l = [].map.call(a.children, function (a) {\n return a.style.position = \"absolute\", a\n });\n a.style.position = \"relative\";\n var m = [];\n l.length && (l[0].style.top = \"0px\", l[0].style.left = c(b(\"Left\", l[0])), m.push(l[0]));\n for (var n = 1; n < l.length; n++) {\n var o = l[n - 1],\n p = l[n],\n q = i(o) + f(p) <= f(a);\n if (!q) break;\n p.style.top = o.style.top, p.style.left = c(i(o) + b(\"Left\", p)), m.push(p)\n }\n for (; n < l.length; n++) {\n j(m);\n var p = l[n],\n r = m.pop();\n p.style.top = c(h(r) + b(\"Top\", p)), p.style.left = c(e(r)), m.push(p)\n }\n j(m);\n var s = m[0];\n a.style.height = c(h(s) + b(\"Bottom\", s));\n var t = f(a);\n window.addEventListener ? window.addEventListener(\"resize\", k) : document.body.onresize = k\n };\n\n const fetchAndRenderTalks = () => {\n const url = 'https://mm.biss.click/api/memo/list';\n const cacheKey = 'talksCache';\n const cacheTimeKey = 'talksCacheTime';\n const cacheDuration = 30 * 60 * 1000; // 半个小时 (30 分钟)\n \n const cachedData = localStorage.getItem(cacheKey);\n const cachedTime = localStorage.getItem(cacheTimeKey);\n const currentTime = new Date().getTime();\n \n // 判断缓存是否有效\n if (cachedData && cachedTime && (currentTime - cachedTime < cacheDuration)) {\n const data = JSON.parse(cachedData);\n renderTalks(data); // 使用缓存渲染数据\n } else {\n if (talkContainer) {\n talkContainer.innerHTML = '';\n fetch(url, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({\n size: 30\n })\n })\n .then(res => res.json())\n .then(data => {\n if (data.code === 0 && data.data && Array.isArray(data.data.list)) {\n // 缓存数据\n localStorage.setItem(cacheKey, JSON.stringify(data.data.list));\n localStorage.setItem(cacheTimeKey, currentTime.toString());\n renderTalks(data.data.list); // 渲染数据\n }\n })\n .catch(error => {\n console.error('Error fetching data:', error);\n });\n }\n }\n \n // 渲染函数\n function renderTalks(list) {\n // 确保 data 是一个数组\n if (Array.isArray(list)) {\n let items = list.map(item => formatTalk(item, url));\n items.forEach(item => talkContainer.appendChild(generateTalkElement(item)));\n waterfall('#talk');\n } else {\n console.error('Data is not an array:', list);\n }\n }\n };\n \n\n const formatTalk = (item, url) => {\n let date = formatTime(new Date(item.createdAt).toString());\n let content = item.content;\n let imgs = item.imgs ? item.imgs.split(',') : [];\n let text = content;\n content = text.replace(/\\[(.*?)\\]\\((.*?)\\)/g, `<a href=\"$2\">@$1</a>`)\n .replace(/- \\[ \\]/g, '⚪')\n .replace(/- \\[x\\]/g, '⚫');\n // 保留换行符,转换 \\n 为 <br>\n\t\tcontent = content.replace(/\\n/g, '<br>');\n // 将content用一个类包裹,便于后续处理\n content = `<div class=\"talk_content_text\">${content}</div>`;\n if (imgs.length > 0) {\n const imgDiv = document.createElement('div');\n imgDiv.className = 'zone_imgbox';\n imgs.forEach(e => {\n const imgLink = document.createElement('a');\n const imgUrl = domain + e;\n imgLink.href = imgUrl;\n imgLink.setAttribute('data-fancybox', 'gallery');\n imgLink.className = 'fancybox';\n imgLink.setAttribute('data-thumb', e);\n const imgTag = document.createElement('img');\n imgTag.src = domain + e;\n imgLink.appendChild(imgTag);\n imgDiv.appendChild(imgLink);\n });\n content += imgDiv.outerHTML;\n }\n\n // 外链分享功能\n if (item.externalUrl) {\n const externalUrl = item.externalUrl;\n const externalTitle = item.externalTitle;\n const externalFavicon = item.externalFavicon;\n\n const externalContainer = `\n <div class=\"shuoshuo-external-link\">\n <a class=\"external-link\" href=\"${externalUrl}\" target=\"_blank\" rel=\"external nofollow noopener noreferrer\">\n <div class=\"external-link-left\" style=\"background-image: url(${externalFavicon})\"></div>\n <div class=\"external-link-right\">\n <div class=\"external-link-title\">${externalTitle}</div>\n <div>点击跳转<i class=\"fa-solid fa-angle-right\"></i></div>\n </div>\n </a>\n </div>`;\n\n content += externalContainer;\n }\n\n const ext = JSON.parse(item.ext || '{}');\n\n if (ext.music && ext.music.id) {\n const music = ext.music;\n const musicUrl = music.api.replace(':server', music.server)\n .replace(':type', music.type)\n .replace(':id', music.id);\n content += `\n <meting-js server=\"${music.server}\" type=\"${music.type}\" id=\"${music.id}\" api=\"${music.api}\"></meting-js>\n `;\n }\n\n if (ext.doubanMovie && ext.doubanMovie.id) {\n const doubanMovie = ext.doubanMovie;\n const doubanMovieUrl = doubanMovie.url;\n const doubanTitle = doubanMovie.title;\n // const doubanDesc = doubanMovie.desc || '暂无描述';\n const doubanImage = doubanMovie.image;\n const doubanDirector = doubanMovie.director || '未知导演';\n const doubanRating = doubanMovie.rating || '暂无评分';\n // const doubanReleaseDate = doubanMovie.releaseDate || '未知上映时间';\n // const doubanActors = doubanMovie.actors || '未知演员';\n const doubanRuntime = doubanMovie.runtime || '未知时长';\n\n content += `\n <a class=\"douban-card\" href=\"${doubanMovieUrl}\" target=\"_blank\">\n <div class=\"douban-card-bgimg\" style=\"background-image: url('${doubanImage}');\"></div>\n <div class=\"douban-card-left\">\n <div class=\"douban-card-img\" style=\"background-image: url('${doubanImage}');\"></div>\n </div>\n <div class=\"douban-card-right\">\n <div class=\"douban-card-item\"><span>电影名: </span><strong>${doubanTitle}</strong></div>\n <div class=\"douban-card-item\"><span>导演: </span><span>${doubanDirector}</span></div>\n <div class=\"douban-card-item\"><span>评分: </span><span>${doubanRating}</span></div>\n <div class=\"douban-card-item\"><span>时长: </span><span>${doubanRuntime}</span></div>\n </div>\n </a>\n `;\n }\n\n if (ext.doubanBook && ext.doubanBook.id) {\n const doubanBook = ext.doubanBook;\n const bookUrl = doubanBook.url;\n const bookTitle = doubanBook.title;\n // const bookDesc = doubanBook.desc;\n const bookImage = doubanBook.image;\n const bookAuthor = doubanBook.author;\n const bookRating = doubanBook.rating;\n const bookPubDate = doubanBook.pubDate;\n\n const bookTemplate = `\n <a class=\"douban-card\" href=\"${bookUrl}\" target=\"_blank\">\n <div class=\"douban-card-bgimg\" style=\"background-image: url('${bookImage}');\"></div>\n <div class=\"douban-card-left\">\n <div class=\"douban-card-img\" style=\"background-image: url('${bookImage}');\"></div>\n </div>\n <div class=\"douban-card-right\">\n <div class=\"douban-card-item\">\n <span>书名: </span><strong>${bookTitle}</strong>\n </div>\n <div class=\"douban-card-item\">\n <span>作者: </span><span>${bookAuthor}</span>\n </div>\n <div class=\"douban-card-item\">\n <span>出版年份: </span><span>${bookPubDate}</span>\n </div>\n <div class=\"douban-card-item\">\n <span>评分: </span><span>${bookRating}</span>\n </div>\n </div>\n </a>\n `;\n\n content += bookTemplate;\n }\n\n if (ext.video && ext.video.type) {\n const videoType = ext.video.type;\n const videoUrl = ext.video.value;\n if (videoType === 'bilibili') {\n // Bilibili 视频模板\n // 从形如https://www.bilibili.com/video/BV1VGAPeAEMQ/?vd_source=91b3158d27d98ff41f842508c3794a13 的链接中提取视频 BV1VGAPeAEMQ\n const biliTemplate = `\n <div style=\"position: relative; padding: 30% 45%; margin-top: 10px;\">\n <iframe \n style=\"position: absolute; width: 100%; height: 100%; left: 0; top: 0; border-radius: 12px;\" \n src=\"${videoUrl}&autoplay=0\"\n scrolling=\"no\" \n frameborder=\"no\" \n allowfullscreen>\n </iframe>\n </div>\n `;\n // 将模板插入到 DOM 中\n content += biliTemplate;\n\n } else if (videoType === 'youtube') {\n // YouTube 视频模板\n // 从形如https://youtu.be/2V6lvCUPT8I?si=DVhUas6l6qlAr6Ru的链接中提取视频 ID2V6lvCUPT8I\n const youtubeTemplate = `\n <div style=\"position: relative; padding: 30% 45%; margin-top: 10px;\">\n <iframe width=\"100%\"\n style=\"position: absolute; width: 100%; height: 100%; left: 0; top: 0; border-radius: 12px;\"\n src=\"${videoUrl}\"\n title=\"YouTube video player\" \n frameborder=\"0\" \n allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" \n referrerpolicy=\"strict-origin-when-cross-origin\" \n allowfullscreen>\n </iframe>\n </div>\n `;\n // 将模板插入到 DOM 中\n content += youtubeTemplate;\n }\n }\n\n return {\n content: content,\n user: item.user.nickname || '匿名',\n avatar: item.user.avatarUrl || 'https://p.liiiu.cn/i/2024/03/29/66061417537af.png',\n date: date,\n location: item.location || '山西',\n tags: item.tags ? item.tags.split(',').filter(tag => tag.trim() !== '') : ['无标签'],\n text: content.replace(/\\[(.*?)\\]\\((.*?)\\)/g, '[链接]' + `${imgs.length ? '[图片]' : ''}`)\n };\n };\n\n const generateTalkElement = (item) => {\n const talkItem = document.createElement('div');\n talkItem.className = 'talk_item';\n\n const talkMeta = document.createElement('div');\n talkMeta.className = 'talk_meta';\n\n const avatar = document.createElement('img');\n avatar.className = 'no-lightbox avatar';\n avatar.src = item.avatar;\n\n const info = document.createElement('div');\n info.className = 'info';\n\n const talkNick = document.createElement('span');\n talkNick.className = 'talk_nick';\n talkNick.innerHTML = `${item.user} ${generateIconSVG()}`;\n\n const talkDate = document.createElement('span');\n talkDate.className = 'talk_date';\n talkDate.textContent = item.date;\n\n const talkContent = document.createElement('div');\n talkContent.className = 'talk_content';\n talkContent.innerHTML = item.content;\n\n const talkBottom = document.createElement('div');\n talkBottom.className = 'talk_bottom';\n\n const TagContainer = document.createElement('div');\n\n const talkTag = document.createElement('span');\n talkTag.className = 'talk_tag';\n talkTag.textContent = `🏷️${item.tags}`;\n\n const locationTag = document.createElement('span');\n locationTag.className = 'location_tag';\n locationTag.textContent = `🌍${item.location}`;\n\n TagContainer.appendChild(talkTag);\n TagContainer.appendChild(locationTag);\n\n const commentLink = document.createElement('a');\n commentLink.href = 'javascript:;';\n commentLink.onclick = () => goComment(item.text);\n const commentIcon = document.createElement('span');\n commentIcon.className = 'icon';\n const commentIconInner = document.createElement('i');\n commentIconInner.className = 'fa-solid fa-message fa-fw';\n commentIcon.appendChild(commentIconInner);\n commentLink.appendChild(commentIcon);\n\n talkMeta.appendChild(avatar);\n info.appendChild(talkNick);\n info.appendChild(talkDate);\n talkMeta.appendChild(info);\n talkItem.appendChild(talkMeta);\n talkItem.appendChild(talkContent);\n talkBottom.appendChild(TagContainer);\n talkBottom.appendChild(commentLink);\n talkItem.appendChild(talkBottom);\n\n return talkItem;\n };\n\n const goComment = (e) => {\n const match = e.match(/<div class=\"talk_content_text\">([\\s\\S]*?)<\\/div>/);\n const textContent = match ? match[1] : \"\";\n const n = document.querySelector(\".atk-textarea\");\n n.value = `> ${textContent}\\n\\n`;\n n.focus();\n btf.snackbarShow(\"已为您引用该说说,不删除空格效果更佳\");\n // const n = document.querySelector(\".atk-textarea\");\n // n.value = `> ${e}\\n\\n`;\n // n.focus();\n // btf.snackbarShow(\"已为您引用该说说,不删除空格效果更佳\");\n };\n\n const formatTime = (time) => {\n const d = new Date(time);\n const ls = [\n d.getFullYear(),\n d.getMonth() + 1,\n d.getDate(),\n d.getHours(),\n d.getMinutes(),\n d.getSeconds(),\n ];\n const r = ls.map((a) => (a.toString().length === 1 ? '0' + a : a));\n return `${r[0]}-${r[1]}-${r[2]} ${r[3]}:${r[4]}`;\n };\n\n fetchAndRenderTalks();\n}\n\nrenderTalks();\n\n// function whenDOMReady() {\n// const talkContainer = document.querySelector('#talk');\n// talkContainer.innerHTML = '';\n// fetchAndRenderTalks();\n// }\n// whenDOMReady();\n// document.addEventListener(\"pjax:complete\", whenDOMReady);\n```\n\n自行修改js文件中的Moments地址为你的地址,在文件中,有一个gocomment函数,实现的是获取卡片中的文本内容,如果如果出现不匹配的情况,请自行修改一下类名,这里我匹配的是artalk的输入框。在这里我把代码做了修改,因为我不想使用s3,结果导致说说图片无法加载。。。\n修改历程:日后再写\n\n然后引入样式文件,这个文件可以在配置文件中引用,也可以在页面文件中类似于shuoshuo.js一样引用,样式内容如下:\n\n```css\n:root {\n --liushen-card-bg: #fff;\n --liushen-card-border: 1px solid #e3e8f7;\n --card-box-shadow: 0 3px 8px 6px rgba(7,17,27,0.09);\n --card-hover-box-shadow: 0 3px 8px 6px rgba(7,17,27,0.2);\n --liushen-card-secondbg: #f1f3f8;\n --liushen-button-hover-bg: #2679cc;\n --liushen-text: #4c4948;\n --liushen-button-bg: #f1f3f8;\n --liushen-fancybox-bg: rgba(255,255,255,0.5);\n}\n\n:root, [data-theme=dark] {\n --liushen-card-bg: #181818;\n --liushen-card-secondbg: #30343f;\n --liushen-card-border: 1px solid #42444a;\n --card-box-shadow: 0 3px 8px 6px rgba(7,17,27,0.09);\n --card-hover-box-shadow: 0 3px 8px 6px rgba(7,17,27,0.2);\n --liushen-button-bg: #30343f;\n --liushen-button-hover-bg: #2679cc;\n --liushen-text: rgba(255,255,255,0.702);\n --liushen-fancybox-bg: rgba(0,0,0,0.5);\n}\n\n/* 卡片初始化 */\n#talk .talk_item {\n width: calc(33.333% - 6px);\n background: var(--liushen-card-bg);\n border: var(--liushen-card-border);\n box-shadow: var(--card-box-shadow);\n transition: box-shadow .3s ease-in-out;\n border-radius: 12px;\n display: flex;\n flex-direction: column;\n padding: 20px;\n margin-bottom: 9px;\n margin-right: 9px;\n}\n#talk .talk_item:hover {\n box-shadow: var(--card-hover-box-shadow);\n}\n\n@media (max-width: 900px) {\n #talk .talk_item {\n width: calc(50% - 5px);\n }\n}\n@media (max-width: 450px) {\n #talk .talk_item {\n width: calc(100%);\n }\n}\n\n#talk{\n position: relative;\n width: 100%;\n box-sizing: border-box;\n}\n\n#talk .talk_meta .avatar {\n margin: 0 !important;\n width: 60px;\n height: 60px;\n border-radius: 12px;\n}\n#talk .talk_bottom,\n#talk .talk_meta {\n display: flex;\n align-items: center;\n}\n#talk .talk_meta {\n display: flex;\n align-items: center;\n width: 100%;\n padding-bottom: 10px;\n border-bottom: 1px dashed grey; /* 添加灰色虚线边框 */\n}\n#talk .talk_bottom {\n margin-top: 15px;\n padding-top: 10px;\n border-top: 1px dashed grey; /* 添加灰色虚线边框 */\n justify-content: space-between;\n}\n#talk .talk_meta .info {\n display: flex;\n flex-direction: column;\n margin-left: 10px;\n}\n#talk .talk_meta .info .talk_nick {\n color: #6dbdc3;\n font-size: 1.2rem;\n}\n#talk .talk_meta .info svg.is-badge.icon {\n width: 15px;\n padding-top: 3px;\n}\n#talk .talk_meta .info span.talk_date {\n opacity: .6;\n}\n#talk .talk_item .talk_content {\n margin-top: 10px;\n}\n#talk .talk_item .talk_content .zone_imgbox {\n display: flex;\n flex-wrap: wrap;\n --w: calc(25% - 8px);\n gap: 10px;\n margin-top: 10px;\n}\n#talk .talk_item .talk_content .zone_imgbox a {\n display: block;\n border-radius: 12px;\n width: var(--w);\n aspect-ratio: 1/1;\n position: relative;\n}\n#talk .talk_item .talk_content .zone_imgbox a:first-child {\n width: 100%;\n aspect-ratio: 1.8;\n}\n#talk .talk_item .talk_content .zone_imgbox img {\n border-radius: 10px;\n width: 100%;\n height: 100%;\n margin: 0 !important;\n object-fit: cover;\n}\n/* 底部 */\n#talk .talk_item .talk_bottom {\n opacity: .9;\n}\n#talk .talk_item .talk_bottom .icon {\n float: right;\n transition: all .3s;\n}\n#talk .talk_item .talk_bottom .icon:hover {\n color: #49b1f5;\n}\n#talk .talk_item .talk_bottom span.talk_tag,\n#talk .talk_item .talk_bottom span.location_tag {\n font-size: 14px;\n background-color: var(--liushen-card-secondbg);\n border-radius: 12px;\n padding: 3px 15px 3px 10px;\n transition: box-shadow 0.3s ease;\n box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);\n}\n\n#talk .talk_item .talk_bottom span.location_tag {\n margin-left: 5px;\n}\n\n#talk .talk_item .talk_bottom span.talk_tag:hover,\n#talk .talk_item .talk_bottom span.location_tag:hover {\n box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);\n}\n#talk .talk_item .talk_content>a {\n margin: 0 3px;\n color: #ff7d73 !important;\n}\n#talk .talk_item .talk_content>a:hover{\n text-decoration: none !important;\n color: #ff5143 !important\n}\n\n@media screen and (max-width: 900px) {\n #talk .talk_item .talk_content .zone_imgbox {\n --w: calc(33% - 5px);\n }\n #talk .talk_item #post-comment{\n margin: 0 3px\n }\n}\n@media screen and (max-width: 768px) {\n .zone_imgbox {\n gap: 6px;\n }\n .zone_imgbox {\n --w: calc(50% - 3px);\n }\n span.talk_date {\n font-size: 14px;\n }\n}\n\n#talk .talk_item .talk_content .douban-card {\n margin-top: 10px !important;\n text-decoration: none;\n align-items: center;\n border-radius: 12px;\n color: #faebd7;\n display: flex;\n justify-content: center;\n margin: 10px;\n max-width: 400px;\n overflow: hidden;\n padding: 15px;\n position: relative;\n}\n\n.douban-card .douban-card-bgimg {\n background-position: 50%;\n background-repeat: no-repeat;\n background-size: 100%;\n filter: blur(15px) brightness(.6);\n height: 115%;\n position: absolute;\n width: 115%;\n}\n\n.douban-card .douban-card-left {\n align-items: center;\n display: flex;\n flex-direction: column;\n position: relative;\n}\n\n.douban-card .douban-card-left .douban-card-img {\n transition: all .5s ease;\n height: 130px;\n position: relative;\n width: 80px;\n background-position: 50%;\n background-repeat: no-repeat;\n background-size: 100%;\n}\n\n.douban-card .douban-card-left:hover .douban-card-img {\n filter: blur(5px) brightness(.6);\n transform: perspective(800px) rotateX(180deg);\n}\n\n.douban-card .douban-card-right {\n color: #faebd7;\n display: flex;\n flex-direction: column;\n font-size: 14px;\n line-height: 1.5;\n margin-left: 12px;\n position: relative;\n}\n\n.douban-card .douban-card-right .douban-card-item {\n margin-top: 4px;\n max-width: 95%;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\n/* 外链卡片 */\n#talk .talk_item .talk_content .shuoshuo-external-link {\n /* 无下划线 */\n width: 100%;\n height: 80px;\n margin-top: 10px;\n border-radius: 12px;\n background-color: var(--liushen-card-secondbg);\n color: var(--liushen-card-text);\n border: var(--liushen-card-border);\n transition: background-color .3s ease-in-out;\n}\n\n.shuoshuo-external-link:hover {\n background-color: var(--liushen-button-hover-bg);\n}\n\n.shuoshuo-external-link .external-link {\n display: flex;\n color: var(--liushen-text) !important;\n width: 100%;\n height: 100%;\n}\n\n.shuoshuo-external-link .external-link:hover {\n color: white !important;\n}\n\n.shuoshuo-external-link .external-link:hover {\n text-decoration: none !important;\n}\n\n.shuoshuo-external-link .external-link-left {\n width: 60px;\n height: 60px;\n margin: 10px;\n border-radius: 12px;\n background-size: cover;\n background-position: center;\n}\n\n.shuoshuo-external-link .external-link-right {\n display: flex;\n flex-direction: column;\n justify-content: center;\n width: calc(100% - 80px);\n padding: 10px;\n}\n\n.shuoshuo-external-link .external-link-right .external-link-title {\n font-size: 1.0rem;\n font-weight: 800;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n\n.shuoshuo-external-link .external-link-right i {\n margin-left: 5px;\n}\n\n.limit {\n width: 100%;\n text-align: center;\n margin-top: 30px;\n}\n```\n\n如果一切正常,应该就可以显示了,但是我在使用时发现卡片是黑色的,把前面的root内容删除之后就好了。\n\n# 参考内容\n\n{% link liushen的博客,liushen,https://blog.liushen.fun/posts/8338183a/ %}\n\n当然还有chatgpt的支持\n","tags":["网站"],"categories":["建站手札"]},{"title":"部署历程","url":"/posts/6e5f5039/","content":"# 前提条件\n\n在开始之前,请确保你已满足以下条件:\n\n* 服务器:\n * 安装了 1Panel 面板的 Linux 服务器\n * 拥有服务器的 SSH 访问权限(本文示例将使用 root 用户,你可以根据实际情况替换为其他有权限的用户)。\n * 服务器上已安装 Git。\n* 1Panel 配置:\n\n已通过 1Panel 创建了一个网站(例如 `blog.yourdomain.com`),并记下该网站的 根目录(`Document Root`)。通常在 1Panel 中,路径类似于 `/opt/1panel/apps/openresty/openresty/www/sites/你的网站目录/index`。请务必替换为你的实际路径。\n本地环境:\n\n* 你的电脑上已安装并配置好 Hexo 博客环境。\n* 你的电脑上已安装 Git。\n* 已安装 Hexo Git 部署插件:\n\n```bash\nnpm install hexo-deployer-git --save\n```\n\nSSH 密钥认证 (关键):\n\n1. 你需要在本地电脑生成 SSH 密钥对(如果还没有的话)。\n2. 必须将你的本地电脑的 SSH 公钥 添加到服务器上对应用户(如 root)的 ~/.ssh/authorized_keys 文件中。这样可以确保 hexo deploy 时 Git PUSH 操作无需输入密码即可完成。\n 配置步骤\n 步骤一:在服务器上安装 Git\n 如果你的服务器尚未安装 Git,请根据你的 Linux 发行版执行相应命令:\n\nDebian/Ubuntu:\n\n```bash\nsudo apt-get update\nsudo apt-get install git -y\n```\n\nFedora/RedHat/CentOS:\n\n```bash\nsudo yum install git -y\n```\n\n步骤二:在服务器上创建 Git 裸仓库 (Bare Repository)\n我们需要在服务器上创建一个 Git “裸仓库”。裸仓库不包含工作目录(即你看不到项目文件),只存储 Git 的版本历史和对象数据,非常适合作为中心仓库或中转仓库。\n\n创建仓库目录:\n选择一个路径来存放你的 Git 仓库。例如,我们选择放在 /root/git/ 目录下(你可以自定义路径)。\n\n# 创建目录 (如果父目录不存在,也一并创建)\n\n```bash\nmkdir -p /root/git/\n```\n\n修改目录权限 (可选但推荐):\n如果你不是一直使用 root 用户,或者希望更精细地控制权限,可以修改目录所有者和权限。如果使用 root,此步通常可以跳过。\n\n将目录所有者改为当前用户 (如果用 root 执行,则为 root)\n\n```bash\nchown -R USER:USER:USER /root/git/\n```\n\n设置权限 (所有者完全控制,同组用户读取执行,其他用户读取执行)\n\n```bash\nchmod -R 755 /root/git/\n```\n\n初始化裸仓库:\n进入你选择的目录,并初始化一个裸仓库。我们将仓库命名为 blog.git (你也可以自定义)。\n\n```bash\ncd /root/git\ngit init --bare blog.git\n```\n\n执行后,你会在 /root/git/ 目录下看到一个名为 blog.git 的文件夹。\n\n步骤三:在服务器上配置 Git 钩子 (post-receive)\nGit 钩子是在 Git 操作过程中的特定时间点自动执行的脚本。post-receive 钩子在服务器成功接收到推送 (push) 后执行。我们将利用这个钩子将推送过来的 Hexo 文件检出 (checkout) 到 1Panel 的网站根目录。\n\n创建钩子文件:\n进入裸仓库的 hooks 目录,并创建一个名为 post-receive 的文件。\n\n```bash\nvim /root/git/blog.git/hooks/post-receive\n```\n\n编辑钩子内容:\n在 vim 编辑器中,按 i 进入插入模式,然后粘贴以下脚本内容:\n\n```bash\n#!/bin/bash\n# 指定 Hexo 网站文件存放的目录 (!!!!务必替换为你的 1Panel 网站实际根目录!!!!)\nWORK_TREE=\"/opt/1panel/apps/openresty/openresty/www/sites/blog/index\" \n# 指定 Git 裸仓库的路径 (!!!!务必替换为你的裸仓库实际路径!!!!)\nGIT_DIR=\"/root/git/blog.git\"\n\n# 执行 Git checkout 命令,强制将内容检出到工作目录\ngit --work-tree=${WORK_TREE} --git-dir=${GIT_DIR} checkout -f\n\necho \"Hexo blog deployed to ${WORK_TREE}\"\n```\n\n# 可选的提交信息\n\n请务必修改:\n\n`root`: 替换为你配置了 SSH 免密登录的服务器用户名。\n`YOUR_SERVER_IP`: 替换为你的服务器公网 IP 地址或域名。\n`22`: 如果你的 SSH 端口不是默认的 22,请修改。\n`/root/git/blog.git`: 替换为你在服务器上创建的裸仓库的 绝对路径。\n`branch`: 确保这个分支名 (main 或 master) 与你的 post-receive 钩子期望检出的分支一致(默认情况下 checkout -f 会检出仓库的 HEAD 指向的分支,通常是 master 或 main)。\n步骤五:部署你的 Hexo 博客\n一切配置完成后,部署就非常简单了:\n\n在本地 Hexo 项目目录下,执行标准的生成和部署命令:\n\n```bash\nhexo clean && hexo generate && hexo deploy\n```\n\n或者直接:\n\n```bash\nhexo d\n```\n\n工作流程:\n\nhexo g 生成静态文件到 public 目录。\nhexo d 使用 hexo-deployer-git 插件:\n将 public 目录的内容提交到一个临时 Git 分支。\n通过 SSH 将这个分支强制推送到你配置的服务器裸仓库 (ssh://root@YOUR_SERVER_IP:22/root/git/blog.git)。\n服务器上的 Git 仓库接收到推送后,自动触发 post-receive 钩子脚本。\n钩子脚本执行 git checkout -f,将最新的网站文件强制检出(部署)到 1Panel 网站的根目录 (/opt/1panel/apps/openresty/openresty/www/sites/blog/index)。\n验证:\n部署命令执行成功后,稍等片刻,然后访问你的博客域名 (http://blog.yourdomain.com 或 https://blog.yourdomain.com),应该就能看到更新后的内容了。\n\n# 故障排除提示\n\n* 权限问题: 检查服务器上 Git 仓库目录、网站根目录以及钩子文件的权限是否正确。钩子脚本需要有权限写入网站根目录。\n* SSH 密钥问题: 确保本地 SSH 公钥已正确添加到服务器的 authorized_keys 文件中,并且本地 SSH 私钥可用。尝试手动 ssh root@YOUR_SERVER_IP 看是否能免密登录。\n* 路径错误: 仔细核对 post-receive 脚本中的 --work-tree 和 --git-dir 路径,以及本地 _config.yml 中的 repo 路径是否完全正确。\n* 钩子未执行: 检查钩子文件是否有执行权限 (chmod +x),文件名是否精确为 post-receive (没有扩展名)。\n* 查看日志: 如果部署失败,可以尝试在服务器上查看 SSH 或 Git 相关日志,或者在钩子脚本中添加一些 echo 输出到日志文件来调试。\n* 通过以上配置,你就实现了一个高效、自动化的 Hexo 博客部署流程!\n","tags":["网站"],"categories":["建站手札"]}] |