From 6dc97f39d756471180a325826291516045656911 Mon Sep 17 00:00:00 2001 From: JohnsonRan Date: Mon, 11 Aug 2025 21:07:51 +0800 Subject: [PATCH 01/14] ci: implement git tag-based automated release workflow --- .github/workflows/docker-image.yml | 44 +++++--------- .github/workflows/release.yml | 95 ++++++++++++++++++++++++++++++ .husky/pre-commit | 5 -- package.json | 1 - scripts/convert-changelog.js | 74 ++++++++++++++++------- src/lib/changelog.ts | 54 +++++++++-------- 6 files changed, 194 insertions(+), 79 deletions(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index bd055cb530..438497f5d6 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -1,11 +1,6 @@ name: Build & Push Docker image on: - push: - branches: - - main - paths-ignore: - - '**.md' pull_request_target: branches: - main @@ -15,6 +10,10 @@ on: types: - labeled - synchronize + workflow_run: + workflows: ['Release'] + types: + - completed workflow_dispatch: @@ -61,22 +60,20 @@ jobs: id: lowercase run: echo "owner=$(echo '${{ github.repository_owner }}' | tr '[:upper:]' '[:lower:]')" >> "$GITHUB_OUTPUT" - - name: Get version from VERSION.txt - id: version - run: | - VERSION=$(cat VERSION.txt | tr -d '[:space:]') - echo "version=$VERSION" >> "$GITHUB_OUTPUT" - echo "Current version: $VERSION" - - name: Extract metadata id: meta uses: docker/metadata-action@v5 + with: images: ghcr.io/${{ steps.lowercase.outputs.owner }}/moontv tags: | type=ref,event=pr type=raw,value=latest,enable={{is_default_branch}} - type=raw,value={{steps.version.outputs.version}} + type=match,pattern=v(.*),group=1,enable=${{ startsWith(github.ref, 'refs/tags/v') }} + + - name: Get latest tag + run: | + echo "latest_tag=$(curl -s https://api.github.com/repos/${{ github.repository }}/tags | jq -r '.[0].name // "latest"' | sed 's/^v//')" >> $GITHUB_ENV - name: Build and push by digest id: build @@ -86,7 +83,8 @@ jobs: file: ./Dockerfile platforms: ${{ matrix.platform }} labels: ${{ steps.meta.outputs.labels }} - outputs: type=image,name=ghcr.io/${{ steps.lowercase.outputs.owner }}/moontv,push-by-digest=true,name-canonical=true,push=true + tags: ghcr.io/${{ steps.lowercase.outputs.owner }}/moontv:${{ env.latest_tag }} + outputs: type=image,name=ghcr.io/${{ steps.lowercase.outputs.owner }}/moontv,name-canonical=true,push=true - name: Export digest run: | @@ -128,13 +126,6 @@ jobs: id: lowercase run: echo "owner=$(echo '${{ github.repository_owner }}' | tr '[:upper:]' '[:lower:]')" >> "$GITHUB_OUTPUT" - - name: Get version from VERSION.txt - id: version - run: | - VERSION=$(cat VERSION.txt | tr -d '[:space:]') - echo "version=$VERSION" >> "$GITHUB_OUTPUT" - echo "Current version: $VERSION" - - name: Extract metadata id: meta uses: docker/metadata-action@v5 @@ -143,7 +134,7 @@ jobs: tags: | type=ref,event=pr,prefix=pr- type=raw,value=latest,enable={{is_default_branch}} - type=raw,value={{steps.version.outputs.version}} + type=match,pattern=v(.*),group=1,enable=${{ startsWith(github.ref, 'refs/tags/v') }} - name: Create manifest list and push working-directory: /tmp/digests @@ -187,7 +178,7 @@ jobs: 构建完成时间:${new Date().toLocaleString('zh-CN', { timeZone: 'Asia/Shanghai' })}` }); - cleanup: + cleanup-refresh: runs-on: ubuntu-latest needs: - merge @@ -200,13 +191,6 @@ jobs: repository: ${{ github.repository }} retain_days: 0 keep_minimum_runs: 2 - - version-cache-refresh: - runs-on: ubuntu-latest - needs: - - cleanup - if: always() && github.event_name != 'pull_request_target' - steps: - name: Refresh VERSION.txt cache run: | echo "Refreshing VERSION.txt cache..." diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000000..b0afb80cf2 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,95 @@ +name: Release + +on: + push: + tags: + - 'v*' + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +permissions: + contents: write + packages: write + +jobs: + release: + runs-on: ubuntu-latest + steps: + - name: Checkout source code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Extract version from tag + id: version + run: | + VERSION=${GITHUB_REF#refs/tags/v} + TAG_NAME=${GITHUB_REF#refs/tags/} + echo "version=$VERSION" >> $GITHUB_OUTPUT + echo "tag=$TAG_NAME" >> $GITHUB_OUTPUT + echo "Version: $VERSION" + echo "Tag: $TAG_NAME" + + - name: Get tag message + id: tag_message + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + TAG_NAME=${{ steps.version.outputs.tag }} + RELEASE_BODY=$(gh release view "$TAG_NAME" --json body -q .body || echo "") + printf '%s\n' "$RELEASE_BODY" > /tmp/tag_message.txt + echo "Tag message saved to /tmp/tag_message.txt" + echo "Tag message content:" + cat /tmp/tag_message.txt + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '18' + + - name: Update version files and generate changelog + run: | + CURRENT_DATE=$(date +%Y-%m-%d) + VERSION="${{ steps.version.outputs.version }}" + TAG_MESSAGE=$(cat /tmp/tag_message.txt) + echo "Updating CHANGELOG file..." + { + echo "## [$VERSION] - $CURRENT_DATE" + echo "" + cat /tmp/tag_message.txt + echo "" + } > /tmp/new_entry.txt + + if [ -f "CHANGELOG" ]; then + cp CHANGELOG CHANGELOG.bak + cat /tmp/new_entry.txt CHANGELOG.bak > CHANGELOG + else + cp /tmp/new_entry.txt CHANGELOG + fi + echo "✅ Updated CHANGELOG with new entry for version $VERSION" + + echo "Updating VERSION.txt..." + echo "$VERSION" > VERSION.txt + echo "✅ Updated VERSION.txt to $VERSION" + + echo "Generating changelog TypeScript file..." + node scripts/convert-changelog.js + + echo "Updating version.ts..." + sed -i "s/const CURRENT_VERSION = '[^']*';/const CURRENT_VERSION = '$VERSION';/" src/lib/version.ts + echo "✅ Updated version.ts to $VERSION" + + - name: Commit generated files + run: | + git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" + git config --local user.name "github-actions[bot]" + git add CHANGELOG VERSION.txt src/lib/changelog.ts src/lib/version.ts + if git diff --staged --quiet; then + echo "No changes to commit" + else + git commit -m "chore: Bump to ${{ steps.version.outputs.version }}" + git push origin HEAD:main + echo "Committed and pushed generated files" + fi diff --git a/.husky/pre-commit b/.husky/pre-commit index 7a0491ea17..c37466e2b3 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1,9 +1,4 @@ #!/bin/sh . "$(dirname "$0")/_/husky.sh" -pnpm gen:changelog -git add VERSION.txt -git add src/lib/version.ts -git add src/lib/changelog.ts - npx lint-staged \ No newline at end of file diff --git a/package.json b/package.json index a28754d596..61be790386 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,6 @@ "format:check": "prettier -c .", "gen:runtime": "node scripts/convert-config.js", "gen:manifest": "node scripts/generate-manifest.js", - "gen:changelog": "node scripts/convert-changelog.js", "postbuild": "echo 'Build completed - sitemap generation disabled'", "prepare": "husky install" }, diff --git a/scripts/convert-changelog.js b/scripts/convert-changelog.js index 66fd1665a6..c88c8f8279 100644 --- a/scripts/convert-changelog.js +++ b/scripts/convert-changelog.js @@ -10,6 +10,7 @@ function parseChangelog(content) { const versions = []; let currentVersion = null; let currentSection = null; + let inVersionContent = false; for (const line of lines) { const trimmedLine = line.trim(); @@ -29,27 +30,38 @@ function parseChangelog(content) { added: [], changed: [], fixed: [], + content: [], // 用于存储原始内容,当没有分类时使用 }; currentSection = null; + inVersionContent = true; continue; } - // 匹配章节标题 - if (trimmedLine === '### Added') { - currentSection = 'added'; - continue; - } else if (trimmedLine === '### Changed') { - currentSection = 'changed'; - continue; - } else if (trimmedLine === '### Fixed') { - currentSection = 'fixed'; - continue; - } + // 如果遇到下一个版本或到达文件末尾,停止处理当前版本 + if (inVersionContent && currentVersion) { + // 匹配章节标题 + if (trimmedLine === '### Added') { + currentSection = 'added'; + continue; + } else if (trimmedLine === '### Changed') { + currentSection = 'changed'; + continue; + } else if (trimmedLine === '### Fixed') { + currentSection = 'fixed'; + continue; + } - // 匹配条目: - 内容 - if (trimmedLine.startsWith('- ') && currentSection && currentVersion) { - const entry = trimmedLine.substring(2); - currentVersion[currentSection].push(entry); + // 匹配条目: - 内容 + if (trimmedLine.startsWith('- ') && currentSection) { + const entry = trimmedLine.substring(2); + currentVersion[currentSection].push(entry); + } else if ( + trimmedLine && + !trimmedLine.startsWith('#') && + !trimmedLine.startsWith('###') + ) { + currentVersion.content.push(trimmedLine); + } } } @@ -58,6 +70,19 @@ function parseChangelog(content) { versions.push(currentVersion); } + // 后处理:如果某个版本没有分类内容,但有 content,则将 content 放到 changed 中 + versions.forEach((version) => { + const hasCategories = + version.added.length > 0 || + version.changed.length > 0 || + version.fixed.length > 0; + if (!hasCategories && version.content.length > 0) { + version.changed = version.content; + } + // 清理 content 字段 + delete version.content; + }); + return { versions }; } @@ -170,10 +195,19 @@ function main() { fs.writeFileSync(outputPath, tsContent, 'utf-8'); - // 更新版本文件 - console.log('正在更新版本文件...'); - updateVersionFile(latestVersion); - updateVersionTs(latestVersion); + // 检查是否在 GitHub Actions 环境中运行 + const isGitHubActions = process.env.GITHUB_ACTIONS === 'true'; + + if (isGitHubActions) { + // 在 GitHub Actions 中,更新版本文件 + console.log('正在更新版本文件...'); + updateVersionFile(latestVersion); + updateVersionTs(latestVersion); + } else { + // 在本地运行时,只提示但不更新版本文件 + console.log('🔧 本地运行模式:跳过版本文件更新'); + console.log('💡 版本文件更新将在 git tag 触发的 release 工作流中完成'); + } console.log(`✅ 成功生成 ${outputPath}`); console.log(`📊 版本统计:`); @@ -183,7 +217,7 @@ function main() { ); }); - console.log('\n🎉 所有更新完成!'); + console.log('\n🎉 转换完成!'); } catch (error) { console.error('❌ 转换失败:', error); process.exit(1); diff --git a/src/lib/changelog.ts b/src/lib/changelog.ts index 22ec926d8f..7aae6f0aa7 100644 --- a/src/lib/changelog.ts +++ b/src/lib/changelog.ts @@ -11,64 +11,72 @@ export interface ChangelogEntry { export const changelog: ChangelogEntry[] = [ { - version: '1.0.4', - date: '2025-08-12', - added: ['优化版本管理工作流,实现单点修改'], - changed: ['版本号现在从CHANGELOG自动提取,无需手动维护VERSION.txt'], + version: "1.0.4", + date: "2025-08-12", + added: [ + "优化版本管理工作流,实现单点修改" + ], + changed: [ + "版本号现在从CHANGELOG自动提取,无需手动维护VERSION.txt" + ], fixed: [ // 无修复内容 - ], + ] }, { - version: '1.0.3', - date: '2025-08-11', + version: "1.0.3", + date: "2025-08-11", added: [ // 无新增内容 ], - changed: ['升级播放器 Artplayer 至版本 5.2.5'], + changed: [ + "升级播放器 Artplayer 至版本 5.2.5" + ], fixed: [ // 无修复内容 - ], + ] }, { - version: '1.0.2', - date: '2025-08-11', + version: "1.0.2", + date: "2025-08-11", added: [ // 无新增内容 ], changed: [ - '版本号比较机制恢复为数字比较,仅当最新版本大于本地版本时才认为有更新', - '[运维] 自动替换 version.ts 中的版本号为 VERSION.txt 中的版本号', + "版本号比较机制恢复为数字比较,仅当最新版本大于本地版本时才认为有更新", + "[运维] 自动替换 version.ts 中的版本号为 VERSION.txt 中的版本号" ], fixed: [ // 无修复内容 - ], + ] }, { - version: '1.0.1', - date: '2025-08-11', + version: "1.0.1", + date: "2025-08-11", added: [ // 无新增内容 ], changed: [ // 无变更内容 ], - fixed: ['修复版本检查功能,只要与最新版本号不一致即认为有更新'], + fixed: [ + "修复版本检查功能,只要与最新版本号不一致即认为有更新" + ] }, { - version: '1.0.0', - date: '2025-08-10', + version: "1.0.0", + date: "2025-08-10", added: [ - '基于 Semantic Versioning 的版本号机制', - '版本信息面板,展示本地变更日志和远程更新日志', + "基于 Semantic Versioning 的版本号机制", + "版本信息面板,展示本地变更日志和远程更新日志" ], changed: [ // 无变更内容 ], fixed: [ // 无修复内容 - ], - }, + ] + } ]; export default changelog; From ecd86daaf615f10ff92ca27010ef4e1f3e60f68a Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 11 Aug 2025 16:09:19 +0000 Subject: [PATCH 02/14] chore: Bump to 1.0.5 --- CHANGELOG | 5 +++++ VERSION.txt | 2 +- src/lib/changelog.ts | 13 +++++++++++++ src/lib/version.ts | 2 +- 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 556261662d..d12aba6f08 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,8 @@ +## [1.0.5] - 2025-08-11 + +### Changed +- 实现基于 Git 标签的自动 Release 工作流 + ## [1.0.4] - 2025-08-12 ### Added diff --git a/VERSION.txt b/VERSION.txt index a6a3a43c3a..1464c521f9 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -1.0.4 \ No newline at end of file +1.0.5 \ No newline at end of file diff --git a/src/lib/changelog.ts b/src/lib/changelog.ts index 7aae6f0aa7..1f346d6cb6 100644 --- a/src/lib/changelog.ts +++ b/src/lib/changelog.ts @@ -10,6 +10,19 @@ export interface ChangelogEntry { } export const changelog: ChangelogEntry[] = [ + { + version: "1.0.5", + date: "2025-08-11", + added: [ + // 无新增内容 + ], + changed: [ + "实现基于 Git 标签的自动 Release 工作流" + ], + fixed: [ + // 无修复内容 + ] + }, { version: "1.0.4", date: "2025-08-12", diff --git a/src/lib/version.ts b/src/lib/version.ts index d6a2ac0c09..411988f01c 100644 --- a/src/lib/version.ts +++ b/src/lib/version.ts @@ -2,7 +2,7 @@ 'use client'; -const CURRENT_VERSION = '1.0.4'; +const CURRENT_VERSION = '1.0.5'; // 版本检查结果枚举 export enum UpdateStatus { From 1b508a0c95323054b79fc8046a8ac34c511eacdc Mon Sep 17 00:00:00 2001 From: shinya Date: Mon, 11 Aug 2025 13:19:47 +0800 Subject: [PATCH 03/14] feat: bangumi daily update selector --- src/app/douban/page.tsx | 17 ++++++- src/components/DoubanSelector.tsx | 57 ++++++++++++++------- src/components/WeekdaySelector.tsx | 82 ++++++++++++++++++++++++++++++ 3 files changed, 136 insertions(+), 20 deletions(-) create mode 100644 src/components/WeekdaySelector.tsx diff --git a/src/app/douban/page.tsx b/src/app/douban/page.tsx index b5b5f1cf2e..e958ce6081 100644 --- a/src/app/douban/page.tsx +++ b/src/app/douban/page.tsx @@ -73,6 +73,9 @@ function DoubanPageClient() { sort: 'T', }); + // 星期选择器状态 + // const [selectedWeekday, setSelectedWeekday] = useState('monday'); + // 获取自定义分类数据 useEffect(() => { const runtimeConfig = (window as any).RUNTIME_CONFIG; @@ -630,6 +633,10 @@ function DoubanPageClient() { [multiLevelValues] ); + const handleWeekdayChange = useCallback((weekday: string) => { + console.log('weekday', weekday); + }, []); + const getPageTitle = () => { // 根据 type 生成标题 return type === 'movie' @@ -643,6 +650,13 @@ function DoubanPageClient() { : '自定义'; }; + const getPageDescription = () => { + if (type === 'anime' && primarySelection === '每日放送') { + return '来自 Bangumi 番组计划的精选内容'; + } + return '来自豆瓣的精选内容'; + }; + const getActivePath = () => { const params = new URLSearchParams(); if (type) params.set('type', type); @@ -663,7 +677,7 @@ function DoubanPageClient() { {getPageTitle()}

- 来自豆瓣的精选内容 + {getPageDescription()}

@@ -677,6 +691,7 @@ function DoubanPageClient() { onPrimaryChange={handlePrimaryChange} onSecondaryChange={handleSecondaryChange} onMultiLevelChange={handleMultiLevelChange} + onWeekdayChange={handleWeekdayChange} /> ) : ( diff --git a/src/components/DoubanSelector.tsx b/src/components/DoubanSelector.tsx index 17d2e11c2c..d7b83fac46 100644 --- a/src/components/DoubanSelector.tsx +++ b/src/components/DoubanSelector.tsx @@ -5,6 +5,7 @@ import React, { useEffect, useRef, useState } from 'react'; import MultiLevelSelector from './MultiLevelSelector'; +import WeekdaySelector from './WeekdaySelector'; interface SelectorOption { label: string; @@ -18,6 +19,7 @@ interface DoubanSelectorProps { onPrimaryChange: (value: string) => void; onSecondaryChange: (value: string) => void; onMultiLevelChange?: (values: Record) => void; + onWeekdayChange: (weekday: string) => void; } const DoubanSelector: React.FC = ({ @@ -27,6 +29,7 @@ const DoubanSelector: React.FC = ({ onPrimaryChange, onSecondaryChange, onMultiLevelChange, + onWeekdayChange, }) => { // 为不同的选择器创建独立的refs和状态 const primaryContainerRef = useRef(null); @@ -95,6 +98,7 @@ const DoubanSelector: React.FC = ({ const animePrimaryOptions: SelectorOption[] = [ { label: '番剧', value: '番剧' }, { label: '剧场版', value: '剧场版' }, + { label: '每日放送', value: '每日放送' }, ]; // 处理多级选择器变化 @@ -468,26 +472,41 @@ const DoubanSelector: React.FC = ({ -
- - 筛选 - -
- {(primarySelection || animePrimaryOptions[0].value) === '番剧' ? ( - - ) : ( - - )} + {/* 筛选部分 - 根据一级选择器显示不同内容 */} + {(primarySelection || animePrimaryOptions[0].value) === '每日放送' ? ( + // 每日放送分类下显示星期选择器 +
+ + 星期 + +
+ +
-
+ ) : ( + // 其他分类下显示原有的筛选功能 +
+ + 筛选 + +
+ {(primarySelection || animePrimaryOptions[0].value) === + '番剧' ? ( + + ) : ( + + )} +
+
+ )}
)} diff --git a/src/components/WeekdaySelector.tsx b/src/components/WeekdaySelector.tsx new file mode 100644 index 0000000000..1fb2855a32 --- /dev/null +++ b/src/components/WeekdaySelector.tsx @@ -0,0 +1,82 @@ +/* eslint-disable react-hooks/exhaustive-deps */ + +'use client'; + +import React, { useEffect, useState } from 'react'; + +interface WeekdaySelectorProps { + onWeekdayChange: (weekday: string) => void; + className?: string; +} + +const weekdays = [ + { value: 'monday', label: '周一', shortLabel: '周一' }, + { value: 'tuesday', label: '周二', shortLabel: '周二' }, + { value: 'wednesday', label: '周三', shortLabel: '周三' }, + { value: 'thursday', label: '周四', shortLabel: '周四' }, + { value: 'friday', label: '周五', shortLabel: '周五' }, + { value: 'saturday', label: '周六', shortLabel: '周六' }, + { value: 'sunday', label: '周日', shortLabel: '周日' }, +]; + +const WeekdaySelector: React.FC = ({ + onWeekdayChange, + className = '', +}) => { + // 获取今天的星期数,默认选中今天 + const getTodayWeekday = (): string => { + const today = new Date().getDay(); + // getDay() 返回 0-6,0 是周日,1-6 是周一到周六 + const weekdayMap = [ + 'sunday', + 'monday', + 'tuesday', + 'wednesday', + 'thursday', + 'friday', + 'saturday', + ]; + return weekdayMap[today]; + }; + + const [selectedWeekday, setSelectedWeekday] = useState( + getTodayWeekday() + ); + + // 组件初始化时通知父组件默认选中的星期 + useEffect(() => { + onWeekdayChange(getTodayWeekday()); + }, []); // 只在组件挂载时执行一次 + + return ( +
+ {weekdays.map((weekday) => { + const isActive = selectedWeekday === weekday.value; + return ( + + ); + })} +
+ ); +}; + +export default WeekdaySelector; From a18405225a61028095c2fa6d7abbb1d17a5a847c Mon Sep 17 00:00:00 2001 From: shinya Date: Mon, 11 Aug 2025 23:32:59 +0800 Subject: [PATCH 04/14] fix: parse changelog --- src/components/VersionPanel.tsx | 104 ++++++++++++++++++-------------- 1 file changed, 58 insertions(+), 46 deletions(-) diff --git a/src/components/VersionPanel.tsx b/src/components/VersionPanel.tsx index 15f84dbb98..ed548fa964 100644 --- a/src/components/VersionPanel.tsx +++ b/src/components/VersionPanel.tsx @@ -87,58 +87,70 @@ export const VersionPanel: React.FC = ({ // 解析变更日志格式 const parseChangelog = (content: string): RemoteChangelogEntry[] => { - const entries: RemoteChangelogEntry[] = []; - const sections = content.split(/(?=^## )/m); - - sections.forEach((section) => { - if (!section.trim()) return; - - const versionMatch = section.match(/^## \[([^\]]+)\]/); - if (!versionMatch) return; - - const version = versionMatch[1]; - const dateMatch = section.match(/\(([^)]+)\)/); - const date = dateMatch ? dateMatch[1] : ''; - - const added: string[] = []; - const changed: string[] = []; - const fixed: string[] = []; - - // 解析各个部分 - const addedMatch = section.match(/### Added\n([\s\S]*?)(?=### |$)/); - if (addedMatch) { - added.push( - ...addedMatch[1] - .split('\n') - .filter((line) => line.trim().startsWith('-')) - .map((line) => line.trim().substring(1).trim()) - ); - } + const lines = content.split('\n'); + const versions: RemoteChangelogEntry[] = []; + let currentVersion: RemoteChangelogEntry | null = null; + let currentSection: string | null = null; + let inVersionContent = false; + + for (const line of lines) { + const trimmedLine = line.trim(); + + // 匹配版本行: ## [X.Y.Z] - YYYY-MM-DD + const versionMatch = trimmedLine.match( + /^## \[([\d.]+)\] - (\d{4}-\d{2}-\d{2})$/ + ); + if (versionMatch) { + if (currentVersion) { + versions.push(currentVersion); + } - const changedMatch = section.match(/### Changed\n([\s\S]*?)(?=### |$)/); - if (changedMatch) { - changed.push( - ...changedMatch[1] - .split('\n') - .filter((line) => line.trim().startsWith('-')) - .map((line) => line.trim().substring(1).trim()) - ); + currentVersion = { + version: versionMatch[1], + date: versionMatch[2], + added: [], + changed: [], + fixed: [], + }; + currentSection = null; + inVersionContent = true; + continue; } - const fixedMatch = section.match(/### Fixed\n([\s\S]*?)(?=### |$)/); - if (fixedMatch) { - fixed.push( - ...fixedMatch[1] - .split('\n') - .filter((line) => line.trim().startsWith('-')) - .map((line) => line.trim().substring(1).trim()) - ); + // 如果遇到下一个版本或到达文件末尾,停止处理当前版本 + if (inVersionContent && currentVersion) { + // 匹配章节标题 + if (trimmedLine === '### Added') { + currentSection = 'added'; + continue; + } else if (trimmedLine === '### Changed') { + currentSection = 'changed'; + continue; + } else if (trimmedLine === '### Fixed') { + currentSection = 'fixed'; + continue; + } + + // 匹配条目: - 内容 + if (trimmedLine.startsWith('- ') && currentSection) { + const entry = trimmedLine.substring(2); + if (currentSection === 'added') { + currentVersion.added.push(entry); + } else if (currentSection === 'changed') { + currentVersion.changed.push(entry); + } else if (currentSection === 'fixed') { + currentVersion.fixed.push(entry); + } + } } + } - entries.push({ version, date, added, changed, fixed }); - }); + // 添加最后一个版本 + if (currentVersion) { + versions.push(currentVersion); + } - return entries; + return versions; }; // 渲染变更日志条目 From 933d4233cfeee80bc316a678eda4e8a208edfa3d Mon Sep 17 00:00:00 2001 From: shinya Date: Tue, 12 Aug 2025 00:20:14 +0800 Subject: [PATCH 05/14] feat: add bangumi calendar --- src/app/douban/page.tsx | 55 +++++++++++++-- src/app/page.tsx | 110 +++++++++++++++++++++++++---- src/components/DoubanSelector.tsx | 2 +- src/components/VideoCard.tsx | 22 ++++-- src/components/WeekdaySelector.tsx | 24 +++---- src/lib/bangumi.client.ts | 29 ++++++++ 6 files changed, 203 insertions(+), 39 deletions(-) create mode 100644 src/lib/bangumi.client.ts diff --git a/src/app/douban/page.tsx b/src/app/douban/page.tsx index e958ce6081..86295b31b0 100644 --- a/src/app/douban/page.tsx +++ b/src/app/douban/page.tsx @@ -6,6 +6,7 @@ import { useSearchParams } from 'next/navigation'; import { Suspense } from 'react'; import { useCallback, useEffect, useRef, useState } from 'react'; +import { GetBangumiCalendarData } from '@/lib/bangumi.client'; import { getDoubanCategories, getDoubanList, @@ -37,6 +38,7 @@ function DoubanPageClient() { primarySelection: '', secondarySelection: '', multiLevelSelection: {} as Record, + selectedWeekday: '', currentPage: 0, }); @@ -51,7 +53,7 @@ function DoubanPageClient() { const [primarySelection, setPrimarySelection] = useState(() => { if (type === 'movie') return '热门'; if (type === 'tv' || type === 'show') return '最近热门'; - if (type === 'anime') return '番剧'; + if (type === 'anime') return '每日放送'; return ''; }); const [secondarySelection, setSecondarySelection] = useState(() => { @@ -74,7 +76,7 @@ function DoubanPageClient() { }); // 星期选择器状态 - // const [selectedWeekday, setSelectedWeekday] = useState('monday'); + const [selectedWeekday, setSelectedWeekday] = useState(''); // 获取自定义分类数据 useEffect(() => { @@ -91,6 +93,7 @@ function DoubanPageClient() { primarySelection, secondarySelection, multiLevelSelection: multiLevelValues, + selectedWeekday, currentPage, }; }, [ @@ -98,6 +101,7 @@ function DoubanPageClient() { primarySelection, secondarySelection, multiLevelValues, + selectedWeekday, currentPage, ]); @@ -154,7 +158,7 @@ function DoubanPageClient() { setPrimarySelection('最近热门'); setSecondarySelection('show'); } else if (type === 'anime') { - setPrimarySelection('番剧'); + setPrimarySelection('每日放送'); setSecondarySelection('全部'); } else { setPrimarySelection(''); @@ -191,6 +195,7 @@ function DoubanPageClient() { primarySelection: string; secondarySelection: string; multiLevelSelection: Record; + selectedWeekday: string; currentPage: number; }, snapshot2: { @@ -198,6 +203,7 @@ function DoubanPageClient() { primarySelection: string; secondarySelection: string; multiLevelSelection: Record; + selectedWeekday: string; currentPage: number; } ) => { @@ -205,6 +211,7 @@ function DoubanPageClient() { snapshot1.type === snapshot2.type && snapshot1.primarySelection === snapshot2.primarySelection && snapshot1.secondarySelection === snapshot2.secondarySelection && + snapshot1.selectedWeekday === snapshot2.selectedWeekday && snapshot1.currentPage === snapshot2.currentPage && JSON.stringify(snapshot1.multiLevelSelection) === JSON.stringify(snapshot2.multiLevelSelection) @@ -247,6 +254,7 @@ function DoubanPageClient() { primarySelection, secondarySelection, multiLevelSelection: multiLevelValues, + selectedWeekday, currentPage: 0, }; @@ -277,6 +285,31 @@ function DoubanPageClient() { } else { throw new Error('没有找到对应的分类'); } + } else if (type === 'anime' && primarySelection === '每日放送') { + const calendarData = await GetBangumiCalendarData(); + const weekdayData = calendarData.find( + (item) => item.weekday.en === selectedWeekday + ); + if (weekdayData) { + data = { + code: 200, + message: 'success', + list: weekdayData.items.map((item) => ({ + id: item.id?.toString() || '', + title: item.name_cn || item.name, + poster: + item.images.large || + item.images.common || + item.images.medium || + item.images.small || + item.images.grid, + rate: item.rating?.score?.toString() || '', + year: item.air_date?.split('-')?.[0] || '', + })), + }; + } else { + throw new Error('没有找到对应的日期'); + } } else if (type === 'anime') { data = await getDoubanRecommends({ kind: primarySelection === '番剧' ? 'tv' : 'movie', @@ -346,6 +379,7 @@ function DoubanPageClient() { primarySelection, secondarySelection, multiLevelValues, + selectedWeekday, getRequestParams, customCategories, ]); @@ -379,6 +413,7 @@ function DoubanPageClient() { primarySelection, secondarySelection, multiLevelValues, + selectedWeekday, loadInitialData, ]); @@ -392,6 +427,7 @@ function DoubanPageClient() { primarySelection, secondarySelection, multiLevelSelection: multiLevelValues, + selectedWeekday, currentPage, }; @@ -417,6 +453,13 @@ function DoubanPageClient() { } else { throw new Error('没有找到对应的分类'); } + } else if (type === 'anime' && primarySelection === '每日放送') { + // 每日放送模式下,不进行数据请求,返回空数据 + data = { + code: 200, + message: 'success', + list: [], + }; } else if (type === 'anime') { data = await getDoubanRecommends({ kind: primarySelection === '番剧' ? 'tv' : 'movie', @@ -501,6 +544,7 @@ function DoubanPageClient() { secondarySelection, customCategories, multiLevelValues, + selectedWeekday, ]); // 设置滚动监听 @@ -634,7 +678,7 @@ function DoubanPageClient() { ); const handleWeekdayChange = useCallback((weekday: string) => { - console.log('weekday', weekday); + setSelectedWeekday(weekday); }, []); const getPageTitle = () => { @@ -725,6 +769,9 @@ function DoubanPageClient() { rate={item.rate} year={item.year} type={type === 'movie' ? 'movie' : ''} // 电影类型严格控制,tv 不控 + isBangumi={ + type === 'anime' && primarySelection === '每日放送' + } /> ))} diff --git a/src/app/page.tsx b/src/app/page.tsx index fa8dcc5c4c..eef4e807eb 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -6,6 +6,10 @@ import { ChevronRight } from 'lucide-react'; import Link from 'next/link'; import { Suspense, useEffect, useState } from 'react'; +import { + BangumiCalendarData, + GetBangumiCalendarData, +} from '@/lib/bangumi.client'; // 客户端收藏 API import { clearAllFavorites, @@ -28,6 +32,9 @@ function HomeClient() { const [hotMovies, setHotMovies] = useState([]); const [hotTvShows, setHotTvShows] = useState([]); const [hotVarietyShows, setHotVarietyShows] = useState([]); + const [bangumiCalendarData, setBangumiCalendarData] = useState< + BangumiCalendarData[] + >([]); const [loading, setLoading] = useState(true); const { announcement } = useSite(); @@ -60,20 +67,22 @@ function HomeClient() { const [favoriteItems, setFavoriteItems] = useState([]); useEffect(() => { - const fetchDoubanData = async () => { + const fetchRecommendData = async () => { try { setLoading(true); // 并行获取热门电影、热门剧集和热门综艺 - const [moviesData, tvShowsData, varietyShowsData] = await Promise.all([ - getDoubanCategories({ - kind: 'movie', - category: '热门', - type: '全部', - }), - getDoubanCategories({ kind: 'tv', category: 'tv', type: 'tv' }), - getDoubanCategories({ kind: 'tv', category: 'show', type: 'show' }), - ]); + const [moviesData, tvShowsData, varietyShowsData, bangumiCalendarData] = + await Promise.all([ + getDoubanCategories({ + kind: 'movie', + category: '热门', + type: '全部', + }), + getDoubanCategories({ kind: 'tv', category: 'tv', type: 'tv' }), + getDoubanCategories({ kind: 'tv', category: 'show', type: 'show' }), + GetBangumiCalendarData(), + ]); if (moviesData.code === 200) { setHotMovies(moviesData.list); @@ -86,14 +95,16 @@ function HomeClient() { if (varietyShowsData.code === 200) { setHotVarietyShows(varietyShowsData.list); } + + setBangumiCalendarData(bangumiCalendarData); } catch (error) { - console.error('获取豆瓣数据失败:', error); + console.error('获取推荐数据失败:', error); } finally { setLoading(false); } }; - fetchDoubanData(); + fetchRecommendData(); }, []); // 处理收藏数据更新的函数 @@ -308,6 +319,81 @@ function HomeClient() { + {/* 每日新番放送 */} +
+
+

+ 新番放送 +

+ + 查看更多 + + +
+ + {loading + ? // 加载状态显示灰色占位数据 + Array.from({ length: 8 }).map((_, index) => ( +
+
+
+
+
+
+ )) + : // 展示当前日期的番剧 + (() => { + // 获取当前日期对应的星期 + const today = new Date(); + const weekdays = [ + 'Sun', + 'Mon', + 'Tue', + 'Wed', + 'Thu', + 'Fri', + 'Sat', + ]; + const currentWeekday = weekdays[today.getDay()]; + + // 找到当前星期对应的番剧数据 + const todayAnimes = + bangumiCalendarData.find( + (item) => item.weekday.en === currentWeekday + )?.items || []; + + return todayAnimes.map((anime, index) => ( +
+ +
+ )); + })()} +
+
+ {/* 热门综艺 */}
diff --git a/src/components/DoubanSelector.tsx b/src/components/DoubanSelector.tsx index d7b83fac46..36c5c8455f 100644 --- a/src/components/DoubanSelector.tsx +++ b/src/components/DoubanSelector.tsx @@ -96,9 +96,9 @@ const DoubanSelector: React.FC = ({ // 动漫一级选择器选项 const animePrimaryOptions: SelectorOption[] = [ + { label: '每日放送', value: '每日放送' }, { label: '番剧', value: '番剧' }, { label: '剧场版', value: '剧场版' }, - { label: '每日放送', value: '每日放送' }, ]; // 处理多级选择器变化 diff --git a/src/components/VideoCard.tsx b/src/components/VideoCard.tsx index 0377af9582..f9638a2939 100644 --- a/src/components/VideoCard.tsx +++ b/src/components/VideoCard.tsx @@ -35,6 +35,7 @@ interface VideoCardProps { rate?: string; items?: SearchResult[]; type?: string; + isBangumi?: boolean; } export default function VideoCard({ @@ -54,6 +55,7 @@ export default function VideoCard({ rate, items, type = '', + isBangumi = false, }: VideoCardProps) { const router = useRouter(); const [favorited, setFavorited] = useState(false); @@ -194,15 +196,18 @@ export default function VideoCard({ const handleClick = useCallback(() => { if (from === 'douban') { router.push( - `/play?title=${encodeURIComponent(actualTitle.trim())}${actualYear ? `&year=${actualYear}` : '' + `/play?title=${encodeURIComponent(actualTitle.trim())}${ + actualYear ? `&year=${actualYear}` : '' }${actualSearchType ? `&stype=${actualSearchType}` : ''}` ); } else if (actualSource && actualId) { router.push( `/play?source=${actualSource}&id=${actualId}&title=${encodeURIComponent( actualTitle - )}${actualYear ? `&year=${actualYear}` : ''}${isAggregate ? '&prefer=true' : '' - }${actualQuery ? `&stitle=${encodeURIComponent(actualQuery.trim())}` : '' + )}${actualYear ? `&year=${actualYear}` : ''}${ + isAggregate ? '&prefer=true' : '' + }${ + actualQuery ? `&stitle=${encodeURIComponent(actualQuery.trim())}` : '' }${actualSearchType ? `&stype=${actualSearchType}` : ''}` ); } @@ -318,10 +323,11 @@ export default function VideoCard({ )}
@@ -345,7 +351,11 @@ export default function VideoCard({ {/* 豆瓣链接 */} {config.showDoubanLink && actualDoubanId && actualDoubanId !== 0 && ( e.stopPropagation()} diff --git a/src/components/WeekdaySelector.tsx b/src/components/WeekdaySelector.tsx index 1fb2855a32..b5d94a280d 100644 --- a/src/components/WeekdaySelector.tsx +++ b/src/components/WeekdaySelector.tsx @@ -10,13 +10,13 @@ interface WeekdaySelectorProps { } const weekdays = [ - { value: 'monday', label: '周一', shortLabel: '周一' }, - { value: 'tuesday', label: '周二', shortLabel: '周二' }, - { value: 'wednesday', label: '周三', shortLabel: '周三' }, - { value: 'thursday', label: '周四', shortLabel: '周四' }, - { value: 'friday', label: '周五', shortLabel: '周五' }, - { value: 'saturday', label: '周六', shortLabel: '周六' }, - { value: 'sunday', label: '周日', shortLabel: '周日' }, + { value: 'Mon', label: '周一', shortLabel: '周一' }, + { value: 'Tue', label: '周二', shortLabel: '周二' }, + { value: 'Wed', label: '周三', shortLabel: '周三' }, + { value: 'Thu', label: '周四', shortLabel: '周四' }, + { value: 'Fri', label: '周五', shortLabel: '周五' }, + { value: 'Sat', label: '周六', shortLabel: '周六' }, + { value: 'Sun', label: '周日', shortLabel: '周日' }, ]; const WeekdaySelector: React.FC = ({ @@ -27,15 +27,7 @@ const WeekdaySelector: React.FC = ({ const getTodayWeekday = (): string => { const today = new Date().getDay(); // getDay() 返回 0-6,0 是周日,1-6 是周一到周六 - const weekdayMap = [ - 'sunday', - 'monday', - 'tuesday', - 'wednesday', - 'thursday', - 'friday', - 'saturday', - ]; + const weekdayMap = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']; return weekdayMap[today]; }; diff --git a/src/lib/bangumi.client.ts b/src/lib/bangumi.client.ts new file mode 100644 index 0000000000..678ebaeb62 --- /dev/null +++ b/src/lib/bangumi.client.ts @@ -0,0 +1,29 @@ +'use client'; + +export interface BangumiCalendarData { + weekday: { + en: string; + }; + items: { + id: number; + name: string; + name_cn: string; + rating: { + score: number; + }; + air_date: string; + images: { + large: string; + common: string; + medium: string; + small: string; + grid: string; + }; + }[]; +} + +export async function GetBangumiCalendarData(): Promise { + const response = await fetch('https://api.bgm.tv/calendar'); + const data = await response.json(); + return data; +} From 1a27bbd6f2195e471daef2c52098aa99cc49eb76 Mon Sep 17 00:00:00 2001 From: shinya Date: Tue, 12 Aug 2025 00:21:43 +0800 Subject: [PATCH 06/14] feat: release 1.1.0 --- CHANGELOG | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index d12aba6f08..e1f7529bad 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,14 @@ +## [1.1.0] - 2025-08-12 + +### Added +- 每日新番放送功能,展示每日新番放送的番剧 + +### Fixed +- 修复远程 CHANGELOG 无法提取变更内容的问题 + ## [1.0.5] - 2025-08-11 -### Changed +### Changed - 实现基于 Git 标签的自动 Release 工作流 ## [1.0.4] - 2025-08-12 @@ -9,7 +17,7 @@ - 优化版本管理工作流,实现单点修改 ### Changed -- 版本号现在从CHANGELOG自动提取,无需手动维护VERSION.txt +- 版本号现在从 CHANGELOG 自动提取,无需手动维护 VERSION.txt ## [1.0.3] - 2025-08-11 From 682ed3797faf785061c916aba0ea73c830b94ca6 Mon Sep 17 00:00:00 2001 From: shinya Date: Tue, 12 Aug 2025 00:23:09 +0800 Subject: [PATCH 07/14] fix: del changelog --- CHANGELOG | 8 -------- 1 file changed, 8 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index e1f7529bad..710d52915c 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,11 +1,3 @@ -## [1.1.0] - 2025-08-12 - -### Added -- 每日新番放送功能,展示每日新番放送的番剧 - -### Fixed -- 修复远程 CHANGELOG 无法提取变更内容的问题 - ## [1.0.5] - 2025-08-11 ### Changed From 6314f36f0a387d142358fc66a9c53f9a32b069a1 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 11 Aug 2025 16:23:58 +0000 Subject: [PATCH 08/14] chore: Bump to 1.1.0 --- CHANGELOG | 8 ++++++++ VERSION.txt | 2 +- src/lib/changelog.ts | 15 ++++++++++++++- src/lib/version.ts | 2 +- 4 files changed, 24 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 710d52915c..7215ec3113 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,11 @@ +## [1.1.0] - 2025-08-11 + +### Added +- 每日新番放送功能,展示每日新番放送的番剧 + +### Fixed +- 修复远程 CHANGELOG 无法提取变更内容的问题 + ## [1.0.5] - 2025-08-11 ### Changed diff --git a/VERSION.txt b/VERSION.txt index 1464c521f9..1cc5f657e0 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -1 +1 @@ -1.0.5 \ No newline at end of file +1.1.0 \ No newline at end of file diff --git a/src/lib/changelog.ts b/src/lib/changelog.ts index 1f346d6cb6..964025c1b9 100644 --- a/src/lib/changelog.ts +++ b/src/lib/changelog.ts @@ -10,6 +10,19 @@ export interface ChangelogEntry { } export const changelog: ChangelogEntry[] = [ + { + version: "1.1.0", + date: "2025-08-11", + added: [ + "每日新番放送功能,展示每日新番放送的番剧" + ], + changed: [ + // 无变更内容 + ], + fixed: [ + "修复远程 CHANGELOG 无法提取变更内容的问题" + ] + }, { version: "1.0.5", date: "2025-08-11", @@ -30,7 +43,7 @@ export const changelog: ChangelogEntry[] = [ "优化版本管理工作流,实现单点修改" ], changed: [ - "版本号现在从CHANGELOG自动提取,无需手动维护VERSION.txt" + "版本号现在从 CHANGELOG 自动提取,无需手动维护 VERSION.txt" ], fixed: [ // 无修复内容 diff --git a/src/lib/version.ts b/src/lib/version.ts index 411988f01c..fca508b394 100644 --- a/src/lib/version.ts +++ b/src/lib/version.ts @@ -2,7 +2,7 @@ 'use client'; -const CURRENT_VERSION = '1.0.5'; +const CURRENT_VERSION = '1.1.0'; // 版本检查结果枚举 export enum UpdateStatus { From 8e3966c6dc08be4ae9cdb99493977a84fb98dc6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=97=8B=E5=BE=8B=E6=97=8B=E5=BE=8B=E4=BD=A0=E5=9C=A8?= =?UTF-8?q?=E5=B9=B2=E4=BB=80=E4=B9=88?= <89735151+JohnsonRan@users.noreply.github.com> Date: Tue, 12 Aug 2025 00:44:55 +0800 Subject: [PATCH 09/14] fix: incorrect timezone --- .github/workflows/release.yml | 5 +++-- CHANGELOG | 6 +++--- src/lib/changelog.ts | 6 +++--- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b0afb80cf2..d5edfa5b16 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -11,11 +11,12 @@ concurrency: permissions: contents: write - packages: write jobs: release: runs-on: ubuntu-latest + env: + TZ: Asia/Shanghai steps: - name: Checkout source code uses: actions/checkout@v4 @@ -47,7 +48,7 @@ jobs: - name: Setup Node.js uses: actions/setup-node@v4 with: - node-version: '18' + node-version: '22' - name: Update version files and generate changelog run: | diff --git a/CHANGELOG b/CHANGELOG index 7215ec3113..8a90c6daf8 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,4 @@ -## [1.1.0] - 2025-08-11 +## [1.1.0] - 2025-08-12 ### Added - 每日新番放送功能,展示每日新番放送的番剧 @@ -6,12 +6,12 @@ ### Fixed - 修复远程 CHANGELOG 无法提取变更内容的问题 -## [1.0.5] - 2025-08-11 +## [1.0.5] - 2025-08-12 ### Changed - 实现基于 Git 标签的自动 Release 工作流 -## [1.0.4] - 2025-08-12 +## [1.0.4] - 2025-08-11 ### Added - 优化版本管理工作流,实现单点修改 diff --git a/src/lib/changelog.ts b/src/lib/changelog.ts index 964025c1b9..790bcaf2f2 100644 --- a/src/lib/changelog.ts +++ b/src/lib/changelog.ts @@ -12,7 +12,7 @@ export interface ChangelogEntry { export const changelog: ChangelogEntry[] = [ { version: "1.1.0", - date: "2025-08-11", + date: "2025-08-12", added: [ "每日新番放送功能,展示每日新番放送的番剧" ], @@ -25,7 +25,7 @@ export const changelog: ChangelogEntry[] = [ }, { version: "1.0.5", - date: "2025-08-11", + date: "2025-08-12", added: [ // 无新增内容 ], @@ -38,7 +38,7 @@ export const changelog: ChangelogEntry[] = [ }, { version: "1.0.4", - date: "2025-08-12", + date: "2025-08-11", added: [ "优化版本管理工作流,实现单点修改" ], From 3dd135a1b2ff4b637bf73c6b19c9b53184c3406c Mon Sep 17 00:00:00 2001 From: shinya Date: Tue, 12 Aug 2025 00:47:53 +0800 Subject: [PATCH 10/14] feat: remove d1 support --- src/app/admin/page.tsx | 211 ++++------ src/app/api/admin/category/route.ts | 4 +- src/app/api/login/route.ts | 1 - src/app/api/register/route.ts | 1 - src/app/layout.tsx | 10 +- src/app/play/page.tsx | 3 - src/lib/d1.db.ts | 587 ---------------------------- src/lib/db.client.ts | 46 +-- src/lib/db.ts | 7 +- 9 files changed, 95 insertions(+), 775 deletions(-) delete mode 100644 src/lib/d1.db.ts diff --git a/src/app/admin/page.tsx b/src/app/admin/page.tsx index 63c7e105f3..bdf7691e9a 100644 --- a/src/app/admin/page.tsx +++ b/src/app/admin/page.tsx @@ -148,10 +148,7 @@ const UserConfig = ({ config, role, refreshConfig }: UserConfigProps) => { // 当前登录用户名 const currentUsername = getAuthInfoFromBrowserCookie()?.username || null; - // 检测存储类型是否为 d1 - const isD1Storage = - typeof window !== 'undefined' && - (window as any).RUNTIME_CONFIG?.STORAGE_TYPE === 'd1'; + // 检测存储类型是否为 upstash const isUpstashStorage = typeof window !== 'undefined' && (window as any).RUNTIME_CONFIG?.STORAGE_TYPE === 'upstash'; @@ -317,15 +314,10 @@ const UserConfig = ({ config, role, refreshConfig }: UserConfigProps) => {
- {category.from !== 'config' && !isD1Storage && !isUpstashStorage && ( + {category.from !== 'config' && !isUpstashStorage && (
- {showAddForm && !isD1Storage && !isUpstashStorage && ( + {showAddForm && !isUpstashStorage && (
{/* 保存排序按钮 */} - {orderChanged && !isD1Storage && !isUpstashStorage && ( + {orderChanged && !isUpstashStorage && (