mirror of
https://github.com/JefferyHcool/BiliNote.git
synced 2026-06-21 07:24:21 +08:00
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>
This commit is contained in:
@@ -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,12 @@ 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,
|
||||
prefetched_transcript: prefetched ?? undefined,
|
||||
}),
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user