Skip to content

Commit

Permalink
ref. 优化Updater体验
Browse files Browse the repository at this point in the history
  • Loading branch information
btjawa committed Feb 2, 2024
1 parent eb6eb3c commit 28249f9
Show file tree
Hide file tree
Showing 8 changed files with 93 additions and 21 deletions.
15 changes: 13 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@

- 获取大会员/付费资源
- 风控验证 - `WBI / _uuid / buvid3/4 / bili_ticket / 极验行为验证`
- 多线程下载 / 断点续传 - `aria2`
- 音视频下载 - `视频 / 合集 / 互动视频 / 课程 / 番剧 (AV + BV + SS + EP)`
- 画质最高支持:`8K + HDR + 杜比视界`
- 伴音音质最高支持:`192K + HiRes无损(48kHz) + 杜比全景声(384K)`
- 帧率最高支持:`120FPS`
- 编码支持:`AVC (H.264) + HEVC (H.265) + AV1`
- 互动视频支持:`回溯 / 控制剧情走向 + 下载每一个剧情对应的资源`
- 互动视频支持:`回溯 / 控制剧情图 + 下载剧情分P`
- 音乐下载 - `AU`
- 音质最高支持:`320K + 无损SQ FLAC`
- 弹幕获取 - `实时弹幕 / 历史弹幕(Json)`
Expand All @@ -35,4 +36,14 @@

# 更多信息

