mirror of
https://github.com/JefferyHcool/BiliNote.git
synced 2026-06-16 13:10:53 +08:00
feat(extension): options 改为多 tab,搬入 web 端的全部设置项
把原来一长条的 options 拆成五个 tab,覆盖 web 端 SettingPage 的全部能力。今后新功能优先在插件里做,web 端逐步退役。 - 通用:后端地址 + 默认供应商/模型 + 默认生成选项(原 Options.vue 内容) - 模型供应商:完整 CRUD —— 列表 / 启用切换 / 编辑 / 测试连接 / 添加 / 模型增删 - 音频转写配置:转写器引擎切换(fast-whisper / mlx-whisper / Groq / 必剪 / 快手)+ Whisper 模型大小切换 + 模型本地下载状态 + 触发下载 · 直接修复 'MLX Whisper 不可用' 报错——非 Mac 用户现在能切到 fast-whisper / Groq - 下载配置:每平台 cookie 显示 / 浏览器一键同步 / 手动粘贴保存 - 部署监控:后端、FFmpeg、CUDA、Whisper 模型 当前状态 logic/api.ts 补齐:provider CRUD / model CRUD / connect_test / transcriber_config / transcriber_models_status / transcriber_download / get_downloader_cookie / deploy_status / sys_health。 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,16 @@
|
||||
import type { GenerateRequest, Model, Provider, TaskStatusResponse } from './types'
|
||||
import type {
|
||||
DeployStatus,
|
||||
GenerateRequest,
|
||||
Model,
|
||||
Provider,
|
||||
ProviderCreatePayload,
|
||||
ProviderUpdatePayload,
|
||||
TaskStatusResponse,
|
||||
TranscriberConfig,
|
||||
TranscriberModelsStatus,
|
||||
TranscriberType,
|
||||
WhisperModelSize,
|
||||
} from './types'
|
||||
import { settings } from './storage'
|
||||
|
||||
interface ApiEnvelope<T> {
|
||||
@@ -44,6 +56,97 @@ export async function setDownloaderCookie(platform: string, cookie: string): Pro
|
||||
})
|
||||
}
|
||||
|
||||
export async function getDownloaderCookie(platform: string): Promise<string | null> {
|
||||
// 后端:未配置时返回 {code:0, msg:'未找到Cookies', data:null};配置时 data: {platform, cookie}
|
||||
const data = await request<{ platform: string, cookie: string } | null>(
|
||||
`/api/get_downloader_cookie/${platform}`,
|
||||
)
|
||||
return data?.cookie ?? null
|
||||
}
|
||||
|
||||
// ---- Provider CRUD ----
|
||||
export async function addProvider(payload: ProviderCreatePayload): Promise<string | null> {
|
||||
return request<string | null>('/api/add_provider', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ logo: 'custom', ...payload }),
|
||||
})
|
||||
}
|
||||
|
||||
export async function updateProvider(payload: ProviderUpdatePayload): Promise<{ id: string, enabled: number }> {
|
||||
return request<{ id: string, enabled: number }>('/api/update_provider', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(payload),
|
||||
})
|
||||
}
|
||||
|
||||
export async function getProviderById(id: string): Promise<Provider> {
|
||||
return request<Provider>(`/api/get_provider_by_id/${id}`)
|
||||
}
|
||||
|
||||
export async function connectTest(id: string): Promise<void> {
|
||||
await request('/api/connect_test', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ id }),
|
||||
})
|
||||
}
|
||||
|
||||
// ---- Model CRUD ----
|
||||
export async function listAllModels(providerId: string): Promise<Model[]> {
|
||||
return request<Model[]>(`/api/model_list/${providerId}`)
|
||||
}
|
||||
|
||||
export async function addModel(providerId: string, modelName: string): Promise<void> {
|
||||
await request('/api/models', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ provider_id: providerId, model_name: modelName }),
|
||||
})
|
||||
}
|
||||
|
||||
export async function deleteModel(modelId: number | string): Promise<void> {
|
||||
await request(`/api/models/delete/${modelId}`)
|
||||
}
|
||||
|
||||
// ---- Transcriber ----
|
||||
export async function getTranscriberConfig(): Promise<TranscriberConfig> {
|
||||
return request<TranscriberConfig>('/api/transcriber_config')
|
||||
}
|
||||
|
||||
export async function setTranscriberConfig(transcriberType: TranscriberType, whisperModelSize?: WhisperModelSize): Promise<TranscriberConfig> {
|
||||
return request<TranscriberConfig>('/api/transcriber_config', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({
|
||||
transcriber_type: transcriberType,
|
||||
whisper_model_size: whisperModelSize ?? null,
|
||||
}),
|
||||
})
|
||||
}
|
||||
|
||||
export async function getTranscriberModelsStatus(): Promise<TranscriberModelsStatus> {
|
||||
return request<TranscriberModelsStatus>('/api/transcriber_models_status')
|
||||
}
|
||||
|
||||
export async function downloadTranscriberModel(modelSize: WhisperModelSize, transcriberType: TranscriberType = 'fast-whisper'): Promise<void> {
|
||||
await request('/api/transcriber_download', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ model_size: modelSize, transcriber_type: transcriberType }),
|
||||
})
|
||||
}
|
||||
|
||||
// ---- Monitor ----
|
||||
export async function getDeployStatus(): Promise<DeployStatus> {
|
||||
return request<DeployStatus>('/api/deploy_status')
|
||||
}
|
||||
|
||||
export async function getSysHealth(): Promise<{ ok: boolean, msg?: string }> {
|
||||
try {
|
||||
await request('/api/sys_health')
|
||||
return { ok: true }
|
||||
}
|
||||
catch (e) {
|
||||
return { ok: false, msg: (e as Error).message }
|
||||
}
|
||||
}
|
||||
|
||||
export async function generateNote(payload: GenerateRequest): Promise<{ task_id: string }> {
|
||||
return request<{ task_id: string }>('/api/generate_note', {
|
||||
method: 'POST',
|
||||
|
||||
Reference in New Issue
Block a user