mirror of
https://github.com/JefferyHcool/BiliNote.git
synced 2026-06-28 03:01:28 +08:00
feat(extension): P2 视频页悬浮按钮 + 右键菜单 + cookie 直通;P3 侧边栏首版
- contentScripts: 仅在支持的视频平台(B 站 / YouTube / 抖音 / 快手)注入悬浮 BiliNote 按钮,点击通过 webext-bridge 发 'bilinote-start' 给 background - background: 处理 bilinote-start 与右键菜单点击;调 /api/generate_note;写 chrome.storage;自动打开侧边栏。logic/storage 是 Vue 反应式版本,service worker 不能 import,因此把常量抽到 logic/constants.ts - contextMenus: onInstalled 时注册"用 BiliNote 总结此视频",限定 4 个支持平台域名 - 浏览器 Cookie 同步:options 页加按钮,按平台读 chrome.cookies.getAll,序列化为 'name=value; ...' 后 POST 给后端 /api/update_downloader_cookie。chrome.cookies + contextMenus 权限补到 manifest - 侧边栏(P3 首版):从 storage 读最近任务并轮询,复用 TaskProgress + MarkdownView。markmap 思维导图与 RAG 问答推到后续 - 修 P1 endpoint 拼错的 bug:/api/get_models_by_provider 实际是 /api/model_enable,404 来自这里 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -2,7 +2,9 @@
|
||||
import { onMounted, ref, watch } from 'vue'
|
||||
import { getModelsByProvider, getProviders, ping } from '~/logic/api'
|
||||
import { settings, settingsReady } from '~/logic/storage'
|
||||
import type { Model, Provider } from '~/logic/types'
|
||||
import { SUPPORTED_COOKIE_PLATFORMS, syncCookieToBackend } from '~/logic/cookies'
|
||||
import { PLATFORM_LABELS } from '~/logic/platform'
|
||||
import type { Model, Platform, Provider } from '~/logic/types'
|
||||
|
||||
const providers = ref<Provider[]>([])
|
||||
const models = ref<Model[]>([])
|
||||
@@ -49,6 +51,19 @@ async function testConnection() {
|
||||
: { kind: 'err', text: '无法连接后端,请检查地址、端口与 CORS 配置' }
|
||||
}
|
||||
|
||||
const cookieStatus = ref<Record<string, { kind: 'ok' | 'err' | 'idle', text: string }>>({})
|
||||
const cookieBusy = ref<Record<string, boolean>>({})
|
||||
|
||||
async function syncCookie(platform: Exclude<Platform, 'local'>) {
|
||||
cookieBusy.value[platform] = true
|
||||
cookieStatus.value[platform] = { kind: 'idle', text: '同步中…' }
|
||||
const res = await syncCookieToBackend(platform)
|
||||
cookieStatus.value[platform] = res.ok
|
||||
? { kind: 'ok', text: `已同步 ${res.count} 条 cookie ✓` }
|
||||
: { kind: 'err', text: res.error || '同步失败' }
|
||||
cookieBusy.value[platform] = false
|
||||
}
|
||||
|
||||
watch(() => settings.value?.providerId, (id) => {
|
||||
if (id)
|
||||
refreshModels(id)
|
||||
@@ -146,6 +161,36 @@ onMounted(async () => {
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="bg-white dark:bg-gray-800 border rounded p-4 mb-4 flex flex-col gap-3">
|
||||
<h2 class="font-semibold">浏览器 Cookie 同步</h2>
|
||||
<p class="text-xs text-gray-500">
|
||||
从当前浏览器读取你已登录站点的 cookie,并写入后端 (POST /api/update_downloader_cookie)。
|
||||
Bilibili / Douyin / Kuaishou 这类需要登录态的下载尤其需要这一步。
|
||||
</p>
|
||||
<div class="flex flex-col gap-2">
|
||||
<div
|
||||
v-for="p in SUPPORTED_COOKIE_PLATFORMS"
|
||||
:key="p"
|
||||
class="flex items-center justify-between gap-2 text-sm"
|
||||
>
|
||||
<span class="w-20">{{ PLATFORM_LABELS[p] }}</span>
|
||||
<button class="btn-secondary" :disabled="cookieBusy[p]" @click="syncCookie(p)">
|
||||
{{ cookieBusy[p] ? '同步中…' : '同步 Cookie' }}
|
||||
</button>
|
||||
<span
|
||||
class="flex-1 text-xs"
|
||||
:class="{
|
||||
'text-green-700': cookieStatus[p]?.kind === 'ok',
|
||||
'text-red-600': cookieStatus[p]?.kind === 'err',
|
||||
'text-gray-500': cookieStatus[p]?.kind === 'idle',
|
||||
}"
|
||||
>
|
||||
{{ cookieStatus[p]?.text || '' }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<p class="text-xs text-gray-500">
|
||||
所有设置自动保存。不在桌面端管理供应商/模型?请在 BiliNote web 端 (http://localhost:3015) 完成。
|
||||
</p>
|
||||
|
||||
Reference in New Issue
Block a user