33 Commits

Author SHA1 Message Date
huangjianwu
1329390f98 feat(desktop): Sidecar 健康度面板 + 重启后端能力
P1 已经把 backend-warning / backend-terminated 横幅做出来了;P2 把
lib.rs 那条 stdout/stderr/terminated 信息流真正落到一个常驻 UI 上:
- 右下角浮动状态点(绿/黄/红),轮询 /api/sys_health 决定颜色
- 点开抽屉看最近 200 行日志(ring buffer),含「重启后端」「复制日志」按钮

Rust:
- src-tauri/src/lib.rs:把 sidecar 启动抽出 spawn_backend_sidecar(),
  CommandChild 存进 SidecarHandle(Mutex<Option<CommandChild>>) 这个 state
- 新增 #[tauri::command] restart_backend_sidecar:kill 旧 child + 重新 spawn +
  emit 'backend-restarted' 给前端
- 监听任务 stdout/stderr emit 时不再用 format!("'{}'", ...) 包引号,原文直传;
  前端 hook 同时兼容旧形式(兜底剥引号)

前端:
- components/BackendHealth/useBackendEvents.ts:listen 四个事件 +
  ring buffer (MAX 200 行) + invoke restart + clipboard 复制日志
- BackendHealthIndicator.tsx:右下角浮动状态点,5s 轮询 /api/sys_health;
  连续 3 次失败或 backend-terminated 触发 → 红
- BackendLogPanel.tsx:右侧抽屉,深色 monospace 日志区 + 操作按钮
- 纯 web 环境(无 __TAURI_INTERNALS__)下静默不挂载

P3 / P4 还在路上。

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-09 14:27:02 +08:00
huangjianwu
9a64a2da8e feat(desktop): 启动期路径诊断 + 顶端横幅,主动暴露已知失败因素
桌面端历史痛点:PyInstaller sidecar 在含非 ASCII / 含空格 / 不可写的安装路径下
直接炸(README:36 仅文字警告"不要中文路径",无主动防御)。Sidecar 退出事件 lib.rs
已 emit 但前端没 listener 消化,用户看到的是空白主页。

- src-tauri/src/lib.rs:
  · setup 中 env::current_exe() 之后做 InstallPathDiagnostics(is_ascii / 空格 /
    父目录 write_probe),命中任一异常就 emit 'backend-warning' 给前端
  · 用 std::thread::spawn + 1500ms sleep 等首屏 listener 挂上再 emit,避免事件丢失
  · 新增 Tauri command get_install_path_diagnostics,前端可主动重查(用户卸载到
    新目录后首次启动)
- BillNote_frontend/src/components/SystemDiagnostic/StartupBanner.tsx(新建):
  · 监听 backend-warning(路径警告,可关闭)+ backend-terminated(致命,常驻)
  · 纯 web 环境(无 __TAURI_INTERNALS__)下静默不挂载,对桌面端定向起效
  · backend-error(stderr 噪音)暂不展示,留给后续 P2 日志面板
- App.tsx:StartupBanner 在 BackendInitDialog 之前就挂载,让"后端还在初始化时"
  也能看见路径警告(正是该场景容易炸)

不改任何业务逻辑;纯桌面端 UX 加固。

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-09 14:22:41 +08:00
Jianwu Huang
e89090bed0 Merge pull request #356 from JefferyHcool/feature/extension-video-understanding
feat(extension): 多模态视频理解开关 + 抽帧/拼图参数(对齐 web NoteForm)
2026-05-09 13:53:34 +08:00
Jianwu Huang
edf2083d71 Merge pull request #355 from JefferyHcool/feature/extension-form-parity
feat(extension): NoteForm 字段对齐 web 端(style 预设 + format 完整 + extras)
2026-05-09 13:53:11 +08:00
huangjianwu
a7c717abbd feat(extension): 多模态视频理解开关 + 抽帧/拼图参数(对齐 web NoteForm)
web 端 NoteForm 早就有 video_understanding / video_interval / grid_size 三件套,
插件之前没有,导致用户在视觉模型上想用「画面理解」时只能去 web 端发任务。

新增字段(types.ts Settings 与 GenerateRequest 同步):
- video_understanding: boolean,默认 false(关)
- video_interval: number,1-30 秒,默认 6(与 web NoteForm 默认一致)
- grid_size: [number, number],1-10,默认 [2,2]

UI 落地:
- popup 「高级」折叠区:开关 + interval + grid_size 行/列三栏,启用时才显示后两个,
  并提示需要选视觉模型
- options General 页:单独一节「视频理解(多模态)」展开同样字段
- popup start() 与 background startTask() 在 generate_note 请求里带上这三个字段;
  关闭时不传(避免覆盖 backend 默认)

回归风险:默认 false,对现有用户行为不变。

依赖:feature/extension-form-parity(叠加在它之上,因为 Settings 是同一片字段域)。

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-07 17:22:57 +08:00
huangjianwu
799ab64a28 feat(extension): NoteForm 字段对齐 web 端(style 预设 + format 完整 + extras)
之前插件 popup / options 的笔记选项跟 web 端 NoteForm 不齐,存在三处差距:

1. style 字段实质 broken
   · backend prompt_builder.get_style_format 是 enum 映射(minimal/detailed/
     academic/tutorial/xiaohongshu/life_journal/task_oriented/business/
     meeting_minutes 共 9 个),不命中直接 return ''
   · 插件原来给的是自由文本框,用户填什么都对不上 enum,等于没传
   · 改:popup + options 都换成 9 个预设的下拉框,与 backend 严格对齐
2. format 字段缺一半
   · backend 支持 toc / link / screenshot / summary 四个
   · 插件只暴露了 screenshot / link 两个 checkbox
   · 改:types.ts 新增 NOTE_FORMATS 常量,UI 渲染完整 4 个 checkbox。
     生成请求时 format 数组、screenshot/link 单布尔由 settings.formats 派生,单一真相源
3. 缺 extras 字段
   · backend VideoRequest.extras 直接拼到 prompt 末尾给 LLM
   · 改:popup 折叠的"高级"区 + options 默认生成选项区都加 textarea

Settings 默认值:style='minimal'、formats=['toc','summary']、extras=''。
旧 settings 里若 style 是无效字符串,下拉会显示空白,用户重选一次即可。

logic/types.ts:
- 新增 NoteStyle / NoteFormat type alias 与 NOTE_STYLES / NOTE_FORMATS 常量
- Settings 接口加 formats: NoteFormat[] / extras: string,style 改为 NoteStyle
- 老的 screenshot / link 布尔保留(向后兼容旧 storage),但 UI 不再绑定,submit 时也由 formats 派生

popup / background / options 三处提交 generate_note 的逻辑同步收口。

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-07 17:18:28 +08:00
huangjianwu
c0837e0132 chore(release): merge release/2.1.4 back into develop 2026-05-07 16:45:11 +08:00
huangjianwu
1aea86a8d6 docs: v2.1.4 CHANGELOG + README 版本
CI 工程化修复,无运行时行为变化。详见 CHANGELOG.md。

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-07 16:44:49 +08:00
Jianwu Huang
9237cac9c3 Merge pull request #351 from JefferyHcool/fix/ci-commitlint
fix(ci): commitlint workflow 去掉伪 input + 规范 release merge commit 格式
2026-05-07 14:47:03 +08:00
Jianwu Huang
f97ab0b7bc Merge pull request #350 from JefferyHcool/fix/ci-drop-linux-tauri-build
ci(tauri): 桌面端构建去掉 Linux,只保留 macOS + Windows
2026-05-07 14:42:30 +08:00
huangjianwu
ac72cc6d6e ci(tauri): 桌面端构建去掉 Linux,只保留 macOS + Windows
Tauri Linux 构建 (ubuntu-22.04, x86_64-unknown-linux-gnu) 在 v2.1.x 这几次发版上
持续 17m+ 才完成,相比 macOS / Windows 更慢,且没有面向 Linux 桌面端用户的实际分发渠道。
直接从 matrix 里去掉。

清理:
- matrix 删除 ubuntu-22.04 条目
- 'Install Linux Dependencies' step(仅 ubuntu 触发)整段移除
- artifact 收集步里的 .deb / .AppImage 两条 find 命令移除

Linux 用户继续可以走 Docker 镜像 (ghcr.io/jefferyhcool/bilinote),那条线没变。

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-07 14:30:07 +08:00
huangjianwu
7358cd0123 fix(ci): commitlint workflow 去掉伪 input + 规范 release merge commit 格式
v2.1.3 push master 时 Lint commit messages job 红了,根因两条:

1. workflow 里写了 'firstParent: false',但 wagoid/commitlint-github-action@v6
   的合法 input 列表里没这个字段,被 ignore 同时打 warn

2. release merge commit 标题 'Release v2.1.3' 不符合 type(scope): subject 格式,
   commitlint 报 subject-empty + type-empty
   · @commitlint/config-conventional 默认 ignore 'Merge ' 前缀的 commit,
     但我们手动 -m 把标题写成 'Release vX.Y.Z' 跳过了豁免

修:
- 去掉 .github/workflows/commitlint.yml 里那条 firstParent 假 input
- RELEASING.md §3 加入 merge commit 标题模板:
  · 合 master 用 'chore(release): vX.Y.Z'
  · 回灌 develop 用 'chore(release): merge release/X.Y.Z back into develop'
- CONTRIBUTING.md §6.3 同步加这条提醒

历史上 master / develop 的 'Release v2.1.x' 那几个 merge commit 已经在 history
里,没法回头改(不能强推 master)。但 commitlint 在 push 时只 lint 推送范围里的
新 commit,旧 commit 不会重新校验,所以不会持续报错。

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-07 14:19:39 +08:00
huangjianwu
80f081613b Merge branch 'release/2.1.3' back into develop 2026-05-07 14:14:43 +08:00
huangjianwu
234e3b9d2a docs: v2.1.3 CHANGELOG + README 版本
修 issue #282(DeepSeek 等非多模态供应商被 400 拒绝)。详见 CHANGELOG.md。

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-07 14:14:22 +08:00
Jianwu Huang
1d93d1c5f5 Merge pull request #345 from voidborne-d/fix/backend-deepseek-content-format
fix(backend): UniversalGPT.create_messages emit string content when no images
2026-05-07 14:12:34 +08:00
huangjianwu
c19d462505 Merge branch 'release/2.1.2' back into develop 2026-05-07 14:06:35 +08:00
huangjianwu
f32a6944d1 docs: v2.1.2 CHANGELOG + README 版本
补 v2.1.1 ghcr.io 镜像构建失败。详见 CHANGELOG.md。

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-07 14:06:16 +08:00
Jianwu Huang
c5c84a8ec7 Merge pull request #349 from JefferyHcool/fix/docker-frontend-build
fix(docker): 修复 Tag push 触发的镜像构建失败
2026-05-07 14:04:38 +08:00
huangjianwu
c4413c66a1 fix(docker): 修复 Tag push 触发的镜像构建失败
ghcr.io 镜像推送在 v2.1.1 tag 上失败,停在 frontend-builder 第 7/7 步
'pnpm run build':vite loadConfigFromBundledFile 1.5s 内挂掉,没具体行号——
典型现象是 vite.config.ts 顶部 import 的某个 plugin(@tailwindcss/vite)的
native binding 在容器里 require 失败。

三处修复:
1. Dockerfile.complete + BillNote_frontend/Dockerfile:node:18-alpine → node:20-alpine
   · Tailwind v4 已不再支持 Node 18(package 现实需要 20+)
   · Vite 6 也建议 Node 20+
2. Dockerfile.complete 的 frontend 阶段:复制 pnpm-lock.yaml + 改用 --frozen-lockfile
   · 之前没传 lockfile,每次 pnpm install 重解析 semver,有可能拉到比本地更新的 native dep
3. BillNote_frontend/pnpm-lock.yaml 强制入库(git add -f)
   · 之前根 .gitignore 有条诡异的 'BiliNote/pnpm-lock.yaml'(拼错的路径),
     虽然没真匹配上这个文件,但 lockfile 历史上一直没被提交,导致 CI 与本地依赖图持续漂移
   · lockfile 里 @tailwindcss/oxide 同时锁了 musl 与 gnu 变体,alpine 跑没问题

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-07 14:01:26 +08:00
Jianwu Huang
26ee15ce28 Merge pull request #347 from JefferyHcool/docs/readme-wechat-qr
docs(readme): 联系和加入社区段落补上微信群二维码
2026-05-07 13:59:47 +08:00
huangjianwu
29fa3d9540 docs(readme): 联系和加入社区段落补上微信群二维码
之前只写"年会恢复更新以后放出最新社区地址",现在直接挂 doc/wechat.png 上去。
GitHub 渲染相对路径图片时按 raw.githubusercontent.com 自动转,无需 CDN。

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-07 13:57:40 +08:00
huangjianwu
61cb4ec9fa Merge branch 'release/2.1.1' back into develop 2026-05-07 13:55:01 +08:00
huangjianwu
c187dce5cb docs: v2.1.1 CHANGELOG + README 版本
工程化与文档收尾,无运行时行为变化。详见 CHANGELOG.md。

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-07 13:54:23 +08:00
Jianwu Huang
424c7f84e2 Merge pull request #346 from JefferyHcool/feature/repo-tooling
chore(repo): 仓库工具链——issue/PR 模板 + commitlint CI + 插件发版工作流
2026-05-07 13:53:04 +08:00
Jianwu Huang
f6a9af4658 Merge pull request #344 from JefferyHcool/chore/update-wechat-qr
chore(docs): 更新群聊微信二维码
2026-05-07 13:51:47 +08:00
voidborne-d
3ff7086491 fix(backend): UniversalGPT.create_messages emit string content when no images
DeepSeek deepseek-chat 等非多模态模型只接受 ``content`` 为字符串。旧实现在
没有 ``video_img_urls`` 输入时也把 ``content`` 拼成
``[{"type":"text","text":...}]`` 多模态数组,导致 DeepSeek API 返回
``Failed to deserialize the JSON body into the target type: messages[0]:
unknown variant `image_url`, expected `text```,整个笔记生成流程随之崩溃。