可转至 [Blog](https://blog.btjawa.top/posts/bilitools)
可转至 [Blog](https://blog.btjawa.top/posts/bilitools)

# 感谢

[Tauri](https://github.com/tauri-apps/tauri)

[哔哩哔哩-API收集整理](https://github.com/SocialSisterYi/bilibili-API-collect)

[FFmpeg](https://github.com/FFmpeg/FFmpeg)

[aria2](https://github.com/aria2/aria2)
16 changes: 8 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"md5": "^2.3.0",
"protobufjs": "^7.2.6",
"qrcode": "^1.5.3",
"sweetalert2": "^11.10.4"
"sweetalert2": "^11.6.13"
},
"devDependencies": {
"@actions/github": "^6.0.0",
Expand Down
14 changes: 7 additions & 7 deletions src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
},
"package": {
"productName": "BiliTools",
"version": "1.0.3"
"version": "1.0.2"
},
"tauri": {
"allowlist": {
Expand Down Expand Up @@ -76,14 +76,14 @@
},
"updater": {
"active": true,
"dialog": true,
"dialog": false,
"pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IEVFQTUzQTQ3NDY3RUZEMjgKUldRby9YNUdSenFsN3JJYklTL0g5RUd2QkhUWklqQUxydVZXdFA4c25ZazI0YjJIbTFFM0JiNjkK",
"endpoints": [
"https://gh.con.sh/https://github.com/btjawa/BiliTools/blob/master/install.json"
],
"windows": {
"installMode": "passive"
}
"https://gh.con.sh/https://raw.githubusercontent.com/btjawa/BiliTools/master/install.json",
"https://mirror.ghproxy.com/https://raw.githubusercontent.com/btjawa/BiliTools/master/install.json",
"https://raw.fgit.cf/btjawa/BiliTools/master/install.json",
"https://raw.githubusercontent.com/btjawa/BiliTools/master/install.json"
]
},
"security": {
"csp": null
Expand Down
9 changes: 8 additions & 1 deletion src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,13 @@ <h1 class="user-profile-name">名称</h1>
<path class="letter letter9" d="m155.08,31.44c-1.57,0-3.13-.27-4.68-.8-1.55-.53-2.8-1.33-3.76-2.4-.29-.32-.41-.68-.36-1.08.05-.4.25-.75.6-1.04.37-.27.76-.37,1.16-.32.4.05.73.23,1,.52.64.75,1.49,1.32,2.54,1.72,1.05.4,2.22.6,3.5.6,1.97,0,3.4-.34,4.28-1.02.88-.68,1.33-1.5,1.36-2.46,0-.96-.45-1.75-1.36-2.38s-2.4-1.11-4.48-1.46c-2.69-.43-4.67-1.17-5.92-2.24-1.25-1.07-1.88-2.33-1.88-3.8,0-1.36.36-2.49,1.08-3.4.72-.91,1.68-1.59,2.88-2.04,1.2-.45,2.52-.68,3.96-.68,1.79,0,3.33.31,4.62.92,1.29.61,2.34,1.44,3.14,2.48.27.35.37.71.32,1.08-.05.37-.27.68-.64.92-.32.19-.69.25-1.1.18-.41-.07-.77-.26-1.06-.58-.67-.77-1.44-1.34-2.32-1.7-.88-.36-1.89-.54-3.04-.54-1.47,0-2.64.3-3.52.9-.88.6-1.32,1.35-1.32,2.26,0,.61.17,1.15.5,1.6.33.45.91.85,1.72,1.2.81.35,1.95.64,3.42.88,2,.32,3.58.79,4.74,1.42,1.16.63,1.99,1.36,2.48,2.2s.74,1.75.74,2.74c0,1.25-.37,2.35-1.1,3.3-.73.95-1.75,1.69-3.04,2.22-1.29.53-2.78.8-4.46.8Z" style="--len: 114.1632308959961px;"/>
</svg>
</icon>
<div class="version">版本:<strong id="version" class="space"></strong>(<span id="platform"></span>;&nbsp;<span id="arch"></span>)</div>
<div class="version">版本:
<strong id="version" class="space"></strong>
(<span id="platform"></span>;&nbsp;<span id="arch"></span>)
<div class="space"></div>
<button class="link" id="version-details">
<a class="fa-solid fa-up-to-line space"></a>版本详情</button>
</div>
<div class="about">
项目地址:<button class="link" t="https://github.com/btjawa/BiliTools">
<i class="fa-brands fa-github space"></i>
Expand Down Expand Up @@ -337,6 +343,7 @@ <h1 class="user-profile-name">名称</h1>
<div class="video-list"></div>
</div>
<script type="module" src="./scripts/gt.0.4.9.js"></script>
<script type="module" src="./scripts/updater.ts"></script>
<script type="module" src="./scripts/pages.js"></script>
<script type="module" src="./scripts/renderer.js"></script>
</body>
Expand Down
5 changes: 4 additions & 1 deletion src/scripts/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,10 @@ $(document).ready(function () {
tdata.set.secret(e);
invoke('init', { secret: tdata.secret });
});
app.getVersion().then(ver => $('#version').html(ver));
app.getVersion().then(ver => {
$('#version').html(ver);
$('#version-details').attr("t", `https://github.com/btjawa/BiliTools/releases/tag/v${ver}`);
});
os.platform().then(type => $('#platform').html(type));
os.arch().then(arch => $('#arch').html(arch));
$('#year').html((new Date()).getFullYear())
Expand Down
48 changes: 48 additions & 0 deletions src/scripts/updater.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { checkUpdate, installUpdate, onUpdaterEvent } from '@tauri-apps/api/updater'
import { invoke } from '@tauri-apps/api/tauri';
import { emit } from '@tauri-apps/api/event';
import { dialog, app } from '@tauri-apps/api';
import { relaunch } from '@tauri-apps/api/process'

import Swal from "sweetalert2";
import * as data from "./data.ts";

const unlisten = await onUpdaterEvent(({ error, status }) => {
// This will log all updater events, including status updates and errors.
console.log('Updater event', error, status)
if (status == "DONE") { Swal.close() } // To close Swal.
})

try {
const { shouldUpdate, manifest } = await checkUpdate()
if (shouldUpdate) {
// You could show a dialog asking the user if they want to install the update here.
console.log("We received a update.");
console.log(manifest);
const choice = await dialog.ask(`新版本:BiliTools v${manifest?.version} 可用!当前版本:v${await app.getVersion()}
\n您想要现在更新吗?
\n更新发布时间:${manifest?.date}
\n更新说明:\n${manifest?.body}
\n注意:更新期间将无法使用APP。
更新下载完成后,将会自动重启应用以完成更新。`, "更新");
if (choice) {
Swal.fire({
title: "正在下载更新...",
allowOutsideClick: false,
didOpen: () => {
Swal.showLoading();
},
});
// Kill aria2c.
invoke("handle_aria2c", { action: "kill", secret: data.secret })
// Install the update. This will also restart the app on Windows!
await installUpdate()
// On macOS and Linux you will need to restart the app manually.
// You could use this step to display another confirmation dialog.
await relaunch()
}
}
} catch (e) { emit("error", e) }

// you need to call unlisten if your handler goes out of scope, for example if the component is unmounted.
unlisten()
5 changes: 4 additions & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ export default defineConfig(async () => ({
// 1. prevent vite from obscuring rust errors
clearScreen: false,
// 2. tauri expects a fixed port, fail if that port is not available
build: { outDir: "../dist" },
build: {
outDir: "../dist",
target: "ESNext"
},
server: {
port: 1420,
strictPort: true,
Expand Down

0 comments on commit 28249f9

Please sign in to comment.