Compare commits
16 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e332ec4ddc | ||
|
|
3b74712f57 | ||
|
|
475e4127c2 | ||
|
|
3041307aa2 | ||
|
|
e2ab8dce60 | ||
|
|
c1806e5321 | ||
|
|
92494966c6 | ||
|
|
f04680b8c2 | ||
|
|
a5b94411fe | ||
|
|
71ae4a4425 | ||
|
|
e8413aefae | ||
|
|
b229225b6e | ||
|
|
5497ed6245 | ||
|
|
155bf652f2 | ||
|
|
86bd77d995 | ||
|
|
b38b356c22 |
37
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
Normal file
37
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
name: Bug Report
|
||||||
|
description: Report a problem or regression
|
||||||
|
title: "[Bug]: "
|
||||||
|
labels:
|
||||||
|
- bug
|
||||||
|
body:
|
||||||
|
- type: input
|
||||||
|
id: app_version
|
||||||
|
attributes:
|
||||||
|
label: App version
|
||||||
|
description: The VidBee version (e.g., 1.2.3)
|
||||||
|
placeholder: 1.2.3
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: input
|
||||||
|
id: os_version
|
||||||
|
attributes:
|
||||||
|
label: OS version
|
||||||
|
description: Your operating system and version (e.g., macOS 14.2, Windows 11 23H2)
|
||||||
|
placeholder: macOS 14.2
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: textarea
|
||||||
|
id: actual
|
||||||
|
attributes:
|
||||||
|
label: Observed behavior
|
||||||
|
placeholder: What actually happened
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: textarea
|
||||||
|
id: logs
|
||||||
|
attributes:
|
||||||
|
label: Logs or screenshots
|
||||||
|
description: Paste relevant logs or add screenshots
|
||||||
|
placeholder: Attach files or paste logs here
|
||||||
|
validations:
|
||||||
|
required: false
|
||||||
38
.github/ISSUE_TEMPLATE/feature_request.yml
vendored
Normal file
38
.github/ISSUE_TEMPLATE/feature_request.yml
vendored
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
name: Feature Request
|
||||||
|
description: Suggest an idea or improvement
|
||||||
|
title: "[Feature]: "
|
||||||
|
labels:
|
||||||
|
- enhancement
|
||||||
|
body:
|
||||||
|
- type: textarea
|
||||||
|
id: problem
|
||||||
|
attributes:
|
||||||
|
label: Problem to solve
|
||||||
|
description: What problem are you trying to solve?
|
||||||
|
placeholder: I want to...
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: textarea
|
||||||
|
id: proposal
|
||||||
|
attributes:
|
||||||
|
label: Proposed solution
|
||||||
|
description: Describe the feature or change you want
|
||||||
|
placeholder: It would be great if...
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: textarea
|
||||||
|
id: alternatives
|
||||||
|
attributes:
|
||||||
|
label: Alternatives considered
|
||||||
|
description: Other solutions or workarounds you considered
|
||||||
|
placeholder: I tried...
|
||||||
|
validations:
|
||||||
|
required: false
|
||||||
|
- type: textarea
|
||||||
|
id: extra
|
||||||
|
attributes:
|
||||||
|
label: Additional context
|
||||||
|
description: Add any other context or screenshots
|
||||||
|
placeholder: Links, screenshots, or related issues
|
||||||
|
validations:
|
||||||
|
required: false
|
||||||
13
.github/workflows/build.yml
vendored
13
.github/workflows/build.yml
vendored
@@ -76,10 +76,10 @@ jobs:
|
|||||||
FFMPEG_OUTPUT: ${{ matrix.ffmpeg_output }}
|
FFMPEG_OUTPUT: ${{ matrix.ffmpeg_output }}
|
||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
curl -L "${{ matrix.ffmpeg_arm_url }}" -o ffmpeg-arm.zip
|
curl -fL --retry 3 --retry-delay 2 --retry-connrefused "${{ matrix.ffmpeg_arm_url }}" -o ffmpeg-arm.zip
|
||||||
unzip -q ffmpeg-arm.zip -d ffmpeg-arm
|
unzip -q ffmpeg-arm.zip -d ffmpeg-arm
|
||||||
|
|
||||||
curl -L "${{ matrix.ffmpeg_x86_url }}" -o ffmpeg-x86.zip
|
curl -fL --retry 3 --retry-delay 2 --retry-connrefused "${{ matrix.ffmpeg_x86_url }}" -o ffmpeg-x86.zip
|
||||||
unzip -q ffmpeg-x86.zip -d ffmpeg-x86
|
unzip -q ffmpeg-x86.zip -d ffmpeg-x86
|
||||||
|
|
||||||
arm_bin="ffmpeg-arm/${{ matrix.ffmpeg_inner_path }}"
|
arm_bin="ffmpeg-arm/${{ matrix.ffmpeg_inner_path }}"
|
||||||
@@ -103,7 +103,11 @@ jobs:
|
|||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
curl -L "${{ matrix.ffmpeg_url }}" -o ffmpeg.tar.xz
|
curl -fL --retry 3 --retry-delay 2 --retry-connrefused "${{ matrix.ffmpeg_url }}" -o ffmpeg.tar.xz
|
||||||
|
if ! tar -tf ffmpeg.tar.xz >/dev/null 2>&1; then
|
||||||
|
echo "::error::Downloaded ffmpeg archive is not a valid tar.xz"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
mkdir ffmpeg
|
mkdir ffmpeg
|
||||||
tar -xf ffmpeg.tar.xz -C ffmpeg
|
tar -xf ffmpeg.tar.xz -C ffmpeg
|
||||||
cp "ffmpeg/${{ matrix.ffmpeg_inner_path }}" "resources/${{ matrix.ffmpeg_output }}"
|
cp "ffmpeg/${{ matrix.ffmpeg_inner_path }}" "resources/${{ matrix.ffmpeg_output }}"
|
||||||
@@ -112,7 +116,7 @@ jobs:
|
|||||||
- name: Download yt-dlp binary
|
- name: Download yt-dlp binary
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
curl -L "https://github.com/yt-dlp/yt-dlp/releases/latest/download/${{ matrix.ytdlp_asset }}" -o "resources/${{ matrix.ytdlp_output }}"
|
curl -fL --retry 3 --retry-delay 2 --retry-connrefused "https://github.com/yt-dlp/yt-dlp/releases/latest/download/${{ matrix.ytdlp_asset }}" -o "resources/${{ matrix.ytdlp_output }}"
|
||||||
if [[ "${{ matrix.platform }}" == "linux" ]] || [[ "${{ matrix.platform }}" == "macos" ]]; then
|
if [[ "${{ matrix.platform }}" == "linux" ]] || [[ "${{ matrix.platform }}" == "macos" ]]; then
|
||||||
chmod +x "resources/${{ matrix.ytdlp_output }}"
|
chmod +x "resources/${{ matrix.ytdlp_output }}"
|
||||||
fi
|
fi
|
||||||
@@ -130,4 +134,3 @@ jobs:
|
|||||||
name: dist-${{ matrix.os }}
|
name: dist-${{ matrix.os }}
|
||||||
path: dist/
|
path: dist/
|
||||||
retention-days: 1
|
retention-days: 1
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"setup": "cp $CONDUCTOR_ROOT_PATH/resources/ resources/ && pnpm install",
|
"setup": "rm -rf resources && cp -r $CONDUCTOR_ROOT_PATH/resources resources && pnpm install",
|
||||||
"run": "pnpm run dev"
|
"run": "pnpm run dev"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "vidbee",
|
"name": "vidbee",
|
||||||
"version": "1.1.1",
|
"version": "1.1.5",
|
||||||
"description": "A modern Electron application for downloading videos and audios",
|
"description": "A modern Electron application for downloading videos and audios",
|
||||||
"main": "./out/main/index.js",
|
"main": "./out/main/index.js",
|
||||||
"author": "VidBee",
|
"author": "VidBee",
|
||||||
@@ -33,6 +33,7 @@
|
|||||||
"@radix-ui/react-dropdown-menu": "^2.1.16",
|
"@radix-ui/react-dropdown-menu": "^2.1.16",
|
||||||
"@radix-ui/react-hover-card": "^1.1.15",
|
"@radix-ui/react-hover-card": "^1.1.15",
|
||||||
"@radix-ui/react-label": "^2.1.7",
|
"@radix-ui/react-label": "^2.1.7",
|
||||||
|
"@radix-ui/react-popover": "^1.1.15",
|
||||||
"@radix-ui/react-progress": "^1.1.7",
|
"@radix-ui/react-progress": "^1.1.7",
|
||||||
"@radix-ui/react-scroll-area": "^1.2.10",
|
"@radix-ui/react-scroll-area": "^1.2.10",
|
||||||
"@radix-ui/react-select": "^2.2.6",
|
"@radix-ui/react-select": "^2.2.6",
|
||||||
@@ -47,6 +48,7 @@
|
|||||||
"better-sqlite3": "^12.4.1",
|
"better-sqlite3": "^12.4.1",
|
||||||
"class-variance-authority": "^0.7.1",
|
"class-variance-authority": "^0.7.1",
|
||||||
"clsx": "^2.1.1",
|
"clsx": "^2.1.1",
|
||||||
|
"cmdk": "^1.1.1",
|
||||||
"dayjs": "^1.11.18",
|
"dayjs": "^1.11.18",
|
||||||
"drizzle-orm": "^0.44.7",
|
"drizzle-orm": "^0.44.7",
|
||||||
"electron-ipc-decorator": "^0.2.0",
|
"electron-ipc-decorator": "^0.2.0",
|
||||||
|
|||||||
60
pnpm-lock.yaml
generated
60
pnpm-lock.yaml
generated
@@ -38,6 +38,9 @@ importers:
|
|||||||
'@radix-ui/react-label':
|
'@radix-ui/react-label':
|
||||||
specifier: ^2.1.7
|
specifier: ^2.1.7
|
||||||
version: 2.1.7(@types/react-dom@19.2.2(@types/react@19.2.2))(@types/react@19.2.2)(react-dom@19.2.0(react@19.2.0))(react@19.2.0)
|
version: 2.1.7(@types/react-dom@19.2.2(@types/react@19.2.2))(@types/react@19.2.2)(react-dom@19.2.0(react@19.2.0))(react@19.2.0)
|
||||||
|
'@radix-ui/react-popover':
|
||||||
|
specifier: ^1.1.15
|
||||||
|
version: 1.1.15(@types/react-dom@19.2.2(@types/react@19.2.2))(@types/react@19.2.2)(react-dom@19.2.0(react@19.2.0))(react@19.2.0)
|
||||||
'@radix-ui/react-progress':
|
'@radix-ui/react-progress':
|
||||||
specifier: ^1.1.7
|
specifier: ^1.1.7
|
||||||
version: 1.1.7(@types/react-dom@19.2.2(@types/react@19.2.2))(@types/react@19.2.2)(react-dom@19.2.0(react@19.2.0))(react@19.2.0)
|
version: 1.1.7(@types/react-dom@19.2.2(@types/react@19.2.2))(@types/react@19.2.2)(react-dom@19.2.0(react@19.2.0))(react@19.2.0)
|
||||||
@@ -80,6 +83,9 @@ importers:
|
|||||||
clsx:
|
clsx:
|
||||||
specifier: ^2.1.1
|
specifier: ^2.1.1
|
||||||
version: 2.1.1
|
version: 2.1.1
|
||||||
|
cmdk:
|
||||||
|
specifier: ^1.1.1
|
||||||
|
version: 1.1.1(@types/react-dom@19.2.2(@types/react@19.2.2))(@types/react@19.2.2)(react-dom@19.2.0(react@19.2.0))(react@19.2.0)
|
||||||
dayjs:
|
dayjs:
|
||||||
specifier: ^1.11.18
|
specifier: ^1.11.18
|
||||||
version: 1.11.18
|
version: 1.11.18
|
||||||
@@ -999,6 +1005,19 @@ packages:
|
|||||||
'@types/react-dom':
|
'@types/react-dom':
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
|
'@radix-ui/react-popover@1.1.15':
|
||||||
|
resolution: {integrity: sha512-kr0X2+6Yy/vJzLYJUPCZEc8SfQcf+1COFoAqauJm74umQhta9M7lNJHP7QQS3vkvcGLQUbWpMzwrXYwrYztHKA==}
|
||||||
|
peerDependencies:
|
||||||
|
'@types/react': '*'
|
||||||
|
'@types/react-dom': '*'
|
||||||
|
react: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc
|
||||||
|
react-dom: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc
|
||||||
|
peerDependenciesMeta:
|
||||||
|
'@types/react':
|
||||||
|
optional: true
|
||||||
|
'@types/react-dom':
|
||||||
|
optional: true
|
||||||
|
|
||||||
'@radix-ui/react-popper@1.2.8':
|
'@radix-ui/react-popper@1.2.8':
|
||||||
resolution: {integrity: sha512-0NJQ4LFFUuWkE7Oxf0htBKS6zLkkjBH+hM1uk7Ng705ReR8m/uelduy1DBo0PyBXPKVnBA6YBlU94MBGXrSBCw==}
|
resolution: {integrity: sha512-0NJQ4LFFUuWkE7Oxf0htBKS6zLkkjBH+hM1uk7Ng705ReR8m/uelduy1DBo0PyBXPKVnBA6YBlU94MBGXrSBCw==}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
@@ -1896,6 +1915,12 @@ packages:
|
|||||||
resolution: {integrity: sha512-eYm0QWBtUrBWZWG0d386OGAw16Z995PiOVo2B7bjWSbHedGl5e0ZWaq65kOGgUSNesEIDkB9ISbTg/JK9dhCZA==}
|
resolution: {integrity: sha512-eYm0QWBtUrBWZWG0d386OGAw16Z995PiOVo2B7bjWSbHedGl5e0ZWaq65kOGgUSNesEIDkB9ISbTg/JK9dhCZA==}
|
||||||
engines: {node: '>=6'}
|
engines: {node: '>=6'}
|
||||||
|
|
||||||
|
cmdk@1.1.1:
|
||||||
|
resolution: {integrity: sha512-Vsv7kFaXm+ptHDMZ7izaRsP70GgrW9NBNGswt9OZaVBLlE0SNpDq8eu/VGXyF9r7M0azK3Wy7OlYXsuyYLFzHg==}
|
||||||
|
peerDependencies:
|
||||||
|
react: ^18 || ^19 || ^19.0.0-rc
|
||||||
|
react-dom: ^18 || ^19 || ^19.0.0-rc
|
||||||
|
|
||||||
color-convert@2.0.1:
|
color-convert@2.0.1:
|
||||||
resolution: {integrity: sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==}
|
resolution: {integrity: sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==}
|
||||||
engines: {node: '>=7.0.0'}
|
engines: {node: '>=7.0.0'}
|
||||||
@@ -4481,6 +4506,29 @@ snapshots:
|
|||||||
'@types/react': 19.2.2
|
'@types/react': 19.2.2
|
||||||
'@types/react-dom': 19.2.2(@types/react@19.2.2)
|
'@types/react-dom': 19.2.2(@types/react@19.2.2)
|
||||||
|
|
||||||
|
'@radix-ui/react-popover@1.1.15(@types/react-dom@19.2.2(@types/react@19.2.2))(@types/react@19.2.2)(react-dom@19.2.0(react@19.2.0))(react@19.2.0)':
|
||||||
|
dependencies:
|
||||||
|
'@radix-ui/primitive': 1.1.3
|
||||||
|
'@radix-ui/react-compose-refs': 1.1.2(@types/react@19.2.2)(react@19.2.0)
|
||||||
|
'@radix-ui/react-context': 1.1.2(@types/react@19.2.2)(react@19.2.0)
|
||||||
|
'@radix-ui/react-dismissable-layer': 1.1.11(@types/react-dom@19.2.2(@types/react@19.2.2))(@types/react@19.2.2)(react-dom@19.2.0(react@19.2.0))(react@19.2.0)
|
||||||
|
'@radix-ui/react-focus-guards': 1.1.3(@types/react@19.2.2)(react@19.2.0)
|
||||||
|
'@radix-ui/react-focus-scope': 1.1.7(@types/react-dom@19.2.2(@types/react@19.2.2))(@types/react@19.2.2)(react-dom@19.2.0(react@19.2.0))(react@19.2.0)
|
||||||
|
'@radix-ui/react-id': 1.1.1(@types/react@19.2.2)(react@19.2.0)
|
||||||
|
'@radix-ui/react-popper': 1.2.8(@types/react-dom@19.2.2(@types/react@19.2.2))(@types/react@19.2.2)(react-dom@19.2.0(react@19.2.0))(react@19.2.0)
|
||||||
|
'@radix-ui/react-portal': 1.1.9(@types/react-dom@19.2.2(@types/react@19.2.2))(@types/react@19.2.2)(react-dom@19.2.0(react@19.2.0))(react@19.2.0)
|
||||||
|
'@radix-ui/react-presence': 1.1.5(@types/react-dom@19.2.2(@types/react@19.2.2))(@types/react@19.2.2)(react-dom@19.2.0(react@19.2.0))(react@19.2.0)
|
||||||
|
'@radix-ui/react-primitive': 2.1.3(@types/react-dom@19.2.2(@types/react@19.2.2))(@types/react@19.2.2)(react-dom@19.2.0(react@19.2.0))(react@19.2.0)
|
||||||
|
'@radix-ui/react-slot': 1.2.3(@types/react@19.2.2)(react@19.2.0)
|
||||||
|
'@radix-ui/react-use-controllable-state': 1.2.2(@types/react@19.2.2)(react@19.2.0)
|
||||||
|
aria-hidden: 1.2.6
|
||||||
|
react: 19.2.0
|
||||||
|
react-dom: 19.2.0(react@19.2.0)
|
||||||
|
react-remove-scroll: 2.7.1(@types/react@19.2.2)(react@19.2.0)
|
||||||
|
optionalDependencies:
|
||||||
|
'@types/react': 19.2.2
|
||||||
|
'@types/react-dom': 19.2.2(@types/react@19.2.2)
|
||||||
|
|
||||||
'@radix-ui/react-popper@1.2.8(@types/react-dom@19.2.2(@types/react@19.2.2))(@types/react@19.2.2)(react-dom@19.2.0(react@19.2.0))(react@19.2.0)':
|
'@radix-ui/react-popper@1.2.8(@types/react-dom@19.2.2(@types/react@19.2.2))(@types/react@19.2.2)(react-dom@19.2.0(react@19.2.0))(react@19.2.0)':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@floating-ui/react-dom': 2.1.6(react-dom@19.2.0(react@19.2.0))(react@19.2.0)
|
'@floating-ui/react-dom': 2.1.6(react-dom@19.2.0(react@19.2.0))(react@19.2.0)
|
||||||
@@ -5429,6 +5477,18 @@ snapshots:
|
|||||||
|
|
||||||
clsx@2.1.1: {}
|
clsx@2.1.1: {}
|
||||||
|
|
||||||
|
cmdk@1.1.1(@types/react-dom@19.2.2(@types/react@19.2.2))(@types/react@19.2.2)(react-dom@19.2.0(react@19.2.0))(react@19.2.0):
|
||||||
|
dependencies:
|
||||||
|
'@radix-ui/react-compose-refs': 1.1.2(@types/react@19.2.2)(react@19.2.0)
|
||||||
|
'@radix-ui/react-dialog': 1.1.15(@types/react-dom@19.2.2(@types/react@19.2.2))(@types/react@19.2.2)(react-dom@19.2.0(react@19.2.0))(react@19.2.0)
|
||||||
|
'@radix-ui/react-id': 1.1.1(@types/react@19.2.2)(react@19.2.0)
|
||||||
|
'@radix-ui/react-primitive': 2.1.3(@types/react-dom@19.2.2(@types/react@19.2.2))(@types/react@19.2.2)(react-dom@19.2.0(react@19.2.0))(react@19.2.0)
|
||||||
|
react: 19.2.0
|
||||||
|
react-dom: 19.2.0(react@19.2.0)
|
||||||
|
transitivePeerDependencies:
|
||||||
|
- '@types/react'
|
||||||
|
- '@types/react-dom'
|
||||||
|
|
||||||
color-convert@2.0.1:
|
color-convert@2.0.1:
|
||||||
dependencies:
|
dependencies:
|
||||||
color-name: 1.1.4
|
color-name: 1.1.4
|
||||||
|
|||||||
@@ -104,40 +104,80 @@ function ensureDir(dir) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function safeUnlink(filePath) {
|
||||||
|
if (fs.existsSync(filePath)) {
|
||||||
|
fs.unlinkSync(filePath)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function getDownloadHeaders(url) {
|
||||||
|
const headers = {
|
||||||
|
'User-Agent': 'vidbee-setup',
|
||||||
|
Accept: '*/*'
|
||||||
|
}
|
||||||
|
if (GITHUB_TOKEN && /github\.com|githubusercontent\.com/.test(url)) {
|
||||||
|
headers.Authorization = `Bearer ${GITHUB_TOKEN}`
|
||||||
|
}
|
||||||
|
return headers
|
||||||
|
}
|
||||||
|
|
||||||
function downloadFile(url, dest) {
|
function downloadFile(url, dest) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const protocol = url.startsWith('https') ? https : http
|
const protocol = url.startsWith('https') ? https : http
|
||||||
const file = fs.createWriteStream(dest)
|
const file = fs.createWriteStream(dest)
|
||||||
|
|
||||||
protocol
|
const request = protocol.get(url, { headers: getDownloadHeaders(url) }, (response) => {
|
||||||
.get(url, (response) => {
|
if (response.statusCode === 302 || response.statusCode === 301) {
|
||||||
if (response.statusCode === 302 || response.statusCode === 301) {
|
// Handle redirect
|
||||||
// Handle redirect
|
|
||||||
file.close()
|
|
||||||
fs.unlinkSync(dest)
|
|
||||||
return downloadFile(response.headers.location, dest).then(resolve).catch(reject)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (response.statusCode !== 200) {
|
|
||||||
file.close()
|
|
||||||
fs.unlinkSync(dest)
|
|
||||||
return reject(new Error(`Failed to download: ${response.statusCode}`))
|
|
||||||
}
|
|
||||||
|
|
||||||
response.pipe(file)
|
|
||||||
file.on('finish', () => {
|
|
||||||
file.close()
|
|
||||||
resolve()
|
|
||||||
})
|
|
||||||
})
|
|
||||||
.on('error', (err) => {
|
|
||||||
file.close()
|
file.close()
|
||||||
fs.unlinkSync(dest)
|
safeUnlink(dest)
|
||||||
reject(err)
|
return downloadFile(response.headers.location, dest).then(resolve).catch(reject)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (response.statusCode !== 200) {
|
||||||
|
file.close()
|
||||||
|
safeUnlink(dest)
|
||||||
|
return reject(new Error(`Failed to download: ${response.statusCode}`))
|
||||||
|
}
|
||||||
|
|
||||||
|
response.pipe(file)
|
||||||
|
file.on('finish', () => {
|
||||||
|
file.close()
|
||||||
|
resolve()
|
||||||
})
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
request.setTimeout(30000, () => {
|
||||||
|
request.destroy(new Error('Download timeout'))
|
||||||
|
})
|
||||||
|
|
||||||
|
request.on('error', (err) => {
|
||||||
|
file.close()
|
||||||
|
safeUnlink(dest)
|
||||||
|
reject(err)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function downloadFileWithRetry(url, dest, retries = 3, delayMs = 2000) {
|
||||||
|
let lastError
|
||||||
|
for (let attempt = 1; attempt <= retries; attempt += 1) {
|
||||||
|
try {
|
||||||
|
await downloadFile(url, dest)
|
||||||
|
return
|
||||||
|
} catch (error) {
|
||||||
|
lastError = error
|
||||||
|
safeUnlink(dest)
|
||||||
|
if (attempt < retries) {
|
||||||
|
const backoff = delayMs * attempt
|
||||||
|
log(`Download failed (attempt ${attempt}/${retries}): ${error.message}`, 'warn')
|
||||||
|
await new Promise((resolve) => setTimeout(resolve, backoff))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw lastError
|
||||||
|
}
|
||||||
|
|
||||||
function fetchJson(url) {
|
function fetchJson(url) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const protocol = url.startsWith('https') ? https : http
|
const protocol = url.startsWith('https') ? https : http
|
||||||
@@ -299,7 +339,7 @@ async function downloadYtDlp(config) {
|
|||||||
const tempPath = path.join(RESOURCES_DIR, `.${asset}.tmp`)
|
const tempPath = path.join(RESOURCES_DIR, `.${asset}.tmp`)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await downloadFile(url, tempPath)
|
await downloadFileWithRetry(url, tempPath)
|
||||||
fs.renameSync(tempPath, outputPath)
|
fs.renameSync(tempPath, outputPath)
|
||||||
setExecutable(outputPath)
|
setExecutable(outputPath)
|
||||||
log(`Downloaded ${output} successfully`, 'success')
|
log(`Downloaded ${output} successfully`, 'success')
|
||||||
@@ -342,7 +382,7 @@ async function downloadFfmpegWindows(config) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await downloadFile(downloadUrl, tempZip)
|
await downloadFileWithRetry(downloadUrl, tempZip)
|
||||||
log('Extracting ffmpeg...', 'info')
|
log('Extracting ffmpeg...', 'info')
|
||||||
extractZip(tempZip, extractDir)
|
extractZip(tempZip, extractDir)
|
||||||
|
|
||||||
@@ -397,7 +437,7 @@ async function downloadFfmpegMac(config) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await downloadFile(downloadUrl, tempZip)
|
await downloadFileWithRetry(downloadUrl, tempZip)
|
||||||
log('Extracting ffmpeg...', 'info')
|
log('Extracting ffmpeg...', 'info')
|
||||||
extractZip(tempZip, extractDir)
|
extractZip(tempZip, extractDir)
|
||||||
|
|
||||||
@@ -451,7 +491,7 @@ async function downloadFfmpegLinux(config) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await downloadFile(downloadUrl, tempTar)
|
await downloadFileWithRetry(downloadUrl, tempTar)
|
||||||
log('Extracting ffmpeg...', 'info')
|
log('Extracting ffmpeg...', 'info')
|
||||||
extractTarXz(tempTar, extractDir)
|
extractTarXz(tempTar, extractDir)
|
||||||
|
|
||||||
@@ -498,7 +538,7 @@ async function downloadDenoRuntime() {
|
|||||||
const downloadUrl = `${DENO_BASE_URL}/${assetName}`
|
const downloadUrl = `${DENO_BASE_URL}/${assetName}`
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await downloadFile(downloadUrl, tempZip)
|
await downloadFileWithRetry(downloadUrl, tempZip)
|
||||||
log('Extracting Deno runtime...', 'info')
|
log('Extracting Deno runtime...', 'info')
|
||||||
extractZip(tempZip, extractDir)
|
extractZip(tempZip, extractDir)
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,10 @@ export const resolveVideoFormatSelector = (options: DownloadOptions): string =>
|
|||||||
const format = options.format
|
const format = options.format
|
||||||
const audioFormat = options.audioFormat
|
const audioFormat = options.audioFormat
|
||||||
|
|
||||||
|
if (format && audioFormat === '') {
|
||||||
|
return format
|
||||||
|
}
|
||||||
|
|
||||||
if (format && (format.includes('/') || (audioFormat === undefined && format.includes('+')))) {
|
if (format && (format.includes('/') || (audioFormat === undefined && format.includes('+')))) {
|
||||||
return format
|
return format
|
||||||
}
|
}
|
||||||
@@ -30,8 +34,8 @@ export const resolveVideoFormatSelector = (options: DownloadOptions): string =>
|
|||||||
return 'bestvideo+none'
|
return 'bestvideo+none'
|
||||||
}
|
}
|
||||||
if (!audioFormat || audioFormat === 'best') {
|
if (!audioFormat || audioFormat === 'best') {
|
||||||
// Use bestvideo+bestaudio to ensure video and audio are merged into a single file
|
// Prefer merged formats, but allow single-file "best" for sites without separate streams.
|
||||||
return 'bestvideo+bestaudio'
|
return 'bestvideo+bestaudio/best'
|
||||||
}
|
}
|
||||||
return `bestvideo+${audioFormat}`
|
return `bestvideo+${audioFormat}`
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,14 @@ import { existsSync } from 'node:fs'
|
|||||||
import { isAbsolute, join, relative, resolve } from 'node:path'
|
import { isAbsolute, join, relative, resolve } from 'node:path'
|
||||||
import { electronApp, optimizer } from '@electron-toolkit/utils'
|
import { electronApp, optimizer } from '@electron-toolkit/utils'
|
||||||
import { APP_PROTOCOL, APP_PROTOCOL_SCHEME } from '@shared/constants'
|
import { APP_PROTOCOL, APP_PROTOCOL_SCHEME } from '@shared/constants'
|
||||||
import { app, BrowserWindow, type BrowserWindowConstructorOptions, protocol, shell } from 'electron'
|
import {
|
||||||
|
app,
|
||||||
|
BrowserWindow,
|
||||||
|
type BrowserWindowConstructorOptions,
|
||||||
|
ipcMain,
|
||||||
|
protocol,
|
||||||
|
shell
|
||||||
|
} from 'electron'
|
||||||
import log from 'electron-log/main'
|
import log from 'electron-log/main'
|
||||||
import { autoUpdater } from 'electron-updater'
|
import { autoUpdater } from 'electron-updater'
|
||||||
import appIcon from '../../build/icon.png?asset'
|
import appIcon from '../../build/icon.png?asset'
|
||||||
@@ -129,6 +136,7 @@ subscriptionManager.on('subscriptions:updated', (subscriptions) => {
|
|||||||
export function createWindow(): void {
|
export function createWindow(): void {
|
||||||
const isMac = process.platform === 'darwin'
|
const isMac = process.platform === 'darwin'
|
||||||
const isWindows = process.platform === 'win32'
|
const isWindows = process.platform === 'win32'
|
||||||
|
const shouldStartHidden = isWindows && app.getLoginItemSettings().wasOpenedAtLogin
|
||||||
|
|
||||||
const windowOptions: BrowserWindowConstructorOptions = {
|
const windowOptions: BrowserWindowConstructorOptions = {
|
||||||
width: 1200,
|
width: 1200,
|
||||||
@@ -168,6 +176,9 @@ export function createWindow(): void {
|
|||||||
})
|
})
|
||||||
|
|
||||||
mainWindow.on('ready-to-show', () => {
|
mainWindow.on('ready-to-show', () => {
|
||||||
|
if (shouldStartHidden) {
|
||||||
|
return
|
||||||
|
}
|
||||||
mainWindow?.show()
|
mainWindow?.show()
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -190,10 +201,48 @@ export function createWindow(): void {
|
|||||||
flushPendingDeepLinks()
|
flushPendingDeepLinks()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Setup error handling for renderer process
|
||||||
|
setupRendererErrorHandling()
|
||||||
|
|
||||||
// Setup download engine event forwarding to renderer
|
// Setup download engine event forwarding to renderer
|
||||||
setupDownloadEvents()
|
setupDownloadEvents()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setupRendererErrorHandling(): void {
|
||||||
|
if (!mainWindow) return
|
||||||
|
|
||||||
|
// Handle uncaught exceptions in renderer process
|
||||||
|
mainWindow.webContents.on('unresponsive', () => {
|
||||||
|
log.error('Renderer process became unresponsive')
|
||||||
|
})
|
||||||
|
|
||||||
|
mainWindow.webContents.on('responsive', () => {
|
||||||
|
log.info('Renderer process became responsive again')
|
||||||
|
})
|
||||||
|
|
||||||
|
// Listen for renderer errors via IPC
|
||||||
|
ipcMain.on('error:renderer', (_event, errorData) => {
|
||||||
|
log.error('Renderer error received:', errorData)
|
||||||
|
|
||||||
|
// Log detailed error information
|
||||||
|
if (errorData.error) {
|
||||||
|
log.error('Error name:', errorData.error.name)
|
||||||
|
log.error('Error message:', errorData.error.message)
|
||||||
|
if (errorData.error.stack) {
|
||||||
|
log.error('Error stack:', errorData.error.stack)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (errorData.errorInfo?.componentStack) {
|
||||||
|
log.error('Component stack:', errorData.errorInfo.componentStack)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (errorData.context) {
|
||||||
|
log.error('Error context:', errorData.context)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
function setupDownloadEvents(): void {
|
function setupDownloadEvents(): void {
|
||||||
downloadEngine.on('download-started', (id: string) => {
|
downloadEngine.on('download-started', (id: string) => {
|
||||||
mainWindow?.webContents.send('download:started', id)
|
mainWindow?.webContents.send('download:started', id)
|
||||||
@@ -379,6 +428,17 @@ app.whenReady().then(async () => {
|
|||||||
// and ignore CommandOrControl + R in production.
|
// and ignore CommandOrControl + R in production.
|
||||||
app.on('browser-window-created', (_, window) => {
|
app.on('browser-window-created', (_, window) => {
|
||||||
optimizer.watchWindowShortcuts(window)
|
optimizer.watchWindowShortcuts(window)
|
||||||
|
|
||||||
|
// Enable F12 to toggle DevTools in both development and production
|
||||||
|
window.webContents.on('before-input-event', (_, input) => {
|
||||||
|
if (input.key === 'F12') {
|
||||||
|
if (window.webContents.isDevToolsOpened()) {
|
||||||
|
window.webContents.closeDevTools()
|
||||||
|
} else {
|
||||||
|
window.webContents.openDevTools()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
// IPC services are automatically registered by electron-ipc-decorator when imported
|
// IPC services are automatically registered by electron-ipc-decorator when imported
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import { type IpcContext, IpcMethod, IpcService } from 'electron-ipc-decorator'
|
import { type IpcContext, IpcMethod, IpcService } from 'electron-ipc-decorator'
|
||||||
import type { AppSettings } from '../../../shared/types'
|
import type { AppSettings } from '../../../shared/types'
|
||||||
import { subscriptionScheduler } from '../../lib/subscription-scheduler'
|
|
||||||
import { settingsManager } from '../../settings'
|
import { settingsManager } from '../../settings'
|
||||||
import { updateTrayMenu } from '../../tray'
|
import { updateTrayMenu } from '../../tray'
|
||||||
import { applyAutoLaunchSetting } from '../../utils/auto-launch'
|
import { applyAutoLaunchSetting } from '../../utils/auto-launch'
|
||||||
@@ -29,10 +28,6 @@ class SettingsService extends IpcService {
|
|||||||
if (key === 'launchAtLogin') {
|
if (key === 'launchAtLogin') {
|
||||||
applyAutoLaunchSetting(value as AppSettings['launchAtLogin'])
|
applyAutoLaunchSetting(value as AppSettings['launchAtLogin'])
|
||||||
}
|
}
|
||||||
|
|
||||||
if (key === 'subscriptionCheckIntervalHours') {
|
|
||||||
subscriptionScheduler.refreshInterval()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@IpcMethod()
|
@IpcMethod()
|
||||||
@@ -55,10 +50,6 @@ class SettingsService extends IpcService {
|
|||||||
if (typeof settings.launchAtLogin === 'boolean') {
|
if (typeof settings.launchAtLogin === 'boolean') {
|
||||||
applyAutoLaunchSetting(settings.launchAtLogin)
|
applyAutoLaunchSetting(settings.launchAtLogin)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (settings.subscriptionCheckIntervalHours !== undefined) {
|
|
||||||
subscriptionScheduler.refreshInterval()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@IpcMethod()
|
@IpcMethod()
|
||||||
@@ -66,7 +57,6 @@ class SettingsService extends IpcService {
|
|||||||
settingsManager.reset()
|
settingsManager.reset()
|
||||||
applyDockVisibility(settingsManager.get('hideDockIcon'))
|
applyDockVisibility(settingsManager.get('hideDockIcon'))
|
||||||
applyAutoLaunchSetting(settingsManager.get('launchAtLogin'))
|
applyAutoLaunchSetting(settingsManager.get('launchAtLogin'))
|
||||||
subscriptionScheduler.refreshInterval()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -36,6 +36,19 @@ interface DownloadProcess {
|
|||||||
process: YTDlpEventEmitter
|
process: YTDlpEventEmitter
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const formatYtDlpCommand = (args: string[]): string => {
|
||||||
|
const quoted = args.map((arg) => {
|
||||||
|
if (arg === '') {
|
||||||
|
return '""'
|
||||||
|
}
|
||||||
|
if (/[\s"'\\]/.test(arg)) {
|
||||||
|
return `"${arg.replace(/(["\\])/g, '\\$1')}"`
|
||||||
|
}
|
||||||
|
return arg
|
||||||
|
})
|
||||||
|
return `yt-dlp ${quoted.join(' ')}`
|
||||||
|
}
|
||||||
|
|
||||||
const ensureDirectoryExists = (dir?: string): void => {
|
const ensureDirectoryExists = (dir?: string): void => {
|
||||||
if (!dir) {
|
if (!dir) {
|
||||||
return
|
return
|
||||||
@@ -732,6 +745,8 @@ class DownloadEngine extends EventEmitter {
|
|||||||
args.push('--ffmpeg-location', ffmpegPath)
|
args.push('--ffmpeg-location', ffmpegPath)
|
||||||
args.push(urlArg)
|
args.push(urlArg)
|
||||||
|
|
||||||
|
scopedLoggers.download.info('yt-dlp command:', formatYtDlpCommand(args))
|
||||||
|
|
||||||
const controller = new AbortController()
|
const controller = new AbortController()
|
||||||
const ytdlpProcess = ytdlp.exec(args, {
|
const ytdlpProcess = ytdlp.exec(args, {
|
||||||
signal: controller.signal
|
signal: controller.signal
|
||||||
|
|||||||
@@ -19,6 +19,11 @@ type ParserItem = {
|
|||||||
isoDate?: string
|
isoDate?: string
|
||||||
pubDate?: string
|
pubDate?: string
|
||||||
youtubeId?: string
|
youtubeId?: string
|
||||||
|
content?: string
|
||||||
|
contentSnippet?: string
|
||||||
|
contentEncoded?: string
|
||||||
|
summary?: string
|
||||||
|
description?: string
|
||||||
mediaThumbnail?: Array<{ url?: string }> | { url?: string }
|
mediaThumbnail?: Array<{ url?: string }> | { url?: string }
|
||||||
mediaContent?: Array<{ url?: string }> | { url?: string }
|
mediaContent?: Array<{ url?: string }> | { url?: string }
|
||||||
enclosure?: Array<{ url?: string; type?: string }> | { url?: string; type?: string }
|
enclosure?: Array<{ url?: string; type?: string }> | { url?: string; type?: string }
|
||||||
@@ -41,24 +46,19 @@ type FeedItem = {
|
|||||||
thumbnail?: string
|
thumbnail?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
const parser = new Parser<{ item: ParserItem }>({
|
const parser = new Parser<Record<string, never>, ParserItem>({
|
||||||
customFields: {
|
customFields: {
|
||||||
item: [
|
item: [
|
||||||
['yt:videoId', 'youtubeId'],
|
['yt:videoId', 'youtubeId'],
|
||||||
['media:thumbnail', 'mediaThumbnail'],
|
['media:thumbnail', 'mediaThumbnail'],
|
||||||
['media:content', 'mediaContent'],
|
['media:content', 'mediaContent'],
|
||||||
['enclosure', 'enclosure']
|
['enclosure', 'enclosure'],
|
||||||
|
['content:encoded', 'contentEncoded'],
|
||||||
|
['description', 'description']
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const clampIntervalHours = (value: number | undefined): number => {
|
|
||||||
if (!value || Number.isNaN(value)) {
|
|
||||||
return 3
|
|
||||||
}
|
|
||||||
return Math.min(24, Math.max(1, value))
|
|
||||||
}
|
|
||||||
|
|
||||||
const sanitizeDownloadId = (subscriptionId: string, itemId: string): string => {
|
const sanitizeDownloadId = (subscriptionId: string, itemId: string): string => {
|
||||||
const base = Buffer.from(`${subscriptionId}:${itemId}`).toString('base64url')
|
const base = Buffer.from(`${subscriptionId}:${itemId}`).toString('base64url')
|
||||||
return `sub_${base}`
|
return `sub_${base}`
|
||||||
@@ -167,7 +167,7 @@ export class SubscriptionScheduler extends EventEmitter {
|
|||||||
if (this.timer) {
|
if (this.timer) {
|
||||||
clearTimeout(this.timer)
|
clearTimeout(this.timer)
|
||||||
}
|
}
|
||||||
const intervalHours = clampIntervalHours(settingsManager.get('subscriptionCheckIntervalHours'))
|
const intervalHours = 3 // Default check interval: 3 hours
|
||||||
const delayMs = initialDelay ?? intervalHours * 60 * 60 * 1000
|
const delayMs = initialDelay ?? intervalHours * 60 * 60 * 1000
|
||||||
this.timer = setTimeout(() => {
|
this.timer = setTimeout(() => {
|
||||||
void this.checkAll().finally(() => this.scheduleNextRun())
|
void this.checkAll().finally(() => this.scheduleNextRun())
|
||||||
@@ -240,13 +240,18 @@ export class SubscriptionScheduler extends EventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const latestItem = normalizedItems[0]
|
const latestItem = normalizedItems[0]
|
||||||
|
const coverUrl = this.resolveSubscriptionCover(
|
||||||
|
feed,
|
||||||
|
normalizedItems,
|
||||||
|
feedItems as ParserItem[]
|
||||||
|
)
|
||||||
subscriptionManager.update(subscription.id, {
|
subscriptionManager.update(subscription.id, {
|
||||||
status: 'up-to-date',
|
status: 'up-to-date',
|
||||||
lastSuccessAt: Date.now(),
|
lastSuccessAt: Date.now(),
|
||||||
lastError: undefined,
|
lastError: undefined,
|
||||||
latestVideoTitle: latestItem?.title ?? subscription.latestVideoTitle,
|
latestVideoTitle: latestItem?.title ?? subscription.latestVideoTitle,
|
||||||
latestVideoPublishedAt: latestItem?.publishedAt ?? subscription.latestVideoPublishedAt,
|
latestVideoPublishedAt: latestItem?.publishedAt ?? subscription.latestVideoPublishedAt,
|
||||||
coverUrl: (feed.image as { url?: string } | undefined)?.url ?? subscription.coverUrl,
|
coverUrl: coverUrl ?? subscription.coverUrl,
|
||||||
title:
|
title:
|
||||||
typeof feed.title === 'string' && feed.title.trim().length > 0
|
typeof feed.title === 'string' && feed.title.trim().length > 0
|
||||||
? feed.title.trim()
|
? feed.title.trim()
|
||||||
@@ -366,6 +371,74 @@ export class SubscriptionScheduler extends EventEmitter {
|
|||||||
return mediaContent.url as string | undefined
|
return mediaContent.url as string | undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Try to parse an image from HTML fields
|
||||||
|
const htmlCandidates = [
|
||||||
|
item.content,
|
||||||
|
item.contentEncoded,
|
||||||
|
item.description,
|
||||||
|
item.summary,
|
||||||
|
item.contentSnippet
|
||||||
|
]
|
||||||
|
for (const html of htmlCandidates) {
|
||||||
|
const imageUrl = this.extractImageFromHtml(html)
|
||||||
|
if (imageUrl) {
|
||||||
|
return imageUrl
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return undefined
|
||||||
|
}
|
||||||
|
|
||||||
|
private resolveSubscriptionCover(
|
||||||
|
feed: Parser.Output<ParserItem>,
|
||||||
|
items: FeedItem[],
|
||||||
|
rawItems: ParserItem[]
|
||||||
|
): string | undefined {
|
||||||
|
const feedImageUrl = typeof feed.image?.url === 'string' ? feed.image.url : undefined
|
||||||
|
if (feedImageUrl) {
|
||||||
|
return feedImageUrl
|
||||||
|
}
|
||||||
|
|
||||||
|
const itunesImageUrl = typeof feed.itunes?.image === 'string' ? feed.itunes.image : undefined
|
||||||
|
if (itunesImageUrl) {
|
||||||
|
return itunesImageUrl
|
||||||
|
}
|
||||||
|
|
||||||
|
const itemThumbnail = items.find((item) => item.thumbnail)?.thumbnail
|
||||||
|
if (itemThumbnail) {
|
||||||
|
return itemThumbnail
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const item of rawItems) {
|
||||||
|
const thumbnail = this.resolveThumbnail(item)
|
||||||
|
if (thumbnail) {
|
||||||
|
return thumbnail
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return undefined
|
||||||
|
}
|
||||||
|
|
||||||
|
private extractImageFromHtml(html?: string): string | undefined {
|
||||||
|
if (!html) {
|
||||||
|
return undefined
|
||||||
|
}
|
||||||
|
|
||||||
|
const srcMatch = html.match(
|
||||||
|
/<img\b[^>]*\b(?:src|data-src|data-original)\b\s*=\s*(['"]?)([^'">\s]+)\1/i
|
||||||
|
)
|
||||||
|
if (srcMatch?.[2]) {
|
||||||
|
return srcMatch[2]
|
||||||
|
}
|
||||||
|
|
||||||
|
const srcsetMatch = html.match(/<img[^>]+srcset\s*=\s*(['"])([^'"]+)\1/i)
|
||||||
|
if (srcsetMatch?.[2]) {
|
||||||
|
const firstCandidate = srcsetMatch[2].split(',')[0]?.trim().split(/\s+/)[0]
|
||||||
|
if (firstCandidate) {
|
||||||
|
return firstCandidate
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return undefined
|
return undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -53,7 +53,11 @@ class SettingsManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getAll(): AppSettings {
|
getAll(): AppSettings {
|
||||||
return this.store.store
|
return {
|
||||||
|
...defaultSettings,
|
||||||
|
downloadPath: DEFAULT_DOWNLOAD_PATH,
|
||||||
|
...this.store.store
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setAll(settings: Partial<AppSettings>): void {
|
setAll(settings: Partial<AppSettings>): void {
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import { useCallback, useEffect, useRef, useState } from 'react'
|
|||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import { HashRouter, Navigate, Route, Routes, useLocation, useNavigate } from 'react-router'
|
import { HashRouter, Navigate, Route, Routes, useLocation, useNavigate } from 'react-router'
|
||||||
import { toast } from 'sonner'
|
import { toast } from 'sonner'
|
||||||
|
import { ErrorBoundary } from './components/error/ErrorBoundary'
|
||||||
import { ipcEvents, ipcServices } from './lib/ipc'
|
import { ipcEvents, ipcServices } from './lib/ipc'
|
||||||
import { About } from './pages/About'
|
import { About } from './pages/About'
|
||||||
import { Home } from './pages/Home'
|
import { Home } from './pages/Home'
|
||||||
@@ -16,6 +17,7 @@ import { Settings } from './pages/Settings'
|
|||||||
import { Subscriptions } from './pages/Subscriptions'
|
import { Subscriptions } from './pages/Subscriptions'
|
||||||
import { loadSettingsAtom, settingsAtom } from './store/settings'
|
import { loadSettingsAtom, settingsAtom } from './store/settings'
|
||||||
import { loadSubscriptionsAtom, setSubscriptionsAtom } from './store/subscriptions'
|
import { loadSubscriptionsAtom, setSubscriptionsAtom } from './store/subscriptions'
|
||||||
|
import { updateAvailableAtom, updateReadyAtom } from './store/update'
|
||||||
|
|
||||||
type Page = 'home' | 'subscriptions' | 'settings' | 'about'
|
type Page = 'home' | 'subscriptions' | 'settings' | 'about'
|
||||||
|
|
||||||
@@ -51,6 +53,8 @@ function AppContent() {
|
|||||||
const setSubscriptions = useSetAtom(setSubscriptionsAtom)
|
const setSubscriptions = useSetAtom(setSubscriptionsAtom)
|
||||||
const [settings] = useAtom(settingsAtom)
|
const [settings] = useAtom(settingsAtom)
|
||||||
const loadSettings = useSetAtom(loadSettingsAtom)
|
const loadSettings = useSetAtom(loadSettingsAtom)
|
||||||
|
const setUpdateReady = useSetAtom(updateReadyAtom)
|
||||||
|
const setUpdateAvailable = useSetAtom(updateAvailableAtom)
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
const updateDownloadInProgressRef = useRef(false)
|
const updateDownloadInProgressRef = useRef(false)
|
||||||
const analyticsScriptRef = useRef<HTMLScriptElement | null>(null)
|
const analyticsScriptRef = useRef<HTMLScriptElement | null>(null)
|
||||||
@@ -174,8 +178,25 @@ function AppContent() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleUpdateDownloaded = (_rawInfo: unknown) => {
|
const handleUpdateAvailable = (rawInfo: unknown) => {
|
||||||
|
const info = (rawInfo ?? {}) as { version?: string }
|
||||||
|
setUpdateAvailable({
|
||||||
|
available: true,
|
||||||
|
version: info.version
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleUpdateDownloaded = (rawInfo: unknown) => {
|
||||||
|
const info = (rawInfo ?? {}) as { version?: string }
|
||||||
resetDownloadState()
|
resetDownloadState()
|
||||||
|
setUpdateReady({
|
||||||
|
ready: true,
|
||||||
|
version: info.version
|
||||||
|
})
|
||||||
|
setUpdateAvailable({
|
||||||
|
available: true,
|
||||||
|
version: info.version
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleUpdateError = (rawMessage: unknown) => {
|
const handleUpdateError = (rawMessage: unknown) => {
|
||||||
@@ -211,19 +232,21 @@ function AppContent() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Only listen to update events that should be shown globally
|
// Only listen to update events that should be shown globally
|
||||||
// update:available is handled in About page only
|
// update:available shows a visual indicator in the sidebar
|
||||||
|
ipcEvents.on('update:available', handleUpdateAvailable)
|
||||||
ipcEvents.on('update:downloaded', handleUpdateDownloaded)
|
ipcEvents.on('update:downloaded', handleUpdateDownloaded)
|
||||||
ipcEvents.on('update:error', handleUpdateError)
|
ipcEvents.on('update:error', handleUpdateError)
|
||||||
ipcEvents.on('update:download-progress', handleDownloadProgress)
|
ipcEvents.on('update:download-progress', handleDownloadProgress)
|
||||||
ipcEvents.on('update:show-notification', handleUpdateNotification)
|
ipcEvents.on('update:show-notification', handleUpdateNotification)
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
|
ipcEvents.removeListener('update:available', handleUpdateAvailable)
|
||||||
ipcEvents.removeListener('update:downloaded', handleUpdateDownloaded)
|
ipcEvents.removeListener('update:downloaded', handleUpdateDownloaded)
|
||||||
ipcEvents.removeListener('update:error', handleUpdateError)
|
ipcEvents.removeListener('update:error', handleUpdateError)
|
||||||
ipcEvents.removeListener('update:download-progress', handleDownloadProgress)
|
ipcEvents.removeListener('update:download-progress', handleDownloadProgress)
|
||||||
ipcEvents.removeListener('update:show-notification', handleUpdateNotification)
|
ipcEvents.removeListener('update:show-notification', handleUpdateNotification)
|
||||||
}
|
}
|
||||||
}, [t])
|
}, [setUpdateAvailable, setUpdateReady, t])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-row h-screen">
|
<div className="flex flex-row h-screen">
|
||||||
@@ -270,11 +293,13 @@ function AppContent() {
|
|||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
return (
|
return (
|
||||||
<ThemeProvider attribute="class" defaultTheme="system" enableSystem>
|
<ErrorBoundary>
|
||||||
<HashRouter>
|
<ThemeProvider attribute="class" defaultTheme="system" enableSystem>
|
||||||
<AppContent />
|
<HashRouter>
|
||||||
</HashRouter>
|
<AppContent />
|
||||||
</ThemeProvider>
|
</HashRouter>
|
||||||
|
</ThemeProvider>
|
||||||
|
</ErrorBoundary>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -78,11 +78,11 @@ const getQualityPreset = (settings: AppSettings): OneClickQualityPreset =>
|
|||||||
|
|
||||||
const buildAudioSelectors = (preset: OneClickQualityPreset): string[] => {
|
const buildAudioSelectors = (preset: OneClickQualityPreset): string[] => {
|
||||||
if (preset === 'worst') {
|
if (preset === 'worst') {
|
||||||
return ['worstaudio']
|
return dedupe(['worstaudio', 'bestaudio'])
|
||||||
}
|
}
|
||||||
|
|
||||||
const abrLimit = qualityPresetToAudioAbr[preset]
|
const abrLimit = qualityPresetToAudioAbr[preset]
|
||||||
// Remove 'best' fallback to ensure merging - only use 'bestaudio' variants
|
// Prefer audio-only selectors so video+audio merges remain valid.
|
||||||
return dedupe([abrLimit ? `bestaudio[abr<=${abrLimit}]` : undefined, 'bestaudio'])
|
return dedupe([abrLimit ? `bestaudio[abr<=${abrLimit}]` : undefined, 'bestaudio'])
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -90,8 +90,8 @@ const buildVideoFormatPreference = (settings: AppSettings): string => {
|
|||||||
const preset = getQualityPreset(settings)
|
const preset = getQualityPreset(settings)
|
||||||
|
|
||||||
if (preset === 'worst') {
|
if (preset === 'worst') {
|
||||||
// Use worstvideo+worstaudio as fallback instead of 'worst' to ensure merging
|
// Prefer separate streams, then fall back to single-file selectors.
|
||||||
return 'worstvideo+worstaudio'
|
return 'worstvideo+worstaudio/worst/best'
|
||||||
}
|
}
|
||||||
|
|
||||||
const maxHeight = qualityPresetToVideoHeight[preset]
|
const maxHeight = qualityPresetToVideoHeight[preset]
|
||||||
@@ -114,16 +114,18 @@ const buildVideoFormatPreference = (settings: AppSettings): string => {
|
|||||||
combinations.push(video)
|
combinations.push(video)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Use bestvideo+bestaudio as fallback instead of 'best' to ensure merging
|
// Prefer merged formats, then allow 'best' as a compatibility fallback.
|
||||||
combinations.push('bestvideo+bestaudio')
|
combinations.push('bestvideo+bestaudio')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
combinations.push('best')
|
||||||
|
|
||||||
return dedupe(combinations).join('/')
|
return dedupe(combinations).join('/')
|
||||||
}
|
}
|
||||||
|
|
||||||
const buildAudioFormatPreference = (settings: AppSettings): string => {
|
const buildAudioFormatPreference = (settings: AppSettings): string => {
|
||||||
const selectors = buildAudioSelectors(getQualityPreset(settings))
|
const selectors = buildAudioSelectors(getQualityPreset(settings))
|
||||||
return selectors.join('/')
|
return dedupe([...selectors, 'best']).join('/')
|
||||||
}
|
}
|
||||||
|
|
||||||
interface DownloadDialogProps {
|
interface DownloadDialogProps {
|
||||||
@@ -788,11 +790,12 @@ export function DownloadDialog({ onOpenSupportedSites, onOpenSettings }: Downloa
|
|||||||
type,
|
type,
|
||||||
format:
|
format:
|
||||||
type === 'video'
|
type === 'video'
|
||||||
? videoInfoCardState.selectedVideoFormat
|
? videoInfoCardState.selectedVideoFormat || undefined
|
||||||
: type === 'extract'
|
: type === 'extract'
|
||||||
? undefined
|
? undefined
|
||||||
: videoInfoCardState.selectedAudioFormat,
|
: videoInfoCardState.selectedAudioFormat || undefined,
|
||||||
audioFormat: type === 'video' ? videoInfoCardState.selectedAudioForVideo : undefined,
|
audioFormat:
|
||||||
|
type === 'video' ? videoInfoCardState.selectedAudioForVideo || undefined : undefined,
|
||||||
extractFormat:
|
extractFormat:
|
||||||
type === 'extract' ? videoInfoCardState.audioExtractor.extractFormat : undefined,
|
type === 'extract' ? videoInfoCardState.audioExtractor.extractFormat : undefined,
|
||||||
extractQuality:
|
extractQuality:
|
||||||
@@ -935,29 +938,33 @@ export function DownloadDialog({ onOpenSupportedSites, onOpenSettings }: Downloa
|
|||||||
{t('sites.viewAll')}
|
{t('sites.viewAll')}
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{settings.oneClickDownload && (
|
|
||||||
<div className="flex items-center gap-2 text-xs text-primary">
|
|
||||||
<div className="w-1.5 h-1.5 rounded-full bg-primary" />
|
|
||||||
<span>{t('download.oneClickDownloadEnabled')}</span>
|
|
||||||
{onOpenSettings && (
|
|
||||||
<Button
|
|
||||||
type="button"
|
|
||||||
variant="ghost"
|
|
||||||
size="sm"
|
|
||||||
className="text-xs h-auto"
|
|
||||||
onClick={() => {
|
|
||||||
setOpen(false)
|
|
||||||
onOpenSettings()
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{t('download.goToSettings')}
|
|
||||||
</Button>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{/* One-click download indicator */}
|
||||||
|
{settings.oneClickDownload && (
|
||||||
|
<div className="w-full">
|
||||||
|
<div className="rounded-lg border bg-muted/30 p-2.5">
|
||||||
|
<div className="flex items-center gap-2 text-xs text-muted-foreground">
|
||||||
|
<span>{t('download.oneClickDownloadEnabled')}</span>
|
||||||
|
{onOpenSettings && (
|
||||||
|
<Button
|
||||||
|
type="button"
|
||||||
|
variant="ghost"
|
||||||
|
size="sm"
|
||||||
|
className="text-xs h-auto"
|
||||||
|
onClick={() => {
|
||||||
|
setOpen(false)
|
||||||
|
onOpenSettings()
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{t('download.goToSettings')}
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
{/* Error Display */}
|
{/* Error Display */}
|
||||||
{error && (
|
{error && (
|
||||||
<div className="rounded-lg border border-destructive/20 bg-destructive/5 p-3">
|
<div className="rounded-lg border border-destructive/20 bg-destructive/5 p-3">
|
||||||
|
|||||||
152
src/renderer/src/components/error/ErrorBoundary.tsx
Normal file
152
src/renderer/src/components/error/ErrorBoundary.tsx
Normal file
@@ -0,0 +1,152 @@
|
|||||||
|
import { ipcServices } from '@renderer/lib/ipc'
|
||||||
|
import { logger } from '@renderer/lib/logger'
|
||||||
|
import { Component, type ErrorInfo, type ReactNode } from 'react'
|
||||||
|
import { type ErrorInfo as ErrorInfoType, ErrorPage } from './ErrorPage'
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
children: ReactNode
|
||||||
|
onError?: (error: Error, errorInfo: ErrorInfo) => void
|
||||||
|
fallback?: (errorInfo: ErrorInfoType) => ReactNode
|
||||||
|
}
|
||||||
|
|
||||||
|
interface State {
|
||||||
|
hasError: boolean
|
||||||
|
errorInfo: ErrorInfoType | null
|
||||||
|
}
|
||||||
|
|
||||||
|
export class ErrorBoundary extends Component<Props, State> {
|
||||||
|
constructor(props: Props) {
|
||||||
|
super(props)
|
||||||
|
this.state = {
|
||||||
|
hasError: false,
|
||||||
|
errorInfo: null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static getDerivedStateFromError(error: Error): Partial<State> {
|
||||||
|
const errorInfo = {
|
||||||
|
error,
|
||||||
|
timestamp: Date.now(),
|
||||||
|
context: {
|
||||||
|
url: window.location.href,
|
||||||
|
userAgent: navigator.userAgent,
|
||||||
|
platform: navigator.platform
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Log error details immediately
|
||||||
|
logger.error('ErrorBoundary: getDerivedStateFromError called', {
|
||||||
|
errorName: error.name,
|
||||||
|
errorMessage: error.message,
|
||||||
|
errorStack: error.stack,
|
||||||
|
url: errorInfo.context.url,
|
||||||
|
timestamp: errorInfo.timestamp
|
||||||
|
})
|
||||||
|
|
||||||
|
return {
|
||||||
|
hasError: true,
|
||||||
|
errorInfo
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async componentDidCatch(error: Error, errorInfo: ErrorInfo): Promise<void> {
|
||||||
|
logger.error('ErrorBoundary caught an error:', {
|
||||||
|
errorName: error.name,
|
||||||
|
errorMessage: error.message,
|
||||||
|
errorStack: error.stack,
|
||||||
|
componentStack: errorInfo.componentStack,
|
||||||
|
errorInfo: JSON.stringify(errorInfo, null, 2)
|
||||||
|
})
|
||||||
|
|
||||||
|
// Get app version if available
|
||||||
|
let appVersion: string | undefined
|
||||||
|
try {
|
||||||
|
if (window?.api && ipcServices?.app) {
|
||||||
|
appVersion = await ipcServices.app.getVersion()
|
||||||
|
logger.info('ErrorBoundary: App version retrieved', { appVersion })
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
logger.warn('Failed to get app version:', err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update state with component stack and version
|
||||||
|
if (this.state.errorInfo) {
|
||||||
|
this.setState({
|
||||||
|
errorInfo: {
|
||||||
|
...this.state.errorInfo,
|
||||||
|
context: {
|
||||||
|
...this.state.errorInfo.context,
|
||||||
|
version: appVersion
|
||||||
|
},
|
||||||
|
errorInfo: {
|
||||||
|
componentStack: errorInfo.componentStack || undefined
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// Call optional error handler
|
||||||
|
if (this.props.onError) {
|
||||||
|
this.props.onError(error, errorInfo)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Send error to main process if available
|
||||||
|
if (window?.api) {
|
||||||
|
try {
|
||||||
|
window.api.send('error:renderer', {
|
||||||
|
error: {
|
||||||
|
name: error.name,
|
||||||
|
message: error.message,
|
||||||
|
stack: error.stack
|
||||||
|
},
|
||||||
|
errorInfo: {
|
||||||
|
componentStack: errorInfo.componentStack
|
||||||
|
},
|
||||||
|
timestamp: Date.now(),
|
||||||
|
context: {
|
||||||
|
url: window.location.href,
|
||||||
|
userAgent: navigator.userAgent,
|
||||||
|
platform: navigator.platform,
|
||||||
|
version: appVersion
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} catch (err) {
|
||||||
|
logger.error('Failed to send error to main process:', err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
handleReload = (): void => {
|
||||||
|
this.setState({
|
||||||
|
hasError: false,
|
||||||
|
errorInfo: null
|
||||||
|
})
|
||||||
|
window.location.reload()
|
||||||
|
}
|
||||||
|
|
||||||
|
handleGoHome = (): void => {
|
||||||
|
this.setState({
|
||||||
|
hasError: false,
|
||||||
|
errorInfo: null
|
||||||
|
})
|
||||||
|
window.location.hash = '/'
|
||||||
|
window.location.reload()
|
||||||
|
}
|
||||||
|
|
||||||
|
render(): ReactNode {
|
||||||
|
if (this.state.hasError && this.state.errorInfo) {
|
||||||
|
if (this.props.fallback) {
|
||||||
|
return this.props.fallback(this.state.errorInfo)
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<ErrorPage
|
||||||
|
errorInfo={this.state.errorInfo}
|
||||||
|
onReload={this.handleReload}
|
||||||
|
onGoHome={this.handleGoHome}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.props.children
|
||||||
|
}
|
||||||
|
}
|
||||||
200
src/renderer/src/components/error/ErrorPage.tsx
Normal file
200
src/renderer/src/components/error/ErrorPage.tsx
Normal file
@@ -0,0 +1,200 @@
|
|||||||
|
import { Button } from '@renderer/components/ui/button'
|
||||||
|
import {
|
||||||
|
Card,
|
||||||
|
CardContent,
|
||||||
|
CardDescription,
|
||||||
|
CardHeader,
|
||||||
|
CardTitle
|
||||||
|
} from '@renderer/components/ui/card'
|
||||||
|
import { ScrollArea } from '@renderer/components/ui/scroll-area'
|
||||||
|
import { Textarea } from '@renderer/components/ui/textarea'
|
||||||
|
import { logger } from '@renderer/lib/logger'
|
||||||
|
import { AlertTriangle, Copy, Home, RefreshCw } from 'lucide-react'
|
||||||
|
import { useState } from 'react'
|
||||||
|
import { useTranslation } from 'react-i18next'
|
||||||
|
import { toast } from 'sonner'
|
||||||
|
|
||||||
|
export interface ErrorInfo {
|
||||||
|
error: Error
|
||||||
|
errorInfo?: {
|
||||||
|
componentStack?: string
|
||||||
|
}
|
||||||
|
timestamp: number
|
||||||
|
context?: {
|
||||||
|
url?: string
|
||||||
|
userAgent?: string
|
||||||
|
platform?: string
|
||||||
|
version?: string
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ErrorPageProps {
|
||||||
|
errorInfo: ErrorInfo
|
||||||
|
onReload?: () => void
|
||||||
|
onGoHome?: () => void
|
||||||
|
}
|
||||||
|
|
||||||
|
export function ErrorPage({ errorInfo, onReload, onGoHome }: ErrorPageProps) {
|
||||||
|
const { t } = useTranslation()
|
||||||
|
const [showDetails, setShowDetails] = useState(false)
|
||||||
|
const [copied, setCopied] = useState(false)
|
||||||
|
|
||||||
|
const errorReport = generateErrorReport(errorInfo)
|
||||||
|
|
||||||
|
const handleCopy = async () => {
|
||||||
|
try {
|
||||||
|
await navigator.clipboard.writeText(errorReport)
|
||||||
|
setCopied(true)
|
||||||
|
toast.success(t('error.copySuccess'))
|
||||||
|
setTimeout(() => setCopied(false), 2000)
|
||||||
|
} catch (error) {
|
||||||
|
logger.error('Failed to copy error report:', error)
|
||||||
|
toast.error(t('error.copyFailed'))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleReload = () => {
|
||||||
|
if (onReload) {
|
||||||
|
onReload()
|
||||||
|
} else {
|
||||||
|
window.location.reload()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="flex items-center justify-center min-h-screen bg-background p-4">
|
||||||
|
<Card className="w-full max-w-3xl">
|
||||||
|
<CardHeader>
|
||||||
|
<div className="flex items-center gap-3">
|
||||||
|
<div className="flex-shrink-0">
|
||||||
|
<AlertTriangle className="h-8 w-8 text-destructive" />
|
||||||
|
</div>
|
||||||
|
<div className="flex-1">
|
||||||
|
<CardTitle className="text-2xl">{t('error.title')}</CardTitle>
|
||||||
|
<CardDescription className="mt-2">{t('error.description')}</CardDescription>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</CardHeader>
|
||||||
|
<CardContent className="space-y-4">
|
||||||
|
{/* Error Message */}
|
||||||
|
<div className="rounded-md bg-destructive/10 border border-destructive/20 p-4">
|
||||||
|
<p className="text-sm font-medium text-destructive mb-1">{t('error.message')}</p>
|
||||||
|
<p className="text-sm text-foreground break-words">
|
||||||
|
{errorInfo.error.message || t('error.unknownError')}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Actions */}
|
||||||
|
<div className="flex flex-wrap gap-2">
|
||||||
|
{onGoHome && (
|
||||||
|
<Button variant="outline" onClick={onGoHome}>
|
||||||
|
<Home className="h-4 w-4 mr-2" />
|
||||||
|
{t('error.goHome')}
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
<Button variant="outline" onClick={handleReload}>
|
||||||
|
<RefreshCw className="h-4 w-4 mr-2" />
|
||||||
|
{t('error.reload')}
|
||||||
|
</Button>
|
||||||
|
<Button variant="outline" onClick={handleCopy}>
|
||||||
|
<Copy className="h-4 w-4 mr-2" />
|
||||||
|
{copied ? t('error.copied') : t('error.copyReport')}
|
||||||
|
</Button>
|
||||||
|
<Button variant="ghost" onClick={() => setShowDetails(!showDetails)}>
|
||||||
|
{showDetails ? t('error.hideDetails') : t('error.showDetails')}
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Error Details */}
|
||||||
|
{showDetails && (
|
||||||
|
<div className="space-y-4">
|
||||||
|
<div>
|
||||||
|
<p className="text-sm font-medium mb-2">{t('error.stackTrace')}</p>
|
||||||
|
<ScrollArea className="h-48 rounded-md border bg-muted/50 p-4">
|
||||||
|
<pre className="text-xs font-mono whitespace-pre-wrap break-words">
|
||||||
|
{errorInfo.error.stack || t('error.noStackTrace')}
|
||||||
|
</pre>
|
||||||
|
</ScrollArea>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{errorInfo.errorInfo?.componentStack && (
|
||||||
|
<div>
|
||||||
|
<p className="text-sm font-medium mb-2">{t('error.componentStack')}</p>
|
||||||
|
<ScrollArea className="h-32 rounded-md border bg-muted/50 p-4">
|
||||||
|
<pre className="text-xs font-mono whitespace-pre-wrap break-words">
|
||||||
|
{errorInfo.errorInfo.componentStack}
|
||||||
|
</pre>
|
||||||
|
</ScrollArea>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<p className="text-sm font-medium mb-2">{t('error.fullReport')}</p>
|
||||||
|
<Textarea
|
||||||
|
readOnly
|
||||||
|
value={errorReport}
|
||||||
|
className="font-mono text-xs min-h-48"
|
||||||
|
onClick={(e) => {
|
||||||
|
const target = e.target as HTMLTextAreaElement
|
||||||
|
target.select()
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{/* Help Text */}
|
||||||
|
<div className="rounded-md bg-muted/50 border p-4">
|
||||||
|
<p className="text-sm text-muted-foreground">{t('error.helpText')}</p>
|
||||||
|
</div>
|
||||||
|
</CardContent>
|
||||||
|
</Card>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function generateErrorReport(errorInfo: ErrorInfo): string {
|
||||||
|
const lines: string[] = []
|
||||||
|
|
||||||
|
lines.push('=== VidBee Error Report ===')
|
||||||
|
lines.push(`Timestamp: ${new Date(errorInfo.timestamp).toISOString()}`)
|
||||||
|
lines.push('')
|
||||||
|
|
||||||
|
if (errorInfo.context) {
|
||||||
|
lines.push('--- Context ---')
|
||||||
|
if (errorInfo.context.version) {
|
||||||
|
lines.push(`App Version: ${errorInfo.context.version}`)
|
||||||
|
}
|
||||||
|
if (errorInfo.context.platform) {
|
||||||
|
lines.push(`Platform: ${errorInfo.context.platform}`)
|
||||||
|
}
|
||||||
|
if (errorInfo.context.url) {
|
||||||
|
lines.push(`URL: ${errorInfo.context.url}`)
|
||||||
|
}
|
||||||
|
if (errorInfo.context.userAgent) {
|
||||||
|
lines.push(`User Agent: ${errorInfo.context.userAgent}`)
|
||||||
|
}
|
||||||
|
lines.push('')
|
||||||
|
}
|
||||||
|
|
||||||
|
lines.push('--- Error ---')
|
||||||
|
lines.push(`Name: ${errorInfo.error.name}`)
|
||||||
|
lines.push(`Message: ${errorInfo.error.message}`)
|
||||||
|
lines.push('')
|
||||||
|
|
||||||
|
if (errorInfo.error.stack) {
|
||||||
|
lines.push('--- Stack Trace ---')
|
||||||
|
lines.push(errorInfo.error.stack)
|
||||||
|
lines.push('')
|
||||||
|
}
|
||||||
|
|
||||||
|
if (errorInfo.errorInfo?.componentStack) {
|
||||||
|
lines.push('--- Component Stack ---')
|
||||||
|
lines.push(errorInfo.errorInfo.componentStack)
|
||||||
|
lines.push('')
|
||||||
|
}
|
||||||
|
|
||||||
|
lines.push('=== End of Report ===')
|
||||||
|
|
||||||
|
return lines.join('\n')
|
||||||
|
}
|
||||||
39
src/renderer/src/components/ui/popover.tsx
Normal file
39
src/renderer/src/components/ui/popover.tsx
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
import * as PopoverPrimitive from '@radix-ui/react-popover'
|
||||||
|
import { cn } from '@renderer/lib/utils'
|
||||||
|
import type * as React from 'react'
|
||||||
|
|
||||||
|
function Popover({ ...props }: React.ComponentProps<typeof PopoverPrimitive.Root>) {
|
||||||
|
return <PopoverPrimitive.Root data-slot="popover" {...props} />
|
||||||
|
}
|
||||||
|
|
||||||
|
function PopoverTrigger({ ...props }: React.ComponentProps<typeof PopoverPrimitive.Trigger>) {
|
||||||
|
return <PopoverPrimitive.Trigger data-slot="popover-trigger" {...props} />
|
||||||
|
}
|
||||||
|
|
||||||
|
function PopoverContent({
|
||||||
|
className,
|
||||||
|
align = 'center',
|
||||||
|
sideOffset = 4,
|
||||||
|
...props
|
||||||
|
}: React.ComponentProps<typeof PopoverPrimitive.Content>) {
|
||||||
|
return (
|
||||||
|
<PopoverPrimitive.Portal>
|
||||||
|
<PopoverPrimitive.Content
|
||||||
|
data-slot="popover-content"
|
||||||
|
align={align}
|
||||||
|
sideOffset={sideOffset}
|
||||||
|
className={cn(
|
||||||
|
'bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-72 origin-(--radix-popover-content-transform-origin) rounded-md border p-4 shadow-md outline-hidden',
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
</PopoverPrimitive.Portal>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function PopoverAnchor({ ...props }: React.ComponentProps<typeof PopoverPrimitive.Anchor>) {
|
||||||
|
return <PopoverPrimitive.Anchor data-slot="popover-anchor" {...props} />
|
||||||
|
}
|
||||||
|
|
||||||
|
export { Popover, PopoverTrigger, PopoverContent, PopoverAnchor }
|
||||||
@@ -67,6 +67,8 @@ interface RemoteImageProps {
|
|||||||
* />
|
* />
|
||||||
* ```
|
* ```
|
||||||
*/
|
*/
|
||||||
|
const IMAGE_LOAD_TIMEOUT_MS = 30000
|
||||||
|
|
||||||
export function RemoteImage({
|
export function RemoteImage({
|
||||||
src,
|
src,
|
||||||
alt,
|
alt,
|
||||||
@@ -91,8 +93,10 @@ export function RemoteImage({
|
|||||||
const imageSrc = shouldUseCache ? cachedSrc : (src ?? undefined)
|
const imageSrc = shouldUseCache ? cachedSrc : (src ?? undefined)
|
||||||
|
|
||||||
const [isImageLoading, setIsImageLoading] = useState(true)
|
const [isImageLoading, setIsImageLoading] = useState(true)
|
||||||
|
const [timedOutSrc, setTimedOutSrc] = useState<string | null>(null)
|
||||||
const isCacheLoading = shouldUseCache && src && cachedSrc === undefined
|
const isCacheLoading = shouldUseCache && src && cachedSrc === undefined
|
||||||
const isLoading = isCacheLoading || isImageLoading
|
const hasTimedOut = Boolean(src) && timedOutSrc === src
|
||||||
|
const isLoading = !hasTimedOut && (isCacheLoading || isImageLoading)
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (imageSrc) {
|
if (imageSrc) {
|
||||||
@@ -102,6 +106,19 @@ export function RemoteImage({
|
|||||||
}
|
}
|
||||||
}, [imageSrc])
|
}, [imageSrc])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!src || hasTimedOut || !isLoading) return
|
||||||
|
|
||||||
|
const timeoutId = window.setTimeout(() => {
|
||||||
|
setTimedOutSrc(src)
|
||||||
|
setIsImageLoading(false)
|
||||||
|
}, IMAGE_LOAD_TIMEOUT_MS)
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
window.clearTimeout(timeoutId)
|
||||||
|
}
|
||||||
|
}, [src, hasTimedOut, isLoading])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
onLoadingChange?.(isLoading)
|
onLoadingChange?.(isLoading)
|
||||||
}, [isLoading, onLoadingChange])
|
}, [isLoading, onLoadingChange])
|
||||||
|
|||||||
@@ -1,22 +1,13 @@
|
|||||||
import { Button } from '@renderer/components/ui/button'
|
import { Button } from '@renderer/components/ui/button'
|
||||||
import {
|
|
||||||
DropdownMenu,
|
|
||||||
DropdownMenuContent,
|
|
||||||
DropdownMenuItem,
|
|
||||||
DropdownMenuTrigger
|
|
||||||
} from '@renderer/components/ui/dropdown-menu'
|
|
||||||
import { Tooltip, TooltipContent, TooltipTrigger } from '@renderer/components/ui/tooltip'
|
import { Tooltip, TooltipContent, TooltipTrigger } from '@renderer/components/ui/tooltip'
|
||||||
import { saveSettingAtom } from '@renderer/store/settings'
|
import { useAtom } from 'jotai'
|
||||||
import { type LanguageCode, languageList, normalizeLanguageCode } from '@shared/languages'
|
|
||||||
import { useSetAtom } from 'jotai'
|
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import { toast } from 'sonner'
|
|
||||||
import '../../assets/title-bar.css'
|
import '../../assets/title-bar.css'
|
||||||
|
import { updateAvailableAtom } from '@renderer/store/update'
|
||||||
import MingcuteCheckCircleFill from '~icons/mingcute/check-circle-fill'
|
import MingcuteCheckCircleFill from '~icons/mingcute/check-circle-fill'
|
||||||
import MingcuteCheckCircleLine from '~icons/mingcute/check-circle-line'
|
import MingcuteCheckCircleLine from '~icons/mingcute/check-circle-line'
|
||||||
import MingcuteDownload3Fill from '~icons/mingcute/download-3-fill'
|
import MingcuteDownload3Fill from '~icons/mingcute/download-3-fill'
|
||||||
import MingcuteDownload3Line from '~icons/mingcute/download-3-line'
|
import MingcuteDownload3Line from '~icons/mingcute/download-3-line'
|
||||||
import MingcuteGlobeLine from '~icons/mingcute/globe-2-line'
|
|
||||||
import MingcuteInformationFill from '~icons/mingcute/information-fill'
|
import MingcuteInformationFill from '~icons/mingcute/information-fill'
|
||||||
import MingcuteInformationLine from '~icons/mingcute/information-line'
|
import MingcuteInformationLine from '~icons/mingcute/information-line'
|
||||||
import MingcuteRssFill from '~icons/mingcute/rss-fill'
|
import MingcuteRssFill from '~icons/mingcute/rss-fill'
|
||||||
@@ -53,10 +44,8 @@ interface SidebarProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function Sidebar({ currentPage, onPageChange, onOpenSupportedSites }: SidebarProps) {
|
export function Sidebar({ currentPage, onPageChange, onOpenSupportedSites }: SidebarProps) {
|
||||||
const { t, i18n } = useTranslation()
|
const { t } = useTranslation()
|
||||||
const saveSetting = useSetAtom(saveSettingAtom)
|
const [updateAvailable] = useAtom(updateAvailableAtom)
|
||||||
|
|
||||||
const languageOptions = languageList
|
|
||||||
|
|
||||||
const navigationItems: NavigationItem[] = [
|
const navigationItems: NavigationItem[] = [
|
||||||
{
|
{
|
||||||
@@ -105,20 +94,6 @@ export function Sidebar({ currentPage, onPageChange, onOpenSupportedSites }: Sid
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
const activeLanguageCode = normalizeLanguageCode(i18n.language)
|
|
||||||
const currentLanguage =
|
|
||||||
languageOptions.find((option) => option.value === activeLanguageCode) ?? languageOptions[0]
|
|
||||||
|
|
||||||
const handleLanguageChange = async (value: LanguageCode) => {
|
|
||||||
if (activeLanguageCode === value) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
await saveSetting({ key: 'language', value })
|
|
||||||
await i18n.changeLanguage(value)
|
|
||||||
toast.success(t('notifications.settingsSaved'))
|
|
||||||
}
|
|
||||||
|
|
||||||
const renderNavigationItem = (item: NavigationItem, showLabel = true) => {
|
const renderNavigationItem = (item: NavigationItem, showLabel = true) => {
|
||||||
const isActive = item.id !== 'supported-sites' && currentPage === item.id
|
const isActive = item.id !== 'supported-sites' && currentPage === item.id
|
||||||
const IconComponent = isActive ? item.icon.active : item.icon.inactive
|
const IconComponent = isActive ? item.icon.active : item.icon.inactive
|
||||||
@@ -161,47 +136,11 @@ export function Sidebar({ currentPage, onPageChange, onOpenSupportedSites }: Sid
|
|||||||
|
|
||||||
<div className="flex-1" />
|
<div className="flex-1" />
|
||||||
|
|
||||||
{/* Language Selector */}
|
|
||||||
<div className="flex flex-col items-center gap-1">
|
|
||||||
<DropdownMenu>
|
|
||||||
<Tooltip>
|
|
||||||
<TooltipTrigger asChild>
|
|
||||||
<DropdownMenuTrigger asChild>
|
|
||||||
<Button variant="ghost" size="icon" className="no-drag rounded-2xl w-12 h-12">
|
|
||||||
<MingcuteGlobeLine className="h-5! w-5!" />
|
|
||||||
</Button>
|
|
||||||
</DropdownMenuTrigger>
|
|
||||||
</TooltipTrigger>
|
|
||||||
<TooltipContent side="right">
|
|
||||||
<p>{t('settings.language')}</p>
|
|
||||||
</TooltipContent>
|
|
||||||
</Tooltip>
|
|
||||||
<DropdownMenuContent side="right" align="end">
|
|
||||||
{languageOptions.map((option) => {
|
|
||||||
const isActive = option.value === currentLanguage.value
|
|
||||||
|
|
||||||
return (
|
|
||||||
<DropdownMenuItem
|
|
||||||
key={option.value}
|
|
||||||
onClick={() => void handleLanguageChange(option.value)}
|
|
||||||
className={isActive ? 'font-semibold bg-muted focus:bg-muted' : undefined}
|
|
||||||
aria-current={isActive}
|
|
||||||
>
|
|
||||||
<div className="flex items-center gap-2">
|
|
||||||
<span className={`${option.flag} rounded-xs text-base`} aria-hidden="true" />
|
|
||||||
<span lang={option.hreflang}>{option.name}</span>
|
|
||||||
</div>
|
|
||||||
</DropdownMenuItem>
|
|
||||||
)
|
|
||||||
})}
|
|
||||||
</DropdownMenuContent>
|
|
||||||
</DropdownMenu>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* Bottom Navigation Items */}
|
{/* Bottom Navigation Items */}
|
||||||
{bottomNavigationItems.map((item) => {
|
{bottomNavigationItems.map((item) => {
|
||||||
const isActive = currentPage === item.id
|
const isActive = currentPage === item.id
|
||||||
const IconComponent = isActive ? item.icon.active : item.icon.inactive
|
const IconComponent = isActive ? item.icon.active : item.icon.inactive
|
||||||
|
const showUpdateDot = item.id === 'about' && updateAvailable.available
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div key={item.id} className="flex flex-col items-center gap-1">
|
<div key={item.id} className="flex flex-col items-center gap-1">
|
||||||
@@ -211,9 +150,14 @@ export function Sidebar({ currentPage, onPageChange, onOpenSupportedSites }: Sid
|
|||||||
variant="ghost"
|
variant="ghost"
|
||||||
size="icon"
|
size="icon"
|
||||||
onClick={() => onPageChange(item.id)}
|
onClick={() => onPageChange(item.id)}
|
||||||
className={`no-drag rounded-2xl w-12 h-12 ${isActive ? 'bg-primary/10' : ''}`}
|
className={`no-drag rounded-2xl w-12 h-12 relative ${
|
||||||
|
isActive ? 'bg-primary/10' : ''
|
||||||
|
}`}
|
||||||
>
|
>
|
||||||
<IconComponent className={`h-5! w-5! ${isActive ? 'text-primary' : ''}`} />
|
<IconComponent className={`h-5! w-5! ${isActive ? 'text-primary' : ''}`} />
|
||||||
|
{showUpdateDot ? (
|
||||||
|
<span className="absolute top-2 right-2 h-2 w-2 rounded-full bg-red-500" />
|
||||||
|
) : null}
|
||||||
</Button>
|
</Button>
|
||||||
</TooltipTrigger>
|
</TooltipTrigger>
|
||||||
<TooltipContent side="right">
|
<TooltipContent side="right">
|
||||||
|
|||||||
@@ -73,23 +73,31 @@ export function FormatSelector({
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// Filter and sort formats
|
// Filter and sort formats
|
||||||
// Exclude m3u8/HLS formats as they are streaming formats not suitable for direct download
|
// Exclude m3u8/HLS formats as they are streaming formats not suitable for direct download
|
||||||
const videos = formats.filter(
|
const isVideoFormat = (format: VideoFormat) =>
|
||||||
(f) =>
|
format.video_ext !== 'none' && format.vcodec && format.vcodec !== 'none'
|
||||||
f.video_ext !== 'none' &&
|
const isAudioFormat = (format: VideoFormat) =>
|
||||||
f.vcodec &&
|
format.acodec &&
|
||||||
f.vcodec !== 'none' &&
|
format.acodec !== 'none' &&
|
||||||
f.protocol !== 'm3u8' &&
|
(format.video_ext === 'none' || !format.video_ext)
|
||||||
f.protocol !== 'm3u8_native'
|
const isHlsFormat = (format: VideoFormat) =>
|
||||||
|
format.protocol === 'm3u8' || format.protocol === 'm3u8_native'
|
||||||
|
|
||||||
|
const videoCandidates = formats.filter(
|
||||||
|
(format) => isVideoFormat(format) && !isHlsFormat(format)
|
||||||
)
|
)
|
||||||
const audios = formats.filter(
|
const audioCandidates = formats.filter(
|
||||||
(f) =>
|
(format) => isAudioFormat(format) && !isHlsFormat(format)
|
||||||
f.acodec &&
|
|
||||||
f.acodec !== 'none' &&
|
|
||||||
(f.video_ext === 'none' || !f.video_ext) &&
|
|
||||||
f.protocol !== 'm3u8' &&
|
|
||||||
f.protocol !== 'm3u8_native'
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const videos =
|
||||||
|
videoCandidates.length > 0
|
||||||
|
? videoCandidates
|
||||||
|
: formats.filter((format) => isVideoFormat(format))
|
||||||
|
const audios =
|
||||||
|
audioCandidates.length > 0
|
||||||
|
? audioCandidates
|
||||||
|
: formats.filter((format) => isAudioFormat(format))
|
||||||
|
|
||||||
// Apply showMoreFormats filter
|
// Apply showMoreFormats filter
|
||||||
const filteredVideos = settings.showMoreFormats
|
const filteredVideos = settings.showMoreFormats
|
||||||
? videos
|
? videos
|
||||||
@@ -99,6 +107,9 @@ export function FormatSelector({
|
|||||||
? audios
|
? audios
|
||||||
: audios.filter((f) => f.ext !== 'webm')
|
: audios.filter((f) => f.ext !== 'webm')
|
||||||
|
|
||||||
|
const finalVideos = filteredVideos.length > 0 ? filteredVideos : videos
|
||||||
|
const finalAudios = filteredAudios.length > 0 ? filteredAudios : audios
|
||||||
|
|
||||||
// Sort formats by quality (best first)
|
// Sort formats by quality (best first)
|
||||||
const sortVideoFormatsByQuality = (a: VideoFormat, b: VideoFormat) => {
|
const sortVideoFormatsByQuality = (a: VideoFormat, b: VideoFormat) => {
|
||||||
// Sort by height (higher is better)
|
// Sort by height (higher is better)
|
||||||
@@ -138,23 +149,34 @@ export function FormatSelector({
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
filteredVideos.sort(sortVideoFormatsByQuality)
|
finalVideos.sort(sortVideoFormatsByQuality)
|
||||||
filteredAudios.sort(sortAudioFormatsByQuality)
|
finalAudios.sort(sortAudioFormatsByQuality)
|
||||||
|
|
||||||
setVideoFormats(filteredVideos)
|
setVideoFormats(finalVideos)
|
||||||
setAudioFormats(filteredAudios)
|
setAudioFormats(finalAudios)
|
||||||
|
|
||||||
// Auto-select best format based on preferences
|
// Auto-select best format based on preferences.
|
||||||
if (filteredVideos.length > 0 && !selectedVideo) {
|
// If no separate audio formats exist, prefer muxed video formats (with audio).
|
||||||
const preferred = pickVideoFormatForPreset(filteredVideos, settings.oneClickQuality)
|
const videosWithAudio = finalVideos.filter(
|
||||||
|
(format) => format.acodec && format.acodec !== 'none'
|
||||||
|
)
|
||||||
|
const autoVideos =
|
||||||
|
finalAudios.length > 0
|
||||||
|
? finalVideos
|
||||||
|
: videosWithAudio.length > 0
|
||||||
|
? videosWithAudio
|
||||||
|
: finalVideos
|
||||||
|
|
||||||
|
if (autoVideos.length > 0 && !selectedVideo) {
|
||||||
|
const preferred = pickVideoFormatForPreset(autoVideos, settings.oneClickQuality)
|
||||||
if (preferred) {
|
if (preferred) {
|
||||||
setSelectedVideo(preferred.format_id)
|
setSelectedVideo(preferred.format_id)
|
||||||
onVideoFormatChange?.(preferred.format_id)
|
onVideoFormatChange?.(preferred.format_id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (filteredAudios.length > 0 && !selectedAudio) {
|
if (finalAudios.length > 0 && !selectedAudio) {
|
||||||
const best = filteredAudios[0]
|
const best = finalAudios[0]
|
||||||
setSelectedAudio(best.format_id)
|
setSelectedAudio(best.format_id)
|
||||||
onAudioFormatChange?.(best.format_id)
|
onAudioFormatChange?.(best.format_id)
|
||||||
}
|
}
|
||||||
@@ -215,67 +237,79 @@ export function FormatSelector({
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (type === 'video') {
|
if (type === 'video') {
|
||||||
|
if (videoFormats.length === 0 && audioFormats.length === 0) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="space-y-5">
|
<div className="space-y-5">
|
||||||
<div className="space-y-3">
|
{videoFormats.length > 0 && (
|
||||||
<Label className="text-sm font-semibold">{t('download.selectVideoFormat')}</Label>
|
<div className="space-y-3">
|
||||||
<Select
|
<Label className="text-sm font-semibold">{t('download.selectVideoFormat')}</Label>
|
||||||
value={selectedVideo}
|
<Select
|
||||||
onValueChange={(value) => {
|
value={selectedVideo}
|
||||||
setSelectedVideo(value)
|
onValueChange={(value) => {
|
||||||
onVideoFormatChange?.(value)
|
setSelectedVideo(value)
|
||||||
}}
|
onVideoFormatChange?.(value)
|
||||||
>
|
}}
|
||||||
<SelectTrigger className="h-11">
|
>
|
||||||
<SelectValue />
|
<SelectTrigger className="h-11">
|
||||||
</SelectTrigger>
|
<SelectValue />
|
||||||
<SelectContent className="max-h-[300px] p-1.5">
|
</SelectTrigger>
|
||||||
{videoFormats.map((format) => (
|
<SelectContent className="max-h-[300px] p-1.5">
|
||||||
<SelectItem
|
{videoFormats.map((format) => (
|
||||||
key={format.format_id}
|
<SelectItem
|
||||||
value={format.format_id}
|
key={format.format_id}
|
||||||
className="cursor-pointer py-2.5"
|
value={format.format_id}
|
||||||
>
|
className="cursor-pointer py-2.5"
|
||||||
<span className="text-sm">{formatVideoLabel(format)}</span>
|
>
|
||||||
</SelectItem>
|
<span className="text-sm">{formatVideoLabel(format)}</span>
|
||||||
))}
|
</SelectItem>
|
||||||
</SelectContent>
|
))}
|
||||||
</Select>
|
</SelectContent>
|
||||||
</div>
|
</Select>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
<div className="space-y-3">
|
{audioFormats.length > 0 && (
|
||||||
<Label className="text-sm font-semibold">{t('download.selectAudioFormat')}</Label>
|
<div className="space-y-3">
|
||||||
<Select
|
<Label className="text-sm font-semibold">{t('download.selectAudioFormat')}</Label>
|
||||||
value={selectedAudio}
|
<Select
|
||||||
onValueChange={(value) => {
|
value={selectedAudio}
|
||||||
setSelectedAudio(value)
|
onValueChange={(value) => {
|
||||||
onAudioFormatChange?.(value)
|
setSelectedAudio(value)
|
||||||
}}
|
onAudioFormatChange?.(value)
|
||||||
>
|
}}
|
||||||
<SelectTrigger className="h-11">
|
>
|
||||||
<SelectValue />
|
<SelectTrigger className="h-11">
|
||||||
</SelectTrigger>
|
<SelectValue />
|
||||||
<SelectContent className="max-h-[300px] p-1.5">
|
</SelectTrigger>
|
||||||
<SelectItem value="none" className="cursor-pointer py-2.5">
|
<SelectContent className="max-h-[300px] p-1.5">
|
||||||
<span className="text-sm">{t('download.noAudio')}</span>
|
<SelectItem value="none" className="cursor-pointer py-2.5">
|
||||||
</SelectItem>
|
<span className="text-sm">{t('download.noAudio')}</span>
|
||||||
{audioFormats.map((format) => (
|
|
||||||
<SelectItem
|
|
||||||
key={format.format_id}
|
|
||||||
value={format.format_id}
|
|
||||||
className="cursor-pointer py-2.5"
|
|
||||||
>
|
|
||||||
<span className="text-sm">{formatAudioLabel(format)}</span>
|
|
||||||
</SelectItem>
|
</SelectItem>
|
||||||
))}
|
{audioFormats.map((format) => (
|
||||||
</SelectContent>
|
<SelectItem
|
||||||
</Select>
|
key={format.format_id}
|
||||||
</div>
|
value={format.format_id}
|
||||||
|
className="cursor-pointer py-2.5"
|
||||||
|
>
|
||||||
|
<span className="text-sm">{formatAudioLabel(format)}</span>
|
||||||
|
</SelectItem>
|
||||||
|
))}
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Audio only
|
// Audio only
|
||||||
|
if (audioFormats.length === 0) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="space-y-3">
|
<div className="space-y-3">
|
||||||
<Label className="text-sm font-semibold">{t('download.selectFormat')}</Label>
|
<Label className="text-sm font-semibold">{t('download.selectFormat')}</Label>
|
||||||
|
|||||||
20
src/renderer/src/lib/logger.ts
Normal file
20
src/renderer/src/lib/logger.ts
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
/**
|
||||||
|
* Renderer process logger utility
|
||||||
|
* Use electron-log/renderer which automatically forwards logs to main process
|
||||||
|
*/
|
||||||
|
|
||||||
|
import log from 'electron-log/renderer'
|
||||||
|
|
||||||
|
// Export electron-log instance
|
||||||
|
export default log
|
||||||
|
|
||||||
|
// Export commonly used logging methods
|
||||||
|
export const logger = log
|
||||||
|
|
||||||
|
// Predefined scoped loggers
|
||||||
|
export const scopedLoggers = {
|
||||||
|
renderer: log.scope('renderer'),
|
||||||
|
error: log.scope('error'),
|
||||||
|
component: log.scope('component'),
|
||||||
|
api: log.scope('api')
|
||||||
|
}
|
||||||
@@ -371,8 +371,7 @@
|
|||||||
"showMoreFormats": "إظهار المزيد من خيارات التنسيق",
|
"showMoreFormats": "إظهار المزيد من خيارات التنسيق",
|
||||||
"showMoreFormatsDescription": "عرض خيارات التنسيق الإضافية في الواجهة",
|
"showMoreFormatsDescription": "عرض خيارات التنسيق الإضافية في الواجهة",
|
||||||
"subscriptionDefaults": {
|
"subscriptionDefaults": {
|
||||||
"filenameDescription": "النمط المستخدم عندما لا يتجاوز الاشتراك اسم ملفه.",
|
"filenameDescription": "النمط المستخدم عندما لا يتجاوز الاشتراك اسم ملفه."
|
||||||
"intervalDescription": "عدد مرات فحص VidBee لكل تغذية اشتراك (1-24 ساعة)."
|
|
||||||
},
|
},
|
||||||
"system": "النظام",
|
"system": "النظام",
|
||||||
"theme": "المظهر",
|
"theme": "المظهر",
|
||||||
@@ -393,7 +392,6 @@
|
|||||||
"description": "التحكم في مكان تخزين تحميلات الاشتراكات وعدد مرات فحص VidBee للفيديوهات الجديدة.",
|
"description": "التحكم في مكان تخزين تحميلات الاشتراكات وعدد مرات فحص VidBee للفيديوهات الجديدة.",
|
||||||
"downloadDirectory": "مجلد التحميل",
|
"downloadDirectory": "مجلد التحميل",
|
||||||
"filenameTemplate": "قالب اسم الملف (الملف فقط)",
|
"filenameTemplate": "قالب اسم الملف (الملف فقط)",
|
||||||
"checkInterval": "فترة الفحص (ساعات)",
|
|
||||||
"onlyLatest": "تحميل أحدث فيديو فقط",
|
"onlyLatest": "تحميل أحدث فيديو فقط",
|
||||||
"onlyLatestDescription": "عند التفعيل، يتخطى VidBee عناصر المتراكمة القديمة ويأخذ فقط آخر تحميل."
|
"onlyLatestDescription": "عند التفعيل، يتخطى VidBee عناصر المتراكمة القديمة ويأخذ فقط آخر تحميل."
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -371,8 +371,7 @@
|
|||||||
"showMoreFormats": "Mehr Formatoptionen anzeigen",
|
"showMoreFormats": "Mehr Formatoptionen anzeigen",
|
||||||
"showMoreFormatsDescription": "Zusätzliche Formatoptionen in der Benutzeroberfläche anzeigen",
|
"showMoreFormatsDescription": "Zusätzliche Formatoptionen in der Benutzeroberfläche anzeigen",
|
||||||
"subscriptionDefaults": {
|
"subscriptionDefaults": {
|
||||||
"filenameDescription": "Muster, das verwendet wird, wenn ein Abonnement seinen Dateinamen nicht überschreibt.",
|
"filenameDescription": "Muster, das verwendet wird, wenn ein Abonnement seinen Dateinamen nicht überschreibt."
|
||||||
"intervalDescription": "Wie oft VidBee jeden Abonnement-Feed überprüft (1-24 Stunden)."
|
|
||||||
},
|
},
|
||||||
"system": "System",
|
"system": "System",
|
||||||
"theme": "Design",
|
"theme": "Design",
|
||||||
@@ -393,7 +392,6 @@
|
|||||||
"description": "Steuern Sie, wo Abonnement-Downloads gespeichert werden und wie oft VidBee nach neuen Videos sucht.",
|
"description": "Steuern Sie, wo Abonnement-Downloads gespeichert werden und wie oft VidBee nach neuen Videos sucht.",
|
||||||
"downloadDirectory": "Download-Verzeichnis",
|
"downloadDirectory": "Download-Verzeichnis",
|
||||||
"filenameTemplate": "Dateinamen-Vorlage (nur Datei)",
|
"filenameTemplate": "Dateinamen-Vorlage (nur Datei)",
|
||||||
"checkInterval": "Prüfintervall (Stunden)",
|
|
||||||
"onlyLatest": "Nur das neueste Video herunterladen",
|
"onlyLatest": "Nur das neueste Video herunterladen",
|
||||||
"onlyLatestDescription": "Wenn aktiviert, überspringt VidBee ältere Backlog-Elemente und lädt nur den neuesten Upload."
|
"onlyLatestDescription": "Wenn aktiviert, überspringt VidBee ältere Backlog-Elemente und lädt nur den neuesten Upload."
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -50,10 +50,12 @@
|
|||||||
"documentation": "Help center",
|
"documentation": "Help center",
|
||||||
"documentationDescription": "Guides, FAQs, and common workflows.",
|
"documentationDescription": "Guides, FAQs, and common workflows.",
|
||||||
"feedback": "Feedback & issues",
|
"feedback": "Feedback & issues",
|
||||||
"feedbackDescription": "Share ideas or report issues on GitHub.",
|
"feedbackDescription": "Share ideas, report issues, or provide feedback through multiple channels.",
|
||||||
"githubIssues": "GitHub Issues",
|
"githubIssues": "GitHub",
|
||||||
"githubIssuesDescription": "Report bugs or request features on GitHub.",
|
"githubIssuesDescription": "Report bugs or request features on GitHub.",
|
||||||
"discord": "Discord Community",
|
"xFeedback": "Twitter",
|
||||||
|
"xFeedbackDescription": "Share feedback or suggestions on X by mentioning @nexmoex.",
|
||||||
|
"discord": "Discord",
|
||||||
"discordDescription": "Join our Discord community for discussions and support.",
|
"discordDescription": "Join our Discord community for discussions and support.",
|
||||||
"license": "License",
|
"license": "License",
|
||||||
"licenseDescription": "Review the open-source license terms.",
|
"licenseDescription": "Review the open-source license terms.",
|
||||||
@@ -204,6 +206,25 @@
|
|||||||
"subscription": "Subscription"
|
"subscription": "Subscription"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"error": {
|
||||||
|
"title": "Something went wrong",
|
||||||
|
"description": "An unexpected error occurred. Please try reloading the application or report this issue if it persists.",
|
||||||
|
"message": "Error Message",
|
||||||
|
"unknownError": "Unknown error occurred",
|
||||||
|
"goHome": "Go Home",
|
||||||
|
"reload": "Reload App",
|
||||||
|
"copyReport": "Copy Error Report",
|
||||||
|
"copied": "Copied!",
|
||||||
|
"copySuccess": "Error report copied to clipboard",
|
||||||
|
"copyFailed": "Failed to copy error report",
|
||||||
|
"showDetails": "Show Details",
|
||||||
|
"hideDetails": "Hide Details",
|
||||||
|
"stackTrace": "Stack Trace",
|
||||||
|
"componentStack": "Component Stack",
|
||||||
|
"noStackTrace": "No stack trace available",
|
||||||
|
"fullReport": "Full Error Report",
|
||||||
|
"helpText": "If this error persists, please copy the error report above and share it with the support team. You can find contact information in the About page."
|
||||||
|
},
|
||||||
"errors": {
|
"errors": {
|
||||||
"clickToCopy": "Click to copy details",
|
"clickToCopy": "Click to copy details",
|
||||||
"clipboardEmpty": "Clipboard is empty",
|
"clipboardEmpty": "Clipboard is empty",
|
||||||
@@ -379,6 +400,7 @@
|
|||||||
"fileSelectError": "Failed to select file",
|
"fileSelectError": "Failed to select file",
|
||||||
"general": "General",
|
"general": "General",
|
||||||
"language": "Language",
|
"language": "Language",
|
||||||
|
"languageDescription": "Choose your preferred language for the application interface",
|
||||||
"light": "Light",
|
"light": "Light",
|
||||||
"hideDockIcon": "Hide Dock icon",
|
"hideDockIcon": "Hide Dock icon",
|
||||||
"hideDockIconDescription": "Remove VidBee from the macOS Dock. Use the menu bar or tray icon to reopen the app.",
|
"hideDockIconDescription": "Remove VidBee from the macOS Dock. Use the menu bar or tray icon to reopen the app.",
|
||||||
@@ -412,8 +434,7 @@
|
|||||||
"showMoreFormats": "Show more format options",
|
"showMoreFormats": "Show more format options",
|
||||||
"showMoreFormatsDescription": "Display additional format options in the interface",
|
"showMoreFormatsDescription": "Display additional format options in the interface",
|
||||||
"subscriptionDefaults": {
|
"subscriptionDefaults": {
|
||||||
"filenameDescription": "Pattern used when a subscription does not override its filename.",
|
"filenameDescription": "Pattern used when a subscription does not override its filename."
|
||||||
"intervalDescription": "How often VidBee checks each subscription feed (1-24 hours)."
|
|
||||||
},
|
},
|
||||||
"system": "System",
|
"system": "System",
|
||||||
"theme": "Theme",
|
"theme": "Theme",
|
||||||
@@ -434,7 +455,6 @@
|
|||||||
"description": "Control where subscription downloads are stored and how often VidBee checks for new videos.",
|
"description": "Control where subscription downloads are stored and how often VidBee checks for new videos.",
|
||||||
"downloadDirectory": "Download directory",
|
"downloadDirectory": "Download directory",
|
||||||
"filenameTemplate": "Filename template",
|
"filenameTemplate": "Filename template",
|
||||||
"checkInterval": "Check interval (hours)",
|
|
||||||
"onlyLatest": "Download only the latest video",
|
"onlyLatest": "Download only the latest video",
|
||||||
"onlyLatestDescription": "When enabled, VidBee skips older backlog items and only grabs the newest upload."
|
"onlyLatestDescription": "When enabled, VidBee skips older backlog items and only grabs the newest upload."
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -371,8 +371,7 @@
|
|||||||
"showMoreFormats": "Mostrar más opciones de formato",
|
"showMoreFormats": "Mostrar más opciones de formato",
|
||||||
"showMoreFormatsDescription": "Mostrar opciones de formato adicionales en la interfaz",
|
"showMoreFormatsDescription": "Mostrar opciones de formato adicionales en la interfaz",
|
||||||
"subscriptionDefaults": {
|
"subscriptionDefaults": {
|
||||||
"filenameDescription": "Patrón usado cuando una suscripción no sobrescribe su nombre de archivo.",
|
"filenameDescription": "Patrón usado cuando una suscripción no sobrescribe su nombre de archivo."
|
||||||
"intervalDescription": "Con qué frecuencia VidBee verifica cada feed de suscripción (1-24 horas)."
|
|
||||||
},
|
},
|
||||||
"system": "Sistema",
|
"system": "Sistema",
|
||||||
"theme": "Tema",
|
"theme": "Tema",
|
||||||
@@ -393,7 +392,6 @@
|
|||||||
"description": "Controla dónde se almacenan las descargas de suscripciones y con qué frecuencia VidBee verifica nuevos videos.",
|
"description": "Controla dónde se almacenan las descargas de suscripciones y con qué frecuencia VidBee verifica nuevos videos.",
|
||||||
"downloadDirectory": "Directorio de descarga",
|
"downloadDirectory": "Directorio de descarga",
|
||||||
"filenameTemplate": "Plantilla de nombre de archivo (solo archivo)",
|
"filenameTemplate": "Plantilla de nombre de archivo (solo archivo)",
|
||||||
"checkInterval": "Intervalo de verificación (horas)",
|
|
||||||
"onlyLatest": "Descargar solo el último video",
|
"onlyLatest": "Descargar solo el último video",
|
||||||
"onlyLatestDescription": "Cuando está habilitado, VidBee omite elementos antiguos del backlog y solo toma la última carga."
|
"onlyLatestDescription": "Cuando está habilitado, VidBee omite elementos antiguos del backlog y solo toma la última carga."
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -371,8 +371,7 @@
|
|||||||
"showMoreFormats": "Afficher plus d'options de format",
|
"showMoreFormats": "Afficher plus d'options de format",
|
||||||
"showMoreFormatsDescription": "Afficher des options de format supplémentaires dans l'interface",
|
"showMoreFormatsDescription": "Afficher des options de format supplémentaires dans l'interface",
|
||||||
"subscriptionDefaults": {
|
"subscriptionDefaults": {
|
||||||
"filenameDescription": "Modèle utilisé lorsqu’un abonnement ne remplace pas son nom de fichier.",
|
"filenameDescription": "Modèle utilisé lorsqu’un abonnement ne remplace pas son nom de fichier."
|
||||||
"intervalDescription": "À quelle fréquence VidBee vérifie chaque flux d'abonnement (1 à 24 heures)."
|
|
||||||
},
|
},
|
||||||
"system": "Système",
|
"system": "Système",
|
||||||
"theme": "Thème",
|
"theme": "Thème",
|
||||||
@@ -485,7 +484,6 @@
|
|||||||
"title": "Ajouter un flux RSS"
|
"title": "Ajouter un flux RSS"
|
||||||
},
|
},
|
||||||
"defaults": {
|
"defaults": {
|
||||||
"checkInterval": "Intervalle de vérification (heures)",
|
|
||||||
"description": "Contrôlez où les téléchargements par abonnement sont stockés et à quelle fréquence VidBee recherche de nouvelles vidéos.",
|
"description": "Contrôlez où les téléchargements par abonnement sont stockés et à quelle fréquence VidBee recherche de nouvelles vidéos.",
|
||||||
"downloadDirectory": "Répertoire de téléchargement",
|
"downloadDirectory": "Répertoire de téléchargement",
|
||||||
"filenameTemplate": "Modèle de nom de fichier (fichier uniquement)",
|
"filenameTemplate": "Modèle de nom de fichier (fichier uniquement)",
|
||||||
|
|||||||
@@ -371,8 +371,7 @@
|
|||||||
"showMoreFormats": "Tampilkan lebih banyak opsi format",
|
"showMoreFormats": "Tampilkan lebih banyak opsi format",
|
||||||
"showMoreFormatsDescription": "Tampilkan opsi format tambahan di antarmuka",
|
"showMoreFormatsDescription": "Tampilkan opsi format tambahan di antarmuka",
|
||||||
"subscriptionDefaults": {
|
"subscriptionDefaults": {
|
||||||
"filenameDescription": "Pola yang digunakan ketika berlangganan tidak menimpa nama filenya.",
|
"filenameDescription": "Pola yang digunakan ketika berlangganan tidak menimpa nama filenya."
|
||||||
"intervalDescription": "Seberapa sering VidBee memeriksa setiap feed berlangganan (1-24 jam)."
|
|
||||||
},
|
},
|
||||||
"system": "Sistem",
|
"system": "Sistem",
|
||||||
"theme": "Tema",
|
"theme": "Tema",
|
||||||
@@ -393,7 +392,6 @@
|
|||||||
"description": "Kontrol di mana unduhan berlangganan disimpan dan seberapa sering VidBee memeriksa video baru.",
|
"description": "Kontrol di mana unduhan berlangganan disimpan dan seberapa sering VidBee memeriksa video baru.",
|
||||||
"downloadDirectory": "Direktori unduhan",
|
"downloadDirectory": "Direktori unduhan",
|
||||||
"filenameTemplate": "Template nama file (hanya file)",
|
"filenameTemplate": "Template nama file (hanya file)",
|
||||||
"checkInterval": "Interval pemeriksaan (jam)",
|
|
||||||
"onlyLatest": "Unduh hanya video terbaru",
|
"onlyLatest": "Unduh hanya video terbaru",
|
||||||
"onlyLatestDescription": "Saat diaktifkan, VidBee melewati item backlog lama dan hanya mengambil unggahan terbaru."
|
"onlyLatestDescription": "Saat diaktifkan, VidBee melewati item backlog lama dan hanya mengambil unggahan terbaru."
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -371,8 +371,7 @@
|
|||||||
"showMoreFormats": "Mostra più opzioni formato",
|
"showMoreFormats": "Mostra più opzioni formato",
|
||||||
"showMoreFormatsDescription": "Visualizza opzioni di formato aggiuntive nell'interfaccia",
|
"showMoreFormatsDescription": "Visualizza opzioni di formato aggiuntive nell'interfaccia",
|
||||||
"subscriptionDefaults": {
|
"subscriptionDefaults": {
|
||||||
"filenameDescription": "Modello utilizzato quando una sottoscrizione non sovrascrive il relativo nome file.",
|
"filenameDescription": "Modello utilizzato quando una sottoscrizione non sovrascrive il relativo nome file."
|
||||||
"intervalDescription": "La frequenza con cui VidBee controlla ciascun feed di abbonamento (1-24 ore)."
|
|
||||||
},
|
},
|
||||||
"system": "Sistema",
|
"system": "Sistema",
|
||||||
"theme": "Tema",
|
"theme": "Tema",
|
||||||
@@ -485,7 +484,6 @@
|
|||||||
"title": "Aggiungi RSS"
|
"title": "Aggiungi RSS"
|
||||||
},
|
},
|
||||||
"defaults": {
|
"defaults": {
|
||||||
"checkInterval": "Intervallo di controllo (ore)",
|
|
||||||
"description": "Controlla dove vengono archiviati i download degli abbonamenti e la frequenza con cui VidBee verifica la presenza di nuovi video.",
|
"description": "Controlla dove vengono archiviati i download degli abbonamenti e la frequenza con cui VidBee verifica la presenza di nuovi video.",
|
||||||
"downloadDirectory": "Scarica la directory",
|
"downloadDirectory": "Scarica la directory",
|
||||||
"filenameTemplate": "Modello nome file (solo file)",
|
"filenameTemplate": "Modello nome file (solo file)",
|
||||||
|
|||||||
@@ -371,8 +371,7 @@
|
|||||||
"showMoreFormats": "より多くのフォーマットオプションを表示",
|
"showMoreFormats": "より多くのフォーマットオプションを表示",
|
||||||
"showMoreFormatsDescription": "インターフェースに追加のフォーマットオプションを表示",
|
"showMoreFormatsDescription": "インターフェースに追加のフォーマットオプションを表示",
|
||||||
"subscriptionDefaults": {
|
"subscriptionDefaults": {
|
||||||
"filenameDescription": "サブスクリプションがそのファイル名をオーバーライドしない場合に使用されるパターン。",
|
"filenameDescription": "サブスクリプションがそのファイル名をオーバーライドしない場合に使用されるパターン。"
|
||||||
"intervalDescription": "VidBee が各サブスクリプション フィードをチェックする頻度 (1 ~ 24 時間)。"
|
|
||||||
},
|
},
|
||||||
"system": "システム",
|
"system": "システム",
|
||||||
"theme": "テーマ",
|
"theme": "テーマ",
|
||||||
@@ -485,7 +484,6 @@
|
|||||||
"title": "RSSを追加"
|
"title": "RSSを追加"
|
||||||
},
|
},
|
||||||
"defaults": {
|
"defaults": {
|
||||||
"checkInterval": "チェック間隔(時間)",
|
|
||||||
"description": "サブスクリプションのダウンロードが保存される場所と、VidBee が新しいビデオをチェックする頻度を制御します。",
|
"description": "サブスクリプションのダウンロードが保存される場所と、VidBee が新しいビデオをチェックする頻度を制御します。",
|
||||||
"downloadDirectory": "ダウンロードディレクトリ",
|
"downloadDirectory": "ダウンロードディレクトリ",
|
||||||
"filenameTemplate": "ファイル名のテンプレート (ファイルのみ)",
|
"filenameTemplate": "ファイル名のテンプレート (ファイルのみ)",
|
||||||
|
|||||||
@@ -371,8 +371,7 @@
|
|||||||
"showMoreFormats": "더 많은 형식 옵션 표시",
|
"showMoreFormats": "더 많은 형식 옵션 표시",
|
||||||
"showMoreFormatsDescription": "인터페이스에 추가 형식 옵션 표시",
|
"showMoreFormatsDescription": "인터페이스에 추가 형식 옵션 표시",
|
||||||
"subscriptionDefaults": {
|
"subscriptionDefaults": {
|
||||||
"filenameDescription": "구독이 파일 이름을 재정의하지 않을 때 사용되는 패턴입니다.",
|
"filenameDescription": "구독이 파일 이름을 재정의하지 않을 때 사용되는 패턴입니다."
|
||||||
"intervalDescription": "VidBee가 각 구독 피드를 확인하는 빈도(1~24시간)."
|
|
||||||
},
|
},
|
||||||
"system": "시스템",
|
"system": "시스템",
|
||||||
"theme": "테마",
|
"theme": "테마",
|
||||||
@@ -485,7 +484,6 @@
|
|||||||
"title": "RSS 추가"
|
"title": "RSS 추가"
|
||||||
},
|
},
|
||||||
"defaults": {
|
"defaults": {
|
||||||
"checkInterval": "확인 간격(시간)",
|
|
||||||
"description": "구독 다운로드가 저장되는 위치와 VidBee가 새 비디오를 확인하는 빈도를 제어합니다.",
|
"description": "구독 다운로드가 저장되는 위치와 VidBee가 새 비디오를 확인하는 빈도를 제어합니다.",
|
||||||
"downloadDirectory": "디렉토리 다운로드",
|
"downloadDirectory": "디렉토리 다운로드",
|
||||||
"filenameTemplate": "파일 이름 템플릿(파일만)",
|
"filenameTemplate": "파일 이름 템플릿(파일만)",
|
||||||
|
|||||||
@@ -371,8 +371,7 @@
|
|||||||
"showMoreFormats": "Mostrar mais opções de formato",
|
"showMoreFormats": "Mostrar mais opções de formato",
|
||||||
"showMoreFormatsDescription": "Exibir opções de formato adicionais na interface",
|
"showMoreFormatsDescription": "Exibir opções de formato adicionais na interface",
|
||||||
"subscriptionDefaults": {
|
"subscriptionDefaults": {
|
||||||
"filenameDescription": "Padrão usado quando uma assinatura não substitui seu nome de arquivo.",
|
"filenameDescription": "Padrão usado quando uma assinatura não substitui seu nome de arquivo."
|
||||||
"intervalDescription": "Com que frequência o VidBee verifica cada feed de assinatura (1 a 24 horas)."
|
|
||||||
},
|
},
|
||||||
"system": "Sistema",
|
"system": "Sistema",
|
||||||
"theme": "Tema",
|
"theme": "Tema",
|
||||||
@@ -485,7 +484,6 @@
|
|||||||
"title": "Adicionar RSS"
|
"title": "Adicionar RSS"
|
||||||
},
|
},
|
||||||
"defaults": {
|
"defaults": {
|
||||||
"checkInterval": "Intervalo de verificação (horas)",
|
|
||||||
"description": "Controle onde os downloads de assinaturas são armazenados e com que frequência o VidBee verifica novos vídeos.",
|
"description": "Controle onde os downloads de assinaturas são armazenados e com que frequência o VidBee verifica novos vídeos.",
|
||||||
"downloadDirectory": "Baixar diretório",
|
"downloadDirectory": "Baixar diretório",
|
||||||
"filenameTemplate": "Modelo de nome de arquivo (somente arquivo)",
|
"filenameTemplate": "Modelo de nome de arquivo (somente arquivo)",
|
||||||
|
|||||||
@@ -371,8 +371,7 @@
|
|||||||
"showMoreFormats": "Показать больше вариантов форматов",
|
"showMoreFormats": "Показать больше вариантов форматов",
|
||||||
"showMoreFormatsDescription": "Отображать дополнительные варианты форматов в интерфейсе",
|
"showMoreFormatsDescription": "Отображать дополнительные варианты форматов в интерфейсе",
|
||||||
"subscriptionDefaults": {
|
"subscriptionDefaults": {
|
||||||
"filenameDescription": "Шаблон, используемый, когда подписка не переопределяет имя файла.",
|
"filenameDescription": "Шаблон, используемый, когда подписка не переопределяет имя файла."
|
||||||
"intervalDescription": "Как часто VidBee проверяет каждый канал подписки (1-24 часа)."
|
|
||||||
},
|
},
|
||||||
"system": "Системная",
|
"system": "Системная",
|
||||||
"theme": "Тема",
|
"theme": "Тема",
|
||||||
@@ -393,7 +392,6 @@
|
|||||||
"description": "Управляйте, где хранятся загрузки подписок и как часто VidBee проверяет новые видео.",
|
"description": "Управляйте, где хранятся загрузки подписок и как часто VidBee проверяет новые видео.",
|
||||||
"downloadDirectory": "Директория загрузки",
|
"downloadDirectory": "Директория загрузки",
|
||||||
"filenameTemplate": "Шаблон имени файла (только файл)",
|
"filenameTemplate": "Шаблон имени файла (только файл)",
|
||||||
"checkInterval": "Интервал проверки (часы)",
|
|
||||||
"onlyLatest": "Загружать только последнее видео",
|
"onlyLatest": "Загружать только последнее видео",
|
||||||
"onlyLatestDescription": "При включении VidBee пропускает старые элементы из очереди и загружает только последнюю загрузку."
|
"onlyLatestDescription": "При включении VidBee пропускает старые элементы из очереди и загружает только последнюю загрузку."
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -372,8 +372,7 @@
|
|||||||
"showMoreFormats": "顯示更多格式選項",
|
"showMoreFormats": "顯示更多格式選項",
|
||||||
"showMoreFormatsDescription": "在介面中顯示額外的格式選項",
|
"showMoreFormatsDescription": "在介面中顯示額外的格式選項",
|
||||||
"subscriptionDefaults": {
|
"subscriptionDefaults": {
|
||||||
"filenameDescription": "當訂閱不覆蓋其文件名時使用的模式。",
|
"filenameDescription": "當訂閱不覆蓋其文件名時使用的模式。"
|
||||||
"intervalDescription": "VidBee 檢查每個訂閱源的頻率(1-24 小時)。"
|
|
||||||
},
|
},
|
||||||
"system": "系統",
|
"system": "系統",
|
||||||
"theme": "主題",
|
"theme": "主題",
|
||||||
@@ -486,7 +485,6 @@
|
|||||||
"title": "添加RSS"
|
"title": "添加RSS"
|
||||||
},
|
},
|
||||||
"defaults": {
|
"defaults": {
|
||||||
"checkInterval": "檢查間隔(小時)",
|
|
||||||
"description": "控制訂閱下載的存儲位置以及 VidBee 檢查新視頻的頻率。",
|
"description": "控制訂閱下載的存儲位置以及 VidBee 檢查新視頻的頻率。",
|
||||||
"downloadDirectory": "下載目錄",
|
"downloadDirectory": "下載目錄",
|
||||||
"filenameTemplate": "文件名模板(僅限文件)",
|
"filenameTemplate": "文件名模板(僅限文件)",
|
||||||
|
|||||||
@@ -372,8 +372,7 @@
|
|||||||
"showMoreFormats": "显示更多格式选项",
|
"showMoreFormats": "显示更多格式选项",
|
||||||
"showMoreFormatsDescription": "在界面中显示额外的格式选项",
|
"showMoreFormatsDescription": "在界面中显示额外的格式选项",
|
||||||
"subscriptionDefaults": {
|
"subscriptionDefaults": {
|
||||||
"filenameDescription": "当订阅不覆盖其文件名时使用的模式。",
|
"filenameDescription": "当订阅不覆盖其文件名时使用的模式。"
|
||||||
"intervalDescription": "VidBee 检查每个订阅源的频率(1-24 小时)。"
|
|
||||||
},
|
},
|
||||||
"system": "系统",
|
"system": "系统",
|
||||||
"theme": "主题",
|
"theme": "主题",
|
||||||
@@ -486,7 +485,6 @@
|
|||||||
"title": "添加RSS"
|
"title": "添加RSS"
|
||||||
},
|
},
|
||||||
"defaults": {
|
"defaults": {
|
||||||
"checkInterval": "检查间隔(小时)",
|
|
||||||
"description": "控制订阅下载的存储位置以及 VidBee 检查新视频的频率。",
|
"description": "控制订阅下载的存储位置以及 VidBee 检查新视频的频率。",
|
||||||
"downloadDirectory": "下载目录",
|
"downloadDirectory": "下载目录",
|
||||||
"filenameTemplate": "文件名模板(仅限文件)",
|
"filenameTemplate": "文件名模板(仅限文件)",
|
||||||
|
|||||||
@@ -6,6 +6,82 @@ import { StrictMode } from 'react'
|
|||||||
import { createRoot } from 'react-dom/client'
|
import { createRoot } from 'react-dom/client'
|
||||||
import App from './App'
|
import App from './App'
|
||||||
import './i18n'
|
import './i18n'
|
||||||
|
import { logger } from './lib/logger'
|
||||||
|
|
||||||
|
// Setup global error handlers
|
||||||
|
setupGlobalErrorHandlers()
|
||||||
|
|
||||||
|
// Get app version asynchronously
|
||||||
|
let appVersion: string | undefined
|
||||||
|
if (window?.api && window.electron?.ipcRenderer) {
|
||||||
|
import('./lib/ipc')
|
||||||
|
.then(({ ipcServices }) => ipcServices.app.getVersion())
|
||||||
|
.then((version) => {
|
||||||
|
appVersion = version
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
logger.warn('Failed to get app version for error reporting:', err)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function setupGlobalErrorHandlers(): void {
|
||||||
|
// Handle uncaught JavaScript errors
|
||||||
|
window.addEventListener('error', (event) => {
|
||||||
|
logger.error('Uncaught error:', event.error)
|
||||||
|
|
||||||
|
if (window?.api) {
|
||||||
|
try {
|
||||||
|
window.api.send('error:renderer', {
|
||||||
|
error: {
|
||||||
|
name: event.error?.name || 'Error',
|
||||||
|
message: event.error?.message || event.message || 'Unknown error',
|
||||||
|
stack: event.error?.stack || event.filename
|
||||||
|
},
|
||||||
|
timestamp: Date.now(),
|
||||||
|
context: {
|
||||||
|
url: window.location.href,
|
||||||
|
userAgent: navigator.userAgent,
|
||||||
|
platform: navigator.platform,
|
||||||
|
version: appVersion,
|
||||||
|
filename: event.filename,
|
||||||
|
lineno: event.lineno,
|
||||||
|
colno: event.colno
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} catch (err) {
|
||||||
|
logger.error('Failed to send error to main process:', err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
// Handle unhandled promise rejections
|
||||||
|
window.addEventListener('unhandledrejection', (event) => {
|
||||||
|
logger.error('Unhandled promise rejection:', event.reason)
|
||||||
|
|
||||||
|
if (window?.api) {
|
||||||
|
try {
|
||||||
|
const error = event.reason instanceof Error ? event.reason : new Error(String(event.reason))
|
||||||
|
|
||||||
|
window.api.send('error:renderer', {
|
||||||
|
error: {
|
||||||
|
name: error.name || 'UnhandledPromiseRejection',
|
||||||
|
message: error.message || String(event.reason),
|
||||||
|
stack: error.stack
|
||||||
|
},
|
||||||
|
timestamp: Date.now(),
|
||||||
|
context: {
|
||||||
|
url: window.location.href,
|
||||||
|
userAgent: navigator.userAgent,
|
||||||
|
platform: navigator.platform,
|
||||||
|
version: appVersion
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} catch (err) {
|
||||||
|
logger.error('Failed to send error to main process:', err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
const rootElement = document.getElementById('root')
|
const rootElement = document.getElementById('root')
|
||||||
if (!rootElement) {
|
if (!rootElement) {
|
||||||
|
|||||||
@@ -1,12 +1,6 @@
|
|||||||
import { Badge } from '@renderer/components/ui/badge'
|
import { Badge } from '@renderer/components/ui/badge'
|
||||||
import { Button } from '@renderer/components/ui/button'
|
import { Button } from '@renderer/components/ui/button'
|
||||||
import {
|
import { Card, CardContent, CardHeader, CardTitle } from '@renderer/components/ui/card'
|
||||||
Card,
|
|
||||||
CardContent,
|
|
||||||
CardDescription,
|
|
||||||
CardHeader,
|
|
||||||
CardTitle
|
|
||||||
} from '@renderer/components/ui/card'
|
|
||||||
import { Progress } from '@renderer/components/ui/progress'
|
import { Progress } from '@renderer/components/ui/progress'
|
||||||
import { Switch } from '@renderer/components/ui/switch'
|
import { Switch } from '@renderer/components/ui/switch'
|
||||||
import { useAtom, useSetAtom } from 'jotai'
|
import { useAtom, useSetAtom } from 'jotai'
|
||||||
@@ -18,14 +12,16 @@ import {
|
|||||||
Github,
|
Github,
|
||||||
Link as LinkIcon,
|
Link as LinkIcon,
|
||||||
MessageCircle,
|
MessageCircle,
|
||||||
|
MessageSquare,
|
||||||
RefreshCw,
|
RefreshCw,
|
||||||
Twitter
|
Twitter
|
||||||
} from 'lucide-react'
|
} from 'lucide-react'
|
||||||
import { useEffect, useMemo, useState } from 'react'
|
import { useCallback, useEffect, useMemo, useState } from 'react'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import { toast } from 'sonner'
|
import { toast } from 'sonner'
|
||||||
import { ipcEvents, ipcServices } from '../lib/ipc'
|
import { ipcEvents, ipcServices } from '../lib/ipc'
|
||||||
import { saveSettingAtom, settingsAtom } from '../store/settings'
|
import { saveSettingAtom, settingsAtom } from '../store/settings'
|
||||||
|
import { updateAvailableAtom, updateReadyAtom } from '../store/update'
|
||||||
|
|
||||||
interface AboutResource {
|
interface AboutResource {
|
||||||
icon: LucideIcon
|
icon: LucideIcon
|
||||||
@@ -45,6 +41,8 @@ type LatestVersionState =
|
|||||||
export function About() {
|
export function About() {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
const [settings, _setSettings] = useAtom(settingsAtom)
|
const [settings, _setSettings] = useAtom(settingsAtom)
|
||||||
|
const [updateReady] = useAtom(updateReadyAtom)
|
||||||
|
const setUpdateAvailable = useSetAtom(updateAvailableAtom)
|
||||||
const [appVersion, setAppVersion] = useState<string>('—')
|
const [appVersion, setAppVersion] = useState<string>('—')
|
||||||
const [latestVersionState, setLatestVersionState] = useState<LatestVersionState>(null)
|
const [latestVersionState, setLatestVersionState] = useState<LatestVersionState>(null)
|
||||||
const [updateDownloadProgress, setUpdateDownloadProgress] = useState<number | null>(null)
|
const [updateDownloadProgress, setUpdateDownloadProgress] = useState<number | null>(null)
|
||||||
@@ -88,6 +86,10 @@ export function About() {
|
|||||||
status: 'available',
|
status: 'available',
|
||||||
version: versionLabel
|
version: versionLabel
|
||||||
})
|
})
|
||||||
|
setUpdateAvailable({
|
||||||
|
available: true,
|
||||||
|
version: versionLabel
|
||||||
|
})
|
||||||
// Reset download progress when new update is available
|
// Reset download progress when new update is available
|
||||||
setUpdateDownloadProgress(0)
|
setUpdateDownloadProgress(0)
|
||||||
}
|
}
|
||||||
@@ -113,7 +115,7 @@ export function About() {
|
|||||||
ipcEvents.removeListener('update:download-progress', handleUpdateDownloadProgress)
|
ipcEvents.removeListener('update:download-progress', handleUpdateDownloadProgress)
|
||||||
ipcEvents.removeListener('update:downloaded', handleUpdateDownloaded)
|
ipcEvents.removeListener('update:downloaded', handleUpdateDownloaded)
|
||||||
}
|
}
|
||||||
}, [t])
|
}, [setUpdateAvailable, t])
|
||||||
|
|
||||||
const handleSettingChange = async (
|
const handleSettingChange = async (
|
||||||
key: keyof typeof settings,
|
key: keyof typeof settings,
|
||||||
@@ -135,6 +137,10 @@ export function About() {
|
|||||||
status: 'available',
|
status: 'available',
|
||||||
version: result.version ?? ''
|
version: result.version ?? ''
|
||||||
})
|
})
|
||||||
|
setUpdateAvailable({
|
||||||
|
available: true,
|
||||||
|
version: result.version
|
||||||
|
})
|
||||||
} else if (result.error) {
|
} else if (result.error) {
|
||||||
toast.error(t('about.notifications.updateError', { error: result.error }))
|
toast.error(t('about.notifications.updateError', { error: result.error }))
|
||||||
setLatestVersionState({
|
setLatestVersionState({
|
||||||
@@ -147,6 +153,10 @@ export function About() {
|
|||||||
status: 'uptodate',
|
status: 'uptodate',
|
||||||
version: result.version ?? appVersion
|
version: result.version ?? appVersion
|
||||||
})
|
})
|
||||||
|
setUpdateAvailable({
|
||||||
|
available: false,
|
||||||
|
version: undefined
|
||||||
|
})
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Failed to check for updates:', error)
|
console.error('Failed to check for updates:', error)
|
||||||
@@ -159,6 +169,10 @@ export function About() {
|
|||||||
openShareUrl('https://vidbee.org/download/')
|
openShareUrl('https://vidbee.org/download/')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const handleRestartToUpdate = () => {
|
||||||
|
void ipcServices.update.quitAndInstall()
|
||||||
|
}
|
||||||
|
|
||||||
const handleCheckForUpdates = async () => {
|
const handleCheckForUpdates = async () => {
|
||||||
try {
|
try {
|
||||||
toast.info(t('about.notifications.checkingUpdates'))
|
toast.info(t('about.notifications.checkingUpdates'))
|
||||||
@@ -170,6 +184,10 @@ export function About() {
|
|||||||
status: 'available',
|
status: 'available',
|
||||||
version: result.version ?? ''
|
version: result.version ?? ''
|
||||||
})
|
})
|
||||||
|
setUpdateAvailable({
|
||||||
|
available: true,
|
||||||
|
version: result.version
|
||||||
|
})
|
||||||
} else if (result.error) {
|
} else if (result.error) {
|
||||||
toast.error(t('about.notifications.updateError', { error: result.error }))
|
toast.error(t('about.notifications.updateError', { error: result.error }))
|
||||||
setLatestVersionState({
|
setLatestVersionState({
|
||||||
@@ -182,6 +200,10 @@ export function About() {
|
|||||||
status: 'uptodate',
|
status: 'uptodate',
|
||||||
version: result.version ?? appVersion
|
version: result.version ?? appVersion
|
||||||
})
|
})
|
||||||
|
setUpdateAvailable({
|
||||||
|
available: false,
|
||||||
|
version: undefined
|
||||||
|
})
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Failed to check for updates:', error)
|
console.error('Failed to check for updates:', error)
|
||||||
@@ -202,13 +224,13 @@ export function About() {
|
|||||||
}
|
}
|
||||||
}, [t])
|
}, [t])
|
||||||
|
|
||||||
const openShareUrl = (url: string) => {
|
const openShareUrl = useCallback((url: string) => {
|
||||||
if (typeof window === 'undefined') {
|
if (typeof window === 'undefined') {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
window.open(url, '_blank', 'noopener,noreferrer')
|
window.open(url, '_blank', 'noopener,noreferrer')
|
||||||
}
|
}, [])
|
||||||
|
|
||||||
const handleShareTwitter = () => {
|
const handleShareTwitter = () => {
|
||||||
openShareUrl(shareLinks.twitter)
|
openShareUrl(shareLinks.twitter)
|
||||||
@@ -243,6 +265,39 @@ export function About() {
|
|||||||
: 'text-muted-foreground'
|
: 'text-muted-foreground'
|
||||||
const latestVersionStatusText = latestVersionStatusKey ? t(latestVersionStatusKey) : null
|
const latestVersionStatusText = latestVersionStatusKey ? t(latestVersionStatusKey) : null
|
||||||
|
|
||||||
|
const handleXFeedback = useCallback(() => {
|
||||||
|
const versionText = appVersion !== '—' ? ` VidBee v${appVersion}` : ' VidBee'
|
||||||
|
const tweetText = encodeURIComponent(`@nexmoex${versionText}`)
|
||||||
|
openShareUrl(`https://x.com/intent/tweet?text=${tweetText}`)
|
||||||
|
}, [appVersion, openShareUrl])
|
||||||
|
|
||||||
|
const feedbackResources = useMemo<AboutResource[]>(
|
||||||
|
() => [
|
||||||
|
{
|
||||||
|
icon: Github,
|
||||||
|
label: t('about.resources.githubIssues'),
|
||||||
|
description: t('about.resources.githubIssuesDescription'),
|
||||||
|
actionLabel: t('about.actions.feedback'),
|
||||||
|
href: 'https://github.com/nexmoe/VidBee/issues/new/choose'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
icon: Twitter,
|
||||||
|
label: t('about.resources.xFeedback'),
|
||||||
|
description: t('about.resources.xFeedbackDescription'),
|
||||||
|
actionLabel: t('about.actions.feedback'),
|
||||||
|
onClick: handleXFeedback
|
||||||
|
},
|
||||||
|
{
|
||||||
|
icon: MessageCircle,
|
||||||
|
label: t('about.resources.discord'),
|
||||||
|
description: t('about.resources.discordDescription'),
|
||||||
|
actionLabel: t('about.actions.visit'),
|
||||||
|
href: 'https://discord.gg/uBqXV6QPdm'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[t, handleXFeedback]
|
||||||
|
)
|
||||||
|
|
||||||
const aboutResources = useMemo<AboutResource[]>(
|
const aboutResources = useMemo<AboutResource[]>(
|
||||||
() => [
|
() => [
|
||||||
{
|
{
|
||||||
@@ -258,20 +313,6 @@ export function About() {
|
|||||||
description: t('about.resources.changelogDescription'),
|
description: t('about.resources.changelogDescription'),
|
||||||
actionLabel: t('about.actions.view'),
|
actionLabel: t('about.actions.view'),
|
||||||
href: 'https://github.com/nexmoe/VidBee/releases'
|
href: 'https://github.com/nexmoe/VidBee/releases'
|
||||||
},
|
|
||||||
{
|
|
||||||
icon: Github,
|
|
||||||
label: t('about.resources.githubIssues'),
|
|
||||||
description: t('about.resources.githubIssuesDescription'),
|
|
||||||
actionLabel: t('about.actions.feedback'),
|
|
||||||
href: 'https://github.com/nexmoe/VidBee/issues/new/choose'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
icon: MessageCircle,
|
|
||||||
label: t('about.resources.discord'),
|
|
||||||
description: t('about.resources.discordDescription'),
|
|
||||||
actionLabel: t('about.actions.visit'),
|
|
||||||
href: 'https://discord.gg/uBqXV6QPdm'
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
[t]
|
[t]
|
||||||
@@ -282,69 +323,87 @@ export function About() {
|
|||||||
<div className="container mx-auto max-w-5xl p-6 space-y-6">
|
<div className="container mx-auto max-w-5xl p-6 space-y-6">
|
||||||
<Card>
|
<Card>
|
||||||
<CardContent className="pt-6">
|
<CardContent className="pt-6">
|
||||||
<div className="flex flex-col gap-4 md:flex-row md:items-center md:justify-between">
|
<div className="flex flex-col gap-4">
|
||||||
<div className="flex items-center gap-4">
|
<div className="flex items-center gap-4">
|
||||||
<img src="./app-icon.png" alt="VidBee" className="h-16 w-16 rounded-2xl" />
|
<img src="./app-icon.png" alt="VidBee" className="h-18 w-18 rounded-2xl" />
|
||||||
<div className="space-y-2">
|
<div className="flex-1 space-y-2">
|
||||||
<div>
|
<div className="flex items-center justify-between gap-4">
|
||||||
<h2 className="text-2xl font-semibold leading-tight">{t('about.appName')}</h2>
|
<div className="flex items-center gap-3">
|
||||||
<p className="text-sm text-muted-foreground">{t('about.description')}</p>
|
<h2 className="text-2xl font-semibold leading-tight">{t('about.appName')}</h2>
|
||||||
</div>
|
<Badge variant="secondary">
|
||||||
<div className="flex flex-wrap items-center gap-2">
|
{t('about.versionLabel', { version: appVersion })}
|
||||||
<Badge variant="secondary">
|
</Badge>
|
||||||
{t('about.versionLabel', { version: appVersion })}
|
{latestVersionState ? (
|
||||||
</Badge>
|
<div className="flex flex-wrap items-center gap-2">
|
||||||
{latestVersionState ? (
|
{latestVersionBadgeText ? (
|
||||||
<div className="flex flex-wrap items-center gap-2">
|
<Badge variant="outline">{latestVersionBadgeText}</Badge>
|
||||||
{latestVersionBadgeText ? (
|
) : null}
|
||||||
<Badge variant="outline">{latestVersionBadgeText}</Badge>
|
{latestVersionStatusText ? (
|
||||||
) : null}
|
<span className={`text-sm ${latestVersionStatusClass}`}>
|
||||||
{latestVersionStatusText ? (
|
{latestVersionStatusText}
|
||||||
<span className={`text-sm ${latestVersionStatusClass}`}>
|
</span>
|
||||||
{latestVersionStatusText}
|
) : null}
|
||||||
</span>
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
</div>
|
|
||||||
) : null}
|
|
||||||
</div>
|
|
||||||
{updateDownloadProgress !== null && (
|
|
||||||
<div className="space-y-2 w-full">
|
|
||||||
<div className="flex items-center justify-between gap-2">
|
|
||||||
<span className="text-sm text-muted-foreground">
|
|
||||||
{t('about.downloadingUpdate')}
|
|
||||||
</span>
|
|
||||||
<span className="text-sm font-medium">
|
|
||||||
{updateDownloadProgress.toFixed(1)}%
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
<Progress value={updateDownloadProgress} className="h-2" />
|
|
||||||
</div>
|
</div>
|
||||||
)}
|
<div className="flex flex-wrap items-center gap-2">
|
||||||
|
<Button variant="outline" size="sm" asChild>
|
||||||
|
<a
|
||||||
|
href="https://github.com/nexmoe/vidbee"
|
||||||
|
target="_blank"
|
||||||
|
rel="noreferrer"
|
||||||
|
aria-label={t('about.actions.openRepo')}
|
||||||
|
>
|
||||||
|
<Github className="h-3.5 w-3.5" />
|
||||||
|
</a>
|
||||||
|
</Button>
|
||||||
|
{updateReady.ready ? (
|
||||||
|
<Button
|
||||||
|
onClick={handleRestartToUpdate}
|
||||||
|
variant="default"
|
||||||
|
size="sm"
|
||||||
|
className="gap-2"
|
||||||
|
>
|
||||||
|
<RefreshCw className="h-3.5 w-3.5" />
|
||||||
|
{t('about.notifications.restartNowAction')}
|
||||||
|
</Button>
|
||||||
|
) : null}
|
||||||
|
{latestVersionState?.status === 'available' ? (
|
||||||
|
<Button
|
||||||
|
onClick={handleGoToDownload}
|
||||||
|
variant="default"
|
||||||
|
size="sm"
|
||||||
|
className="gap-2"
|
||||||
|
>
|
||||||
|
<Download className="h-3.5 w-3.5" />
|
||||||
|
{t('about.actions.goToDownload')}
|
||||||
|
</Button>
|
||||||
|
) : null}
|
||||||
|
<Button onClick={handleCheckForUpdates} size="sm" className="gap-2">
|
||||||
|
<RefreshCw className="h-3.5 w-3.5" />
|
||||||
|
{t('about.actions.checkUpdates')}
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<p className="text-sm text-muted-foreground">{t('about.description')}</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex items-center gap-2">
|
|
||||||
<Button variant="outline" size="icon" asChild>
|
|
||||||
<a
|
|
||||||
href="https://github.com/nexmoe/vidbee"
|
|
||||||
target="_blank"
|
|
||||||
rel="noreferrer"
|
|
||||||
aria-label={t('about.actions.openRepo')}
|
|
||||||
>
|
|
||||||
<Github className="h-4 w-4" />
|
|
||||||
</a>
|
|
||||||
</Button>
|
|
||||||
{latestVersionState?.status === 'available' ? (
|
|
||||||
<Button onClick={handleGoToDownload} variant="default" className="gap-2">
|
|
||||||
<Download className="h-4 w-4" />
|
|
||||||
{t('about.actions.goToDownload')}
|
|
||||||
</Button>
|
|
||||||
) : null}
|
|
||||||
<Button onClick={handleCheckForUpdates} className="gap-2">
|
|
||||||
<RefreshCw className="h-4 w-4" />
|
|
||||||
{t('about.actions.checkUpdates')}
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
{updateDownloadProgress !== null && (
|
||||||
|
<div className="flex flex-col gap-3 pt-4">
|
||||||
|
<div className="space-y-2 w-full">
|
||||||
|
<div className="flex items-center justify-between gap-2">
|
||||||
|
<span className="text-sm text-muted-foreground">
|
||||||
|
{t('about.downloadingUpdate')}
|
||||||
|
</span>
|
||||||
|
<span className="text-sm font-medium">
|
||||||
|
{updateDownloadProgress.toFixed(1)}%
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<Progress value={updateDownloadProgress} className="h-2" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
<div className="flex items-center justify-between gap-4 pt-6">
|
<div className="flex items-center justify-between gap-4 pt-6">
|
||||||
<div className="space-y-1">
|
<div className="space-y-1">
|
||||||
<p className="font-medium leading-none">{t('about.autoUpdateTitle')}</p>
|
<p className="font-medium leading-none">{t('about.autoUpdateTitle')}</p>
|
||||||
@@ -361,7 +420,6 @@ export function About() {
|
|||||||
<Card>
|
<Card>
|
||||||
<CardHeader>
|
<CardHeader>
|
||||||
<CardTitle>{t('about.shareTitle')}</CardTitle>
|
<CardTitle>{t('about.shareTitle')}</CardTitle>
|
||||||
<CardDescription>{t('about.shareDescription')}</CardDescription>
|
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
<CardContent className="space-y-4">
|
<CardContent className="space-y-4">
|
||||||
<div className="flex flex-col gap-4 md:flex-row md:items-center md:justify-between">
|
<div className="flex flex-col gap-4 md:flex-row md:items-center md:justify-between">
|
||||||
@@ -408,6 +466,45 @@ export function About() {
|
|||||||
<Card>
|
<Card>
|
||||||
<CardContent className="p-0">
|
<CardContent className="p-0">
|
||||||
<div className="flex flex-col divide-y">
|
<div className="flex flex-col divide-y">
|
||||||
|
{/* Feedback section - merged into one row */}
|
||||||
|
<div className="flex items-center justify-between gap-4 px-6 py-4">
|
||||||
|
<div className="flex items-center gap-4">
|
||||||
|
<div className="flex h-10 w-10 items-center justify-center rounded-full bg-muted/60">
|
||||||
|
<MessageSquare className="h-5 w-5 text-muted-foreground" />
|
||||||
|
</div>
|
||||||
|
<div className="space-y-1">
|
||||||
|
<p className="font-medium leading-none">{t('about.resources.feedback')}</p>
|
||||||
|
<p className="text-sm text-muted-foreground">
|
||||||
|
{t('about.resources.feedbackDescription')}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div className="flex flex-wrap gap-2">
|
||||||
|
{feedbackResources.map((resource) => {
|
||||||
|
const Icon = resource.icon
|
||||||
|
return resource.href ? (
|
||||||
|
<Button key={resource.label} variant="outline" size="sm" asChild>
|
||||||
|
<a href={resource.href} target="_blank" rel="noreferrer" className="gap-2">
|
||||||
|
<Icon className="h-4 w-4" />
|
||||||
|
{resource.label}
|
||||||
|
</a>
|
||||||
|
</Button>
|
||||||
|
) : (
|
||||||
|
<Button
|
||||||
|
key={resource.label}
|
||||||
|
variant="outline"
|
||||||
|
size="sm"
|
||||||
|
onClick={resource.onClick}
|
||||||
|
className="gap-2"
|
||||||
|
>
|
||||||
|
<Icon className="h-4 w-4" />
|
||||||
|
{resource.label}
|
||||||
|
</Button>
|
||||||
|
)
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{/* Other resources */}
|
||||||
{aboutResources.map((resource) => {
|
{aboutResources.map((resource) => {
|
||||||
const Icon = resource.icon
|
const Icon = resource.icon
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -18,42 +18,50 @@ import {
|
|||||||
} from '@renderer/components/ui/select'
|
} from '@renderer/components/ui/select'
|
||||||
import { Switch } from '@renderer/components/ui/switch'
|
import { Switch } from '@renderer/components/ui/switch'
|
||||||
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@renderer/components/ui/tabs'
|
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@renderer/components/ui/tabs'
|
||||||
|
import { type LanguageCode, languageList, normalizeLanguageCode } from '@shared/languages'
|
||||||
import type { OneClickQualityPreset } from '@shared/types'
|
import type { OneClickQualityPreset } from '@shared/types'
|
||||||
import { useAtom, useSetAtom } from 'jotai'
|
import { useAtom, useSetAtom } from 'jotai'
|
||||||
import { useTheme } from 'next-themes'
|
import { useTheme } from 'next-themes'
|
||||||
import { useEffect, useState } from 'react'
|
import { useEffect, useState } from 'react'
|
||||||
import { useTranslation } from 'react-i18next'
|
import { useTranslation } from 'react-i18next'
|
||||||
import { toast } from 'sonner'
|
import { toast } from 'sonner'
|
||||||
|
import { ipcServices } from '../lib/ipc'
|
||||||
|
import { logger } from '../lib/logger'
|
||||||
import { loadSettingsAtom, saveSettingAtom, settingsAtom } from '../store/settings'
|
import { loadSettingsAtom, saveSettingAtom, settingsAtom } from '../store/settings'
|
||||||
|
|
||||||
const clampSubscriptionInterval = (value: string) => {
|
|
||||||
const parsed = Number.parseInt(value, 10)
|
|
||||||
if (Number.isNaN(parsed)) {
|
|
||||||
return 3
|
|
||||||
}
|
|
||||||
return Math.min(24, Math.max(1, parsed))
|
|
||||||
}
|
|
||||||
|
|
||||||
export function Settings() {
|
export function Settings() {
|
||||||
const { t } = useTranslation()
|
const { t, i18n: i18nInstance } = useTranslation()
|
||||||
const { theme, setTheme } = useTheme()
|
const { theme, setTheme } = useTheme()
|
||||||
const [settings, _setSettings] = useAtom(settingsAtom)
|
const [settings, _setSettings] = useAtom(settingsAtom)
|
||||||
const loadSettings = useSetAtom(loadSettingsAtom)
|
const loadSettings = useSetAtom(loadSettingsAtom)
|
||||||
const saveSetting = useSetAtom(saveSettingAtom)
|
const saveSetting = useSetAtom(saveSettingAtom)
|
||||||
const [platform, setPlatform] = useState<string>('')
|
const [platform, setPlatform] = useState<string>('')
|
||||||
|
const [activeTab, setActiveTab] = useState<string>('general')
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
loadSettings()
|
logger.info('[Settings] Component mounted, loading settings...')
|
||||||
|
try {
|
||||||
|
loadSettings()
|
||||||
|
// Note: settings will be logged in the next useEffect after it's loaded
|
||||||
|
} catch (error) {
|
||||||
|
logger.error('[Settings] Failed to load settings:', error)
|
||||||
|
}
|
||||||
}, [loadSettings])
|
}, [loadSettings])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
logger.info('[Settings] Settings state updated', {
|
||||||
|
settingsKeys: Object.keys(settings),
|
||||||
|
settingsValues: settings
|
||||||
|
})
|
||||||
|
}, [settings])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const fetchPlatform = async () => {
|
const fetchPlatform = async () => {
|
||||||
try {
|
try {
|
||||||
const { ipcServices } = await import('../lib/ipc')
|
|
||||||
const platformInfo = await ipcServices.app.getPlatform()
|
const platformInfo = await ipcServices.app.getPlatform()
|
||||||
setPlatform(platformInfo)
|
setPlatform(platformInfo)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Failed to get platform info:', error)
|
logger.error('Failed to get platform info:', error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,57 +74,60 @@ export function Settings() {
|
|||||||
key: keyof typeof settings,
|
key: keyof typeof settings,
|
||||||
value: (typeof settings)[keyof typeof settings]
|
value: (typeof settings)[keyof typeof settings]
|
||||||
) => {
|
) => {
|
||||||
await saveSetting({ key, value })
|
try {
|
||||||
toast.success(t('notifications.settingsSaved'))
|
logger.info('[Settings] Changing setting', { key, value, currentValue: settings[key] })
|
||||||
|
await saveSetting({ key, value })
|
||||||
|
toast.success(t('notifications.settingsSaved'))
|
||||||
|
logger.info('[Settings] Setting changed successfully', { key, value })
|
||||||
|
} catch (error) {
|
||||||
|
logger.error('[Settings] Failed to change setting', { key, value, error })
|
||||||
|
toast.error(t('settings.saveError') || 'Failed to save setting')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleSelectPath = async () => {
|
const handleSelectPath = async () => {
|
||||||
try {
|
try {
|
||||||
const { ipcServices } = await import('../lib/ipc')
|
|
||||||
const path = await ipcServices.fs.selectDirectory()
|
const path = await ipcServices.fs.selectDirectory()
|
||||||
if (path) {
|
if (path) {
|
||||||
await handleSettingChange('downloadPath', path)
|
await handleSettingChange('downloadPath', path)
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Failed to select directory:', error)
|
logger.error('Failed to select directory:', error)
|
||||||
toast.error(t('settings.directorySelectError'))
|
toast.error(t('settings.directorySelectError'))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleSelectConfigFile = async () => {
|
const handleSelectConfigFile = async () => {
|
||||||
try {
|
try {
|
||||||
const { ipcServices } = await import('../lib/ipc')
|
|
||||||
const path = await ipcServices.fs.selectFile()
|
const path = await ipcServices.fs.selectFile()
|
||||||
if (path) {
|
if (path) {
|
||||||
await handleSettingChange('configPath', path)
|
await handleSettingChange('configPath', path)
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Failed to select file:', error)
|
logger.error('Failed to select file:', error)
|
||||||
toast.error(t('settings.fileSelectError'))
|
toast.error(t('settings.fileSelectError'))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleSelectCookiesFile = async () => {
|
const handleSelectCookiesFile = async () => {
|
||||||
try {
|
try {
|
||||||
const { ipcServices } = await import('../lib/ipc')
|
|
||||||
const path = await ipcServices.fs.selectFile()
|
const path = await ipcServices.fs.selectFile()
|
||||||
if (path) {
|
if (path) {
|
||||||
await handleSettingChange('cookiesPath', path)
|
await handleSettingChange('cookiesPath', path)
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Failed to select cookies file:', error)
|
logger.error('Failed to select cookies file:', error)
|
||||||
toast.error(t('settings.fileSelectError'))
|
toast.error(t('settings.fileSelectError'))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleOpenCookiesFaq = async () => {
|
const handleOpenCookiesFaq = async () => {
|
||||||
try {
|
try {
|
||||||
const { ipcServices } = await import('../lib/ipc')
|
|
||||||
await ipcServices.fs.openExternal(
|
await ipcServices.fs.openExternal(
|
||||||
'https://github.com/yt-dlp/yt-dlp/wiki/FAQ#how-do-i-pass-cookies-to-yt-dlp'
|
'https://github.com/yt-dlp/yt-dlp/wiki/FAQ#how-do-i-pass-cookies-to-yt-dlp'
|
||||||
)
|
)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Failed to open cookies FAQ:', error)
|
logger.error('Failed to open cookies FAQ:', error)
|
||||||
toast.error(t('settings.openLinkError'))
|
toast.error(t('settings.openLinkError'))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -131,6 +142,21 @@ export function Settings() {
|
|||||||
await handleSettingChange('theme', value)
|
await handleSettingChange('theme', value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const languageOptions = languageList
|
||||||
|
const activeLanguageCode = normalizeLanguageCode(i18nInstance.language)
|
||||||
|
const currentLanguage =
|
||||||
|
languageOptions.find((option) => option.value === activeLanguageCode) ?? languageOptions[0]
|
||||||
|
|
||||||
|
const handleLanguageChange = async (value: LanguageCode) => {
|
||||||
|
if (activeLanguageCode === value) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
await saveSetting({ key: 'language', value })
|
||||||
|
await i18nInstance.changeLanguage(value)
|
||||||
|
toast.success(t('notifications.settingsSaved'))
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="h-full bg-background">
|
<div className="h-full bg-background">
|
||||||
<div className="container mx-auto max-w-4xl p-6 space-y-6">
|
<div className="container mx-auto max-w-4xl p-6 space-y-6">
|
||||||
@@ -139,7 +165,29 @@ export function Settings() {
|
|||||||
<p className="text-muted-foreground">{t('settings.description')}</p>
|
<p className="text-muted-foreground">{t('settings.description')}</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Tabs defaultValue="general">
|
<Tabs
|
||||||
|
value={activeTab}
|
||||||
|
onValueChange={(value) => {
|
||||||
|
logger.info('[Settings] Tab changed', { from: activeTab, to: value })
|
||||||
|
setActiveTab(value)
|
||||||
|
try {
|
||||||
|
if (value === 'advanced') {
|
||||||
|
logger.info('[Settings] Entering advanced tab', {
|
||||||
|
settings: settings,
|
||||||
|
settingsKeys: Object.keys(settings),
|
||||||
|
maxConcurrentDownloads: settings.maxConcurrentDownloads,
|
||||||
|
browserForCookies: settings.browserForCookies,
|
||||||
|
cookiesPath: settings.cookiesPath,
|
||||||
|
proxy: settings.proxy,
|
||||||
|
configPath: settings.configPath,
|
||||||
|
enableAnalytics: settings.enableAnalytics
|
||||||
|
})
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
logger.error('[Settings] Error when entering advanced tab:', error)
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
>
|
||||||
<TabsList className="grid w-full grid-cols-2">
|
<TabsList className="grid w-full grid-cols-2">
|
||||||
<TabsTrigger value="general">{t('settings.general')}</TabsTrigger>
|
<TabsTrigger value="general">{t('settings.general')}</TabsTrigger>
|
||||||
<TabsTrigger value="advanced">{t('settings.advanced')}</TabsTrigger>
|
<TabsTrigger value="advanced">{t('settings.advanced')}</TabsTrigger>
|
||||||
@@ -185,6 +233,53 @@ export function Settings() {
|
|||||||
</Select>
|
</Select>
|
||||||
</ItemActions>
|
</ItemActions>
|
||||||
</Item>
|
</Item>
|
||||||
|
|
||||||
|
<ItemSeparator />
|
||||||
|
|
||||||
|
<Item variant="muted">
|
||||||
|
<ItemContent>
|
||||||
|
<ItemTitle>{t('settings.language')}</ItemTitle>
|
||||||
|
<ItemDescription>{t('settings.languageDescription')}</ItemDescription>
|
||||||
|
</ItemContent>
|
||||||
|
<ItemActions>
|
||||||
|
<Select
|
||||||
|
value={currentLanguage.value}
|
||||||
|
onValueChange={(value) => void handleLanguageChange(value as LanguageCode)}
|
||||||
|
>
|
||||||
|
<SelectTrigger className="w-48">
|
||||||
|
<SelectValue placeholder={currentLanguage.name}>
|
||||||
|
<div className="flex items-center gap-2">
|
||||||
|
<span
|
||||||
|
className={`${currentLanguage.flag} rounded-xs text-base`}
|
||||||
|
aria-hidden="true"
|
||||||
|
/>
|
||||||
|
<span lang={currentLanguage.hreflang}>{currentLanguage.name}</span>
|
||||||
|
</div>
|
||||||
|
</SelectValue>
|
||||||
|
</SelectTrigger>
|
||||||
|
<SelectContent>
|
||||||
|
{languageOptions.map((option) => {
|
||||||
|
const isActive = option.value === currentLanguage.value
|
||||||
|
return (
|
||||||
|
<SelectItem
|
||||||
|
key={option.value}
|
||||||
|
value={option.value}
|
||||||
|
className={isActive ? 'font-semibold bg-muted' : undefined}
|
||||||
|
>
|
||||||
|
<div className="flex items-center gap-2">
|
||||||
|
<span
|
||||||
|
className={`${option.flag} rounded-xs text-base`}
|
||||||
|
aria-hidden="true"
|
||||||
|
/>
|
||||||
|
<span lang={option.hreflang}>{option.name}</span>
|
||||||
|
</div>
|
||||||
|
</SelectItem>
|
||||||
|
)
|
||||||
|
})}
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
|
</ItemActions>
|
||||||
|
</Item>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
@@ -316,41 +411,21 @@ export function Settings() {
|
|||||||
</ItemContent>
|
</ItemContent>
|
||||||
<ItemActions>
|
<ItemActions>
|
||||||
<Switch
|
<Switch
|
||||||
checked={settings.showMoreFormats}
|
checked={settings.showMoreFormats ?? false}
|
||||||
onCheckedChange={(value) => handleSettingChange('showMoreFormats', value)}
|
onCheckedChange={(value) => {
|
||||||
|
try {
|
||||||
|
logger.info('[Settings] Toggling showMoreFormats', { value })
|
||||||
|
handleSettingChange('showMoreFormats', value)
|
||||||
|
} catch (error) {
|
||||||
|
logger.error('[Settings] Error toggling showMoreFormats:', error)
|
||||||
|
}
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
</ItemActions>
|
</ItemActions>
|
||||||
</Item>
|
</Item>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Item variant="muted">
|
|
||||||
<ItemContent>
|
|
||||||
<ItemTitle>{t('subscriptions.defaults.checkInterval')}</ItemTitle>
|
|
||||||
<ItemDescription>
|
|
||||||
{t('settings.subscriptionDefaults.intervalDescription')}
|
|
||||||
</ItemDescription>
|
|
||||||
</ItemContent>
|
|
||||||
<ItemActions>
|
|
||||||
<Input
|
|
||||||
type="number"
|
|
||||||
min={1}
|
|
||||||
max={24}
|
|
||||||
defaultValue={settings.subscriptionCheckIntervalHours}
|
|
||||||
key={`subscription-interval-${settings.subscriptionCheckIntervalHours}`}
|
|
||||||
onBlur={(event) =>
|
|
||||||
void handleSettingChange(
|
|
||||||
'subscriptionCheckIntervalHours',
|
|
||||||
clampSubscriptionInterval(event.target.value)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
className="w-24"
|
|
||||||
/>
|
|
||||||
</ItemActions>
|
|
||||||
</Item>
|
|
||||||
|
|
||||||
<ItemSeparator />
|
|
||||||
|
|
||||||
<Item variant="muted">
|
<Item variant="muted">
|
||||||
<ItemContent>
|
<ItemContent>
|
||||||
<ItemTitle>{t('settings.maxConcurrentDownloads')}</ItemTitle>
|
<ItemTitle>{t('settings.maxConcurrentDownloads')}</ItemTitle>
|
||||||
@@ -359,23 +434,55 @@ export function Settings() {
|
|||||||
</ItemDescription>
|
</ItemDescription>
|
||||||
</ItemContent>
|
</ItemContent>
|
||||||
<ItemActions>
|
<ItemActions>
|
||||||
<Select
|
{(() => {
|
||||||
value={settings.maxConcurrentDownloads.toString()}
|
try {
|
||||||
onValueChange={(value) =>
|
const maxConcurrent = settings.maxConcurrentDownloads ?? 5
|
||||||
handleSettingChange('maxConcurrentDownloads', Number(value))
|
const maxConcurrentStr = maxConcurrent.toString()
|
||||||
|
logger.info('[Settings] Rendering max concurrent downloads select', {
|
||||||
|
maxConcurrent,
|
||||||
|
maxConcurrentStr,
|
||||||
|
type: typeof maxConcurrent
|
||||||
|
})
|
||||||
|
return (
|
||||||
|
<Select
|
||||||
|
value={maxConcurrentStr}
|
||||||
|
onValueChange={(value) => {
|
||||||
|
try {
|
||||||
|
const numValue = Number(value)
|
||||||
|
logger.info('[Settings] Max concurrent downloads changed', {
|
||||||
|
oldValue: maxConcurrent,
|
||||||
|
newValue: numValue,
|
||||||
|
stringValue: value
|
||||||
|
})
|
||||||
|
handleSettingChange('maxConcurrentDownloads', numValue)
|
||||||
|
} catch (error) {
|
||||||
|
logger.error(
|
||||||
|
'[Settings] Error changing max concurrent downloads:',
|
||||||
|
error
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<SelectTrigger className="w-20">
|
||||||
|
<SelectValue />
|
||||||
|
</SelectTrigger>
|
||||||
|
<SelectContent>
|
||||||
|
{[1, 2, 3, 4, 5, 6, 7, 8, 9, 10].map((num) => (
|
||||||
|
<SelectItem key={num} value={num.toString()}>
|
||||||
|
{num}
|
||||||
|
</SelectItem>
|
||||||
|
))}
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
|
)
|
||||||
|
} catch (error) {
|
||||||
|
logger.error(
|
||||||
|
'[Settings] Error rendering max concurrent downloads select:',
|
||||||
|
error
|
||||||
|
)
|
||||||
|
return <div>Error loading max concurrent downloads setting</div>
|
||||||
}
|
}
|
||||||
>
|
})()}
|
||||||
<SelectTrigger className="w-20">
|
|
||||||
<SelectValue />
|
|
||||||
</SelectTrigger>
|
|
||||||
<SelectContent>
|
|
||||||
{[1, 2, 3, 4, 5, 6, 7, 8, 9, 10].map((num) => (
|
|
||||||
<SelectItem key={num} value={num.toString()}>
|
|
||||||
{num}
|
|
||||||
</SelectItem>
|
|
||||||
))}
|
|
||||||
</SelectContent>
|
|
||||||
</Select>
|
|
||||||
</ItemActions>
|
</ItemActions>
|
||||||
</Item>
|
</Item>
|
||||||
|
|
||||||
@@ -387,12 +494,33 @@ export function Settings() {
|
|||||||
<ItemDescription>{t('settings.proxyDescription')}</ItemDescription>
|
<ItemDescription>{t('settings.proxyDescription')}</ItemDescription>
|
||||||
</ItemContent>
|
</ItemContent>
|
||||||
<ItemActions>
|
<ItemActions>
|
||||||
<Input
|
{(() => {
|
||||||
placeholder={t('settings.proxyPlaceholder')}
|
try {
|
||||||
value={settings.proxy}
|
const proxyValue = settings.proxy ?? ''
|
||||||
onChange={(e) => handleSettingChange('proxy', e.target.value)}
|
logger.info('[Settings] Rendering proxy input', { proxyValue })
|
||||||
className="w-64"
|
return (
|
||||||
/>
|
<Input
|
||||||
|
placeholder={t('settings.proxyPlaceholder')}
|
||||||
|
value={proxyValue}
|
||||||
|
onChange={(e) => {
|
||||||
|
try {
|
||||||
|
logger.info('[Settings] Proxy value changed', {
|
||||||
|
oldValue: proxyValue,
|
||||||
|
newValue: e.target.value
|
||||||
|
})
|
||||||
|
handleSettingChange('proxy', e.target.value)
|
||||||
|
} catch (error) {
|
||||||
|
logger.error('[Settings] Error changing proxy:', error)
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
className="w-64"
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
} catch (error) {
|
||||||
|
logger.error('[Settings] Error rendering proxy input:', error)
|
||||||
|
return <div>Error loading proxy setting</div>
|
||||||
|
}
|
||||||
|
})()}
|
||||||
</ItemActions>
|
</ItemActions>
|
||||||
</Item>
|
</Item>
|
||||||
|
|
||||||
@@ -404,17 +532,37 @@ export function Settings() {
|
|||||||
<ItemDescription>{t('settings.configFileDescription')}</ItemDescription>
|
<ItemDescription>{t('settings.configFileDescription')}</ItemDescription>
|
||||||
</ItemContent>
|
</ItemContent>
|
||||||
<ItemActions>
|
<ItemActions>
|
||||||
<div className="flex gap-2 w-full max-w-md">
|
{(() => {
|
||||||
<Input value={settings.configPath} readOnly className="flex-1" />
|
try {
|
||||||
<Button onClick={handleSelectConfigFile}>{t('settings.selectPath')}</Button>
|
const configPathValue = settings.configPath ?? ''
|
||||||
<Button
|
logger.info('[Settings] Rendering config file input', { configPathValue })
|
||||||
variant="secondary"
|
return (
|
||||||
onClick={() => void handleSettingChange('configPath', '')}
|
<div className="flex gap-2 w-full max-w-md">
|
||||||
disabled={!settings.configPath}
|
<Input value={configPathValue} readOnly className="flex-1" />
|
||||||
>
|
<Button onClick={handleSelectConfigFile}>
|
||||||
{t('settings.clearConfigFile')}
|
{t('settings.selectPath')}
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
<Button
|
||||||
|
variant="secondary"
|
||||||
|
onClick={() => {
|
||||||
|
try {
|
||||||
|
logger.info('[Settings] Clearing config path')
|
||||||
|
void handleSettingChange('configPath', '')
|
||||||
|
} catch (error) {
|
||||||
|
logger.error('[Settings] Error clearing config path:', error)
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
disabled={!configPathValue}
|
||||||
|
>
|
||||||
|
{t('settings.clearConfigFile')}
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
} catch (error) {
|
||||||
|
logger.error('[Settings] Error rendering config file input:', error)
|
||||||
|
return <div>Error loading config file setting</div>
|
||||||
|
}
|
||||||
|
})()}
|
||||||
</ItemActions>
|
</ItemActions>
|
||||||
</Item>
|
</Item>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
@@ -426,27 +574,58 @@ export function Settings() {
|
|||||||
<ItemDescription>{t('settings.browserForCookiesDescription')}</ItemDescription>
|
<ItemDescription>{t('settings.browserForCookiesDescription')}</ItemDescription>
|
||||||
</ItemContent>
|
</ItemContent>
|
||||||
<ItemActions>
|
<ItemActions>
|
||||||
<Select
|
{(() => {
|
||||||
value={settings.browserForCookies}
|
try {
|
||||||
onValueChange={(value) => handleSettingChange('browserForCookies', value)}
|
const browserValue = settings.browserForCookies ?? 'none'
|
||||||
>
|
logger.info('[Settings] Rendering browser for cookies select', {
|
||||||
<SelectTrigger className="w-32">
|
browserValue
|
||||||
<SelectValue />
|
})
|
||||||
</SelectTrigger>
|
return (
|
||||||
<SelectContent>
|
<Select
|
||||||
<SelectItem value="none">{t('settings.none')}</SelectItem>
|
value={browserValue}
|
||||||
<SelectItem value="chrome">{t('settings.browserOptions.chrome')}</SelectItem>
|
onValueChange={(value) => {
|
||||||
<SelectItem value="chromium">
|
try {
|
||||||
{t('settings.browserOptions.chromium')}
|
logger.info('[Settings] Browser for cookies changed', {
|
||||||
</SelectItem>
|
oldValue: browserValue,
|
||||||
<SelectItem value="firefox">
|
newValue: value
|
||||||
{t('settings.browserOptions.firefox')}
|
})
|
||||||
</SelectItem>
|
handleSettingChange('browserForCookies', value)
|
||||||
<SelectItem value="edge">{t('settings.browserOptions.edge')}</SelectItem>
|
} catch (error) {
|
||||||
<SelectItem value="safari">{t('settings.browserOptions.safari')}</SelectItem>
|
logger.error('[Settings] Error changing browser for cookies:', error)
|
||||||
<SelectItem value="brave">{t('settings.browserOptions.brave')}</SelectItem>
|
}
|
||||||
</SelectContent>
|
}}
|
||||||
</Select>
|
>
|
||||||
|
<SelectTrigger className="w-32">
|
||||||
|
<SelectValue />
|
||||||
|
</SelectTrigger>
|
||||||
|
<SelectContent>
|
||||||
|
<SelectItem value="none">{t('settings.none')}</SelectItem>
|
||||||
|
<SelectItem value="chrome">
|
||||||
|
{t('settings.browserOptions.chrome')}
|
||||||
|
</SelectItem>
|
||||||
|
<SelectItem value="chromium">
|
||||||
|
{t('settings.browserOptions.chromium')}
|
||||||
|
</SelectItem>
|
||||||
|
<SelectItem value="firefox">
|
||||||
|
{t('settings.browserOptions.firefox')}
|
||||||
|
</SelectItem>
|
||||||
|
<SelectItem value="edge">
|
||||||
|
{t('settings.browserOptions.edge')}
|
||||||
|
</SelectItem>
|
||||||
|
<SelectItem value="safari">
|
||||||
|
{t('settings.browserOptions.safari')}
|
||||||
|
</SelectItem>
|
||||||
|
<SelectItem value="brave">
|
||||||
|
{t('settings.browserOptions.brave')}
|
||||||
|
</SelectItem>
|
||||||
|
</SelectContent>
|
||||||
|
</Select>
|
||||||
|
)
|
||||||
|
} catch (error) {
|
||||||
|
logger.error('[Settings] Error rendering browser for cookies select:', error)
|
||||||
|
return <div>Error loading browser for cookies setting</div>
|
||||||
|
}
|
||||||
|
})()}
|
||||||
</ItemActions>
|
</ItemActions>
|
||||||
</Item>
|
</Item>
|
||||||
|
|
||||||
@@ -458,17 +637,37 @@ export function Settings() {
|
|||||||
<ItemDescription>{t('settings.cookiesFileDescription')}</ItemDescription>
|
<ItemDescription>{t('settings.cookiesFileDescription')}</ItemDescription>
|
||||||
</ItemContent>
|
</ItemContent>
|
||||||
<ItemActions>
|
<ItemActions>
|
||||||
<div className="flex gap-2 w-full max-w-md">
|
{(() => {
|
||||||
<Input value={settings.cookiesPath ?? ''} readOnly className="flex-1" />
|
try {
|
||||||
<Button onClick={handleSelectCookiesFile}>{t('settings.selectPath')}</Button>
|
const cookiesPathValue = settings.cookiesPath ?? ''
|
||||||
<Button
|
logger.info('[Settings] Rendering cookies file input', { cookiesPathValue })
|
||||||
variant="secondary"
|
return (
|
||||||
onClick={() => void handleSettingChange('cookiesPath', '')}
|
<div className="flex gap-2 w-full max-w-md">
|
||||||
disabled={!settings.cookiesPath}
|
<Input value={cookiesPathValue} readOnly className="flex-1" />
|
||||||
>
|
<Button onClick={handleSelectCookiesFile}>
|
||||||
{t('settings.clearCookiesFile')}
|
{t('settings.selectPath')}
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
<Button
|
||||||
|
variant="secondary"
|
||||||
|
onClick={() => {
|
||||||
|
try {
|
||||||
|
logger.info('[Settings] Clearing cookies path')
|
||||||
|
void handleSettingChange('cookiesPath', '')
|
||||||
|
} catch (error) {
|
||||||
|
logger.error('[Settings] Error clearing cookies path:', error)
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
disabled={!cookiesPathValue}
|
||||||
|
>
|
||||||
|
{t('settings.clearCookiesFile')}
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
} catch (error) {
|
||||||
|
logger.error('[Settings] Error rendering cookies file input:', error)
|
||||||
|
return <div>Error loading cookies file setting</div>
|
||||||
|
}
|
||||||
|
})()}
|
||||||
</ItemActions>
|
</ItemActions>
|
||||||
</Item>
|
</Item>
|
||||||
|
|
||||||
@@ -477,12 +676,10 @@ export function Settings() {
|
|||||||
<Item variant="muted">
|
<Item variant="muted">
|
||||||
<ItemContent>
|
<ItemContent>
|
||||||
<ItemTitle>{t('settings.cookiesHelpTitle')}</ItemTitle>
|
<ItemTitle>{t('settings.cookiesHelpTitle')}</ItemTitle>
|
||||||
<ItemDescription>
|
<ul className="list-disc list-inside space-y-1 text-muted-foreground text-sm leading-normal">
|
||||||
<ul className="list-disc list-inside space-y-1">
|
<li>{t('settings.cookiesHelpBrowser')}</li>
|
||||||
<li>{t('settings.cookiesHelpBrowser')}</li>
|
<li>{t('settings.cookiesHelpFile')}</li>
|
||||||
<li>{t('settings.cookiesHelpFile')}</li>
|
</ul>
|
||||||
</ul>
|
|
||||||
</ItemDescription>
|
|
||||||
</ItemContent>
|
</ItemContent>
|
||||||
<ItemActions>
|
<ItemActions>
|
||||||
<Button variant="link" className="px-0" onClick={handleOpenCookiesFaq}>
|
<Button variant="link" className="px-0" onClick={handleOpenCookiesFaq}>
|
||||||
@@ -499,10 +696,33 @@ export function Settings() {
|
|||||||
<ItemDescription>{t('settings.enableAnalyticsDescription')}</ItemDescription>
|
<ItemDescription>{t('settings.enableAnalyticsDescription')}</ItemDescription>
|
||||||
</ItemContent>
|
</ItemContent>
|
||||||
<ItemActions>
|
<ItemActions>
|
||||||
<Switch
|
{(() => {
|
||||||
checked={settings.enableAnalytics}
|
try {
|
||||||
onCheckedChange={(value) => handleSettingChange('enableAnalytics', value)}
|
const analyticsValue = settings.enableAnalytics ?? true
|
||||||
/>
|
logger.info('[Settings] Rendering enable analytics switch', {
|
||||||
|
analyticsValue
|
||||||
|
})
|
||||||
|
return (
|
||||||
|
<Switch
|
||||||
|
checked={analyticsValue}
|
||||||
|
onCheckedChange={(value) => {
|
||||||
|
try {
|
||||||
|
logger.info('[Settings] Enable analytics changed', {
|
||||||
|
oldValue: analyticsValue,
|
||||||
|
newValue: value
|
||||||
|
})
|
||||||
|
handleSettingChange('enableAnalytics', value)
|
||||||
|
} catch (error) {
|
||||||
|
logger.error('[Settings] Error changing enable analytics:', error)
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
} catch (error) {
|
||||||
|
logger.error('[Settings] Error rendering enable analytics switch:', error)
|
||||||
|
return <div>Error loading enable analytics setting</div>
|
||||||
|
}
|
||||||
|
})()}
|
||||||
</ItemActions>
|
</ItemActions>
|
||||||
</Item>
|
</Item>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|||||||
21
src/renderer/src/store/update.ts
Normal file
21
src/renderer/src/store/update.ts
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
import { atom } from 'jotai'
|
||||||
|
|
||||||
|
type UpdateReadyState = {
|
||||||
|
ready: boolean
|
||||||
|
version?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
type UpdateAvailableState = {
|
||||||
|
available: boolean
|
||||||
|
version?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export const updateReadyAtom = atom<UpdateReadyState>({
|
||||||
|
ready: false,
|
||||||
|
version: undefined
|
||||||
|
})
|
||||||
|
|
||||||
|
export const updateAvailableAtom = atom<UpdateAvailableState>({
|
||||||
|
available: false,
|
||||||
|
version: undefined
|
||||||
|
})
|
||||||
@@ -270,7 +270,6 @@ export interface AppSettings {
|
|||||||
launchAtLogin: boolean
|
launchAtLogin: boolean
|
||||||
autoUpdate: boolean
|
autoUpdate: boolean
|
||||||
subscriptionOnlyLatestDefault: boolean
|
subscriptionOnlyLatestDefault: boolean
|
||||||
subscriptionCheckIntervalHours: number
|
|
||||||
enableAnalytics: boolean
|
enableAnalytics: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -295,6 +294,5 @@ export const defaultSettings: AppSettings = {
|
|||||||
launchAtLogin: false,
|
launchAtLogin: false,
|
||||||
autoUpdate: true,
|
autoUpdate: true,
|
||||||
subscriptionOnlyLatestDefault: true,
|
subscriptionOnlyLatestDefault: true,
|
||||||
subscriptionCheckIntervalHours: 3,
|
|
||||||
enableAnalytics: true
|
enableAnalytics: true
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user