一个用于下载和管理 bilibili bv 视频的桌面应用
- vitejs
- react-router@7
- tailwindcss
- antd-ui
- jotai
- react-query
- eslint@9
- react-dev-inspector
pnpm dev感谢bilibili-API-collect开源项目
先使用 vite 创建项目, 或者其他的模版项目; 然后根据官方文档额外安装 tauri@v2
-
安装 shell 插件
-
配置
src-tauri/tauri.conf.json{ "bundle": { "externalBin": ["binaries/ffmpeg"] } } -
配置 shell 的执行权限
src-tauri/capabilities/default.json{ "permissions": [ { "identifier": "shell:allow-execute", "allow": [ { "name": "binaries/ffmpeg", "sidecar": true, // sidecar 模式 "args": true // 允许 ffmpeg 输入参数(居然不是默认允许的,草弹) } ] } ] } -
根据
ffmpeg-bins/copy-ffmpeg.mjs中所述, 准备 ffmpeg 可执行文件
- 安装 http 插件
- 配置
src-tauri/Cargo.tomltauri-plugin-http = { version = "2", features = ["unsafe-headers"] } - 参考
src/core/request.ts中的getCORSHeaders, 使请求允许跨域 - 配置权限
src-tauri/capabilities/default.json{ "permissions": [ { "identifier": "http:default", "allow": [{ "url": "https://api.bilibili.com/*" }] // 可以使用通配符, 允许所有域名 } ] }
参考文档 convertfilesrc , csp
配置
{
"app": {
"security": {
"csp": {
"default-src": "'self' customprotocol: asset:",
"connect-src": "ipc: http://ipc.localhost",
"img-src": "'self' asset: http://asset.localhost blob: data:",
"style-src": "'unsafe-inline' 'self'"
},
"assetProtocol": {
"enable": true,
"scope": ["**/*"] // 由于本 app 的资源文件夹是任意配置的, 因此不限制访问路径
}
}
}
}- 在项目根目录(package.json 所在目录)添加
app-icon.png图标文件. 大小为 512x512 - 执行
pnpm tauri icon生成所有平台所需的图标文件
打包时添加--debug参数可以在打包后的应用中使用调试工具
pnpm tauri build --debug另外可以在src-tauri/Cargo.toml配置中添加devtools默认开启调试模式
tauri = { version = "2.2.4", features = ["protocol-asset", "devtools"] }
执行以下脚本, 用于创建 tag 和推送代码
release-version.sh在 github 仓库中运行 github action, 用于构建和发布应用; 在 release 页面可看到最新版本的草稿, 需手动发布