修复方式:``create_messages`` 在没有截图时退回 string content;有截图时维持
原多模态数组形态,多模态模型功能不退化。同时把 ``_build_merge_messages`` 也
改为 string content —— 合并阶段从不带图片,旧的数组形态会让长视频 chunk
之后的合并阶段同样命中 DeepSeek 400。

新增 ``backend/tests/test_universal_gpt_content_format.py`` (6 cases):

- 无图片 / 显式空 image 列表都走 string content
- 有图片仍输出多模态数组(含 ``image_url`` + ``detail: auto``)
- 纯文本响应里完全不含 ``image_url`` 字段
- ``_build_merge_messages`` 用 string content + 仍带入 partials 文本

红基线:在不打补丁的 ``universal_gpt.py`` 上跑这 6 个 case,3 个 string-
content 断言会失败(命中 issue #282 的同一根因),打补丁后 6/6 通过。

Closes #282
2026-05-07 13:50:59 +08:00
huangjianwu
f583f3cc8c chore(frontend): about 页移除 QQ 群联系方式,仅保留微信群
QQ 群已不再活跃维护,关联展示也容易让用户搜不到。保留微信群入口即可。

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-07 13:50:23 +08:00
huangjianwu
2e7fe8d3a8 chore(frontend): 关于页二维码改为 import 本地资源,不再依赖 CDN
之前 about 页直接拉腾讯云 COS 上的 wechat.png,每次换码都要手动重新上传 CDN
+ 刷缓存。改成 import @/assets/wechat.png,由 Vite 打包,更新时只需替换文件。

doc/wechat.png 仍保留作为源 / 备份。

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-07 13:49:25 +08:00
huangjianwu
1e055c3068 chore(docs): 更新群聊微信二维码
doc/wechat.png 替换为最新版(396×396)。

⚠️ 前端 SettingPage/about.tsx:207 实际渲染的是腾讯云 COS 上的同名文件
   https://common-1304618721.cos.ap-chengdu.myqcloud.com/wechat.png
仓库这边只是源文件,CDN 那份需要项目维护者手动重新上传:
- 登录腾讯云 COS 控制台
- 找到 common-1304618721 桶
- 把根目录的 wechat.png 替换为 doc/wechat.png 这一份

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-07 13:47:23 +08:00
huangjianwu
b2af0e4e53 chore(repo): 仓库工具链——issue/PR 模板 + commitlint CI + 插件发版工作流
把 CONTRIBUTING.md 里写的规范落到 GitHub 工程化层。

Issue / PR 模板:
- .github/ISSUE_TEMPLATE/{config,bug_report,feature_request}.yml
  · yml 表单形式,跟随当前工作区分类(backend / frontend / extension / Tauri)
  · bug_report 强制选版本 + 部署方式 + 复现步骤;提交前自查不夹带 secrets
  · config.yml 禁用空白 issue,引导 Discussions
- .github/pull_request_template.md:把 CONTRIBUTING §5.2 的 PR 正文要求落成 checklist
- 删旧版 .md 模板(含中文文件名那条),避免新老两套并存

Commitlint:
- .commitlintrc.json:extend conventional + 自定义 type 白名单(feat/fix/docs/style/refactor/perf/test/build/ci/chore/ui/revert)
- .github/workflows/commitlint.yml:用 wagoid/commitlint-github-action@v6,PR + push develop/master 时校验
  · subject-case / subject-full-stop 关掉,兼容中文 subject
  · header-max-length 100 字符 warn 级别,不阻塞合并

插件发版工作流:
- .github/workflows/release-extension.yml:v* tag push 时
  · cd BillNote_extension && pnpm install + build
  · pack:zip / pack:xpi / pack:crx(crx 缺 key 自动跳过)
  · 产物重命名带版本后缀,挂到对应 GitHub Release
- 末尾保留 publish-chrome / publish-edge / publish-firefox 三段注释,配齐 secrets 即可启用商店自动发布
- RELEASING.md:发版执行手册,覆盖 release/* 流程 + 各商店人工上传步骤 + 自动发布所需 secrets

CONTRIBUTING.md 关联文档区指到新增的 RELEASING.md,commit 章节加 commitlint 落地说明。

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-07 13:45:32 +08:00
Jianwu Huang
3d0838ba72 Merge pull request #343 from JefferyHcool/feature/contributing-doc
docs(contributing): 新增贡献指南,落地简化 Git Flow 分支管理
2026-05-07 13:26:23 +08:00
huangjianwu
ee58a65bcd docs(contributing): 新增贡献指南,落地简化 Git Flow 分支管理
落地分支模型:
- master:稳定主干,仅接受 release/hotfix 合入,禁止直接提交
- develop:长期开发集成分支,常规开发都从这里起
- feature/* / fix/*:短生命周期,基于 develop
- release/*:基于 develop,发版后合入 master + 回灌 develop
- hotfix/*:基于 master,处理线上紧急故障

同时收录:
- 多工作区命名 scope 约定(extension / frontend / backend / bilibili / ...)
- commit message 格式(type(scope): subject)+ PR 标题/正文要求
- 合并方式:feature/fix → develop 用 Squash;release/hotfix → master 用 --no-ff
- simple-git-hooks 残留 .git/hooks/pre-commit 的清理办法
- 语义化版本 + CHANGELOG.md 更新流程
- 禁止事项 + 历史分支迁移要求

适配自 emplai-ui doc/前端仓库分支管理办法.md,按本仓库实际情况调整:
master 不改名为 main、补充多工作区 scope、把发版与 tag 流程串联到 README/CHANGELOG。

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-07 13:13:32 +08:00
huangjianwu
cfc3053be8 Merge upstream master (PR #341) into develop 2026-05-07 13:10:28 +08:00
33 changed files with 12818 additions and 209 deletions

28
.commitlintrc.json Normal file
View File

@@ -0,0 +1,28 @@
{
"extends": ["@commitlint/config-conventional"],
"rules": {
"type-enum": [
2,
"always",
[
"feat",
"fix",
"docs",
"style",
"refactor",
"perf",
"test",
"build",
"ci",
"chore",
"ui",
"revert"
]
],
"subject-case": [0],
"subject-full-stop": [0],
"header-max-length": [1, "always", 100],
"body-max-line-length": [0],
"footer-max-line-length": [0]
}
}

View File

@@ -1,49 +0,0 @@
---
name: Bug report
about: 上报一些bug
title: "[BUG]"
labels: bug
assignees: JefferyHcool
---
---
name: 🐛 Bug 反馈
about: 提交一个 Bug 报告,帮助我们改进
title: "[Bug] "
labels: bug
assignees: ''
---
**版本说明**
请说明的你的版本号
**部署方式**
使用的是什么方式部署代码环境部署docker部署桌面端在线预览
**描述问题**
清晰、简明地描述你遇到的问题是什么。
**复现步骤**
复现该问题的步骤:
1. 进入页面 '...'
2. 点击 '...'
3. 滚动到 '...'
4. 出现错误
**预期行为**
清晰、简明地描述你本来预期发生的行为。
**截图**
如果适用,请添加截图以帮助说明问题。
**桌面端(请补充以下信息)**
- 操作系统:例如 Windows / macOS / Ubuntu
- 浏览器:例如 Chrome、Safari
**其他补充信息**
请补充任何其他相关信息。

93
.github/ISSUE_TEMPLATE/bug_report.yml vendored Normal file
View File

@@ -0,0 +1,93 @@
name: 🐛 Bug 报告
description: 报告一个可复现的问题
title: "[Bug] "
labels: ["bug"]
body:
- type: markdown
attributes:
value: |
感谢反馈。请尽量提供完整的复现路径与日志,便于排查。
⚠️ **不要**贴 API key、SESSDATA、密钥等敏感信息。
- type: dropdown
id: workspace
attributes:
label: 受影响的工作区
multiple: true
options:
- 后端 (backend/)
- Web 前端 (BillNote_frontend/)
- 浏览器插件 (BillNote_extension/)
- Tauri 桌面端
- 文档 / 其他
validations:
required: true
- type: input
id: version
attributes:
label: 版本
description: BiliNote 版本号README 顶部,例如 v2.1.0
placeholder: v2.1.0
validations:
required: true
- type: dropdown
id: deploy
attributes:
label: 部署方式
options:
- 源码运行
- Docker (docker-compose.yml)
- Docker GPU (docker-compose.gpu.yml)
- 桌面端安装包 (Tauri Release)
- 其他
validations:
required: true
- type: textarea
id: repro
attributes:
label: 复现步骤
description: 一步步说明如何触发问题
placeholder: |
1. 打开 ...
2. 点击 ...
3. 看到 ...
validations:
required: true
- type: textarea
id: expected
attributes:
label: 期望行为
validations:
required: true
- type: textarea
id: actual
attributes:
label: 实际行为
description: 含错误信息、截图、录屏均可
validations:
required: true
- type: textarea
id: env
attributes:
label: 运行环境
description: 操作系统、Python 版本、Node 版本、浏览器(如适用)
placeholder: |
- OS: macOS 14.5 / Windows 11 / Ubuntu 22.04
- Python: 3.11.6
- Node: 20.18.0
- Browser: Chrome 124如涉及插件/前端)
- GPU: 无 / NVIDIA 4070如涉及 fast-whisper / video understanding
- type: textarea
id: logs
attributes:
label: 日志 / 堆栈
description: 后端 console、前端 DevTools、扩展 background 页都可以贴
render: text
- type: checkboxes
id: pre-checks
attributes:
label: 提交前自查
options:
- label: 我已搜索过 [Issues](https://github.com/JefferyHcool/BiliNote/issues?q=),确认不是重复问题
required: true
- label: 我提供的日志中**不**包含 API key、cookie、SESSDATA 等敏感信息
required: true

8
.github/ISSUE_TEMPLATE/config.yml vendored Normal file
View File

@@ -0,0 +1,8 @@
blank_issues_enabled: false
contact_links:
- name: 📖 文档与常见问题
url: https://docs.bilinote.app/
about: 安装与配置遇到问题,先看一下文档
- name: 💬 提问 / 讨论
url: https://github.com/JefferyHcool/BiliNote/discussions
about: 用法咨询、想法征集请发到 Discussions不是 bug 才用 Issues

View File

@@ -0,0 +1,40 @@
name: ✨ 功能建议
description: 提议新功能或改进
title: "[Feature] "
labels: ["enhancement"]
body:
- type: textarea
id: problem
attributes:
label: 想解决什么问题?
description: 描述你遇到的实际场景或痛点。
validations:
required: true
- type: textarea
id: proposal
attributes:
label: 建议方案
description: 期望的功能或交互。可附草图 / 示例。
validations:
required: true
- type: textarea
id: alternatives
attributes:
label: 备选方案
description: 你考虑过哪些其他做法?为什么没采用?
- type: dropdown
id: workspace
attributes:
label: 涉及的工作区
multiple: true
options:
- 后端 (backend/)
- Web 前端 (BillNote_frontend/)
- 浏览器插件 (BillNote_extension/)
- Tauri 桌面端
- 不确定
- type: textarea
id: extra
attributes:
label: 其他补充
description: 关联 issue、参考资料、产品截图等

View File

@@ -1,29 +0,0 @@
---
name: 新增功能建议
about: 一些新的功能建议
title: "[FEATHURE]"
labels: enhancement
assignees: JefferyHcool
---
---
name: ✨ 功能请求
about: 提出一个新的功能建议
title: "[Feature] "
labels: enhancement
assignees: ''
---
**这个功能请求是否与某个问题相关?请描述**
清晰简要地描述问题是什么。例如:每次遇到 [...] 都让我感到很沮丧。
**描述你希望实现的解决方案**
清晰简要地描述你希望发生的事情。
**描述你考虑过的备选方案**
清晰简要地描述你考虑过的其他解决方案或功能。
**其他补充信息**
请在此添加关于功能请求的其他上下文或截图。

39
.github/pull_request_template.md vendored Normal file
View File

@@ -0,0 +1,39 @@
<!--
PR 标题请遵循 type(scope): subject 格式,例如:
feat(extension): 侧边栏接入思维导图
fix(bilibili): 修正字幕优先链路在未登录态下的回退
分支命名 / 提交规范见 CONTRIBUTING.md。
-->
## 改动概述
<!-- 一句话说清这个 PR 做了什么 -->
## 为什么
<!-- 背景、关联 issueFixes #xxx / Refs #xxx)、用户场景 -->
## 做了什么
<!-- 关键文件、关键决策。可贴关键片段或截图 -->
## 测试方式
- [ ] `pnpm typecheck && pnpm build`(前端 / 插件)通过
- [ ] `python -m py_compile <文件>` 或本地 backend 启动验证(后端)通过
- [ ] 手动验证步骤:
<!-- 描述如何复现验证UI 改动请附截图 / 录屏 -->
## 回归风险
<!-- 影响面、可能受波及的功能、是否需要前后端 / 配置 同步部署 -->
## Checklist
- [ ] 分支命名遵循 [CONTRIBUTING.md §3](../CONTRIBUTING.md#3-分支命名)`feature/*` / `fix/*` / `release/*` / `hotfix/*`
- [ ] base 分支正确(常规改动 → `develop`;线上紧急 → `master`;发版 → 见 §4.3
- [ ] Commit message 遵循 `type(scope): subject` 格式([CONTRIBUTING.md §5.1](../CONTRIBUTING.md#51-commit-message-格式)
- [ ] 已自测核心流程
- [ ] 已更新相关文档(`README.md` / `CHANGELOG.md` / `CLAUDE.md` / 模块 README如适用
- [ ] 未夹带 secrets / `.env` / 大型二进制
- [ ] 单 PR 不跨多个工作区做无关改动

30
.github/workflows/commitlint.yml vendored Normal file
View File

@@ -0,0 +1,30 @@
name: Commit Lint
on:
pull_request:
types: [opened, synchronize, reopened, edited]
push:
branches:
- develop
- master
permissions:
contents: read
pull-requests: read
jobs:
commitlint:
name: Lint commit messages
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Run commitlint
uses: wagoid/commitlint-github-action@v6
with:
configFile: .commitlintrc.json
failOnWarnings: false
helpURL: https://github.com/JefferyHcool/BiliNote/blob/develop/CONTRIBUTING.md#5-提交规范

View File

@@ -13,8 +13,6 @@ jobs:
include:
- platform: macos-latest
target: universal-apple-darwin
- platform: ubuntu-22.04
target: x86_64-unknown-linux-gnu
- platform: windows-latest
target: x86_64-pc-windows-msvc
@@ -24,13 +22,6 @@ jobs:
- name: Checkout Code
uses: actions/checkout@v4
# Linux 系统依赖Tauri 需要)
- name: Install Linux Dependencies
if: matrix.platform == 'ubuntu-22.04'
run: |
sudo apt-get update
sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf
# 设置 Python 环境(带 pip 缓存)
- name: Set up Python
uses: actions/setup-python@v5
@@ -103,9 +94,6 @@ jobs:
# Windows: .msi, .exe (NSIS)
find "$BUNDLE_DIR" -name "*.msi" -exec cp {} release-artifacts/ \; 2>/dev/null || true
find "$BUNDLE_DIR/nsis" -name "*.exe" -exec cp {} release-artifacts/ \; 2>/dev/null || true
# Linux: .deb, .AppImage
find "$BUNDLE_DIR" -name "*.deb" -exec cp {} release-artifacts/ \; 2>/dev/null || true
find "$BUNDLE_DIR" -name "*.AppImage" -exec cp {} release-artifacts/ \; 2>/dev/null || true
echo "=== Collected artifacts ==="
ls -lh release-artifacts/

115
.github/workflows/release-extension.yml vendored Normal file
View File

@@ -0,0 +1,115 @@
name: Release Extension
# 在 v* tag push 时触发,构建插件并把产物挂到对应 GitHub Release。
# 商店上传仍走人工(详见 RELEASING.md如果将来配齐了商店 API secrets
# 把本文件末尾注释的 publish-* job 解开就是自动发布。
on:
push:
tags:
- 'v*'
permissions:
contents: write
jobs:
build:
name: Build & attach to release
runs-on: ubuntu-latest
defaults:
run:
working-directory: BillNote_extension
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup pnpm
uses: pnpm/action-setup@v3
with:
version: 9
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
cache: pnpm
cache-dependency-path: BillNote_extension/pnpm-lock.yaml
- name: Install
run: pnpm install --frozen-lockfile
- name: Build
run: pnpm build
- name: Pack zip (Chrome / Edge upload format)
run: pnpm pack:zip
- name: Pack xpi (Firefox Add-ons)
run: pnpm pack:xpi
- name: Pack crx (self-host sideload)
# crx 需要稳定 key.pem 才能保持插件 ID 不变CI 没有就跳过,不阻塞主流程。
# 想生成稳定 crx把 key 存到 secret EXTENSION_CRX_KEY下面解开几行。
run: |
# if [ -n "${{ secrets.EXTENSION_CRX_KEY }}" ]; then
# echo "${{ secrets.EXTENSION_CRX_KEY }}" > key.pem
# pnpm pack:crx
# else
pnpm pack:crx || true
# fi
continue-on-error: true
- name: Rename artifacts with version suffix
run: |
VERSION="${GITHUB_REF#refs/tags/v}"
[ -f extension.zip ] && mv extension.zip "bilinote-extension-${VERSION}.zip"
[ -f extension.xpi ] && mv extension.xpi "bilinote-extension-${VERSION}.xpi"
[ -f extension.crx ] && mv extension.crx "bilinote-extension-${VERSION}.crx"
ls -la *.zip *.xpi *.crx 2>/dev/null || true
- name: Attach to GitHub Release
uses: softprops/action-gh-release@v2
with:
files: |
BillNote_extension/bilinote-extension-*.zip
BillNote_extension/bilinote-extension-*.xpi
BillNote_extension/bilinote-extension-*.crx
fail_on_unmatched_files: false
generate_release_notes: false
# ---------- 商店自动发布(默认禁用,配齐 secrets 后可启用) ----------
#
# publish-chrome:
# needs: build
# runs-on: ubuntu-latest
# steps:
# - uses: actions/download-artifact@v4
# - uses: mnao305/chrome-extension-upload@v5
# with:
# file-path: BillNote_extension/bilinote-extension-${{ github.ref_name }}.zip
# extension-id: ${{ secrets.CHROME_EXTENSION_ID }}
# client-id: ${{ secrets.CHROME_CLIENT_ID }}
# client-secret: ${{ secrets.CHROME_CLIENT_SECRET }}
# refresh-token: ${{ secrets.CHROME_REFRESH_TOKEN }}
#
# publish-edge:
# needs: build
# runs-on: ubuntu-latest
# steps:
# - uses: wdzeng/edge-addon@v2
# with:
# product-id: ${{ secrets.EDGE_PRODUCT_ID }}
# zip-path: BillNote_extension/bilinote-extension-${{ github.ref_name }}.zip
# client-id: ${{ secrets.EDGE_CLIENT_ID }}
# api-key: ${{ secrets.EDGE_API_KEY }}
#
# publish-firefox:
# needs: build
# runs-on: ubuntu-latest
# steps:
# - uses: trmcnvn/firefox-addon@v3
# with:
# uuid: ${{ secrets.FIREFOX_ADDON_UUID }}
# xpi: BillNote_extension/bilinote-extension-${{ github.ref_name }}.xpi
# api-key: ${{ secrets.FIREFOX_API_KEY }}
# api-secret: ${{ secrets.FIREFOX_API_SECRET }}

View File

@@ -70,6 +70,7 @@ async function startTask(url: string): Promise<{ ok: boolean, taskId?: string, e
// B 站:先在浏览器里抓字幕(带本地登录态 cookie随提交带过去
const prefetched = platform === 'bilibili' ? await fetchBilibiliSubtitle(url) : null
const formats = settings.formats || []
try {
const res = await fetch(`${backend}/api/generate_note`, {
method: 'POST',
@@ -80,13 +81,15 @@ async function startTask(url: string): Promise<{ ok: boolean, taskId?: string, e
quality: settings.quality,
provider_id: settings.providerId,
model_name: settings.modelName,
screenshot: settings.screenshot,
link: settings.link,
// backend 同时接受 format 数组与 screenshot/link 单独布尔;从 formats 派生保持单一真相源
format: [...formats],
screenshot: formats.includes('screenshot'),
link: formats.includes('link'),
style: settings.style || undefined,
format: [
...(settings.screenshot ? ['screenshot'] : []),
...(settings.link ? ['link'] : []),
],
extras: settings.extras || undefined,
video_understanding: settings.video_understanding || undefined,
video_interval: settings.video_understanding ? settings.video_interval : undefined,
grid_size: settings.video_understanding ? settings.grid_size : undefined,
prefetched_transcript: prefetched ?? undefined,
}),
})

View File

@@ -7,9 +7,14 @@ export const DEFAULT_SETTINGS: Settings = {
providerId: '',
modelName: '',
quality: 'medium',
formats: ['toc', 'summary'],
screenshot: false,
link: false,
style: '',
style: 'minimal',
extras: '',
video_understanding: false,
video_interval: 6,
grid_size: [2, 2],
}
export const MAX_TASKS = 30

View File

@@ -40,6 +40,9 @@ export interface GenerateRequest {
format?: string[]
style?: string
extras?: string
video_understanding?: boolean
video_interval?: number
grid_size?: [number, number]
// 客户端在浏览器里直接抓到的字幕,跳过后端的 download_subtitles + 音频转写
prefetched_transcript?: {
language: string
@@ -78,14 +81,52 @@ export interface TaskRecord {
result?: NoteResult
}
// 与 backend/app/gpt/prompt_builder.py note_styles 一一对齐
export type NoteStyle =
| 'minimal' | 'detailed' | 'academic' | 'tutorial'
| 'xiaohongshu' | 'life_journal' | 'task_oriented'
| 'business' | 'meeting_minutes'
// 与 backend/app/gpt/prompt_builder.py note_formats 一一对齐
export type NoteFormat = 'toc' | 'link' | 'screenshot' | 'summary'
export const NOTE_STYLES: Array<{ value: NoteStyle, label: string }> = [
{ value: 'minimal', label: '精简' },
{ value: 'detailed', label: '详细' },
{ value: 'tutorial', label: '教程' },
{ value: 'academic', label: '学术' },
{ value: 'xiaohongshu', label: '小红书' },
{ value: 'life_journal', label: '生活向' },
{ value: 'task_oriented', label: '任务导向' },
{ value: 'business', label: '商业风格' },
{ value: 'meeting_minutes', label: '会议纪要' },
]
export const NOTE_FORMATS: Array<{ value: NoteFormat, label: string }> = [
{ value: 'toc', label: '目录' },
{ value: 'summary', label: 'AI 总结' },
{ value: 'screenshot', label: '原片截图' },
{ value: 'link', label: '原片跳转' },
]
export interface Settings {
backendUrl: string
providerId: string
modelName: string
quality: Quality
// 输出 format 的 toggle 集合screenshot / link 与下方两个布尔保持联动)
formats: NoteFormat[]
screenshot: boolean
link: boolean
style: string
style: NoteStyle
extras: string
// 多模态视频理解:抽帧拼图喂给视觉模型,提升画面相关问题的回答质量
// 要求所选 model 是视觉模型(如 gpt-4o / gemini / claude-opus 系列),文字模型会忽略图片
video_understanding: boolean
// 抽帧间隔(秒),范围 1-30默认 6
video_interval: number
// 拼图网格 [rows, cols],每张拼图最多 rows*cols 帧。默认 [2,2]
grid_size: [number, number]
}
export interface ProviderUpdatePayload {

View File

@@ -3,9 +3,16 @@ import { onMounted, ref } from 'vue'
import { getProviders, ping } from '~/logic/api'
import { settings, settingsReady } from '~/logic/storage'
import { getModelsByProvider } from '~/logic/api'
import type { Model, Provider } from '~/logic/types'
import { NOTE_FORMATS, NOTE_STYLES, type Model, type NoteFormat, type Provider } from '~/logic/types'
import { watch } from 'vue'
function toggleFormat(value: NoteFormat, checked: boolean) {
const cur = settings.value.formats || []
settings.value.formats = checked
? Array.from(new Set([...cur, value]))
: cur.filter(v => v !== value)
}
const providers = ref<Provider[]>([])
const models = ref<Model[]>([])
const status = ref<{ kind: 'idle' | 'ok' | 'err', text: string }>({ kind: 'idle', text: '' })
@@ -128,13 +135,67 @@ onMounted(async () => {
</label>
<label class="flex flex-col gap-1">
<span class="text-gray-600">笔记风格</span>
<input v-model="settings.style" class="input" placeholder="留空使用默认">
<select v-model="settings.style" class="input">
<option v-for="s in NOTE_STYLES" :key="s.value" :value="s.value">{{ s.label }}</option>
</select>
</label>
<label class="flex items-center gap-2">
<input v-model="settings.screenshot" type="checkbox"> 自动插入截图
</div>
<div class="flex flex-col gap-1 text-sm">
<span class="text-gray-600">输出形式 web NoteForm 对齐</span>
<div class="flex flex-wrap gap-x-4 gap-y-2">
<label v-for="f in NOTE_FORMATS" :key="f.value" class="flex items-center gap-2">
<input
type="checkbox"
:checked="(settings.formats || []).includes(f.value)"
@change="toggleFormat(f.value, ($event.target as HTMLInputElement).checked)"
>
{{ f.label }}
</label>
</div>
</div>
<label class="flex flex-col gap-1 text-sm">
<span class="text-gray-600">额外提示词追加到 prompt 末尾</span>
<textarea
v-model="settings.extras"
class="input resize-y"
rows="3"
placeholder="例如:重点关注游戏开发部分;保留所有专业术语原文"
/>
</label>
</section>
<section class="section-card">
<h2 class="font-semibold">视频理解多模态</h2>
<p class="text-xs text-gray-500">
启用后会按抽帧间隔截取视频帧拼成网格图连同字幕一起喂给视觉模型提升画面相关问题的回答质量
<strong class="text-amber-700">需要选择视觉模型</strong>GPT-4o / Gemini / Claude 文字模型会忽略图片
</p>
<label class="flex items-center gap-2 text-sm">
<input v-model="settings.video_understanding" type="checkbox">
启用视频理解
</label>
<div v-if="settings.video_understanding" class="grid grid-cols-3 gap-3 text-sm">
<label class="flex flex-col gap-1">
<span class="text-gray-600">抽帧间隔(, 1-30)</span>
<input v-model.number="settings.video_interval" type="number" min="1" max="30" class="input">
</label>
<label class="flex items-center gap-2">
<input v-model="settings.link" type="checkbox"> 插入原片跳转链接
<label class="flex flex-col gap-1">
<span class="text-gray-600">拼图行 (1-10)</span>
<input
:value="settings.grid_size?.[0] ?? 2"
type="number" min="1" max="10" class="input"
@input="settings.grid_size = [Number(($event.target as HTMLInputElement).value) || 2, settings.grid_size?.[1] ?? 2]"
>
</label>
<label class="flex flex-col gap-1">
<span class="text-gray-600">拼图列 (1-10)</span>
<input
:value="settings.grid_size?.[1] ?? 2"
type="number" min="1" max="10" class="input"
@input="settings.grid_size = [settings.grid_size?.[0] ?? 2, Number(($event.target as HTMLInputElement).value) || 2]"
>
</label>
</div>
</section>

View File

@@ -4,7 +4,7 @@ import { detectPlatform } from '~/logic/platform'
import { settings, settingsReady, tasks, tasksReady, upsertTask } from '~/logic/storage'
import { generateNote, getTaskStatus, resolveImageUrl } from '~/logic/api'
import { fetchBilibiliSubtitle } from '~/logic/bilibili-subtitle'
import type { TaskRecord } from '~/logic/types'
import { NOTE_FORMATS, NOTE_STYLES, type NoteFormat, type TaskRecord } from '~/logic/types'
const tabUrl = ref<string>('')
const tabTitle = ref<string>('')
@@ -67,19 +67,22 @@ async function start() {
try {
// B 站:在用户浏览器里直接抓字幕(带本地登录态 cookie跳过后端的 download_subtitles 与音频转写
const prefetched = platform.value === 'bilibili' ? await fetchBilibiliSubtitle(tabUrl.value) : null
const formats = settings.value.formats || []
const { task_id } = await generateNote({
video_url: tabUrl.value,
platform: platform.value!,
quality: settings.value.quality,
provider_id: settings.value.providerId,
model_name: settings.value.modelName,
screenshot: settings.value.screenshot,
link: settings.value.link,
// backend VideoRequest 同时接受 format 数组与 screenshot/link 单独布尔,从 formats 派生保持单一真相源
format: [...formats],
screenshot: formats.includes('screenshot'),
link: formats.includes('link'),
style: settings.value.style || undefined,
format: [
...(settings.value.screenshot ? ['screenshot'] : []),
...(settings.value.link ? ['link'] : []),
],
extras: settings.value.extras || undefined,
video_understanding: settings.value.video_understanding || undefined,
video_interval: settings.value.video_understanding ? settings.value.video_interval : undefined,
grid_size: settings.value.video_understanding ? settings.value.grid_size : undefined,
prefetched_transcript: prefetched ?? undefined,
})
activeTaskId.value = task_id
@@ -108,6 +111,13 @@ function openOptions() {
browser.runtime.openOptionsPage()
}
function toggleFormat(value: NoteFormat, checked: boolean) {
const cur = settings.value.formats || []
settings.value.formats = checked
? Array.from(new Set([...cur, value]))
: cur.filter(v => v !== value)
}
async function openSidePanel() {
// 只能在用户操作触发的同步上下文里调,且需要明确的 tabId
try {
@@ -176,7 +186,7 @@ onUnmounted(() => {
</div>
<fieldset class="border rounded p-2 flex flex-col gap-2" :disabled="!supported || submitting">
<div class="grid grid-cols-3 gap-2 text-xs">
<div class="grid grid-cols-2 gap-2 text-xs">
<label class="flex flex-col gap-1">
<span class="text-gray-600">画质</span>
<select v-model="settings.quality" class="border rounded px-1 py-0.5">
@@ -185,14 +195,76 @@ onUnmounted(() => {
<option value="slow">高质</option>
</select>
</label>
<label class="flex items-center gap-1 mt-4">
<input v-model="settings.screenshot" type="checkbox"> 截图
</label>
<label class="flex items-center gap-1 mt-4">
<input v-model="settings.link" type="checkbox"> 跳转
<label class="flex flex-col gap-1">
<span class="text-gray-600">笔记风格</span>
<select v-model="settings.style" class="border rounded px-1 py-0.5">
<option v-for="s in NOTE_STYLES" :key="s.value" :value="s.value">{{ s.label }}</option>
</select>
</label>
</div>
<div class="flex flex-col gap-1 text-xs">
<span class="text-gray-600">输出形式</span>
<div class="flex flex-wrap gap-x-3 gap-y-1">
<label v-for="f in NOTE_FORMATS" :key="f.value" class="flex items-center gap-1">
<input
type="checkbox"
:checked="(settings.formats || []).includes(f.value)"
@change="toggleFormat(f.value, ($event.target as HTMLInputElement).checked)"
>
{{ f.label }}
</label>
</div>
</div>
<details class="text-xs">
<summary class="cursor-pointer text-gray-500">高级</summary>
<label class="flex flex-col gap-1 mt-2">
<span class="text-gray-600">额外提示词追加到 prompt 末尾</span>
<textarea
v-model="settings.extras"
class="border rounded px-1 py-1 resize-y"
rows="2"
placeholder="例如:重点关注游戏开发部分;保留所有专业术语原文"
/>
</label>
<label class="flex items-center gap-2 mt-2">
<input v-model="settings.video_understanding" type="checkbox">
<span class="text-gray-600">启用视频理解抽帧拼图喂视觉模型</span>
</label>
<div v-if="settings.video_understanding" class="grid grid-cols-3 gap-2 mt-2">
<label class="flex flex-col gap-1">
<span class="text-gray-600">抽帧间隔()</span>
<input
v-model.number="settings.video_interval"
type="number" min="1" max="30"
class="border rounded px-1 py-0.5"
>
</label>
<label class="flex flex-col gap-1">
<span class="text-gray-600">拼图行</span>
<input
:value="settings.grid_size?.[0] ?? 2"
type="number" min="1" max="10"
class="border rounded px-1 py-0.5"
@input="settings.grid_size = [Number(($event.target as HTMLInputElement).value) || 2, settings.grid_size?.[1] ?? 2]"
>
</label>
<label class="flex flex-col gap-1">
<span class="text-gray-600">拼图列</span>
<input
:value="settings.grid_size?.[1] ?? 2"
type="number" min="1" max="10"
class="border rounded px-1 py-0.5"
@input="settings.grid_size = [settings.grid_size?.[0] ?? 2, Number(($event.target as HTMLInputElement).value) || 2]"
>
</label>
</div>
<p v-if="settings.video_understanding" class="text-amber-700 mt-1">
需要选择视觉模型GPT-4o / Gemini / Claude 文字模型会忽略图片
</p>
</details>
<div class="text-xs text-gray-600">
<span v-if="settings.providerId && settings.modelName">
模型{{ settings.modelName }}

View File

@@ -1,5 +1,6 @@
# === 前端构建阶段 ===
FROM node:18-alpine AS builder
# Tailwind v4 / Vite 6 需要 Node 20+alpine + pnpm 会按 lockfile 拉 musl native binary。
FROM node:20-alpine AS builder
RUN corepack enable && corepack prepare pnpm@latest --activate

10810
BillNote_frontend/pnpm-lock.yaml generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1,8 +1,14 @@
use tauri::{Manager, Emitter};
use tauri::{Manager, Emitter, State};
use tauri_plugin_shell::ShellExt;
use tauri_plugin_shell::process::CommandEvent;
use tauri_plugin_shell::process::{CommandChild, CommandEvent};
use std::env;
use std::collections::HashMap;
use std::path::Path;
use std::sync::Mutex;
use serde::Serialize;
// Sidecar 子进程句柄,用 Mutex 包裹方便 restart 时杀旧进程
struct SidecarHandle(Mutex<Option<CommandChild>>);
#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
@@ -18,77 +24,31 @@ pub fn run() {
}
let exe_path = env::current_exe().expect("无法获取当前可执行文件路径");
let sidecar_dir = exe_path.parent().expect("无法获取可执行文件的父目录");
// 收集所有系统环境变量
let mut all_env_vars = HashMap::new();
for (key, value) in env::vars() {
all_env_vars.insert(key, value);
// 安装路径诊断PyInstaller sidecar 在含非 ASCII / 空格的路径下经常炸README 已警告但缺主动防御)
// 命中时把诊断信息 emit 给前端,由顶端横幅展示,不阻断启动
let diag = analyze_install_path(&exe_path);
if diag.path_has_non_ascii || diag.path_has_space || !diag.parent_writable {
let app_handle = app.handle().clone();
// 等前端首屏挂载好 listenersetup 阶段 window 已存在但 React 还没 render
// 用独立线程 + 标准 sleep不引入 tokio 依赖
std::thread::spawn(move || {
std::thread::sleep(std::time::Duration::from_millis(1500));
if let Some(window) = app_handle.get_webview_window("main") {
let _ = window.emit("backend-warning", &diag);
}
});
}
// 增强 PATH 环境变量,添加常见的二进制路径
let current_path = all_env_vars.get("PATH").cloned().unwrap_or_default();
let additional_paths = get_additional_binary_paths();
let enhanced_path = enhance_path_variable(&current_path, &additional_paths);
all_env_vars.insert("PATH".to_string(), enhanced_path);
// 打印一些关键环境变量用于调试
println!("Enhanced PATH: {}", all_env_vars.get("PATH").unwrap_or(&"Not found".to_string()));
println!("Total environment variables: {}", all_env_vars.len());
// 检查 ffmpeg 是否在 PATH 中可用
check_ffmpeg_availability();
// 启动 Python 后端侧车
let mut sidecar_command = app.shell().sidecar("BiliNoteBackend").unwrap();
// 设置所有环境变量到 sidecar
for (key, value) in &all_env_vars {
sidecar_command = sidecar_command.env(key, value);
}
let (mut rx, _child) = sidecar_command
.current_dir(sidecar_dir)
.spawn()
.expect("Failed to spawn sidecar");
// 获取主窗口句柄用于发送事件
let window = app.get_webview_window("main").unwrap();
tauri::async_runtime::spawn(async move {
// 读取诸如 stdout 之类的事件
while let Some(event) = rx.recv().await {
match event {
CommandEvent::Stdout(line) => {
let output = String::from_utf8_lossy(&line);
println!("Backend stdout: {}", output);
// 发送到前端
window
.emit("backend-message", Some(format!("'{}'", output)))
.expect("failed to emit event");
}
CommandEvent::Stderr(line) => {
let error = String::from_utf8_lossy(&line);
eprintln!("Backend stderr: {}", error);
window
.emit("backend-error", Some(format!("'{}'", error)))
.expect("failed to emit event");
}
CommandEvent::Terminated(payload) => {
println!("Backend terminated with code: {:?}", payload.code);
window
.emit("backend-terminated", Some(payload.code))
.expect("failed to emit event");
break;
}
_ => {
println!("Backend event: {:?}", event);
}
}
}
});
// 启动 Sidecar 并把 child handle 存到 state方便后续 restart_backend_sidecar 使用
let child = spawn_backend_sidecar(app.handle()).map_err(|e| {
eprintln!("Sidecar 启动失败: {}", e);
e
})?;
app.manage(SidecarHandle(Mutex::new(Some(child))));
Ok(())
})
@@ -96,7 +56,9 @@ pub fn run() {
get_system_env_vars,
find_executable_path,
run_command_with_env,
test_ffmpeg_access
test_ffmpeg_access,
get_install_path_diagnostics,
restart_backend_sidecar
])
.run(tauri::generate_context!())
.expect("error while running tauri application");
@@ -268,6 +230,150 @@ async fn test_ffmpeg_access() -> Result<String, String> {
run_command_with_env("ffmpeg".to_string(), vec!["-version".to_string()]).await
}
// 启动后端 Sidecar负责装环境变量、spawn、挂 stdout/stderr/terminated 监听并 emit 给前端。
// 第一次启动 + restart_backend_sidecar 都走这里,保持单一启动路径。
fn spawn_backend_sidecar(app_handle: &tauri::AppHandle) -> Result<CommandChild, String> {
let exe_path = env::current_exe().map_err(|e| format!("无法获取可执行文件路径: {}", e))?;
let sidecar_dir = exe_path
.parent()
.ok_or("无法获取可执行文件父目录")?
.to_path_buf();
// 收集所有系统环境变量并增强 PATH含 ffmpeg 常见安装位置)
let mut all_env_vars = HashMap::new();
for (key, value) in env::vars() {
all_env_vars.insert(key, value);
}
let current_path = all_env_vars.get("PATH").cloned().unwrap_or_default();
let additional_paths = get_additional_binary_paths();
let enhanced_path = enhance_path_variable(&current_path, &additional_paths);
all_env_vars.insert("PATH".to_string(), enhanced_path);
let mut sidecar_command = app_handle
.shell()
.sidecar("BiliNoteBackend")
.map_err(|e| format!("找不到 BiliNoteBackend sidecar: {}", e))?;
for (key, value) in &all_env_vars {
sidecar_command = sidecar_command.env(key, value);
}
let (mut rx, child) = sidecar_command
.current_dir(sidecar_dir)
.spawn()
.map_err(|e| format!("spawn sidecar 失败: {}", e))?;
// 异步监听 stdout / stderr / terminated 事件,转发到前端 webview
let app_handle_for_listener = app_handle.clone();
tauri::async_runtime::spawn(async move {
while let Some(event) = rx.recv().await {
// window 句柄每次重新取,允许窗口关闭重开
let window = app_handle_for_listener.get_webview_window("main");
match event {
CommandEvent::Stdout(line) => {
let output = String::from_utf8_lossy(&line).to_string();
println!("Backend stdout: {}", output);
if let Some(w) = window {
let _ = w.emit("backend-message", Some(output));
}
}
CommandEvent::Stderr(line) => {
let error = String::from_utf8_lossy(&line).to_string();
eprintln!("Backend stderr: {}", error);
if let Some(w) = window {
let _ = w.emit("backend-error", Some(error));
}
}
CommandEvent::Terminated(payload) => {
println!("Backend terminated with code: {:?}", payload.code);
if let Some(w) = window {
let _ = w.emit("backend-terminated", Some(payload.code));
}
break;
}
_ => {
println!("Backend event: {:?}", event);
}
}
}
});
Ok(child)
}
// 重启 sidecar杀旧 childspawn 新 child回写到 state。
#[tauri::command]
fn restart_backend_sidecar(
state: State<'_, SidecarHandle>,
app: tauri::AppHandle,
) -> Result<(), String> {
// 1. 拿出旧 child 并 killkill 失败也继续,可能进程已经退了)
{
let mut guard = state.0.lock().map_err(|e| format!("锁 sidecar state 失败: {}", e))?;
if let Some(child) = guard.take() {
let _ = child.kill();
}
}
// 2. 重新 spawn
let new_child = spawn_backend_sidecar(&app)?;
{
let mut guard = state.0.lock().map_err(|e| format!("锁 sidecar state 失败: {}", e))?;
*guard = Some(new_child);
}
// 3. emit 一个事件让前端知道已重启
if let Some(window) = app.get_webview_window("main") {
let _ = window.emit("backend-restarted", ());
}
Ok(())
}
// 安装路径诊断PyInstaller 在含非 ASCII / 空格的路径下加载 _internal/* 经常炸;
// 父目录不可写时模型 / 配置 / 日志也无法落盘
#[derive(Serialize, Clone)]
struct InstallPathDiagnostics {
exe_path: String,
path_has_non_ascii: bool,
path_has_space: bool,
parent_writable: bool,
platform: String,
}
fn analyze_install_path(exe_path: &Path) -> InstallPathDiagnostics {
let path_str = exe_path.to_string_lossy().to_string();
// 不在 ASCII 范围内的字符(中文 / 日文 / 西里尔等都会命中 PyInstaller 路径解析坑)
let has_non_ascii = path_str.chars().any(|c| !c.is_ascii());
// 空格本身在 Windows shell 引号场景偶尔出问题,且 macOS path 里也偶尔触发 sidecar 启动失败
let has_space = path_str.contains(' ');
// 父目录可写PyInstaller 解压 _internal/、写日志、写配置都需要这个
let parent = exe_path.parent();
let parent_writable = parent
.and_then(|p| {
let probe = p.join(".bilinote_write_probe");
match std::fs::write(&probe, b"x") {
Ok(_) => {
let _ = std::fs::remove_file(&probe);
Some(true)
}
Err(_) => Some(false),
}
})
.unwrap_or(false);
InstallPathDiagnostics {
exe_path: path_str,
path_has_non_ascii: has_non_ascii,
path_has_space: has_space,
parent_writable,
platform: std::env::consts::OS.to_string(),
}
}
// Tauri 命令:让前端按需重新查询诊断结果(比如用户卸载到新目录后重启)
#[tauri::command]
fn get_install_path_diagnostics() -> InstallPathDiagnostics {
let exe_path = env::current_exe().unwrap_or_default();
analyze_install_path(&exe_path)
}
// 可选:添加一个函数来动态更新 sidecar 的环境变量
#[tauri::command]
async fn update_sidecar_environment(

View File

@@ -5,6 +5,8 @@ import { useTaskPolling } from '@/hooks/useTaskPolling.ts'
import { useCheckBackend } from '@/hooks/useCheckBackend.ts'
import { systemCheck } from '@/services/system.ts'
import BackendInitDialog from '@/components/BackendInitDialog'
import StartupBanner from '@/components/SystemDiagnostic/StartupBanner'
import BackendHealthIndicator from '@/components/BackendHealth/BackendHealthIndicator'
import Index from '@/pages/Index.tsx'
import { HomePage } from './pages/HomePage/Home.tsx'
@@ -34,6 +36,7 @@ function App() {
if (!initialized) {
return (
<>
<StartupBanner />
<BackendInitDialog open={loading} />
</>
)
@@ -42,6 +45,8 @@ function App() {
// 后端已初始化,渲染主应用
return (
<>
<StartupBanner />
<BackendHealthIndicator />
<BrowserRouter>
<Suspense fallback={<div className="flex h-screen items-center justify-center"></div>}>
<Routes>

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

View File

@@ -0,0 +1,111 @@
import { useEffect, useState } from 'react'
import { useBackendEvents } from './useBackendEvents'
import BackendLogPanel from './BackendLogPanel'
// 健康度判定:
// - 绿sidecar running 且 /sys_health 通
// - 黄sidecar running 但 /sys_health 失败 (ffmpeg 缺等)
// - 红sidecar terminated 或 /sys_health 连续 3 次失败
type Health = 'green' | 'yellow' | 'red' | 'unknown'
const HEALTH_POLL_MS = 5000
const SYS_HEALTH_PATH = '/api/sys_health'
function backendBase(): string {
// 与 services/request.ts 用的一致
const fromEnv = (import.meta as any).env?.VITE_API_BASE_URL as string | undefined
return (fromEnv ?? '').replace(/\/$/, '')
}
const BackendHealthIndicator = () => {
const { status, isTauri, exitCode, logs, restart, copyLogs } = useBackendEvents()
const [open, setOpen] = useState(false)
const [healthCheckFailures, setHealthCheckFailures] = useState(0)
const [lastHealthOk, setLastHealthOk] = useState<boolean | null>(null)
// 仅在 Tauri 环境挂指示器;纯 web 用户由 useCheckBackend 接管
useEffect(() => {
if (!isTauri) return
let mounted = true
async function ping() {
try {
const res = await fetch(`${backendBase()}${SYS_HEALTH_PATH}`)
const ok = res.ok
if (!mounted) return
if (ok) {
setHealthCheckFailures(0)
setLastHealthOk(true)
}
else {
setHealthCheckFailures(c => c + 1)
setLastHealthOk(false)
}
}
catch {
if (!mounted) return
setHealthCheckFailures(c => c + 1)
setLastHealthOk(false)
}
}
ping()
const t = setInterval(ping, HEALTH_POLL_MS)
return () => {
mounted = false
clearInterval(t)
}
}, [isTauri])
if (!isTauri) return null
const health: Health = (() => {
if (status === 'terminated') return 'red'
if (healthCheckFailures >= 3) return 'red'
if (lastHealthOk === false) return 'yellow'
if (lastHealthOk === true) return 'green'
return 'unknown'
})()
const colorMap: Record<Health, string> = {
green: 'bg-green-500',
yellow: 'bg-amber-500',
red: 'bg-red-500',
unknown: 'bg-gray-400',
}
const labelMap: Record<Health, string> = {
green: '后端运行正常',
yellow: '后端运行中(部分检查未通过)',
red: status === 'terminated' ? `后端已退出 (code=${exitCode ?? 'unknown'})` : '后端无响应',
unknown: '后端状态未知',
}
return (
<>
<button
className="fixed right-3 bottom-3 z-[9998] flex items-center gap-2 rounded-full border bg-white px-3 py-1.5 text-xs shadow hover:shadow-md"
title={labelMap[health]}
onClick={() => setOpen(true)}
>
<span className={`inline-block h-2 w-2 rounded-full ${colorMap[health]}${health === 'red' || health === 'yellow' ? ' animate-pulse' : ''}`} />
<span className="text-gray-700"></span>
</button>
{open && (
<BackendLogPanel
status={status}
exitCode={exitCode}
logs={logs}
health={health}
onRestart={restart}
onCopyLogs={copyLogs}
onClose={() => setOpen(false)}
/>
)}
</>
)
}
export default BackendHealthIndicator

View File

@@ -0,0 +1,108 @@
import { useEffect, useRef, useState } from 'react'
import type { LogEntry, BackendStatus } from './useBackendEvents'
interface Props {
status: BackendStatus
exitCode: number | null
logs: LogEntry[]
health: 'green' | 'yellow' | 'red' | 'unknown'
onRestart: () => Promise<void>
onCopyLogs: () => Promise<boolean>
onClose: () => void
}
const BackendLogPanel = ({ status, exitCode, logs, health, onRestart, onCopyLogs, onClose }: Props) => {
const [restarting, setRestarting] = useState(false)
const [copied, setCopied] = useState(false)
const scrollRef = useRef<HTMLDivElement>(null)
// 新日志进来自动滚到底
useEffect(() => {
if (scrollRef.current)
scrollRef.current.scrollTop = scrollRef.current.scrollHeight
}, [logs])
async function handleRestart() {
setRestarting(true)
try { await onRestart() }
catch { /* errors already in log via useBackendEvents */ }
finally { setRestarting(false) }
}
async function handleCopy() {
const ok = await onCopyLogs()
setCopied(ok)
setTimeout(() => setCopied(false), 1500)
}
return (
<>
{/* 半透明遮罩 */}
<div className="fixed inset-0 z-[9998] bg-black/20" onClick={onClose} />
<aside className="fixed right-0 bottom-0 top-0 z-[9999] flex w-[480px] max-w-[90vw] flex-col border-l bg-white shadow-2xl">
<header className="flex items-center justify-between border-b px-4 py-3">
<div>
<h2 className="text-base font-semibold"></h2>
<div className="mt-0.5 text-xs text-gray-500">
{status === 'terminated'
? `已退出(退出码 ${exitCode ?? 'unknown'}`
: health === 'red'
? '运行中但无响应'
: health === 'yellow'
? '运行中,部分系统检查未通过'
: '运行正常'}
</div>
</div>
<button className="rounded p-1 text-gray-500 hover:bg-gray-100" onClick={onClose}></button>
</header>
<div className="flex items-center gap-2 border-b px-4 py-2">
<button
className="rounded bg-blue-600 px-3 py-1 text-sm text-white hover:bg-blue-700 disabled:opacity-50"
disabled={restarting}
onClick={handleRestart}
>
{restarting ? '重启中…' : '重启后端'}
</button>
<button
className="rounded bg-gray-100 px-3 py-1 text-sm text-gray-700 hover:bg-gray-200"
onClick={handleCopy}
>
{copied ? '已复制 ✓' : '复制日志'}
</button>
<span className="ml-auto text-xs text-gray-400">
{logs.length}
</span>
</div>
<div
ref={scrollRef}
className="flex-1 overflow-auto bg-gray-900 p-3 font-mono text-xs text-gray-100"
>
{logs.length === 0 ? (
<div className="text-gray-500 italic"></div>
) : (
logs.map((l, i) => (
<div
key={`${l.ts}-${i}`}
className={`whitespace-pre-wrap break-all leading-snug ${l.level === 'error' ? 'text-red-300' : 'text-gray-100'}`}
>
<span className="mr-2 text-gray-500">
{new Date(l.ts).toISOString().slice(11, 19)}
</span>
{l.text}
</div>
))
)}
</div>
<footer className="border-t px-4 py-2 text-xs text-gray-500">
退 / issue
</footer>
</aside>
</>
)
}
export default BackendLogPanel

