From 68e3cf372fdacb05fa5f88ff47c2f43731b924b5 Mon Sep 17 00:00:00 2001 From: Vaica <94612053+zqlit@users.noreply.github.com> Date: Wed, 21 Jan 2026 13:13:54 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dlink=5Flite.json=20bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/RefreshCDN.yml | 33 -- .github/workflows/upy.yml | 24 ++ RefreshCDN.py => scripts/RefreshCDN.py | 0 scripts/add_draft_to_hidden.ps1 | 5 +- scripts/check_links.js | 19 +- scripts/update_link_lite_json.ps1 | 5 +- themes/Ying/static/json/link_lite.json | 406 ++++++++++++------------- 7 files changed, 251 insertions(+), 241 deletions(-) delete mode 100644 .github/workflows/RefreshCDN.yml rename RefreshCDN.py => scripts/RefreshCDN.py (100%) diff --git a/.github/workflows/RefreshCDN.yml b/.github/workflows/RefreshCDN.yml deleted file mode 100644 index bb77dbc3..00000000 --- a/.github/workflows/RefreshCDN.yml +++ /dev/null @@ -1,33 +0,0 @@ -name: Refresh CDN - -on: - push: - branches: - - main - schedule: - - cron: '0 */12 * * *' # 每 12 小时执行一次 - -jobs: - refresh-cdn: - runs-on: ubuntu-latest - steps: - - name: 检出代码 - uses: actions/checkout@v2 - - - name: 安装 Python - uses: actions/setup-python@v2 - with: - python-version: '3.x' - - - name: 安装依赖 - run: pip install requests - - - name: 等待源站部署 - run: sleep 1m # 这里用了个笨办法,等待 1 分钟后进行刷新 - - - name: 刷新 CDN - run: python RefreshCDN.py - env: - DOGECLOUD_ACCESS_KEY: ${{ secrets.DOGECLOUD_ACCESS_KEY }} - DOGECLOUD_SECRET_KEY: ${{ secrets.DOGECLOUD_SECRET_KEY }} - CDN_URL_LIST: ${{ secrets.CDN_URL_LIST }} \ No newline at end of file diff --git a/.github/workflows/upy.yml b/.github/workflows/upy.yml index fc3f8778..43c003b3 100644 --- a/.github/workflows/upy.yml +++ b/.github/workflows/upy.yml @@ -21,6 +21,15 @@ jobs: hugo-version: '0.128.2' extended: true + - name: Run Pre-Build Scripts + shell: pwsh + run: | + # 1. 自动生成友链 JSON (即使本地漏提交也能保证是最新的) + ./scripts/update_link_lite_json.ps1 + + # 2. 自动处理隐藏文章 (防止 status: hidden 的文章意外泄露) + ./scripts/add_draft_to_hidden.ps1 + - name: Build run: rm -rf public && hugo --minify @@ -43,3 +52,18 @@ jobs: password: ${{ secrets.UPYUN_PASSWORD }} dir: 'public' # 确认这个目录是您的构建输出目录 publish_dir: '/' # 发布到 UpYun 的根目录 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.x' + + - name: Install dependencies + run: pip install requests + + - name: Refresh DogeCloud CDN + env: + DOGECLOUD_ACCESS_KEY: ${{ secrets.DOGECLOUD_ACCESS_KEY }} + DOGECLOUD_SECRET_KEY: ${{ secrets.DOGECLOUD_SECRET_KEY }} + CDN_URL_LIST: ${{ secrets.CDN_URL_LIST }} + run: python scripts/RefreshCDN.py diff --git a/RefreshCDN.py b/scripts/RefreshCDN.py similarity index 100% rename from RefreshCDN.py rename to scripts/RefreshCDN.py diff --git a/scripts/add_draft_to_hidden.ps1 b/scripts/add_draft_to_hidden.ps1 index 20c0f2d2..3d07bdf2 100644 --- a/scripts/add_draft_to_hidden.ps1 +++ b/scripts/add_draft_to_hidden.ps1 @@ -84,8 +84,9 @@ foreach ($file in $files) { continue } - # Save file using .NET method to ensure UTF8 - [System.IO.File]::WriteAllText($file.FullName, $newContent, [System.Text.Encoding]::UTF8) + # Save file using .NET method to ensure UTF8 without BOM + $utf8NoBom = New-Object System.Text.UTF8Encoding $false + [System.IO.File]::WriteAllText($file.FullName, $newContent, $utf8NoBom) Write-Host " -> Saved changes to $($file.Name)" -ForegroundColor Green $count++ } diff --git a/scripts/check_links.js b/scripts/check_links.js index cefbe146..de95435b 100644 --- a/scripts/check_links.js +++ b/scripts/check_links.js @@ -87,10 +87,27 @@ async function main() { process.exit(1); } + let linksData; let links; try { const fileContent = fs.readFileSync(LINKS_FILE, 'utf8'); - links = JSON.parse(fileContent); + linksData = JSON.parse(fileContent); + // Adapt to both array (old) and object with friends key (new) + if (Array.isArray(linksData)) { + links = linksData; + } else if (linksData.friends && Array.isArray(linksData.friends)) { + // The new format has [name, url, avatar] arrays inside friends array + // We need to convert them to objects {name, url} for the checker + links = linksData.friends.map(item => { + if (Array.isArray(item)) { + return { name: item[0], url: item[1] }; + } + return item; + }); + } else { + console.error('Error: Unknown JSON format'); + process.exit(1); + } } catch (e) { console.error('Error parsing JSON:', e.message); process.exit(1); diff --git a/scripts/update_link_lite_json.ps1 b/scripts/update_link_lite_json.ps1 index 9148524c..8a5e341e 100644 --- a/scripts/update_link_lite_json.ps1 +++ b/scripts/update_link_lite_json.ps1 @@ -94,7 +94,8 @@ if (-not (Test-Path $jsonDir)) { New-Item -ItemType Directory -Path $jsonDir | Out-Null } -# Write to file -[System.IO.File]::WriteAllText($jsonPath, $json, [System.Text.Encoding]::UTF8) +# Write to file without BOM +$utf8NoBom = New-Object System.Text.UTF8Encoding $false +[System.IO.File]::WriteAllText($jsonPath, $json, $utf8NoBom) Write-Host "Successfully generated $jsonPath" -ForegroundColor Green diff --git a/themes/Ying/static/json/link_lite.json b/themes/Ying/static/json/link_lite.json index 9d498fb3..448c78b2 100644 --- a/themes/Ying/static/json/link_lite.json +++ b/themes/Ying/static/json/link_lite.json @@ -1,204 +1,204 @@ -{ - "friends": [ - [ - "吾柯", - "https://blog.keepke.com", - "https://blog.keepke.com/logo.png" - ], - [ - "叶开", - "https://qq.md", - "https://cravatar.cn/avatar/4741124456fb02fa4da30494dbc6c99e?d=monsterid\u0026s=80" - ], - [ - "一泽", - "https://yang99.fun", - "https://q.qlogo.cn/g?b=qq\u0026nk=3369963811@qq.com\u0026s=100" - ], - [ - "七栀", - "https://qydzz.cn", - "https://qydzz.cn/logo.png" - ], - [ - "若志随笔", - "https://www.rz.sb", - "https://q1.qlogo.cn/g?b=qq\u0026nk=80360650\u0026s=640" - ], - [ - "黑桃三", - "https://heitaosan.com", - "https://s2.ax1x.com/2020/01/03/lUmf81.png" - ], - [ - "十七的小栈", - "https://blog.allnull.cn", - "https://cravatar.cn/avatar/56238a7f177c534928fd3cf4161ab59e?s=65\u0026r=G\u0026d=mm" - ], - [ - "Vian", - "https://vian.top", - "https://www.vian.top/avatar.ico" - ], - [ - "油油", - "https://blog.200011.net", - "https://q1.qlogo.cn/g?b=qq\u0026nk=1376652515\u0026s=640" - ], - [ - "段先森", - "https://duanxiansen.com", - "https://q.qlogo.cn/g?b=qq\u0026nk=2443266417@qq.com\u0026s=100" - ], - [ - "Fivk博客", - "https://blog.fivk.cn", - "https://q1.qlogo.cn/g?b=qq\u0026nk=11470226\u0026s=640" - ], - [ - "百品博客", - "https://baipin.pw", - "https://www.baipin.pw/wp-content/uploads/2019/07/cropped-ABUIABACGAAg_bP2wwUorbiplQQwgAU4gAU.jpg" - ], - [ - "WhiteFan", - "https://www.baifan97.cn", - "https://ypy.baifan97.cn/typecho/uploads/img/avatar.png" - ], - [ - "北枫", - "https://beifeng.me", - "https://q1.qlogo.cn/g?b=qq\u0026nk=41777657\u0026s=640" - ], - [ - "团团生活志", - "https://t-t.live", - "https://img.t-t.live/img/tx.png" - ], - [ - "臭袜子", - "https://huziyan.com", - "https://huziyan.com/usr/themes/icefox/assets/img/tx.jpg" - ], - [ - "岳泽以", - "https://www.yuezeyi.com", - "https://q2.qlogo.cn/g?b=qq\u0026nk=2780008080\u0026s=100" - ], - [ - "三石的记录", - "https://www.fllv.cn", - "https://cdn.helingqi.com/wavatar/a25a7640aa68e6d26e32afee8120f7e5?s=65\u0026r=G\u0026d=" - ], - [ - "竹春廿柒", - "https://mojinxi.cn", - "https://mojinxi.cn/img/logo.png" - ], - [ - "大嘴狗狗", - "https://www.sirit.com.cn", - "https://www.sirit.com.cn/siritlogo.png" - ], - [ - "半截の诗", - "https://sweetjing.cc/", - "https://q1.qlogo.cn/g?b=qq\u0026nk=1486823198\u0026s=640" - ], - [ - "XIAOMING\u0027S BLOG", - "https://vimin.cc", - "https://cravatar.cn/avatar/6eb95597489dd26f15a973e667d71aef?s=100\u0026amp;r=G\u0026amp;d=" - ], - [ - "网友小宋", - "https://xyzbz.cn", - "https://cravatar.cn/avatar/120340d1df519f4e28613fe5d404b286?s=65\u0026r=G\u0026d=" - ], - [ - "微风忆夏", - "https://sumiler.com", - "https://cravatar.cn/avatar//a35f5ef7a4bce3b7cfa6f538ffcae7aa" - ], - [ - "林林杂语", - "https://www.xiaozonglin.cn", - "https://cravatar.cn/avatar/04bfc914bd50b42eb507bf66aad0cc31?d=mp" - ], - [ - "西瓜撞地球", - "https://www.bio-w.cn", - "https://bu.dusays.com/2022/10/17/634d313602a1e.png" - ], - [ - "Kris Yan", - "https://blog.krisyan.dev", - "https://cravatar.cn/avatar/05729ab2ca3b99203a674859f77d592b?\u0026d=mp" - ], - [ - "Echo 的小窝", - "https://www.liveout.cn/", - "https://cravatar.cn/avatar/d9d83d9ebd03447fff3b094e140a0cbe" - ], - [ - "未来往事", - "https://felixway.cn", - "https://cravatar.cn/avatar/2ee35215cbea58cd8b2605e7f517d689?\u0026d=mp" - ], - [ - "小稚生活志", - "https://ihello.cc", - "https://bu.dusays.com/2024/02/02/65bbce27b129a.jpg" - ], - [ - "风呼呼", - "https://whooc.com", - "https://whooc.com/logo" - ], - [ - "柳橙睿", - "https://www.liuchengrui.cn", - "https://www.liuchengrui.cn/myphoto.png" - ], - [ - "永恒末匕", - "https://likaijian.com", - "https://q.qlogo.cn/headimg_dl?dst_uin=1527335101\u0026spec=640" - ], - [ - "刘郎阁", - "https://vjo.cc", - "https://yjvc.cn/usr/uploads/logo.jpeg" - ], - [ - "浮沉流年", - "https://www.fcln.net", - "https://cravatar.cn/avatar//4355eea603309a0c159ca27f54e27c89?s=65\u0026r=G\u0026d=" - ], - [ - "二十六", - "https://www.ershiliu.com/", - "https://www.ershiliu.com/favicon.ico" - ], - [ - "阿呆日记", - "https://dai.ge", - "https://dai.ge/img/logo.png" - ], - [ - "邹江博客", - "https://www.zoujiang.com", - "https://www.zoujiang.com/logo.jpg" - ], - [ - "清梦云熙", - "https://skylan.cc", - "https://cravatar.cn/avatar/853572275a978dbccefbe2242ba1c415" - ], - [ - "如约而至", - "https://aloner.ink", - "https://cravatar.cn/avatar/af1874b7856255302fc3df5102a6ce6d" - ] - ] +{ + "friends": [ + [ + "吾柯", + "https://blog.keepke.com", + "https://blog.keepke.com/logo.png" + ], + [ + "叶开", + "https://qq.md", + "https://cravatar.cn/avatar/4741124456fb02fa4da30494dbc6c99e?d=monsterid&s=80" + ], + [ + "一泽", + "https://yang99.fun", + "https://q.qlogo.cn/g?b=qq&nk=3369963811@qq.com&s=100" + ], + [ + "七栀", + "https://qydzz.cn", + "https://qydzz.cn/logo.png" + ], + [ + "若志随笔", + "https://www.rz.sb", + "https://q1.qlogo.cn/g?b=qq&nk=80360650&s=640" + ], + [ + "黑桃三", + "https://heitaosan.com", + "https://s2.ax1x.com/2020/01/03/lUmf81.png" + ], + [ + "十七的小栈", + "https://blog.allnull.cn", + "https://cravatar.cn/avatar/56238a7f177c534928fd3cf4161ab59e?s=65&r=G&d=mm" + ], + [ + "Vian", + "https://vian.top", + "https://www.vian.top/avatar.ico" + ], + [ + "油油", + "https://blog.200011.net", + "https://q1.qlogo.cn/g?b=qq&nk=1376652515&s=640" + ], + [ + "段先森", + "https://duanxiansen.com", + "https://q.qlogo.cn/g?b=qq&nk=2443266417@qq.com&s=100" + ], + [ + "Fivk博客", + "https://blog.fivk.cn", + "https://q1.qlogo.cn/g?b=qq&nk=11470226&s=640" + ], + [ + "百品博客", + "https://baipin.pw", + "https://www.baipin.pw/wp-content/uploads/2019/07/cropped-ABUIABACGAAg_bP2wwUorbiplQQwgAU4gAU.jpg" + ], + [ + "WhiteFan", + "https://www.baifan97.cn", + "https://ypy.baifan97.cn/typecho/uploads/img/avatar.png" + ], + [ + "北枫", + "https://beifeng.me", + "https://q1.qlogo.cn/g?b=qq&nk=41777657&s=640" + ], + [ + "团团生活志", + "https://t-t.live", + "https://img.t-t.live/img/tx.png" + ], + [ + "臭袜子", + "https://huziyan.com", + "https://huziyan.com/usr/themes/icefox/assets/img/tx.jpg" + ], + [ + "岳泽以", + "https://www.yuezeyi.com", + "https://q2.qlogo.cn/g?b=qq&nk=2780008080&s=100" + ], + [ + "三石的记录", + "https://www.fllv.cn", + "https://cdn.helingqi.com/wavatar/a25a7640aa68e6d26e32afee8120f7e5?s=65&r=G&d=" + ], + [ + "竹春廿柒", + "https://mojinxi.cn", + "https://mojinxi.cn/img/logo.png" + ], + [ + "大嘴狗狗", + "https://www.sirit.com.cn", + "https://www.sirit.com.cn/siritlogo.png" + ], + [ + "半截の诗", + "https://sweetjing.cc/", + "https://q1.qlogo.cn/g?b=qq&nk=1486823198&s=640" + ], + [ + "XIAOMING'S BLOG", + "https://vimin.cc", + "https://cravatar.cn/avatar/6eb95597489dd26f15a973e667d71aef?s=100&r=G&d=" + ], + [ + "网友小宋", + "https://xyzbz.cn", + "https://cravatar.cn/avatar/120340d1df519f4e28613fe5d404b286?s=65&r=G&d=" + ], + [ + "微风忆夏", + "https://sumiler.com", + "https://cravatar.cn/avatar//a35f5ef7a4bce3b7cfa6f538ffcae7aa" + ], + [ + "林林杂语", + "https://www.xiaozonglin.cn", + "https://cravatar.cn/avatar/04bfc914bd50b42eb507bf66aad0cc31?d=mp" + ], + [ + "西瓜撞地球", + "https://www.bio-w.cn", + "https://bu.dusays.com/2022/10/17/634d313602a1e.png" + ], + [ + "Kris Yan", + "https://blog.krisyan.dev", + "https://cravatar.cn/avatar/05729ab2ca3b99203a674859f77d592b?&d=mp" + ], + [ + "Echo 的小窝", + "https://www.liveout.cn/", + "https://cravatar.cn/avatar/d9d83d9ebd03447fff3b094e140a0cbe" + ], + [ + "未来往事", + "https://felixway.cn", + "https://cravatar.cn/avatar/2ee35215cbea58cd8b2605e7f517d689?&d=mp" + ], + [ + "小稚生活志", + "https://ihello.cc", + "https://bu.dusays.com/2024/02/02/65bbce27b129a.jpg" + ], + [ + "风呼呼", + "https://whooc.com", + "https://whooc.com/logo" + ], + [ + "柳橙睿", + "https://www.liuchengrui.cn", + "https://www.liuchengrui.cn/myphoto.png" + ], + [ + "永恒末匕", + "https://likaijian.com", + "https://q.qlogo.cn/headimg_dl?dst_uin=1527335101&spec=640" + ], + [ + "刘郎阁", + "https://vjo.cc", + "https://yjvc.cn/usr/uploads/logo.jpeg" + ], + [ + "浮沉流年", + "https://www.fcln.net", + "https://cravatar.cn/avatar//4355eea603309a0c159ca27f54e27c89?s=65&r=G&d=" + ], + [ + "二十六", + "https://www.ershiliu.com/", + "https://www.ershiliu.com/favicon.ico" + ], + [ + "阿呆日记", + "https://dai.ge", + "https://dai.ge/img/logo.png" + ], + [ + "邹江博客", + "https://www.zoujiang.com", + "https://www.zoujiang.com/logo.jpg" + ], + [ + "清梦云熙", + "https://skylan.cc", + "https://cravatar.cn/avatar/853572275a978dbccefbe2242ba1c415" + ], + [ + "如约而至", + "https://aloner.ink", + "https://cravatar.cn/avatar/af1874b7856255302fc3df5102a6ce6d" + ] + ] } \ No newline at end of file