一个用于下载和管理 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.toml
tauri-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 的资源文件夹是任意配置的, 因此不限制访问路径
}
}
}
}
打包时添加--debug
参数可以在打包后的应用中使用调试工具
pnpm tauri build --debug
另外可以在src-tauri/Cargo.toml
配置中添加devtools
默认开启调试模式
tauri = { version = "2.2.4", features = ["protocol-asset", "devtools"] }
修改 package.json
和src-tauri/tauri.conf.json
中的version
字段; 创建并推送标签; 在github-action
中执行脚本
git tag 'app-v1.1.1'
git push origin --tags