View File

@@ -0,0 +1,119 @@
import { useEffect, useRef, useState } from 'react'
// 桌面端 Sidecar 健康度。监听 Tauri 侧的 backend-message / backend-error /
// backend-terminated / backend-restarted 事件,把 stdout/stderr 缓冲成 ring buffer
// 同时维护进程运行状态。
const isTauri = typeof window !== 'undefined' && '__TAURI_INTERNALS__' in window
export type LogLevel = 'info' | 'error'
export interface LogEntry {
level: LogLevel
text: string
ts: number
}
export type BackendStatus = 'running' | 'terminated'
const MAX_LOG_LINES = 200
interface BackendEvents {
status: BackendStatus
exitCode: number | null
logs: LogEntry[]
/** 调 Tauri 命令重启 sidecar */
restart: () => Promise<void>
/** 复制全部日志到剪贴板 */
copyLogs: () => Promise<boolean>
isTauri: boolean
}
export function useBackendEvents(): BackendEvents {
const [status, setStatus] = useState<BackendStatus>('running')
const [exitCode, setExitCode] = useState<number | null>(null)
const [logs, setLogs] = useState<LogEntry[]>([])
// 用 ref 持有最新 logs 数组append 时不被闭包陷阱卡到旧值
const logsRef = useRef<LogEntry[]>([])
function append(entry: LogEntry) {
const next = logsRef.current.concat(entry)
if (next.length > MAX_LOG_LINES)
next.splice(0, next.length - MAX_LOG_LINES)
logsRef.current = next
setLogs(next)
}
useEffect(() => {
if (!isTauri) return
let unlisteners: Array<() => void> = []
;(async () => {
const { listen } = await import('@tauri-apps/api/event')
const offMsg = await listen<string>('backend-message', event => {
append({ level: 'info', text: stripQuotes(event.payload), ts: Date.now() })
})
const offErr = await listen<string>('backend-error', event => {
append({ level: 'error', text: stripQuotes(event.payload), ts: Date.now() })
})
const offTerm = await listen<number | null>('backend-terminated', event => {
setStatus('terminated')
setExitCode(event.payload ?? null)
append({
level: 'error',
text: `[Backend terminated] code=${event.payload ?? 'unknown'}`,
ts: Date.now(),
})
})
const offRestart = await listen('backend-restarted', () => {
setStatus('running')
setExitCode(null)
append({ level: 'info', text: '[Backend restarted]', ts: Date.now() })
})
unlisteners = [offMsg, offErr, offTerm, offRestart]
})()
return () => {
unlisteners.forEach(fn => fn())
}
}, [])
async function restart() {
if (!isTauri) return
const { invoke } = await import('@tauri-apps/api/core')
try {
await invoke('restart_backend_sidecar')
}
catch (e) {
append({ level: 'error', text: `[Restart failed] ${(e as Error).message ?? e}`, ts: Date.now() })
throw e
}
}
async function copyLogs() {
const text = logsRef.current
.map(l => `${new Date(l.ts).toISOString().slice(11, 19)} ${l.level === 'error' ? 'E' : 'I'} ${l.text}`)
.join('\n')
try {
await navigator.clipboard.writeText(text)
return true
}
catch {
return false
}
}
return { status, exitCode, logs, restart, copyLogs, isTauri }
}
// Rust 早期版本 emit 时把 stdout 包了一层 '...',新版本已经直接 emit 原文。
// 这里做兼容:去掉外层单引号(如果有的话)。
function stripQuotes(s: string): string {
if (typeof s !== 'string') return String(s)
if (s.length >= 2 && s.startsWith("'") && s.endsWith("'"))
return s.slice(1, -1)
return s
}

