diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 57c23f5..38e976c 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -17,11 +17,11 @@ jobs: - name: Checkout code uses: actions/checkout@v3 - # 读取 version 文件并设置版本号 - - name: Read version from file + # 从 worker.js 中读取版本号 + - name: Read version from worker.js id: version run: | - VERSION=$(cat danmu_api/version) + VERSION=$(grep 'const VERSION' danmu_api/worker.js | sed -E 's/.*const VERSION = "(.*)".*/\1/') echo "VERSION=$VERSION" >> $GITHUB_ENV # 设置 Docker 镜像缓存(可选,加速构建) @@ -43,4 +43,4 @@ jobs: # 推送 Docker 镜像到 Docker Hub - name: Push Docker image to Docker Hub run: | - docker buildx build --platform linux/amd64,linux/arm64 -t ${{ secrets.DOCKER_USERNAME }}/danmu-api:${{ env.VERSION }} --push . \ No newline at end of file + docker buildx build --platform linux/amd64,linux/arm64 -t ${{ secrets.DOCKER_USERNAME }}/danmu-api:${{ env.VERSION }} --push . diff --git a/danmu_api/README.md b/danmu_api/README.md index 7dd5995..abb00b3 100644 --- a/danmu_api/README.md +++ b/danmu_api/README.md @@ -1,4 +1,4 @@ -# MuMu 弹幕 API 服务器 +# LogVar 弹幕 API 服务器 一个人人都能部署的基于 js 的弹幕 API 服务器,兼容弹弹play的搜索、详情查询和弹幕获取功能,并提供日志记录,支持vercel/cloudflare/docker/claw等部署方式。 @@ -117,7 +117,6 @@ danmu_api/ ├── danmu_api/ │ ├── README.md # 项目文档 │ ├── server.js # 本地node启动脚本 -│ ├── version # 定义版本号 │ ├── worker.js # 主 API 服务器代码 │ ├── worker.test.js # 测试文件 ├── .gitignore diff --git a/danmu_api/version b/danmu_api/version deleted file mode 100644 index 8a9ecc2..0000000 --- a/danmu_api/version +++ /dev/null @@ -1 +0,0 @@ -0.0.1 \ No newline at end of file diff --git a/danmu_api/worker.js b/danmu_api/worker.js index 948f768..1a826fb 100644 --- a/danmu_api/worker.js +++ b/danmu_api/worker.js @@ -1,5 +1,6 @@ // 全局状态(Cloudflare 和 Vercel 都可能重用实例) // ⚠️ 不是持久化存储,每次冷启动会丢失 +const VERSION = "0.0.2"; let animes = []; let episodeIds = []; let episodeNum = 10001; // 全局变量,用于自增 ID @@ -687,7 +688,8 @@ async function handleRequest(req, env) { if (path === "/" && method === "GET") { log("log", "Accessed homepage with repository information"); return jsonResponse({ - message: "Welcome to the MuMu Danmu API server", + message: "Welcome to the LogVar Danmu API server", + version: VERSION, repository: "https://github.com/huangxd-/danmu_api.git", description: "一个人人都能部署的基于 js 的弹幕 API 服务器,兼容弹弹play的搜索、详情查询和弹幕获取功能,并提供日志记录,支持vercel/cloudflare/docker/claw等部署方式", notice: "本项目仅为个人爱好开发,代码开源。如有任何侵权行为,请联系本人删除。" diff --git a/danmu_api/worker.test.js b/danmu_api/worker.test.js index 5bd8d07..2d37646 100644 --- a/danmu_api/worker.test.js +++ b/danmu_api/worker.test.js @@ -32,7 +32,7 @@ test('worker.js API endpoints', async (t) => { assert.equal(res.status, 200); assert.equal(res.headers.get('Content-Type'), 'application/json'); - assert.deepEqual(body.message, 'Welcome to the MuMu Danmu API server'); + assert.deepEqual(body.message, 'Welcome to the LogVar Danmu API server'); }); await t.test('GET tencent danmu', async () => {