View File

@@ -0,0 +1,123 @@
import { useEffect, useState } from 'react'
// 桌面端启动诊断横幅。监听 Tauri 侧 emit 的 backend-warning / backend-error / backend-terminated。
// 只在 Tauri 环境生效;纯 web 环境(无 window.__TAURI_INTERNALS__下静默不挂载。
type Severity = 'info' | 'warning' | 'error'
interface DiagnosticPayload {
exe_path?: string
path_has_non_ascii?: boolean
path_has_space?: boolean
parent_writable?: boolean
platform?: string
}
interface BannerState {
severity: Severity
title: string
detail: string
payload?: DiagnosticPayload
dismissible: boolean
}
const isTauri = typeof window !== 'undefined' && '__TAURI_INTERNALS__' in window
function describeWarning(payload: DiagnosticPayload): { title: string; detail: string } {
const parts: string[] = []
if (payload.path_has_non_ascii) {
parts.push('安装路径包含非 ASCII 字符(中文 / 日文等)')
}
if (payload.path_has_space) {
parts.push('安装路径包含空格')
}
if (payload.parent_writable === false) {
parts.push('安装目录不可写(缺少权限或只读)')
}
return {
title: '检测到可能导致后端启动失败的安装路径',
detail:
`${parts.join('')}\n` +
'建议把 BiliNote 重新安装到一个纯英文、无空格、可写的路径下(如 C:\\BiliNote\\ 或 /Applications/)。\n' +
`当前路径:${payload.exe_path || '未知'}`,
}
}
const StartupBanner = () => {
const [banner, setBanner] = useState<BannerState | null>(null)
useEffect(() => {
if (!isTauri) return
let unlisteners: Array<() => void> = []
;(async () => {
const { listen } = await import('@tauri-apps/api/event')
const offWarning = await listen<DiagnosticPayload>('backend-warning', event => {
const { title, detail } = describeWarning(event.payload || {})
setBanner({
severity: 'warning',
title,
detail,
payload: event.payload,
dismissible: true,
})
})
const offTerminated = await listen<number | null>('backend-terminated', event => {
setBanner({
severity: 'error',
title: '后端进程已退出',
detail: `退出码:${event.payload ?? '未知'}。打开「部署监控」或重启应用以恢复。`,
dismissible: false,
})
})
// backend-error 是 sidecar stderr量大噪音多这里不直接展示留给 P2 的日志面板。
unlisteners = [offWarning, offTerminated]
})()
return () => {
unlisteners.forEach(fn => fn())
}
}, [])
if (!banner) return null
const colorByLevel: Record<Severity, string> = {
info: 'bg-blue-50 border-blue-300 text-blue-900',
warning: 'bg-amber-50 border-amber-300 text-amber-900',
error: 'bg-red-50 border-red-300 text-red-900',
}
const iconByLevel: Record<Severity, string> = {
info: '',
warning: '⚠️',
error: '✕',
}
return (
<div
className={`fixed left-0 right-0 top-0 z-[9999] flex items-start gap-3 border-b px-4 py-2 text-sm shadow-sm ${colorByLevel[banner.severity]}`}
>
<span className="text-lg">{iconByLevel[banner.severity]}</span>
<div className="flex-1 min-w-0">
<div className="font-medium">{banner.title}</div>
<pre className="mt-0.5 whitespace-pre-wrap break-words font-sans text-xs opacity-90">
{banner.detail}
</pre>
</div>
{banner.dismissible && (
<button
className="shrink-0 rounded px-2 py-0.5 text-xs hover:bg-black/10"
onClick={() => setBanner(null)}
>
</button>
)}
</div>
)
}
export default StartupBanner

View File

@@ -5,6 +5,7 @@ import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs'
import { Github, Star, ExternalLink, Download } from 'lucide-react'
import { ScrollArea } from '@/components/ui/scroll-area.tsx'
import logo from '@/assets/icon.svg'
import wechatQr from '@/assets/wechat.png'
export default function AboutPage() {
const images = [
@@ -197,14 +198,10 @@ export default function AboutPage() {
<h2 className="mb-8 text-center text-3xl font-bold"></h2>
<div className="mx-auto max-w-3xl">
<div className="flex flex-col items-center justify-center gap-8">
<div className="text-center">
<h3 className="mb-3 text-xl font-semibold">BiliNote QQ </h3>
<p className="text-lg font-medium">785367111</p>
</div>
<div className="text-center">
<h3 className="mb-3 text-xl font-semibold">BiliNote </h3>
<div className="bg-muted mx-auto flex h-52 w-52 items-center justify-center rounded-md">
<img src={'https://common-1304618721.cos.ap-chengdu.myqcloud.com/wechat.png'} />
<img src={wechatQr} alt="BiliNote 交流微信群" className="h-full w-full object-contain" />
</div>
</div>
</div>

View File

@@ -2,6 +2,62 @@
本项目所有重要变更记录于此。格式参考 [Keep a Changelog](https://keepachangelog.com/zh-CN/1.1.0/),遵循 [语义化版本](https://semver.org/lang/zh-CN/)。
## [2.1.4] - 2026-05-07
CI 工程化修复,无运行时行为变化。
### Internal
- 桌面端 Tauri 构建矩阵去掉 Linux`ubuntu-22.04 / x86_64-unknown-linux-gnu`。Linux 桌面端构建持续 17m+且无对应分发渠道Linux 用户继续可以走 Docker 镜像 (`ghcr.io/jefferyhcool/bilinote`)
- commitlint workflow 去掉无效的 `firstParent` inputwagoid/commitlint-github-action@v6 不支持,被忽略并打 warn
- 规范 release merge commit 标题:`chore(release): vX.Y.Z`(合 master/ `chore(release): merge release/X.Y.Z back into develop`(回灌 develop让 commitlint 能正确识别。`RELEASING.md` §3 与 `CONTRIBUTING.md` §6.3 同步更新
## [2.1.3] - 2026-05-07
### Fixed
- DeepSeek 等非多模态供应商被 400 拒绝issue #282`UniversalGPT.create_messages``_build_merge_messages` 此前**无条件**把 content 拼成 OpenAI 多模态数组 `[{"type":"text",...}]`DeepSeek `deepseek-chat` 等模型不识别 `image_url` 变体直接报 `invalid_request_error``GPTFactory.from_config` 一律实例化 `UniversalGPT`,所以问题覆盖**所有**通过模型设置页接入的非多模态供应商,不止 DeepSeek。
- 现按 `video_img_urls` 是否非空切换 content 形态:有图保留多模态数组(视觉模型不退化),无图退回 string。合并阶段历来不带图统一改 string。
- 与同包内 `deepseek_gpt.py` / `openai_gpt.py` / `qwen_gpt.py` 的 message builder 行为对齐。
- 新增 `backend/tests/test_universal_gpt_content_format.py` 6 个 case 回归覆盖(含 `image_url` 字面 not-in JSON 断言)。
感谢 @voidborne-d 的修复(#345)。
## [2.1.2] - 2026-05-07
补 v2.1.1 上 ghcr.io 镜像构建失败的坑。
### Fixed
- Docker 镜像构建失败v2.1.1 tag 触发的 ghcr.io 推送在 frontend-builder 第 7/7 步 `pnpm run build` 挂掉vite `loadConfigFromBundledFile` 加载 `@tailwindcss/vite` plugin 时 1.5s 内异常退出)。
- `Dockerfile.complete``BillNote_frontend/Dockerfile``node:18-alpine``node:20-alpine`Tailwind v4 已不再支持 Node 18Vite 6 也推荐 Node 20+
- `Dockerfile.complete` 的 frontend 阶段同时复制 `pnpm-lock.yaml` 并改用 `--frozen-lockfile`,杜绝每次构建重解析 semver 拉到比本地新的 native dep
- `BillNote_frontend/pnpm-lock.yaml` 强制入库(之前一直未提交,导致 CI / 本地依赖图持续漂移)
- README 联系社区段补上微信群二维码(之前只写"年会恢复更新以后放出最新社区地址"
## [2.1.1] - 2026-05-07
工程化与文档收尾,无运行时行为变化。
### Added
- [`CONTRIBUTING.md`](./CONTRIBUTING.md) — 贡献指南,落地简化 Git Flowmaster + develop + 短生命周期分支)+ 提交规范 + 合并规范
- [`RELEASING.md`](./RELEASING.md) — 发版手册Release Manager 视角),含 release/* 流程 + 各商店人工上传步骤 + 自动发布所需 secrets
- `.github/ISSUE_TEMPLATE/{config,bug_report,feature_request}.yml` — 表单形式的 issue 模板,按工作区分类
- `.github/pull_request_template.md` — PR 模板,把 CONTRIBUTING §5.2 落成 checklist
- `.commitlintrc.json` + `.github/workflows/commitlint.yml` — commitlint CIPR + push develop/master 时校验,自定义 type 白名单,兼容中文 subject
- `.github/workflows/release-extension.yml``v*` tag push 时自动构建插件 .zip / .xpi / .crx 并挂到对应 GitHub Release商店自动发布以注释形式预留
### Changed
- 关于页二维码改为 `import @/assets/wechat.png`,不再依赖腾讯云 COS CDN更新只需替换文件 + 跑构建
- 群聊 QR 替换为最新版本(`doc/wechat.png` + `BillNote_frontend/src/assets/wechat.png`
### Removed
- 关于页 QQ 群联系方式(号 785367111已不再活跃维护
- 旧版 `.md` 格式 issue 模板(被新 yml 表单模板取代)
## [2.1.0] - 2026-05-07
本次发布的主线是**浏览器插件**和 **B 站字幕优先链路**。配合一些后端 / 前端体验修复。

341
CONTRIBUTING.md Normal file
View File

@@ -0,0 +1,341 @@
# 贡献指南
欢迎为 BiliNote 贡献代码。本文档约定分支管理、提交规范、合并流程。新贡献者请通读一遍后再开 PR。
> 关联文档
> - [README.md](./README.md):项目概览、快速开始
> - [CLAUDE.md](./CLAUDE.md):仓库结构 + 各 workspace 开发命令
> - [CHANGELOG.md](./CHANGELOG.md):版本变更记录
> - [RELEASING.md](./RELEASING.md)发版执行手册Release Manager 视角)
---
## 1. 仓库结构与工作区
本仓库为多工作区单体仓:
| 路径 | 内容 | 主要命令 |
|---|---|---|
| `backend/` | Python 3.11 + FastAPI | `pip install -r requirements.txt && python main.py` |
| `BillNote_frontend/` | React 19 + Vite | `pnpm install && pnpm dev` |
| `BillNote_extension/` | Vue 3 + Vite + WebExtension MV3 | `pnpm install && pnpm dev` |
详细结构与开发命令见 [CLAUDE.md](./CLAUDE.md)。提交时**单 PR 不要跨多个工作区做无关改动**,便于评审与回滚。
---
## 2. 分支模型
采用简化 Git Flow稳定主干 `master` + 长期开发集成 `develop` + 短生命周期业务分支。
| 分支类型 | 命名 | 长期保留 | 创建来源 | 合并去向 | 用途 |
|---|---|---|---|---|---|
| 生产主干 | `master` | ✅ | 仓库默认分支 | — | 始终保持可发布状态;只接收 `release/*``hotfix/*` 合入 |
| 开发主干 | `develop` | ✅ | `master` | `release/*` 回灌后 | 日常需求集成;常规开发都从这里起 |
| 功能分支 | `feature/*` | ❌ | `develop` | `develop` | 新功能 / 需求开发 |
| 修复分支 | `fix/*` | ❌ | `develop` | `develop` | 开发期间发现的缺陷修复(非线上问题) |
| 发布分支 | `release/*` | ❌ | `develop` | `master` + `develop` | 版本冻结、回归、发版准备 |
| 热修复 | `hotfix/*` | ❌ | `master` | `master` + `develop` | 线上紧急问题 |
### 基本原则
- `master` 只保存**已发布代码**,不接受日常开发提交。
- `develop` 是**唯一**长期开发集成分支。
- 所有业务开发**必须**用短生命周期分支,禁止长期占用个人开发分支。
- 一个分支只承载一个需求或一类明确的修复事项。
---
## 3. 分支命名
### 命名格式
```
feature/<scope>-<事项>
fix/<scope>-<事项>
release/<版本号>
hotfix/<scope>-<事项>
```
`<scope>` 优先用代码 scope与 commit message scope 对齐,见 §5常用
- `extension` — 浏览器插件(`BillNote_extension/`
- `frontend` — Web 前端(`BillNote_frontend/`
- `backend` — Python 后端(`backend/`
- `bilibili` / `youtube` / `douyin` / `kuaishou` — 平台特定改动
- `transcriber` — 音频转写
- `gpt` / `chat` — LLM / RAG
- `docker` / `ci` — 构建与发布
- `docs` — 文档
### 命名示例
```bash
# 功能开发
feature/extension-side-panel
feature/youtube-subtitle-innertube
feature/backend-rag-chat
# 开发期修复
fix/extension-task-status-unwrap
fix/bilibili-cookie-injection
fix/mlx-whisper-repo-id
# 发版
release/2.1.0
release/2.2.0
# 线上热修
hotfix/backend-cors-regex
hotfix/frontend-provider-switch
```
### 命名要求
- 全小写字母 / 数字 / 中划线
- `<事项>` 要表达**具体行为**,避免 `test` / `update` / `temp` / `wip` 这类无意义名
- `release/<版本号>` 必须与实际 tag 一致(如 `release/2.1.0``v2.1.0`
---
## 4. 标准协作流程
### 4.1 日常需求开发
```bash
git checkout develop
git pull origin develop
git checkout -b feature/<scope>-<事项>
# … 开发 + 自测 + commit …
git push -u origin feature/<scope>-<事项>
# 在 GitHub 上发起 PRbase = developcompare = 你的分支
```
合并通过且 PR closed 后,**删除本地与远端分支**
```bash
git branch -d feature/<scope>-<事项>
git push origin --delete feature/<scope>-<事项>
```
### 4.2 开发期缺陷修复
提测或联调中发现问题时,从 `develop``fix/*`。**不要在原 `feature/*` 上长期叠加零散修复**。
适用场景:
- 已合入 `develop` 后被测试打回的问题
- 多个功能集成后暴露的兼容性问题
- 非线上环境问题
### 4.3 版本发布
```bash
# 1. 从 develop 切 release
git checkout develop && git pull origin develop
git checkout -b release/<版本号>
# 2. 在 release 分支上:更新 README 版本号、写 CHANGELOG.md、必要的小修
git commit -am "docs: <版本号> CHANGELOG + README 版本"
git push -u origin release/<版本号>
# 3. 进入冻结期PR base=master 合并;同时 PR base=develop 回灌
# 4. master 上打 tag
git checkout master && git pull
git tag -a v<版本号> -m "BiliNote v<版本号>" && git push origin v<版本号>
# 5. release 分支已合入两边,删除
git push origin --delete release/<版本号>
```
要点:
- **冻结期内 `release/*` 不再合入新需求**,只允许修复发布缺陷。
- 发版窗口期内的新需求继续基于 `develop` 开发,**不进入当前 `release/*`**。
- 发布完成后必须把 `release/*` 同步回 `develop`,避免漏修。
### 4.4 线上紧急修复
```bash
git checkout master && git pull
git checkout -b hotfix/<scope>-<事项>
# … 修 + commit …
# PR base=master合入后立刻打 patch tag如 v2.1.1)发版
# 同一改动同时 PR base=develop 回灌
```
要点:
- `hotfix/*` 仅处理**线上阻断性 / 高优先级**缺陷。
- 非紧急问题不得绕过 `develop` 直接走热修流程。
- 若当前存在 `release/*` 即将发布,需评估是否同步到对应 release避免修复丢失。
---
## 5. 提交规范
### 5.1 Commit message 格式
> CI 已接入 [commitlint](https://commitlint.js.org)[`.commitlintrc.json`](./.commitlintrc.json) + [`.github/workflows/commitlint.yml`](./.github/workflows/commitlint.yml))。
> PR 上所有 commit 都会被校验type 不在白名单时合并按钮会被卡。
```
type(scope): subject
```
例:
```
feat(extension): 侧边栏接入思维导图markmap与 RAG 问答
fix(bilibili): 修正字幕优先链路在未登录态下的回退
docs(contributing): 新增贡献指南
chore(ci): 优化 docker 构建缓存
```
#### type
| type | 说明 |
|---|---|
| `feat` | 新功能 |
| `fix` | 缺陷修复 |
| `docs` | 文档变更 |
| `style` | 代码风格调整(不影响行为) |
| `refactor` | 重构(非 feat / 非 fix |
| `perf` | 性能优化 |
| `test` | 测试增删 |
| `build` | 构建系统 / 依赖变更 |
| `ci` | CI 配置变更 |
| `chore` | 杂项(不归入以上类别) |
| `ui` | 界面 / 交互层调整(仓库内既有用法) |
| `revert` | 回滚 |
#### scope
与 §3 的分支 scope 保持一致:`extension` / `frontend` / `backend` / `bilibili` / `youtube` / `douyin` / `kuaishou` / `transcriber` / `gpt` / `chat` / `docker` / `ci` / `docs` 等。
#### subject
- 用中文或英文都可以,**保持一种风格**。
- 用现在时陈述("新增 X" / "修复 Y" / "Add X" / "Fix Y")。
- 首字母不大写,结尾不加句号。
- 单行控制在 72 字符以内;如需详细说明,正文与标题之间空一行。
### 5.2 PR 标题与正文
- **PR 标题**沿用 commit message 格式,描述本次 PR 的总体改动。
- **PR 正文**应包含:
- 改动的"为什么"(背景 / issue / 用户场景)
- 改动的"做了什么"(关键文件、关键决策)
- **测试方式**(如何验证、覆盖了哪些 case
- **回归风险**与影响面
- 是否需要后端 / 前端 / 配置同步部署
---
## 6. 合并规范
### 6.1 合并前要求
- 合并前必须**先同步**目标分支最新代码(`git pull --rebase` 或在 PR 上点 "Update branch")。
- 合并前必须完成**自测**,确保核心流程可用。
- 后端改动需 `python -m py_compile` 至少通过;前端 / 插件改动需 `pnpm typecheck && pnpm build` 通过。
- **冲突由分支负责人解决**,不得留给评审人或发版人员。
### 6.2 评审
- 默认通过 PR 合并,**不允许**绕过 PR 直接 push 到 `master``develop`
- 评审人至少关注:业务影响、回归风险、是否夹带无关改动、目录归属是否合理。
- 修文档 / 改注释这种小变更允许 1 人评审通过;改业务逻辑 / 协议 / 共享模块至少 2 人评审。
### 6.3 合并方式
- `feature/*` / `fix/*` 合入 `develop`:推荐 **Squash and merge**,保持 develop 历史线性。
- `release/*` 合入 `master` 与回灌 `develop`:使用 **Merge commit (--no-ff)**,保留发版结构。
· merge commit 标题用 `chore(release): vX.Y.Z`(合 master`chore(release): merge release/X.Y.Z back into develop`(回灌 develop保证 commitlint 通过。
- `hotfix/*` 同上 release。
### 6.4 合并后
- 短期分支合并完成后**必须删除**(远端 + 本地)。
- 已完成的分支不得继续承接新需求;如需后续迭代请重新基于最新目标分支开新分支。
---
## 7. Git 钩子注意事项
`BillNote_extension/` 早期使用 `simple-git-hooks``postinstall`,会在仓库根目录 `.git/hooks/pre-commit` 注入 `pnpm lint-staged`,但仓库根没有 `package.json`,导致**任何 commit 都被钩子卡死**。**已在 v2.1.0 起移除**该 postinstall 配置。
如果你机器上还残留旧版本装下来的 hook
```bash
# 一次性清理
rm .git/hooks/pre-commit
# 或临时绕过本次 commit
SKIP_SIMPLE_GIT_HOOKS=1 git commit -m "..."
```
---
## 8. 版本号与 CHANGELOG
- 版本号遵循 [语义化版本](https://semver.org/lang/zh-CN/)`MAJOR.MINOR.PATCH`
- `MAJOR`:破坏性 API 变更或重大重构
- `MINOR`:新增特性、向后兼容
- `PATCH`bug 修复、向后兼容
- 每次发版**必须更新 [CHANGELOG.md](./CHANGELOG.md)**,按 [Keep a Changelog](https://keepachangelog.com/zh-CN/1.1.0/) 格式分类Added / Changed / Fixed / Removed / Security / Internal
- 发版同时更新 `README.md` 顶部的版本号与"v\<版本号\> 新增"摘要段。
- `master` 上打 tag 形如 `vX.Y.Z`,注释中包含本次发布主线 + 引用 `CHANGELOG.md`
---
## 9. 禁止事项
- ❌ 直接在 `master` 上开发、提交、修复普通问题
- ❌ 新增长期 `dev-*` / `wip-*` / `<姓名>-dev` 个人分支作为日常协作分支
- ❌ 一个分支同时承载多个需求 / 多个缺陷 / 跨版本内容
- ❌ 未评审、未自测、未通过基础校验直接合并
-`release/*` 冻结后继续混入新需求
-`hotfix/*` 只合入 `master` 而不回灌 `develop`
- ❌ 提交 / 仓库内包含密钥、API key、`.env` 等敏感文件
- ❌ 提交 `node_modules/` / `dist/` / `extension/dist/` / `__pycache__/` / 大型二进制(参考各级 `.gitignore`
---
## 10. 历史分支迁移
仓库历史上存在多条已合并但未删除的分支(见 `git branch -a`)。即日起:
- 不再创建 `dev-*` / `<姓名>-*` 个人分支
- 已合入主干的旧分支,由发版人统一清理
- 未完成需求应尽快迁移到符合 §3 命名规范的新分支
---
## 11. 推荐流程图
```text
master ← hotfix/* (线上紧急修复)
↑ ↑
│ │
release/* ← develop ← feature/* (功能开发)
│ ↑
└───────────┘
fix/* (开发期修复)
回灌
```
---
## 12. 执行口径速查
| 场景 | 流程 |
|---|---|
| 新功能 | `develop``feature/*``develop` |
| 提测后发现问题 | `develop``fix/*``develop` |
| 版本发布 | `develop``release/*``master` + `develop`;打 tag |
| 线上紧急故障 | `master``hotfix/*``master` + `develop`;打 patch tag |
| 发版期内新需求 | 基于 `develop``feature/*`**不**进入当前 `release/*` |
---
如有改进建议,欢迎开 PR 修订本文档(`docs(contributing): ...`)。

View File

@@ -26,15 +26,18 @@ RUN pip install --no-cache-dir -i ${PIP_INDEX} -r requirements.txt
COPY ./backend /tmp/backend
# === 阶段2构建 Frontend ===
FROM node:18-alpine AS frontend-builder
# Node 18-alpine 跑不动 Tailwind v4 / Vite 6前者要求 Node 20+,后者推荐 Node 20+
# 升到 node:20-alpine。alpine 走 muslpnpm 会按 lockfile 拉 *-linux-x64-musl native binary。
FROM node:20-alpine AS frontend-builder
RUN corepack enable && corepack prepare pnpm@latest --activate
WORKDIR /tmp/frontend
# 先复制 package.json 利用依赖层缓存
COPY ./BillNote_frontend/package.json ./
RUN pnpm install
# 先复制 package.json + lockfile 利用依赖层缓存
# --frozen-lockfile 保证 CI 与本地开发依赖版本一致,杜绝 semver 漂移引入的破坏性升级
COPY ./BillNote_frontend/package.json ./BillNote_frontend/pnpm-lock.yaml ./
RUN pnpm install --frozen-lockfile
COPY ./BillNote_frontend /tmp/frontend

View File

@@ -3,7 +3,7 @@
<p align="center">
<img src="./doc/icon.svg" alt="BiliNote Banner" width="50" height="50" />
</p>
<h1 align="center" > BiliNote v2.1.0</h1>
<h1 align="center" > BiliNote v2.1.4</h1>
</div>
<p align="center"><i>AI 视频笔记生成工具 让 AI 为你的视频做笔记</i></p>
@@ -53,6 +53,28 @@ BiliNote 是一个开源的 AI 视频笔记助手支持通过哔哩哔哩、Y
- 笔记顶部视频封面 Banner 展示
- 工作区和生成历史面板支持折叠/展开
### v2.1.4 修订
- CI桌面端 Tauri 构建去掉 Linux17m+ 慢线退役Linux 用户继续走 Docker 镜像)
- CIcommitlint workflow 修复 + 规范 release merge commit 标题约定
### v2.1.3 修订
- 修复 DeepSeek 等非多模态供应商被 400 拒绝的问题issue #282`UniversalGPT` 的 message builder 按是否带图切换 string / 多模态数组形态
- 感谢 @voidborne-d (#345)
### v2.1.2 修订
- 修复 v2.1.1 触发的 ghcr.io Docker 镜像构建失败Node 18 + Tailwind v4 不兼容、缺 lockfile
- README 补上微信群二维码
### v2.1.1 修订
- 工程化与文档收尾CONTRIBUTING.md / RELEASING.md / issue + PR 模板 / commitlint CI / 插件发版工作流
- 关于页群聊二维码:换成最新版,改为 import 本地资源,不再依赖 CDN
- 关于页移除 QQ 群入口(仅保留微信群)
- 详见 [CHANGELOG.md](./CHANGELOG.md)
### v2.1.0 新增
- 浏览器插件Chrome / Edge / Firefox MV3—— 工具栏 popup、视频页悬浮按钮、右键菜单、侧边栏Markdown / 思维导图 / AI 问答)四件套
@@ -198,7 +220,12 @@ docker-compose -f docker-compose.gpu.yml up -d
- [ ] 笔记导出为 PDF / Word / Notion
### Contact and Join-联系和加入社区
年会恢复更新以后放出最新社区地址
扫码加入 BiliNote 交流微信群(如二维码失效,请到 [Issues](https://github.com/JefferyHcool/BiliNote/issues) 反馈):
<p align="center">
<img src="./doc/wechat.png" alt="BiliNote 交流微信群" width="240" />
</p>

161
RELEASING.md Normal file
View File

@@ -0,0 +1,161 @@
# 发版手册Release Manager
本文档面向**发版执行者**,覆盖从 `develop` 切发版到产物上架商店的完整步骤。日常分支与提交规范见 [CONTRIBUTING.md](./CONTRIBUTING.md)。
---
## 流程总览
```
develop ──→ release/X.Y.Z ──→ PR ─→ master ──→ 打 tag vX.Y.Z
│ │ │
└──→ PR 回灌 ──→ develop └──→ CI 自动构建插件产物 + 挂到 GitHub Release
人工上传商店Chrome/Edge/Firefox
```
---
## 1. 切发布分支
```bash
git checkout develop && git pull origin develop
git checkout -b release/X.Y.Z
```
版本号遵循 [SemVer](https://semver.org/lang/zh-CN/)`MAJOR.MINOR.PATCH`
## 2. 写 CHANGELOG更新版本号
`release/X.Y.Z` 上:
- 编辑 [`CHANGELOG.md`](./CHANGELOG.md),新增 `## [X.Y.Z] - YYYY-MM-DD` 段,按 Keep a Changelog 分类Added / Changed / Fixed / Removed / Security / Internal
- 编辑 [`README.md`](./README.md) 顶部标题中的版本号 + 新增"vX.Y.Z 新增"摘要段
- 重大变更也同步更新 [`CLAUDE.md`](./CLAUDE.md)
```bash
git commit -am "docs: vX.Y.Z CHANGELOG + README 版本"
git push -u origin release/X.Y.Z
```
## 3. 合并到 master + 回灌 develop
在 GitHub 上发起两个 PR
| PR | base | 合并方式 | 合并后 commit 标题 |
|---|---|---|---|
| `release/X.Y.Z``master` | `master` | **Merge commit (--no-ff)** | `chore(release): vX.Y.Z` |
| `release/X.Y.Z``develop` | `develop` | **Merge commit (--no-ff)** | `chore(release): merge release/X.Y.Z back into develop` |
> ⚠️ Merge commit 的标题**必须**符合 `type(scope): subject` 格式commitlint 在 push 到 master/develop 时会校验)。
> 历史上用过 `Release vX.Y.Z` 这种形式,会被 commitlint 报 `type-empty` / `subject-empty`。
`master` 分支保护要求 review 通过。回灌 `develop` 是为了把发版冻结期内的小修同步回来。
## 4. 打 tag
```bash
git checkout master && git pull origin master
git tag -a vX.Y.Z -m "BiliNote vX.Y.Z
主线:
- ...
详见 CHANGELOG.md"
git push origin vX.Y.Z
```
push tag **会自动触发 [`.github/workflows/release-extension.yml`](.github/workflows/release-extension.yml)**:构建插件并把 `.zip` / `.xpi` / `.crx` 挂到对应 GitHub Release。
## 5. 创建 GitHub Release如果还没有
CI 默认会创建 / 更新 `vX.Y.Z` 对应的 Release。如果你想自己写 release notes
1. 打开 https://github.com/JefferyHcool/BiliNote/releases/new
2. Tag: 选 `vX.Y.Z`
3. Title: `vX.Y.Z`
4. Body: 直接贴 [`CHANGELOG.md`](./CHANGELOG.md) 的对应段
5. CI 跑完后 Release 页面会自动出现 `bilinote-extension-X.Y.Z.zip` / `.xpi` / `.crx`
## 6. 上传到各商店(人工)
商店审核普遍 1-3 个工作日。建议**先上 Chrome → Edge → Firefox**Edge 接受同一份 zip
### Chrome Web Store
1. https://chrome.google.com/webstore/devconsole
2. 选 BiliNote → 左侧 **Package****Upload new package**
3. 上传 `bilinote-extension-X.Y.Z.zip`
4. 检查 listing描述 / 图标 / 截图无变化可保持),点 **Submit for review**
### Microsoft Edge Add-ons
1. https://partner.microsoft.com/dashboard/microsoftedge
2. 选 BiliNote → **New submission**
3. 上传同一份 `.zip`Edge Add-ons 与 Chrome 完全兼容 MV3
4. 提交审核
### Firefox Add-ons (AMO)
1. https://addons.mozilla.org/developers/
2. 选 BiliNote → **Upload New Version**
3. 上传 `bilinote-extension-X.Y.Z.xpi`
4. 选择"在 AMO 公开"或"自托管"
5. 提交审核
### 桌面端 (Tauri)
仓库已有 GitHub Actions 在 `v*` tag 时构建桌面端安装包并自动挂到 GitHub Release无需额外操作。
## 7. 清理
```bash
# release 分支已合到 master 与 develop删掉
git push origin --delete release/X.Y.Z
git branch -d release/X.Y.Z
```
---
## 自动发布到商店(可选)
`.github/workflows/release-extension.yml` 末尾有三段商店自动发布的 job 注释。要启用:
1. 在 https://github.com/JefferyHcool/BiliNote/settings/secrets/actions 加 secrets
| 商店 | 需要的 secret |
|---|---|
| Chrome | `CHROME_EXTENSION_ID``CHROME_CLIENT_ID``CHROME_CLIENT_SECRET``CHROME_REFRESH_TOKEN` |
| Edge | `EDGE_PRODUCT_ID``EDGE_CLIENT_ID``EDGE_API_KEY` |
| Firefox | `FIREFOX_ADDON_UUID``FIREFOX_API_KEY``FIREFOX_API_SECRET` |
2. 解开 workflow 文件末尾的 `publish-chrome` / `publish-edge` / `publish-firefox` job 注释。
3. 推 tag 时即自动发布。
> Chrome 各 secret 的获取方式:[chrome-webstore-upload-cli 文档](https://github.com/fregante/chrome-webstore-upload-cli/blob/main/How%20to%20generate%20Google%20API%20keys.md)
> Edge[Edge Add-ons API](https://learn.microsoft.com/en-us/microsoft-edge/extensions-chromium/publish/api/using-addons-api)
> Firefoxhttps://addons.mozilla.org/en-US/developers/addon/api/key/
---
## 紧急 hotfix 发版
线上紧急问题不走 `release/*`,走 `hotfix/*`
```bash
git checkout master && git pull
git checkout -b hotfix/<scope>-<事项>
# … 修复 ...
# PR base=master 合入;同时 PR base=develop 回灌
```
合入 master 后通常打 patch tag`v2.1.1`CI 流程同上。
---
## 历史发布快查
| Version | Date | Tag |
|---|---|---|
| 2.1.0 | 2026-05-07 | [`v2.1.0`](https://github.com/JefferyHcool/BiliNote/releases/tag/v2.1.0) |
| 2.0.0 | (上游 web 端 v2.0.0) | [`v2.0.0`](https://github.com/JefferyHcool/BiliNote/releases/tag/v2.0.0) |

View File

@@ -53,20 +53,26 @@ class UniversalGPT(GPT):
extras=kwargs.get('extras'),
)
# ⛳ 组装 content 数组,支持 text + image_url 混合
content: List[dict] = [{"type": "text", "text": content_text}]
video_img_urls = kwargs.get('video_img_urls', [])
for url in video_img_urls:
content.append({
"type": "image_url",
"image_url": {
"url": url,
"detail": "auto"
}
})
content: list[dict] | str
if video_img_urls:
# 有截图时走 OpenAI 多模态 content 数组text + image_url
content = [{"type": "text", "text": content_text}]
for url in video_img_urls:
content.append({
"type": "image_url",
"image_url": {
"url": url,
"detail": "auto"
}
})
else:
# 纯文本场景退回 string contentDeepSeek deepseek-chat 等非多模态模型
# 不识别 [{"type":"text",...}] 数组形态,会返回 invalid_request_error
# issue #282。OpenAI 规范本身也允许 content 为 string。
content = content_text
# 正确格式:整体包在一个 message 里role + content array
messages = [{
"role": "user",
"content": content
@@ -83,9 +89,10 @@ class UniversalGPT(GPT):
def _build_merge_messages(self, partials: list) -> list:
merge_text = MERGE_PROMPT + "\n\n" + "\n\n---\n\n".join(partials)
# 合并阶段没有图片,直接用 string content 兼容非多模态模型issue #282
return [{
"role": "user",
"content": [{"type": "text", "text": merge_text}]
"content": merge_text
}]
def _checkpoint_path(self, checkpoint_key: str) -> Path:

View File

@@ -0,0 +1,189 @@
"""issue #282 回归测试UniversalGPT 拼装 content 时按是否有图片切换 string / array 形态。
DeepSeek deepseek-chat 等非多模态模型只接受 ``content`` 为字符串,旧实现无条件
emit ``[{"type":"text","text":...}]`` 导致 ``invalid_request_error``。
"""
import importlib.util
import pathlib
import sys
import types
import unittest
def _install_stubs():
app_mod = types.ModuleType("app")
gpt_pkg = types.ModuleType("app.gpt")
models_pkg = types.ModuleType("app.models")
base_mod = types.ModuleType("app.gpt.base")
class _GPT:
pass
base_mod.GPT = _GPT
prompt_builder_mod = types.ModuleType("app.gpt.prompt_builder")
def _generate_base_prompt(**_kwargs):
return "PROMPT_BODY"
prompt_builder_mod.generate_base_prompt = _generate_base_prompt
prompt_mod = types.ModuleType("app.gpt.prompt")
prompt_mod.BASE_PROMPT = ""
prompt_mod.AI_SUM = ""
prompt_mod.SCREENSHOT = ""
prompt_mod.LINK = ""
prompt_mod.MERGE_PROMPT = "MERGE_HEAD"
utils_mod = types.ModuleType("app.gpt.utils")
def _fix_markdown(text):
return text
utils_mod.fix_markdown = _fix_markdown
request_chunker_mod = types.ModuleType("app.gpt.request_chunker")
class _RequestChunker:
def __init__(self, *_args, **_kwargs):
pass
def group_texts_by_budget(self, texts, _builder, **_kwargs):
return [texts]
request_chunker_mod.RequestChunker = _RequestChunker
gpt_model_mod = types.ModuleType("app.models.gpt_model")
class _GPTSource:
pass
gpt_model_mod.GPTSource = _GPTSource
transcriber_model_mod = types.ModuleType("app.models.transcriber_model")
class _TranscriptSegment:
def __init__(self, **kwargs):
self.start = kwargs.get("start", 0)
self.end = kwargs.get("end", 0)
self.text = kwargs.get("text", "")
transcriber_model_mod.TranscriptSegment = _TranscriptSegment
sys.modules.setdefault("app", app_mod)
sys.modules.setdefault("app.gpt", gpt_pkg)
sys.modules.setdefault("app.models", models_pkg)
sys.modules["app.gpt.base"] = base_mod
sys.modules["app.gpt.prompt_builder"] = prompt_builder_mod
sys.modules["app.gpt.prompt"] = prompt_mod
sys.modules["app.gpt.utils"] = utils_mod
sys.modules["app.gpt.request_chunker"] = request_chunker_mod
sys.modules["app.models.gpt_model"] = gpt_model_mod
sys.modules["app.models.transcriber_model"] = transcriber_model_mod
def _load_universal_gpt_class():
_install_stubs()
root = pathlib.Path(__file__).resolve().parents[1]
module_path = root / "app" / "gpt" / "universal_gpt.py"
spec = importlib.util.spec_from_file_location(
"universal_gpt_content_format", module_path
)
if spec is None or spec.loader is None:
raise ImportError("universal_gpt module spec not found")
module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(module)
return module.UniversalGPT
UniversalGPT = _load_universal_gpt_class()
class _DummyClient:
"""create_messages 不会真的调用 client给个空壳即可。"""
def _make_gpt():
return UniversalGPT(_DummyClient(), model="deepseek-chat")
class TestCreateMessagesContentFormat(unittest.TestCase):
"""覆盖 create_messages 在不同 video_img_urls 输入下的输出形态。"""
def test_no_images_emits_string_content(self):
"""无图片时 content 为 strDeepSeek / 非多模态模型可解析)。"""
gpt = _make_gpt()
messages = gpt.create_messages(segments=[])
self.assertEqual(len(messages), 1)
self.assertEqual(messages[0]["role"], "user")
self.assertIsInstance(messages[0]["content"], str)
self.assertEqual(messages[0]["content"], "PROMPT_BODY")
def test_empty_image_list_emits_string_content(self):
"""显式传入空列表也要走纯文本分支,避免图片字段误触发。"""
gpt = _make_gpt()
messages = gpt.create_messages(segments=[], video_img_urls=[])
self.assertIsInstance(messages[0]["content"], str)
def test_with_images_emits_multimodal_array(self):
"""有图片时保留多模态 array 形态,确保多模态模型功能不退化。"""
gpt = _make_gpt()
messages = gpt.create_messages(
segments=[],
video_img_urls=["https://example.com/a.jpg", "https://example.com/b.jpg"],
)
content = messages[0]["content"]
self.assertIsInstance(content, list)
self.assertEqual(len(content), 3) # 1 text + 2 images
self.assertEqual(content[0], {"type": "text", "text": "PROMPT_BODY"})
self.assertEqual(content[1]["type"], "image_url")
self.assertEqual(content[1]["image_url"]["url"], "https://example.com/a.jpg")
self.assertEqual(content[1]["image_url"]["detail"], "auto")
self.assertEqual(content[2]["image_url"]["url"], "https://example.com/b.jpg")
def test_no_image_url_field_when_no_images(self):
"""纯文本响应里不应该出现 image_url 关键字 —— 这是触发 DeepSeek 400 的根因。"""
gpt = _make_gpt()
messages = gpt.create_messages(segments=[])
import json
serialized = json.dumps(messages, ensure_ascii=False)
self.assertNotIn("image_url", serialized)
class TestBuildMergeMessagesContentFormat(unittest.TestCase):
"""合并阶段从不带图片,应该统一走 string content 路径。"""
def test_merge_messages_use_string_content(self):
"""否则长视频 chunk 后的合并阶段还会复现 issue #282 错误。"""
gpt = _make_gpt()
messages = gpt._build_merge_messages(["partial-A", "partial-B"])
self.assertEqual(len(messages), 1)
self.assertEqual(messages[0]["role"], "user")
self.assertIsInstance(messages[0]["content"], str)
self.assertIn("MERGE_HEAD", messages[0]["content"])
self.assertIn("partial-A", messages[0]["content"])
self.assertIn("partial-B", messages[0]["content"])
def test_merge_messages_no_image_url_field(self):
gpt = _make_gpt()
messages = gpt._build_merge_messages(["x"])
import json
serialized = json.dumps(messages, ensure_ascii=False)
self.assertNotIn("image_url", serialized)
if __name__ == "__main__":
unittest.main()

Binary file not shown.

Before

Width:  |  Height:  |  Size: 623 KiB

After

Width:  |  Height:  |  Size: 11 KiB