Compare commits
19 Commits
56aeafbf41
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4d5cac7a46 | ||
|
|
bbcb10b3ca | ||
|
|
1554be25d2 | ||
|
|
05887fd7a3 | ||
|
|
63648f9d7c | ||
|
|
0a439dbd71 | ||
|
|
f164569e89 | ||
|
|
f4bdb85841 | ||
|
|
36bd5061a4 | ||
|
|
dde9ed7718 | ||
|
|
8ae5f4f66c | ||
|
|
eada45bd9c | ||
|
|
77407c7e28 | ||
|
|
ac00c54ca3 | ||
|
|
14b0e96c7d | ||
|
|
fd28d4764a | ||
|
|
618fd2d933 | ||
|
|
54f841355b | ||
|
|
5fa6b5b616 |
@@ -3,8 +3,3 @@
|
|||||||
A simple Youtube downloader.
|
A simple Youtube downloader.
|
||||||
|
|
||||||
Generated by Gemini CLI.
|
Generated by Gemini CLI.
|
||||||
|
|
||||||
## Problems
|
|
||||||
|
|
||||||
1. windows 上打包后运行命令会出现黑窗,而且还是会出现找不到 js-runtimes 的问题,但是 quickjs 是正常下载了
|
|
||||||
2. macos 上未测试
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "stream-capture",
|
"name": "stream-capture",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "0.1.0",
|
"version": "1.2.0",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
|
|||||||
12
splashscreen.html
Normal file
12
splashscreen.html
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
|
<title>StreamCapture Loading</title>
|
||||||
|
</head>
|
||||||
|
<body class="font-sans antialiased">
|
||||||
|
<div id="app"></div>
|
||||||
|
<script type="module" src="/src/splash/main.ts"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
3
src-tauri/Cargo.lock
generated
3
src-tauri/Cargo.lock
generated
@@ -3971,9 +3971,10 @@ checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "stream-capture"
|
name = "stream-capture"
|
||||||
version = "0.1.0"
|
version = "1.2.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
|
"base64 0.22.1",
|
||||||
"chrono",
|
"chrono",
|
||||||
"futures-util",
|
"futures-util",
|
||||||
"regex",
|
"regex",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "stream-capture"
|
name = "stream-capture"
|
||||||
version = "0.1.0"
|
version = "1.2.0"
|
||||||
description = "A Tauri App"
|
description = "A Tauri App"
|
||||||
authors = ["you"]
|
authors = ["you"]
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
@@ -19,6 +19,7 @@ tauri-plugin-dialog = "2"
|
|||||||
serde = { version = "1", features = ["derive"] }
|
serde = { version = "1", features = ["derive"] }
|
||||||
serde_json = "1"
|
serde_json = "1"
|
||||||
reqwest = { version = "0.12", features = ["json", "rustls-tls", "stream"] }
|
reqwest = { version = "0.12", features = ["json", "rustls-tls", "stream"] }
|
||||||
|
base64 = "0.22"
|
||||||
tokio = { version = "1", features = ["full"] }
|
tokio = { version = "1", features = ["full"] }
|
||||||
anyhow = "1.0"
|
anyhow = "1.0"
|
||||||
chrono = { version = "0.4", features = ["serde"] }
|
chrono = { version = "0.4", features = ["serde"] }
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
"$schema": "../gen/schemas/desktop-schema.json",
|
"$schema": "../gen/schemas/desktop-schema.json",
|
||||||
"identifier": "default",
|
"identifier": "default",
|
||||||
"description": "Capability for the main window",
|
"description": "Capability for the main window",
|
||||||
"windows": ["main"],
|
"windows": ["main", "splashscreen"],
|
||||||
"permissions": [
|
"permissions": [
|
||||||
"core:default",
|
"core:default",
|
||||||
"opener:default",
|
"opener:default",
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ use tauri::AppHandle;
|
|||||||
use anyhow::{Result, anyhow};
|
use anyhow::{Result, anyhow};
|
||||||
#[cfg(target_family = "unix")]
|
#[cfg(target_family = "unix")]
|
||||||
use std::os::unix::fs::PermissionsExt;
|
use std::os::unix::fs::PermissionsExt;
|
||||||
|
#[cfg(target_os = "windows")]
|
||||||
|
use std::os::windows::process::CommandExt;
|
||||||
use zip::ZipArchive;
|
use zip::ZipArchive;
|
||||||
use std::io::Cursor;
|
use std::io::Cursor;
|
||||||
|
|
||||||
@@ -13,6 +15,9 @@ use crate::storage::{self};
|
|||||||
const YT_DLP_REPO_URL: &str = "https://github.com/yt-dlp/yt-dlp/releases/latest/download";
|
const YT_DLP_REPO_URL: &str = "https://github.com/yt-dlp/yt-dlp/releases/latest/download";
|
||||||
// Bellard's QuickJS binary releases URL
|
// Bellard's QuickJS binary releases URL
|
||||||
const QJS_REPO_URL: &str = "https://bellard.org/quickjs/binary_releases";
|
const QJS_REPO_URL: &str = "https://bellard.org/quickjs/binary_releases";
|
||||||
|
// FFmpeg builds
|
||||||
|
const FFMPEG_GITHUB_API: &str = "https://api.github.com/repos/BtbN/FFmpeg-Builds/releases/latest";
|
||||||
|
const FFMPEG_EVERMEET_BASE: &str = "https://evermeet.cx/ffmpeg";
|
||||||
|
|
||||||
pub fn get_ytdlp_binary_name() -> &'static str {
|
pub fn get_ytdlp_binary_name() -> &'static str {
|
||||||
if cfg!(target_os = "windows") {
|
if cfg!(target_os = "windows") {
|
||||||
@@ -60,10 +65,23 @@ pub fn get_qjs_path(app: &AppHandle) -> Result<PathBuf> {
|
|||||||
Ok(get_bin_dir(app)?.join(get_qjs_binary_name()))
|
Ok(get_bin_dir(app)?.join(get_qjs_binary_name()))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn get_ffmpeg_binary_name() -> &'static str {
|
||||||
|
if cfg!(target_os = "windows") {
|
||||||
|
"ffmpeg.exe"
|
||||||
|
} else {
|
||||||
|
"ffmpeg"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn get_ffmpeg_path(app: &AppHandle) -> Result<PathBuf> {
|
||||||
|
Ok(get_bin_dir(app)?.join(get_ffmpeg_binary_name()))
|
||||||
|
}
|
||||||
|
|
||||||
pub fn check_binaries(app: &AppHandle) -> bool {
|
pub fn check_binaries(app: &AppHandle) -> bool {
|
||||||
let ytdlp = get_ytdlp_path(app).map(|p| p.exists()).unwrap_or(false);
|
let ytdlp = get_ytdlp_path(app).map(|p| p.exists()).unwrap_or(false);
|
||||||
let qjs = get_qjs_path(app).map(|p| p.exists()).unwrap_or(false);
|
let qjs = get_qjs_path(app).map(|p| p.exists()).unwrap_or(false);
|
||||||
ytdlp && qjs
|
let ffmpeg = get_ffmpeg_path(app).map(|p| p.exists()).unwrap_or(false);
|
||||||
|
ytdlp && qjs && ffmpeg
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- yt-dlp Logic ---
|
// --- yt-dlp Logic ---
|
||||||
@@ -93,6 +111,17 @@ pub async fn download_ytdlp(app: &AppHandle) -> Result<PathBuf> {
|
|||||||
fs::set_permissions(&path, perms)?;
|
fs::set_permissions(&path, perms)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(target_os = "macos")]
|
||||||
|
{
|
||||||
|
// Remove quarantine attribute to allow execution on macOS
|
||||||
|
std::process::Command::new("xattr")
|
||||||
|
.arg("-d")
|
||||||
|
.arg("com.apple.quarantine")
|
||||||
|
.arg(&path)
|
||||||
|
.output()
|
||||||
|
.ok();
|
||||||
|
}
|
||||||
|
|
||||||
Ok(path)
|
Ok(path)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -104,9 +133,13 @@ pub async fn update_ytdlp(app: &AppHandle) -> Result<String> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Use built-in update for yt-dlp
|
// Use built-in update for yt-dlp
|
||||||
let output = std::process::Command::new(&path)
|
let mut cmd = std::process::Command::new(&path);
|
||||||
.arg("-U")
|
cmd.arg("-U");
|
||||||
.output()?;
|
|
||||||
|
#[cfg(target_os = "windows")]
|
||||||
|
cmd.creation_flags(0x08000000);
|
||||||
|
|
||||||
|
let output = cmd.output()?;
|
||||||
|
|
||||||
if !output.status.success() {
|
if !output.status.success() {
|
||||||
let stderr = String::from_utf8_lossy(&output.stderr).to_string();
|
let stderr = String::from_utf8_lossy(&output.stderr).to_string();
|
||||||
@@ -127,9 +160,13 @@ pub fn get_ytdlp_version(app: &AppHandle) -> Result<String> {
|
|||||||
return Ok("未安装".to_string());
|
return Ok("未安装".to_string());
|
||||||
}
|
}
|
||||||
|
|
||||||
let output = std::process::Command::new(&path)
|
let mut cmd = std::process::Command::new(&path);
|
||||||
.arg("--version")
|
cmd.arg("--version");
|
||||||
.output()?;
|
|
||||||
|
#[cfg(target_os = "windows")]
|
||||||
|
cmd.creation_flags(0x08000000);
|
||||||
|
|
||||||
|
let output = cmd.output()?;
|
||||||
|
|
||||||
if output.status.success() {
|
if output.status.success() {
|
||||||
Ok(String::from_utf8_lossy(&output.stdout).trim().to_string())
|
Ok(String::from_utf8_lossy(&output.stdout).trim().to_string())
|
||||||
@@ -194,22 +231,31 @@ pub async fn download_qjs(app: &AppHandle) -> Result<PathBuf> {
|
|||||||
let source_name = get_qjs_source_name_in_zip();
|
let source_name = get_qjs_source_name_in_zip();
|
||||||
let target_name = get_qjs_binary_name(); // quickjs.exe or quickjs
|
let target_name = get_qjs_binary_name(); // quickjs.exe or quickjs
|
||||||
|
|
||||||
let mut found = false;
|
let mut found_exe = false;
|
||||||
for i in 0..archive.len() {
|
for i in 0..archive.len() {
|
||||||
let mut file = archive.by_index(i)?;
|
let mut file = archive.by_index(i)?;
|
||||||
// Filenames in zip might be like "quickjs-win-x86_64-2024-01-13/qjs.exe"
|
// Filenames in zip might be like "quickjs-win-x86_64-2024-01-13/qjs.exe"
|
||||||
let name = file.name();
|
let name = file.name().to_string();
|
||||||
|
|
||||||
|
// Skip directories
|
||||||
|
if file.is_dir() {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
let filename_only = name.split('/').last().unwrap_or("");
|
let filename_only = name.split('/').last().unwrap_or("");
|
||||||
|
|
||||||
if filename_only == source_name {
|
if filename_only == source_name {
|
||||||
let mut out_file = fs::File::create(bin_dir.join(target_name))?;
|
let mut out_file = fs::File::create(bin_dir.join(target_name))?;
|
||||||
std::io::copy(&mut file, &mut out_file)?;
|
std::io::copy(&mut file, &mut out_file)?;
|
||||||
found = true;
|
found_exe = true;
|
||||||
break;
|
} else if filename_only.ends_with(".dll") {
|
||||||
|
// Extract DLLs (needed for Windows MinGW builds, e.g. libwinpthread-1.dll)
|
||||||
|
let mut out_file = fs::File::create(bin_dir.join(filename_only))?;
|
||||||
|
std::io::copy(&mut file, &mut out_file)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if !found {
|
if !found_exe {
|
||||||
return Err(anyhow!("在下载的压缩包中找不到 {}", source_name));
|
return Err(anyhow!("在下载的压缩包中找不到 {}", source_name));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -222,6 +268,17 @@ pub async fn download_qjs(app: &AppHandle) -> Result<PathBuf> {
|
|||||||
fs::set_permissions(&final_path, perms)?;
|
fs::set_permissions(&final_path, perms)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(target_os = "macos")]
|
||||||
|
{
|
||||||
|
// Remove quarantine attribute to allow execution on macOS
|
||||||
|
std::process::Command::new("xattr")
|
||||||
|
.arg("-d")
|
||||||
|
.arg("com.apple.quarantine")
|
||||||
|
.arg(&final_path)
|
||||||
|
.output()
|
||||||
|
.ok();
|
||||||
|
}
|
||||||
|
|
||||||
Ok(final_path)
|
Ok(final_path)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -231,6 +288,178 @@ pub async fn update_qjs(app: &AppHandle) -> Result<String> {
|
|||||||
Ok("QuickJS 已更新/安装".to_string())
|
Ok("QuickJS 已更新/安装".to_string())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// --- FFmpeg Logic ---
|
||||||
|
|
||||||
|
pub async fn download_ffmpeg(app: &AppHandle) -> Result<PathBuf> {
|
||||||
|
let bin_dir = get_bin_dir(app)?;
|
||||||
|
if cfg!(target_os = "windows") {
|
||||||
|
// Query GitHub releases API to find a suitable win64 zip asset
|
||||||
|
let client = reqwest::Client::new();
|
||||||
|
let resp = client.get(FFMPEG_GITHUB_API)
|
||||||
|
.header(reqwest::header::USER_AGENT, "stream-capture")
|
||||||
|
.send()
|
||||||
|
.await?;
|
||||||
|
if !resp.status().is_success() {
|
||||||
|
return Err(anyhow!("无法获取 FFmpeg releases 信息"));
|
||||||
|
}
|
||||||
|
let json: serde_json::Value = resp.json().await?;
|
||||||
|
let mut download_url: Option<String> = None;
|
||||||
|
if let Some(assets) = json.get("assets").and_then(|a| a.as_array()) {
|
||||||
|
for asset in assets {
|
||||||
|
if let (Some(name), Some(url)) = (asset.get("name").and_then(|n| n.as_str()), asset.get("browser_download_url").and_then(|u| u.as_str())) {
|
||||||
|
let lname = name.to_lowercase();
|
||||||
|
// Prefer GPL static build, avoid shared to get a single exe
|
||||||
|
if lname.contains("win64") && lname.contains("gpl") && !lname.contains("shared") && lname.ends_with(".zip") {
|
||||||
|
download_url = Some(url.to_string());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if download_url.is_none() {
|
||||||
|
// fallback: choose first zip asset that is NOT shared if possible
|
||||||
|
for asset in assets {
|
||||||
|
if let (Some(url), Some(name)) = (asset.get("browser_download_url").and_then(|u| u.as_str()), asset.get("name").and_then(|n| n.as_str())) {
|
||||||
|
let lname = name.to_lowercase();
|
||||||
|
if lname.ends_with(".zip") && !lname.contains("shared") {
|
||||||
|
download_url = Some(url.to_string());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let url = download_url.ok_or(anyhow!("未找到适合 Windows 的 FFmpeg 发行包"))?;
|
||||||
|
let resp = client.get(&url).header(reqwest::header::USER_AGENT, "stream-capture").send().await?;
|
||||||
|
if !resp.status().is_success() {
|
||||||
|
return Err(anyhow!("下载 FFmpeg 失败"));
|
||||||
|
}
|
||||||
|
let bytes = resp.bytes().await?;
|
||||||
|
let mut archive = ZipArchive::new(Cursor::new(bytes))?;
|
||||||
|
|
||||||
|
let mut found = false;
|
||||||
|
for i in 0..archive.len() {
|
||||||
|
let mut file = archive.by_index(i)?;
|
||||||
|
if file.is_dir() { continue; }
|
||||||
|
let name = file.name().to_string();
|
||||||
|
let filename_only = name.split('/').last().unwrap_or("");
|
||||||
|
// Only extract the executable, ignore DLLs
|
||||||
|
if filename_only.eq_ignore_ascii_case("ffmpeg.exe") {
|
||||||
|
let mut out_file = fs::File::create(bin_dir.join(filename_only))?;
|
||||||
|
std::io::copy(&mut file, &mut out_file)?;
|
||||||
|
found = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !found {
|
||||||
|
return Err(anyhow!("在 FFmpeg 压缩包中未找到 ffmpeg 可执行文件"));
|
||||||
|
}
|
||||||
|
|
||||||
|
let final_path = get_ffmpeg_path(app)?;
|
||||||
|
Ok(final_path)
|
||||||
|
} else if cfg!(target_os = "macos") {
|
||||||
|
// Fetch listing page and find latest ffmpeg-*.zip
|
||||||
|
let resp = reqwest::get(FFMPEG_EVERMEET_BASE).await?;
|
||||||
|
if !resp.status().is_success() {
|
||||||
|
return Err(anyhow!("无法获取 evermeet.ffmpeg 列表"));
|
||||||
|
}
|
||||||
|
let body = resp.text().await?;
|
||||||
|
let re = regex::Regex::new(r#"href="(ffmpeg-[0-9][^"]*\.zip)"#)?;
|
||||||
|
let mut candidates: Vec<&str> = Vec::new();
|
||||||
|
for cap in re.captures_iter(&body) {
|
||||||
|
if let Some(m) = cap.get(1) {
|
||||||
|
candidates.push(m.as_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let filename = candidates.last().ok_or(anyhow!("未在 evermeet 找到 ffmpeg zip 文件"))?;
|
||||||
|
let url = format!("{}/{}", FFMPEG_EVERMEET_BASE, filename);
|
||||||
|
let resp = reqwest::get(&url).await?;
|
||||||
|
if !resp.status().is_success() {
|
||||||
|
return Err(anyhow!("下载 FFmpeg macOS 版本失败"));
|
||||||
|
}
|
||||||
|
let bytes = resp.bytes().await?;
|
||||||
|
let mut archive = ZipArchive::new(Cursor::new(bytes))?;
|
||||||
|
|
||||||
|
let mut found = false;
|
||||||
|
for i in 0..archive.len() {
|
||||||
|
let mut file = archive.by_index(i)?;
|
||||||
|
if file.is_dir() { continue; }
|
||||||
|
let name = file.name().to_string();
|
||||||
|
let filename_only = name.split('/').last().unwrap_or("");
|
||||||
|
if filename_only == "ffmpeg" {
|
||||||
|
let mut out_file = fs::File::create(bin_dir.join("ffmpeg"))?;
|
||||||
|
std::io::copy(&mut file, &mut out_file)?;
|
||||||
|
found = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !found {
|
||||||
|
return Err(anyhow!("在 FFmpeg 压缩包中未找到 ffmpeg 可执行文件"));
|
||||||
|
}
|
||||||
|
|
||||||
|
let final_path = get_ffmpeg_path(app)?;
|
||||||
|
#[cfg(target_family = "unix")]
|
||||||
|
{
|
||||||
|
let mut perms = fs::metadata(&final_path)?.permissions();
|
||||||
|
perms.set_mode(0o755);
|
||||||
|
fs::set_permissions(&final_path, perms)?;
|
||||||
|
}
|
||||||
|
#[cfg(target_os = "macos")]
|
||||||
|
{
|
||||||
|
std::process::Command::new("xattr").arg("-d").arg("com.apple.quarantine").arg(&final_path).output().ok();
|
||||||
|
}
|
||||||
|
Ok(final_path)
|
||||||
|
} else {
|
||||||
|
Err(anyhow!("当前操作系统不支持自动下载 FFmpeg"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn update_ffmpeg(app: &AppHandle) -> Result<String> {
|
||||||
|
let path = get_ffmpeg_path(app)?;
|
||||||
|
if !path.exists() {
|
||||||
|
download_ffmpeg(app).await?;
|
||||||
|
return Ok("FFmpeg 已安装".to_string());
|
||||||
|
}
|
||||||
|
// Re-download to update
|
||||||
|
download_ffmpeg(app).await?;
|
||||||
|
|
||||||
|
// Update settings timestamp
|
||||||
|
let mut settings = storage::load_settings(app)?;
|
||||||
|
settings.last_updated = Some(chrono::Utc::now());
|
||||||
|
storage::save_settings(app, &settings)?;
|
||||||
|
|
||||||
|
Ok("FFmpeg 已更新".to_string())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn get_ffmpeg_version(app: &AppHandle) -> Result<String> {
|
||||||
|
let path = get_ffmpeg_path(app)?;
|
||||||
|
if !path.exists() {
|
||||||
|
return Ok("未安装".to_string());
|
||||||
|
}
|
||||||
|
let mut cmd = std::process::Command::new(&path);
|
||||||
|
cmd.arg("-version");
|
||||||
|
#[cfg(target_os = "windows")]
|
||||||
|
cmd.creation_flags(0x08000000);
|
||||||
|
|
||||||
|
let output = cmd.output()?;
|
||||||
|
if output.status.success() {
|
||||||
|
// Prefer stdout, fallback to stderr if stdout empty
|
||||||
|
let out = if !output.stdout.is_empty() {
|
||||||
|
String::from_utf8_lossy(&output.stdout).to_string()
|
||||||
|
} else {
|
||||||
|
String::from_utf8_lossy(&output.stderr).to_string()
|
||||||
|
};
|
||||||
|
|
||||||
|
if let Some(first_line) = out.lines().next() {
|
||||||
|
let v = first_line.trim().to_string();
|
||||||
|
if !v.is_empty() {
|
||||||
|
return Ok(v);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// If we couldn't obtain a usable version string, treat as not installed
|
||||||
|
Ok("未安装".to_string())
|
||||||
|
}
|
||||||
|
|
||||||
pub fn get_qjs_version(app: &AppHandle) -> Result<String> {
|
pub fn get_qjs_version(app: &AppHandle) -> Result<String> {
|
||||||
let path = get_qjs_path(app)?;
|
let path = get_qjs_path(app)?;
|
||||||
if !path.exists() {
|
if !path.exists() {
|
||||||
@@ -243,11 +472,46 @@ pub async fn ensure_binaries(app: &AppHandle) -> Result<()> {
|
|||||||
let ytdlp = get_ytdlp_path(app)?;
|
let ytdlp = get_ytdlp_path(app)?;
|
||||||
if !ytdlp.exists() {
|
if !ytdlp.exists() {
|
||||||
download_ytdlp(app).await?;
|
download_ytdlp(app).await?;
|
||||||
|
} else {
|
||||||
|
#[cfg(target_os = "macos")]
|
||||||
|
{
|
||||||
|
std::process::Command::new("xattr")
|
||||||
|
.arg("-d")
|
||||||
|
.arg("com.apple.quarantine")
|
||||||
|
.arg(&ytdlp)
|
||||||
|
.output()
|
||||||
|
.ok();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let qjs = get_qjs_path(app)?;
|
let qjs = get_qjs_path(app)?;
|
||||||
if !qjs.exists() {
|
if !qjs.exists() {
|
||||||
download_qjs(app).await?;
|
download_qjs(app).await?;
|
||||||
|
} else {
|
||||||
|
#[cfg(target_os = "macos")]
|
||||||
|
{
|
||||||
|
std::process::Command::new("xattr")
|
||||||
|
.arg("-d")
|
||||||
|
.arg("com.apple.quarantine")
|
||||||
|
.arg(&qjs)
|
||||||
|
.output()
|
||||||
|
.ok();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let ffmpeg = get_ffmpeg_path(app)?;
|
||||||
|
if !ffmpeg.exists() {
|
||||||
|
download_ffmpeg(app).await?;
|
||||||
|
} else {
|
||||||
|
#[cfg(target_os = "macos")]
|
||||||
|
{
|
||||||
|
std::process::Command::new("xattr")
|
||||||
|
.arg("-d")
|
||||||
|
.arg("com.apple.quarantine")
|
||||||
|
.arg(&ffmpeg)
|
||||||
|
.output()
|
||||||
|
.ok();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
@@ -29,6 +29,11 @@ pub async fn update_quickjs(app: AppHandle) -> Result<String, String> {
|
|||||||
binary_manager::update_qjs(&app).await.map_err(|e| e.to_string())
|
binary_manager::update_qjs(&app).await.map_err(|e| e.to_string())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub async fn update_ffmpeg(app: AppHandle) -> Result<String, String> {
|
||||||
|
binary_manager::update_ffmpeg(&app).await.map_err(|e| e.to_string())
|
||||||
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub fn get_ytdlp_version(app: AppHandle) -> Result<String, String> {
|
pub fn get_ytdlp_version(app: AppHandle) -> Result<String, String> {
|
||||||
binary_manager::get_ytdlp_version(&app).map_err(|e| e.to_string())
|
binary_manager::get_ytdlp_version(&app).map_err(|e| e.to_string())
|
||||||
@@ -39,6 +44,33 @@ pub fn get_quickjs_version(app: AppHandle) -> Result<String, String> {
|
|||||||
binary_manager::get_qjs_version(&app).map_err(|e| e.to_string())
|
binary_manager::get_qjs_version(&app).map_err(|e| e.to_string())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub fn get_ffmpeg_version(app: AppHandle) -> Result<String, String> {
|
||||||
|
binary_manager::get_ffmpeg_version(&app).map_err(|e| e.to_string())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub async fn fetch_image(url: String) -> Result<String, String> {
|
||||||
|
use base64::{Engine as _, engine::general_purpose};
|
||||||
|
|
||||||
|
let client = reqwest::Client::new();
|
||||||
|
let res = client.get(&url)
|
||||||
|
.header("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36")
|
||||||
|
.send()
|
||||||
|
.await
|
||||||
|
.map_err(|e| e.to_string())?;
|
||||||
|
|
||||||
|
let bytes = res.bytes().await.map_err(|e| e.to_string())?;
|
||||||
|
|
||||||
|
// Convert to base64
|
||||||
|
let b64 = general_purpose::STANDARD.encode(&bytes);
|
||||||
|
|
||||||
|
// Simple heuristic for mime type
|
||||||
|
let mime = if url.to_lowercase().ends_with(".png") { "image/png" } else { "image/jpeg" };
|
||||||
|
|
||||||
|
Ok(format!("data:{};base64,{}", mime, b64))
|
||||||
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub async fn fetch_metadata(app: AppHandle, url: String, parse_mix_playlist: bool) -> Result<downloader::MetadataResult, String> {
|
pub async fn fetch_metadata(app: AppHandle, url: String, parse_mix_playlist: bool) -> Result<downloader::MetadataResult, String> {
|
||||||
downloader::fetch_metadata(&app, &url, parse_mix_playlist).await.map_err(|e| e.to_string())
|
downloader::fetch_metadata(&app, &url, parse_mix_playlist).await.map_err(|e| e.to_string())
|
||||||
@@ -67,7 +99,7 @@ pub async fn start_download(app: AppHandle, url: String, options: DownloadOption
|
|||||||
output_path: output_dir,
|
output_path: output_dir,
|
||||||
timestamp: chrono::Utc::now(),
|
timestamp: chrono::Utc::now(),
|
||||||
status: status.to_string(),
|
status: status.to_string(),
|
||||||
format: options.quality,
|
format: options.output_format,
|
||||||
};
|
};
|
||||||
|
|
||||||
let _ = storage::add_history_item(&app, item);
|
let _ = storage::add_history_item(&app, item);
|
||||||
@@ -101,6 +133,16 @@ pub fn delete_history_item(app: AppHandle, id: String) -> Result<(), String> {
|
|||||||
storage::delete_history_item(&app, &id).map_err(|e| e.to_string())
|
storage::delete_history_item(&app, &id).map_err(|e| e.to_string())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub async fn close_splash(app: AppHandle) {
|
||||||
|
if let Some(splash) = app.get_webview_window("splashscreen") {
|
||||||
|
splash.close().unwrap();
|
||||||
|
}
|
||||||
|
if let Some(main) = app.get_webview_window("main") {
|
||||||
|
main.show().unwrap();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub fn open_in_explorer(app: AppHandle, path: String) -> Result<(), String> {
|
pub fn open_in_explorer(app: AppHandle, path: String) -> Result<(), String> {
|
||||||
let path_to_open = if Path::new(&path).exists() {
|
let path_to_open = if Path::new(&path).exists() {
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ use serde::{Deserialize, Serialize};
|
|||||||
use anyhow::{Result, anyhow};
|
use anyhow::{Result, anyhow};
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
use crate::binary_manager;
|
use crate::binary_manager;
|
||||||
|
use crate::storage;
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||||
pub struct VideoMetadata {
|
pub struct VideoMetadata {
|
||||||
@@ -15,6 +16,7 @@ pub struct VideoMetadata {
|
|||||||
pub thumbnail: String,
|
pub thumbnail: String,
|
||||||
pub duration: Option<f64>,
|
pub duration: Option<f64>,
|
||||||
pub uploader: Option<String>,
|
pub uploader: Option<String>,
|
||||||
|
pub url: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||||
@@ -36,6 +38,8 @@ pub struct DownloadOptions {
|
|||||||
pub is_audio_only: bool,
|
pub is_audio_only: bool,
|
||||||
pub quality: String, // e.g., "1080", "720", "best"
|
pub quality: String, // e.g., "1080", "720", "best"
|
||||||
pub output_path: String, // Directory
|
pub output_path: String, // Directory
|
||||||
|
pub output_format: String, // "original", "mp4", "webm", "mkv", "m4a", "aac", "opus", "vorbis", "wav", etc.
|
||||||
|
pub cookies_path: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Clone, Debug)]
|
#[derive(Serialize, Clone, Debug)]
|
||||||
@@ -58,36 +62,89 @@ pub struct LogEvent {
|
|||||||
pub async fn fetch_metadata(app: &AppHandle, url: &str, parse_mix_playlist: bool) -> Result<MetadataResult> {
|
pub async fn fetch_metadata(app: &AppHandle, url: &str, parse_mix_playlist: bool) -> Result<MetadataResult> {
|
||||||
app.emit("download-log", LogEvent {
|
app.emit("download-log", LogEvent {
|
||||||
id: "Analysis".to_string(),
|
id: "Analysis".to_string(),
|
||||||
message: format!("Starting metadata fetch for URL: {}", url),
|
message: format!("正在为 URL: {} 获取元数据", url),
|
||||||
level: "info".to_string(),
|
level: "info".to_string(),
|
||||||
}).ok();
|
}).ok();
|
||||||
|
|
||||||
let ytdlp_path = binary_manager::get_ytdlp_path(app)?;
|
let ytdlp_path = binary_manager::get_ytdlp_path(app)?;
|
||||||
let qjs_path = binary_manager::get_qjs_path(app)?; // Get absolute path to quickjs
|
let qjs_path = binary_manager::get_qjs_path(app)?; // Get absolute path to quickjs
|
||||||
|
|
||||||
let mut cmd = Command::new(ytdlp_path);
|
// Load settings to check for cookies
|
||||||
|
let settings = storage::load_settings(app)?;
|
||||||
|
|
||||||
|
let mut args = Vec::new();
|
||||||
|
|
||||||
// Pass the runtime and its absolute path to --js-runtimes
|
// Pass the runtime and its absolute path to --js-runtimes
|
||||||
cmd.arg("--js-runtimes").arg(format!("quickjs:{}", qjs_path.to_string_lossy()));
|
// Rust's Command automatically handles spaces in arguments, so we should NOT quote the path here.
|
||||||
|
args.push("--js-runtimes".to_string());
|
||||||
|
args.push(format!("quickjs:{}", qjs_path.to_string_lossy()));
|
||||||
|
|
||||||
cmd.arg("--dump-single-json")
|
let mut has_cookies = false;
|
||||||
.arg("--flat-playlist")
|
if let Some(cookies) = &settings.cookies_path {
|
||||||
.arg("--no-warnings");
|
if !cookies.is_empty() {
|
||||||
|
if std::path::Path::new(cookies).exists() {
|
||||||
if parse_mix_playlist {
|
args.push("--cookies".to_string());
|
||||||
cmd.arg("--playlist-end").arg("20");
|
args.push(cookies.clone());
|
||||||
|
has_cookies = true;
|
||||||
|
app.emit("download-log", LogEvent {
|
||||||
|
id: "Analysis".to_string(),
|
||||||
|
message: format!("已加载 Cookies: {}", cookies),
|
||||||
|
level: "info".to_string(),
|
||||||
|
}).ok();
|
||||||
|
} else {
|
||||||
|
app.emit("download-log", LogEvent {
|
||||||
|
id: "Analysis".to_string(),
|
||||||
|
message: format!("Cookies 文件不存在: {}", cookies),
|
||||||
|
level: "error".to_string(),
|
||||||
|
}).ok();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd.arg(url);
|
args.push("--dump-single-json".to_string());
|
||||||
|
args.push("--flat-playlist".to_string());
|
||||||
|
args.push("--no-warnings".to_string());
|
||||||
|
|
||||||
|
if has_cookies {
|
||||||
|
// When using cookies, avoid skipping JS player to prevent challenge errors
|
||||||
|
args.push("--extractor-args".to_string());
|
||||||
|
args.push("youtube:skip=dash,hls,translated_subs".to_string());
|
||||||
|
} else {
|
||||||
|
// Optimize metadata fetching: skip heavy manifests and player JS execution.
|
||||||
|
// Skipping JS prevents slow QuickJS spin-up and signature decryption, drastically speeding up single video parsing.
|
||||||
|
args.push("--extractor-args".to_string());
|
||||||
|
args.push("youtube:skip=dash,hls,translated_subs;player_skip=js".to_string());
|
||||||
|
}
|
||||||
|
|
||||||
|
if parse_mix_playlist {
|
||||||
|
args.push("--playlist-end".to_string());
|
||||||
|
args.push("20".to_string());
|
||||||
|
}
|
||||||
|
|
||||||
|
args.push(url.to_string());
|
||||||
|
|
||||||
|
let mut cmd = Command::new(&ytdlp_path);
|
||||||
|
#[cfg(target_os = "windows")]
|
||||||
|
cmd.creation_flags(0x08000000);
|
||||||
|
|
||||||
|
cmd.args(&args);
|
||||||
cmd.stderr(Stdio::piped());
|
cmd.stderr(Stdio::piped());
|
||||||
|
|
||||||
|
// Log the full command
|
||||||
|
let full_cmd_str = format!("{} {}", ytdlp_path.to_string_lossy(), args.join(" "));
|
||||||
|
app.emit("download-log", LogEvent {
|
||||||
|
id: "Analysis".to_string(),
|
||||||
|
message: format!("正在执行分析命令: {}", full_cmd_str),
|
||||||
|
level: "info".to_string(),
|
||||||
|
}).ok();
|
||||||
|
|
||||||
let output = cmd.output().await?;
|
let output = cmd.output().await?;
|
||||||
|
|
||||||
if !output.status.success() {
|
if !output.status.success() {
|
||||||
let stderr = String::from_utf8_lossy(&output.stderr);
|
let stderr = String::from_utf8_lossy(&output.stderr);
|
||||||
app.emit("download-log", LogEvent {
|
app.emit("download-log", LogEvent {
|
||||||
id: "Analysis".to_string(),
|
id: "Analysis".to_string(),
|
||||||
message: format!("Metadata fetch failed: {}", stderr),
|
message: format!("元数据获取失败: {}", stderr),
|
||||||
level: "error".to_string(),
|
level: "error".to_string(),
|
||||||
}).ok();
|
}).ok();
|
||||||
return Err(anyhow!("yt-dlp error: {}", stderr));
|
return Err(anyhow!("yt-dlp error: {}", stderr));
|
||||||
@@ -114,7 +171,7 @@ pub async fn fetch_metadata(app: &AppHandle, url: &str, parse_mix_playlist: bool
|
|||||||
|
|
||||||
app.emit("download-log", LogEvent {
|
app.emit("download-log", LogEvent {
|
||||||
id: "Analysis".to_string(),
|
id: "Analysis".to_string(),
|
||||||
message: "Metadata fetch success (Playlist)".to_string(),
|
message: "元数据获取成功(播放列表)".to_string(),
|
||||||
level: "info".to_string(),
|
level: "info".to_string(),
|
||||||
}).ok();
|
}).ok();
|
||||||
|
|
||||||
@@ -126,7 +183,7 @@ pub async fn fetch_metadata(app: &AppHandle, url: &str, parse_mix_playlist: bool
|
|||||||
let result = MetadataResult::Video(parse_video_metadata(&json));
|
let result = MetadataResult::Video(parse_video_metadata(&json));
|
||||||
app.emit("download-log", LogEvent {
|
app.emit("download-log", LogEvent {
|
||||||
id: "Analysis".to_string(),
|
id: "Analysis".to_string(),
|
||||||
message: "Metadata fetch success (Video)".to_string(),
|
message: "元数据获取成功(视频)".to_string(),
|
||||||
level: "info".to_string(),
|
level: "info".to_string(),
|
||||||
}).ok();
|
}).ok();
|
||||||
|
|
||||||
@@ -142,12 +199,17 @@ fn parse_video_metadata(json: &serde_json::Value) -> VideoMetadata {
|
|||||||
_ => format!("https://i.ytimg.com/vi/{}/mqdefault.jpg", id),
|
_ => format!("https://i.ytimg.com/vi/{}/mqdefault.jpg", id),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let url = json["webpage_url"].as_str()
|
||||||
|
.or_else(|| json["url"].as_str())
|
||||||
|
.map(|s| s.to_string());
|
||||||
|
|
||||||
VideoMetadata {
|
VideoMetadata {
|
||||||
id,
|
id,
|
||||||
title: json["title"].as_str().unwrap_or("Unknown Title").to_string(),
|
title: json["title"].as_str().unwrap_or("Unknown Title").to_string(),
|
||||||
thumbnail,
|
thumbnail,
|
||||||
duration: json["duration"].as_f64(),
|
duration: json["duration"].as_f64(),
|
||||||
uploader: json["uploader"].as_str().map(|s| s.to_string()),
|
uploader: json["uploader"].as_str().map(|s| s.to_string()),
|
||||||
|
url,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -159,12 +221,24 @@ pub async fn download_video(
|
|||||||
) -> Result<String> {
|
) -> Result<String> {
|
||||||
let ytdlp_path = binary_manager::get_ytdlp_path(&app)?;
|
let ytdlp_path = binary_manager::get_ytdlp_path(&app)?;
|
||||||
let qjs_path = binary_manager::get_qjs_path(&app)?; // Get absolute path to quickjs
|
let qjs_path = binary_manager::get_qjs_path(&app)?; // Get absolute path to quickjs
|
||||||
|
let ffmpeg_path = binary_manager::get_ffmpeg_path(&app)?; // Get absolute path to ffmpeg
|
||||||
|
|
||||||
let mut args = Vec::new();
|
let mut args = Vec::new();
|
||||||
|
|
||||||
// Pass the runtime and its absolute path to --js-runtimes
|
// Pass the runtime and its absolute path to --js-runtimes
|
||||||
args.push("--js-runtimes".to_string());
|
args.push("--js-runtimes".to_string());
|
||||||
|
// Rust's Command automatically handles spaces in arguments, so we should NOT quote the path here.
|
||||||
args.push(format!("quickjs:{}", qjs_path.to_string_lossy()));
|
args.push(format!("quickjs:{}", qjs_path.to_string_lossy()));
|
||||||
|
// Pass ffmpeg location so yt-dlp can find our managed ffmpeg
|
||||||
|
args.push("--ffmpeg-location".to_string());
|
||||||
|
args.push(ffmpeg_path.to_string_lossy().to_string());
|
||||||
|
|
||||||
|
if let Some(cookies) = &options.cookies_path {
|
||||||
|
if !cookies.is_empty() {
|
||||||
|
args.push("--cookies".to_string());
|
||||||
|
args.push(cookies.clone());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
args.push(url);
|
args.push(url);
|
||||||
|
|
||||||
@@ -176,16 +250,25 @@ pub async fn download_video(
|
|||||||
// Formats
|
// Formats
|
||||||
if options.is_audio_only {
|
if options.is_audio_only {
|
||||||
args.push("-x".to_string());
|
args.push("-x".to_string());
|
||||||
args.push("--audio-format".to_string());
|
// Only set audio format if not "original"
|
||||||
args.push("mp3".to_string());
|
if options.output_format != "original" {
|
||||||
|
args.push("--audio-format".to_string());
|
||||||
|
args.push(options.output_format.clone());
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
let format_arg = if options.quality == "best" {
|
let format_arg = if options.quality == "best" {
|
||||||
"bestvideo+bestaudio/best".to_string()
|
"bestvideo+bestaudio/best".to_string()
|
||||||
} else {
|
} else {
|
||||||
format!("bestvideo[height<={}]+bestaudio/best[height<={}]", options.quality, options.quality)
|
format!("bestvideo[height<={}]+bestaudio/best[height<={}]/best", options.quality, options.quality)
|
||||||
};
|
};
|
||||||
args.push("-f".to_string());
|
args.push("-f".to_string());
|
||||||
args.push(format_arg);
|
args.push(format_arg);
|
||||||
|
|
||||||
|
// Only set merge output format if not "original"
|
||||||
|
if options.output_format != "original" {
|
||||||
|
args.push("--merge-output-format".to_string());
|
||||||
|
args.push(options.output_format.clone());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Progress output
|
// Progress output
|
||||||
@@ -195,11 +278,13 @@ pub async fn download_video(
|
|||||||
let full_cmd_str = format!("{} {}", ytdlp_path.to_string_lossy(), args.join(" "));
|
let full_cmd_str = format!("{} {}", ytdlp_path.to_string_lossy(), args.join(" "));
|
||||||
app.emit("download-log", LogEvent {
|
app.emit("download-log", LogEvent {
|
||||||
id: id.clone(),
|
id: id.clone(),
|
||||||
message: format!("Executing command: {}", full_cmd_str),
|
message: format!("正在执行命令: {}", full_cmd_str),
|
||||||
level: "info".to_string(),
|
level: "info".to_string(),
|
||||||
}).ok();
|
}).ok();
|
||||||
|
|
||||||
let mut cmd = Command::new(ytdlp_path);
|
let mut cmd = Command::new(ytdlp_path);
|
||||||
|
#[cfg(target_os = "windows")]
|
||||||
|
cmd.creation_flags(0x08000000);
|
||||||
|
|
||||||
let mut child = cmd
|
let mut child = cmd
|
||||||
.args(&args)
|
.args(&args)
|
||||||
@@ -233,7 +318,7 @@ pub async fn download_video(
|
|||||||
app.emit("download-progress", ProgressEvent {
|
app.emit("download-progress", ProgressEvent {
|
||||||
id: id.clone(),
|
id: id.clone(),
|
||||||
progress: pct,
|
progress: pct,
|
||||||
speed: "TODO".to_string(),
|
speed: "待定".to_string(),
|
||||||
status: "downloading".to_string(),
|
status: "downloading".to_string(),
|
||||||
}).ok();
|
}).ok();
|
||||||
}
|
}
|
||||||
@@ -268,7 +353,7 @@ pub async fn download_video(
|
|||||||
speed: "-".to_string(),
|
speed: "-".to_string(),
|
||||||
status: "finished".to_string(),
|
status: "finished".to_string(),
|
||||||
}).ok();
|
}).ok();
|
||||||
Ok("Download complete".to_string())
|
Ok("下载完成".to_string())
|
||||||
} else {
|
} else {
|
||||||
app.emit("download-progress", ProgressEvent {
|
app.emit("download-progress", ProgressEvent {
|
||||||
id: id.clone(),
|
id: id.clone(),
|
||||||
@@ -276,6 +361,6 @@ pub async fn download_video(
|
|||||||
speed: "-".to_string(),
|
speed: "-".to_string(),
|
||||||
status: "error".to_string(),
|
status: "error".to_string(),
|
||||||
}).ok();
|
}).ok();
|
||||||
Err(anyhow!("Download process failed"))
|
Err(anyhow!("下载进程失败"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,8 +13,11 @@ pub fn run() {
|
|||||||
commands::init_ytdlp,
|
commands::init_ytdlp,
|
||||||
commands::update_ytdlp,
|
commands::update_ytdlp,
|
||||||
commands::update_quickjs,
|
commands::update_quickjs,
|
||||||
|
commands::update_ffmpeg,
|
||||||
commands::get_ytdlp_version,
|
commands::get_ytdlp_version,
|
||||||
commands::get_quickjs_version,
|
commands::get_quickjs_version,
|
||||||
|
commands::get_ffmpeg_version,
|
||||||
|
commands::fetch_image,
|
||||||
commands::fetch_metadata,
|
commands::fetch_metadata,
|
||||||
commands::start_download,
|
commands::start_download,
|
||||||
commands::get_settings,
|
commands::get_settings,
|
||||||
@@ -22,6 +25,7 @@ pub fn run() {
|
|||||||
commands::get_history,
|
commands::get_history,
|
||||||
commands::clear_history,
|
commands::clear_history,
|
||||||
commands::delete_history_item,
|
commands::delete_history_item,
|
||||||
|
commands::close_splash,
|
||||||
commands::open_in_explorer
|
commands::open_in_explorer
|
||||||
])
|
])
|
||||||
.run(tauri::generate_context!())
|
.run(tauri::generate_context!())
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ use chrono::{DateTime, Utc};
|
|||||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||||
pub struct Settings {
|
pub struct Settings {
|
||||||
pub download_path: String,
|
pub download_path: String,
|
||||||
|
pub cookies_path: Option<String>,
|
||||||
pub theme: String, // 'light', 'dark', 'system'
|
pub theme: String, // 'light', 'dark', 'system'
|
||||||
pub last_updated: Option<DateTime<Utc>>,
|
pub last_updated: Option<DateTime<Utc>>,
|
||||||
}
|
}
|
||||||
@@ -19,6 +20,7 @@ impl Default for Settings {
|
|||||||
// but for default struct we can keep it empty or a placeholder.
|
// but for default struct we can keep it empty or a placeholder.
|
||||||
Self {
|
Self {
|
||||||
download_path: "".to_string(),
|
download_path: "".to_string(),
|
||||||
|
cookies_path: None,
|
||||||
theme: "system".to_string(),
|
theme: "system".to_string(),
|
||||||
last_updated: None,
|
last_updated: None,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"$schema": "https://schema.tauri.app/config/2",
|
"$schema": "https://schema.tauri.app/config/2",
|
||||||
"productName": "stream-capture",
|
"productName": "StreamCapture",
|
||||||
"version": "0.1.0",
|
"version": "1.2.0",
|
||||||
"identifier": "top.volan.stream-capture",
|
"identifier": "top.volan.stream-capture",
|
||||||
"build": {
|
"build": {
|
||||||
"beforeDevCommand": "pnpm dev",
|
"beforeDevCommand": "pnpm dev",
|
||||||
@@ -12,9 +12,22 @@
|
|||||||
"app": {
|
"app": {
|
||||||
"windows": [
|
"windows": [
|
||||||
{
|
{
|
||||||
"title": "Stream Capture",
|
"label": "main",
|
||||||
|
"title": "流萤 - 视频下载 v1.2.0",
|
||||||
"width": 1300,
|
"width": 1300,
|
||||||
"height": 850
|
"height": 900,
|
||||||
|
"visible": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "splashscreen",
|
||||||
|
"title": "StreamCapture Loading",
|
||||||
|
"url": "splashscreen.html",
|
||||||
|
"width": 400,
|
||||||
|
"height": 300,
|
||||||
|
"decorations": false,
|
||||||
|
"center": true,
|
||||||
|
"resizable": false,
|
||||||
|
"alwaysOnTop": true
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"security": {
|
"security": {
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
// filepath: src/App.vue
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { onMounted } from 'vue'
|
import { onMounted } from 'vue'
|
||||||
import { RouterView, RouterLink, useRoute } from 'vue-router'
|
import { RouterView, RouterLink, useRoute } from 'vue-router'
|
||||||
@@ -23,7 +22,7 @@ onMounted(async () => {
|
|||||||
<template>
|
<template>
|
||||||
<div class="flex h-screen bg-gray-50 dark:bg-zinc-950 text-zinc-900 dark:text-gray-100 font-sans overflow-hidden">
|
<div class="flex h-screen bg-gray-50 dark:bg-zinc-950 text-zinc-900 dark:text-gray-100 font-sans overflow-hidden">
|
||||||
<!-- Sidebar -->
|
<!-- Sidebar -->
|
||||||
<aside class="w-20 lg:w-64 bg-white dark:bg-zinc-900 border-r border-gray-200 dark:border-zinc-800 flex flex-col flex-shrink-0">
|
<aside class="w-20 lg:w-48 bg-white dark:bg-zinc-900 border-r border-gray-200 dark:border-zinc-800 flex flex-col flex-shrink-0">
|
||||||
<div class="p-6 flex items-center gap-3 justify-center lg:justify-start">
|
<div class="p-6 flex items-center gap-3 justify-center lg:justify-start">
|
||||||
<div class="w-8 h-8 bg-blue-600 rounded-lg flex items-center justify-center text-white shrink-0">
|
<div class="w-8 h-8 bg-blue-600 rounded-lg flex items-center justify-center text-white shrink-0">
|
||||||
<Download class="w-5 h-5" />
|
<Download class="w-5 h-5" />
|
||||||
|
|||||||
44
src/splash/App.vue
Normal file
44
src/splash/App.vue
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { onMounted, ref } from 'vue'
|
||||||
|
import { invoke } from '@tauri-apps/api/core'
|
||||||
|
import { Loader2, DownloadCloud, CheckCircle2, AlertCircle } from 'lucide-vue-next'
|
||||||
|
|
||||||
|
const status = ref('正在初始化...')
|
||||||
|
const isError = ref(false)
|
||||||
|
|
||||||
|
onMounted(async () => {
|
||||||
|
try {
|
||||||
|
status.value = '正在检查运行环境...'
|
||||||
|
// This command checks and downloads binaries if missing
|
||||||
|
await invoke('init_ytdlp')
|
||||||
|
|
||||||
|
status.value = '准备就绪'
|
||||||
|
setTimeout(async () => {
|
||||||
|
await invoke('close_splash')
|
||||||
|
}, 800)
|
||||||
|
} catch (e: any) {
|
||||||
|
status.value = '启动错误: ' + (e.toString() || '未知错误')
|
||||||
|
isError.value = true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="h-screen w-screen bg-white dark:bg-zinc-900 flex flex-col items-center justify-center select-none cursor-default p-8 text-center overflow-hidden" data-tauri-drag-region>
|
||||||
|
<div class="mb-6 relative w-20 h-20 bg-blue-600 rounded-2xl shadow-xl flex items-center justify-center text-white">
|
||||||
|
<DownloadCloud v-if="!isError" class="w-10 h-10" />
|
||||||
|
<AlertCircle v-else class="w-10 h-10" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<h1 class="text-xl font-bold text-zinc-900 dark:text-white mb-6">流萤 - 视频下载</h1>
|
||||||
|
|
||||||
|
<div class="flex flex-col items-center gap-3 w-full max-w-xs">
|
||||||
|
<div class="flex items-center gap-2.5 text-sm font-medium transition-colors duration-300"
|
||||||
|
:class="isError ? 'text-red-500' : 'text-gray-600 dark:text-gray-300'">
|
||||||
|
<Loader2 v-if="!isError && status !== '准备就绪'" class="animate-spin w-4 h-4" />
|
||||||
|
<CheckCircle2 v-if="status === '准备就绪'" class="w-4 h-4 text-green-500" />
|
||||||
|
<span>{{ status }}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
5
src/splash/main.ts
Normal file
5
src/splash/main.ts
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
import { createApp } from 'vue'
|
||||||
|
import App from './App.vue'
|
||||||
|
import '../style.css'
|
||||||
|
|
||||||
|
createApp(App).mount('#app')
|
||||||
@@ -12,10 +12,15 @@ export const useAnalysisStore = defineStore('analysis', () => {
|
|||||||
const isMix = ref(false)
|
const isMix = ref(false)
|
||||||
const scanMix = ref(false)
|
const scanMix = ref(false)
|
||||||
|
|
||||||
|
// Input mode state
|
||||||
|
const isBatchMode = ref(false)
|
||||||
|
|
||||||
const options = ref({
|
const options = ref({
|
||||||
is_audio_only: false,
|
is_audio_only: false,
|
||||||
quality: 'best',
|
quality: 'best',
|
||||||
output_path: ''
|
output_path: '',
|
||||||
|
output_format: 'original',
|
||||||
|
cookies_path: ''
|
||||||
})
|
})
|
||||||
|
|
||||||
function toggleEntry(id: string) {
|
function toggleEntry(id: string) {
|
||||||
@@ -54,5 +59,5 @@ export const useAnalysisStore = defineStore('analysis', () => {
|
|||||||
scanMix.value = false
|
scanMix.value = false
|
||||||
}
|
}
|
||||||
|
|
||||||
return { url, loading, error, metadata, options, isMix, scanMix, toggleEntry, setAllEntries, invertSelection, reset }
|
return { url, loading, error, metadata, options, isMix, scanMix, isBatchMode, toggleEntry, setAllEntries, invertSelection, reset }
|
||||||
})
|
})
|
||||||
@@ -5,6 +5,7 @@ import { ref } from 'vue'
|
|||||||
|
|
||||||
export interface Settings {
|
export interface Settings {
|
||||||
download_path: string
|
download_path: string
|
||||||
|
cookies_path?: string
|
||||||
theme: 'light' | 'dark' | 'system'
|
theme: 'light' | 'dark' | 'system'
|
||||||
last_updated: string | null
|
last_updated: string | null
|
||||||
}
|
}
|
||||||
@@ -12,12 +13,14 @@ export interface Settings {
|
|||||||
export const useSettingsStore = defineStore('settings', () => {
|
export const useSettingsStore = defineStore('settings', () => {
|
||||||
const settings = ref<Settings>({
|
const settings = ref<Settings>({
|
||||||
download_path: '',
|
download_path: '',
|
||||||
|
cookies_path: '',
|
||||||
theme: 'system',
|
theme: 'system',
|
||||||
last_updated: null
|
last_updated: null
|
||||||
})
|
})
|
||||||
|
|
||||||
const ytdlpVersion = ref('Checking...')
|
const ytdlpVersion = ref('Checking...')
|
||||||
const quickjsVersion = ref('Checking...')
|
const quickjsVersion = ref('Checking...')
|
||||||
|
const ffmpegVersion = ref('Checking...')
|
||||||
const isInitializing = ref(true)
|
const isInitializing = ref(true)
|
||||||
|
|
||||||
async function loadSettings() {
|
async function loadSettings() {
|
||||||
@@ -49,6 +52,7 @@ export const useSettingsStore = defineStore('settings', () => {
|
|||||||
console.error(e)
|
console.error(e)
|
||||||
ytdlpVersion.value = 'Error'
|
ytdlpVersion.value = 'Error'
|
||||||
quickjsVersion.value = 'Error'
|
quickjsVersion.value = 'Error'
|
||||||
|
ffmpegVersion.value = 'Error'
|
||||||
} finally {
|
} finally {
|
||||||
isInitializing.value = false
|
isInitializing.value = false
|
||||||
}
|
}
|
||||||
@@ -57,6 +61,7 @@ export const useSettingsStore = defineStore('settings', () => {
|
|||||||
async function refreshVersions() {
|
async function refreshVersions() {
|
||||||
ytdlpVersion.value = await invoke('get_ytdlp_version')
|
ytdlpVersion.value = await invoke('get_ytdlp_version')
|
||||||
quickjsVersion.value = await invoke('get_quickjs_version')
|
quickjsVersion.value = await invoke('get_quickjs_version')
|
||||||
|
ffmpegVersion.value = await invoke('get_ffmpeg_version')
|
||||||
}
|
}
|
||||||
|
|
||||||
function applyTheme(theme: string) {
|
function applyTheme(theme: string) {
|
||||||
@@ -76,5 +81,5 @@ export const useSettingsStore = defineStore('settings', () => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
return { settings, loadSettings, save, initYtdlp, refreshVersions, ytdlpVersion, quickjsVersion, isInitializing }
|
return { settings, loadSettings, save, initYtdlp, refreshVersions, ytdlpVersion, quickjsVersion, ffmpegVersion, isInitializing }
|
||||||
})
|
})
|
||||||
@@ -54,7 +54,7 @@ onMounted(loadHistory)
|
|||||||
<header class="mb-8 flex justify-between items-center">
|
<header class="mb-8 flex justify-between items-center">
|
||||||
<div>
|
<div>
|
||||||
<h1 class="text-3xl font-bold text-zinc-900 dark:text-white">下载历史</h1>
|
<h1 class="text-3xl font-bold text-zinc-900 dark:text-white">下载历史</h1>
|
||||||
<p class="text-gray-500 dark:text-gray-400 mt-2">管理您的下载记录。</p>
|
<!-- <p class="text-gray-500 dark:text-gray-400 mt-2">管理您的下载记录。</p> -->
|
||||||
</div>
|
</div>
|
||||||
<button
|
<button
|
||||||
@click="clearHistory"
|
@click="clearHistory"
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { watch } from 'vue'
|
import { watch } from 'vue'
|
||||||
import { invoke } from '@tauri-apps/api/core'
|
import { invoke } from '@tauri-apps/api/core'
|
||||||
import { Loader2 } from 'lucide-vue-next'
|
import { Loader2, List, Link } from 'lucide-vue-next'
|
||||||
import { useQueueStore } from '../stores/queue'
|
import { useQueueStore } from '../stores/queue'
|
||||||
import { useSettingsStore } from '../stores/settings'
|
import { useSettingsStore } from '../stores/settings'
|
||||||
import { useAnalysisStore } from '../stores/analysis'
|
import { useAnalysisStore } from '../stores/analysis'
|
||||||
@@ -18,6 +18,26 @@ const qualityOptions = [
|
|||||||
{ label: '480p', value: '480' },
|
{ label: '480p', value: '480' },
|
||||||
]
|
]
|
||||||
|
|
||||||
|
const videoFormatOptions = [
|
||||||
|
{ label: '原格式', value: 'original' },
|
||||||
|
{ label: 'MP4', value: 'mp4' },
|
||||||
|
{ label: 'WebM', value: 'webm' },
|
||||||
|
{ label: 'Matroska (MKV)', value: 'mkv' },
|
||||||
|
{ label: 'FLV', value: 'flv' },
|
||||||
|
{ label: 'AVI', value: 'avi' },
|
||||||
|
]
|
||||||
|
|
||||||
|
const audioFormatOptions = [
|
||||||
|
{ label: '原格式', value: 'original' },
|
||||||
|
{ label: 'MP3', value: 'mp3' },
|
||||||
|
{ label: 'M4A', value: 'm4a' },
|
||||||
|
{ label: 'AAC', value: 'aac' },
|
||||||
|
{ label: 'Opus', value: 'opus' },
|
||||||
|
{ label: 'Vorbis', value: 'vorbis' },
|
||||||
|
{ label: 'WAV', value: 'wav' },
|
||||||
|
{ label: 'FLAC', value: 'flac' },
|
||||||
|
]
|
||||||
|
|
||||||
// Sync default download path if not set
|
// Sync default download path if not set
|
||||||
watch(() => settingsStore.settings.download_path, (newPath) => {
|
watch(() => settingsStore.settings.download_path, (newPath) => {
|
||||||
if (newPath && !analysisStore.options.output_path) {
|
if (newPath && !analysisStore.options.output_path) {
|
||||||
@@ -36,6 +56,43 @@ watch(() => analysisStore.url, (newUrl) => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Reset format to original when toggling audio-only mode
|
||||||
|
watch(() => analysisStore.options.is_audio_only, () => {
|
||||||
|
analysisStore.options.output_format = 'original'
|
||||||
|
})
|
||||||
|
|
||||||
|
async function processThumbnail(url: string | undefined): Promise<string | undefined> {
|
||||||
|
if (!url) return undefined;
|
||||||
|
// Check if it's an Instagram URL or similar that needs proxying
|
||||||
|
if (url.includes('instagram.com') || url.includes('fbcdn.net') || url.includes('cdninstagram.com')) {
|
||||||
|
try {
|
||||||
|
return await invoke<string>('fetch_image', { url });
|
||||||
|
} catch (e) {
|
||||||
|
console.warn('Thumbnail fetch failed, falling back to URL', e);
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function processMetadataThumbnails(metadata: any) {
|
||||||
|
if (!metadata) return;
|
||||||
|
|
||||||
|
// Process single video thumbnail
|
||||||
|
if (metadata.thumbnail) {
|
||||||
|
metadata.thumbnail = await processThumbnail(metadata.thumbnail);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Process playlist entries
|
||||||
|
if (metadata.entries && Array.isArray(metadata.entries)) {
|
||||||
|
await Promise.all(metadata.entries.map(async (entry: any) => {
|
||||||
|
if (entry.thumbnail) {
|
||||||
|
entry.thumbnail = await processThumbnail(entry.thumbnail);
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function analyze() {
|
async function analyze() {
|
||||||
if (!analysisStore.url) return
|
if (!analysisStore.url) return
|
||||||
analysisStore.loading = true
|
analysisStore.loading = true
|
||||||
@@ -43,36 +100,105 @@ async function analyze() {
|
|||||||
analysisStore.metadata = null
|
analysisStore.metadata = null
|
||||||
|
|
||||||
try {
|
try {
|
||||||
let urlToScan = analysisStore.url;
|
if (analysisStore.isBatchMode) {
|
||||||
let parseMix = false;
|
// Batch Mode Logic
|
||||||
|
const lines = analysisStore.url.split('\n').map(l => l.trim()).filter(l => l);
|
||||||
|
const validLinks = lines.filter(l => {
|
||||||
|
if (!(l.startsWith('http://') || l.startsWith('https://'))) return false;
|
||||||
|
|
||||||
if (analysisStore.isMix) {
|
// Allow if it has NO list param
|
||||||
if (analysisStore.scanMix) {
|
if (!l.includes('list=')) return true;
|
||||||
// Keep URL as is, tell backend to limit scan
|
|
||||||
parseMix = true;
|
// Allow if it has list param BUT ALSO has v= (video in playlist/mix)
|
||||||
} else {
|
if (l.includes('list=') && l.includes('v=')) return true;
|
||||||
// Strip list param
|
|
||||||
try {
|
// Otherwise ignore (pure playlist)
|
||||||
const u = new URL(urlToScan);
|
return false;
|
||||||
u.searchParams.delete('list');
|
});
|
||||||
u.searchParams.delete('index');
|
|
||||||
u.searchParams.delete('start_radio');
|
if (validLinks.length === 0) {
|
||||||
urlToScan = u.toString();
|
throw new Error("未找到有效的单个视频链接(已忽略纯播放列表链接)。");
|
||||||
} catch (e) {
|
|
||||||
// Fallback regex if URL parsing fails
|
|
||||||
urlToScan = urlToScan.replace(/&list=[^&]+/, '');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const results: any[] = [];
|
||||||
|
|
||||||
|
// Process sequentially to be safe
|
||||||
|
for (let link of validLinks) {
|
||||||
|
try {
|
||||||
|
// If it's a mix/playlist context (has v= and list=), strip the list param to treat as single video
|
||||||
|
if (link.includes('list=') && link.includes('v=')) {
|
||||||
|
try {
|
||||||
|
const u = new URL(link);
|
||||||
|
u.searchParams.delete('list');
|
||||||
|
u.searchParams.delete('index');
|
||||||
|
u.searchParams.delete('start_radio');
|
||||||
|
link = u.toString();
|
||||||
|
} catch (e) {
|
||||||
|
link = link.replace(/&list=[^&]+/, '');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ensure we don't accidentally trigger mix parsing on single links if logic fails
|
||||||
|
const res = await invoke<any>('fetch_metadata', { url: link, parseMixPlaylist: false });
|
||||||
|
|
||||||
|
// Only add if it's a single video (no entries)
|
||||||
|
if (!res.entries) {
|
||||||
|
results.push(res);
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.warn(`Failed to parse ${link}`, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (results.length === 0) {
|
||||||
|
throw new Error("所有链接解析失败或均为播放列表。");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Process thumbnails for batch results
|
||||||
|
await Promise.all(results.map(r => processMetadataThumbnails(r)));
|
||||||
|
|
||||||
|
// Construct synthetic playlist
|
||||||
|
analysisStore.metadata = {
|
||||||
|
id: 'batch_download_' + Date.now(),
|
||||||
|
title: `批量解析结果 (${results.length} 个视频)`,
|
||||||
|
entries: results.map(e => ({ ...e, selected: true }))
|
||||||
|
};
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// Single Link Mode
|
||||||
|
let urlToScan = analysisStore.url;
|
||||||
|
let parseMix = false;
|
||||||
|
|
||||||
|
if (analysisStore.isMix) {
|
||||||
|
if (analysisStore.scanMix) {
|
||||||
|
// Keep URL as is, tell backend to limit scan
|
||||||
|
parseMix = true;
|
||||||
|
} else {
|
||||||
|
// Strip list param
|
||||||
|
try {
|
||||||
|
const u = new URL(urlToScan);
|
||||||
|
u.searchParams.delete('list');
|
||||||
|
u.searchParams.delete('index');
|
||||||
|
u.searchParams.delete('start_radio');
|
||||||
|
urlToScan = u.toString();
|
||||||
|
} catch (e) {
|
||||||
|
// Fallback regex if URL parsing fails
|
||||||
|
urlToScan = urlToScan.replace(/&list=[^&]+/, '');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const res = await invoke<any>('fetch_metadata', { url: urlToScan, parseMixPlaylist: parseMix })
|
||||||
|
|
||||||
|
await processMetadataThumbnails(res);
|
||||||
|
|
||||||
|
// Initialize selected state for playlist entries
|
||||||
|
if (res.entries) {
|
||||||
|
res.entries = res.entries.map((e: any) => ({ ...e, selected: true }))
|
||||||
|
}
|
||||||
|
|
||||||
|
analysisStore.metadata = res
|
||||||
}
|
}
|
||||||
|
|
||||||
const res = await invoke<any>('fetch_metadata', { url: urlToScan, parseMixPlaylist: parseMix })
|
|
||||||
|
|
||||||
// Initialize selected state for playlist entries
|
|
||||||
if (res.entries) {
|
|
||||||
res.entries = res.entries.map((e: any) => ({ ...e, selected: true }))
|
|
||||||
}
|
|
||||||
|
|
||||||
analysisStore.metadata = res
|
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
analysisStore.error = e.toString()
|
analysisStore.error = e.toString()
|
||||||
} finally {
|
} finally {
|
||||||
@@ -88,6 +214,9 @@ async function startDownload() {
|
|||||||
analysisStore.options.output_path = settingsStore.settings.download_path
|
analysisStore.options.output_path = settingsStore.settings.download_path
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Ensure cookies path is set from settings
|
||||||
|
analysisStore.options.cookies_path = settingsStore.settings.cookies_path || ''
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (analysisStore.metadata.entries) {
|
if (analysisStore.metadata.entries) {
|
||||||
// Playlist Download
|
// Playlist Download
|
||||||
@@ -99,7 +228,7 @@ async function startDownload() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (const entry of selectedEntries) {
|
for (const entry of selectedEntries) {
|
||||||
const videoUrl = `https://www.youtube.com/watch?v=${entry.id}`
|
const videoUrl = entry.url || `https://www.youtube.com/watch?v=${entry.id}`
|
||||||
const id = await invoke<string>('start_download', {
|
const id = await invoke<string>('start_download', {
|
||||||
url: videoUrl,
|
url: videoUrl,
|
||||||
options: analysisStore.options,
|
options: analysisStore.options,
|
||||||
@@ -159,31 +288,58 @@ async function startDownload() {
|
|||||||
<div class="max-w-5xl mx-auto p-8">
|
<div class="max-w-5xl mx-auto p-8">
|
||||||
<header class="mb-8">
|
<header class="mb-8">
|
||||||
<h1 class="text-3xl font-bold text-zinc-900 dark:text-white">新建下载</h1>
|
<h1 class="text-3xl font-bold text-zinc-900 dark:text-white">新建下载</h1>
|
||||||
<p class="text-gray-500 dark:text-gray-400 mt-2">粘贴 URL 开始下载媒体。</p>
|
<!-- <p class="text-gray-500 dark:text-gray-400 mt-2">粘贴 URL 开始下载媒体。</p> -->
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
<!-- Input Section -->
|
<!-- Input Section -->
|
||||||
<div class="bg-white dark:bg-zinc-900 p-6 rounded-2xl shadow-sm border border-gray-200 dark:border-zinc-800 mb-8">
|
<div class="bg-white dark:bg-zinc-900 p-6 rounded-2xl shadow-sm border border-gray-200 dark:border-zinc-800 mb-8">
|
||||||
<div class="flex gap-4">
|
|
||||||
<input
|
<!-- Input Area with Batch Toggle -->
|
||||||
v-model="analysisStore.url"
|
<div class="flex flex-col gap-3">
|
||||||
type="text"
|
<div class="flex justify-end mb-1">
|
||||||
placeholder="https://youtube.com/watch?v=..."
|
<button
|
||||||
class="flex-1 bg-gray-50 dark:bg-zinc-800 border-none rounded-xl px-4 py-3 text-zinc-900 dark:text-white focus:ring-2 focus:ring-blue-500 outline-none"
|
@click="analysisStore.isBatchMode = !analysisStore.isBatchMode"
|
||||||
@keyup.enter="analyze"
|
class="text-xs font-medium flex items-center gap-1.5 px-3 py-1.5 rounded-lg transition-colors"
|
||||||
/>
|
:class="analysisStore.isBatchMode ? 'bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-400' : 'bg-gray-100 text-gray-600 dark:bg-zinc-800 dark:text-gray-400 hover:bg-gray-200 dark:hover:bg-zinc-700'"
|
||||||
<button
|
>
|
||||||
@click="analyze"
|
<List v-if="analysisStore.isBatchMode" class="w-3.5 h-3.5" />
|
||||||
:disabled="analysisStore.loading"
|
<Link v-else class="w-3.5 h-3.5" />
|
||||||
class="bg-blue-600 hover:bg-blue-700 text-white px-6 py-3 rounded-xl font-medium transition-colors disabled:opacity-50 flex items-center gap-2 shrink-0"
|
{{ analysisStore.isBatchMode ? '单链接模式' : '批量输入模式' }}
|
||||||
>
|
</button>
|
||||||
<Loader2 v-if="analysisStore.loading" class="animate-spin w-5 h-5" />
|
</div>
|
||||||
<span v-else>解析</span>
|
|
||||||
</button>
|
<div class="flex gap-4 items-start">
|
||||||
|
<div class="flex-1 relative">
|
||||||
|
<textarea
|
||||||
|
v-if="analysisStore.isBatchMode"
|
||||||
|
v-model="analysisStore.url"
|
||||||
|
placeholder="每行输入一个链接..."
|
||||||
|
rows="5"
|
||||||
|
class="w-full bg-gray-50 dark:bg-zinc-800 border-none rounded-xl px-4 py-3 text-zinc-900 dark:text-white focus:ring-2 focus:ring-blue-500 outline-none resize-none font-mono text-sm leading-relaxed"
|
||||||
|
></textarea>
|
||||||
|
<input
|
||||||
|
v-else
|
||||||
|
v-model="analysisStore.url"
|
||||||
|
type="text"
|
||||||
|
placeholder="https://..."
|
||||||
|
class="w-full bg-gray-50 dark:bg-zinc-800 border-none rounded-xl px-4 py-3 text-zinc-900 dark:text-white focus:ring-2 focus:ring-blue-500 outline-none"
|
||||||
|
@keyup.enter="analyze"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<button
|
||||||
|
@click="analyze"
|
||||||
|
:disabled="analysisStore.loading"
|
||||||
|
class="bg-blue-600 hover:bg-blue-700 text-white px-6 py-3 rounded-xl font-medium transition-colors disabled:opacity-50 flex items-center gap-2 shrink-0 h-[48px]"
|
||||||
|
>
|
||||||
|
<Loader2 v-if="analysisStore.loading" class="animate-spin w-5 h-5" />
|
||||||
|
<span v-else>解析</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Mix Toggle -->
|
<!-- Mix Toggle (Only in Single Mode) -->
|
||||||
<div v-if="analysisStore.isMix" class="mt-4 flex items-center gap-3">
|
<div v-if="!analysisStore.isBatchMode && analysisStore.isMix" class="mt-4 flex items-center gap-3">
|
||||||
<button
|
<button
|
||||||
@click="analysisStore.scanMix = !analysisStore.scanMix"
|
@click="analysisStore.scanMix = !analysisStore.scanMix"
|
||||||
class="w-12 h-6 rounded-full relative transition-colors duration-200 ease-in-out flex-shrink-0"
|
class="w-12 h-6 rounded-full relative transition-colors duration-200 ease-in-out flex-shrink-0"
|
||||||
@@ -217,31 +373,30 @@ async function startDownload() {
|
|||||||
|
|
||||||
<!-- Left: Selection Controls -->
|
<!-- Left: Selection Controls -->
|
||||||
<div class="flex items-center gap-2 w-full md:w-auto">
|
<div class="flex items-center gap-2 w-full md:w-auto">
|
||||||
<button @click="analysisStore.setAllEntries(true)" class="text-xs font-medium px-3 py-1.5 rounded-lg bg-white dark:bg-zinc-700 hover:bg-gray-100 dark:hover:bg-zinc-600 text-zinc-700 dark:text-gray-200 border border-gray-200 dark:border-zinc-600 transition-colors shadow-sm">全选</button>
|
<button @click="analysisStore.setAllEntries(true)" class="text-base font-medium px-3 py-1.5 rounded-lg bg-white dark:bg-zinc-700 hover:bg-gray-100 dark:hover:bg-zinc-600 text-zinc-700 dark:text-gray-200 border border-gray-200 dark:border-zinc-600 transition-colors shadow-sm">全选</button>
|
||||||
<button @click="analysisStore.setAllEntries(false)" class="text-xs font-medium px-3 py-1.5 rounded-lg bg-white dark:bg-zinc-700 hover:bg-gray-100 dark:hover:bg-zinc-600 text-zinc-700 dark:text-gray-200 border border-gray-200 dark:border-zinc-600 transition-colors shadow-sm">取消全选</button>
|
<button @click="analysisStore.setAllEntries(false)" class="text-base font-medium px-3 py-1.5 rounded-lg bg-white dark:bg-zinc-700 hover:bg-gray-100 dark:hover:bg-zinc-600 text-zinc-700 dark:text-gray-200 border border-gray-200 dark:border-zinc-600 transition-colors shadow-sm">取消全选</button>
|
||||||
<button @click="analysisStore.invertSelection()" class="text-xs font-medium px-3 py-1.5 rounded-lg bg-white dark:bg-zinc-700 hover:bg-gray-100 dark:hover:bg-zinc-600 text-zinc-700 dark:text-gray-200 border border-gray-200 dark:border-zinc-600 transition-colors shadow-sm">反选</button>
|
<button @click="analysisStore.invertSelection()" class="text-base font-medium px-3 py-1.5 rounded-lg bg-white dark:bg-zinc-700 hover:bg-gray-100 dark:hover:bg-zinc-600 text-zinc-700 dark:text-gray-200 border border-gray-200 dark:border-zinc-600 transition-colors shadow-sm">反选</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Right: Settings -->
|
<!-- Right: Settings -->
|
||||||
<div class="flex items-center gap-6 w-full md:w-auto justify-end">
|
<div class="flex items-center gap-6 w-full md:w-auto justify-end">
|
||||||
<!-- Audio Only Toggle -->
|
<!-- Audio Only Toggle -->
|
||||||
<div class="flex items-center gap-3">
|
<div class="flex items-center gap-x-4 p-3 bg-gray-50 dark:bg-zinc-800 rounded-xl">
|
||||||
<span class="font-medium text-sm text-zinc-700 dark:text-gray-300">仅音频</span>
|
<span class="font-medium text-base text-zinc-700 dark:text-gray-300">仅音频</span>
|
||||||
<button
|
<button
|
||||||
@click="analysisStore.options.is_audio_only = !analysisStore.options.is_audio_only"
|
@click="analysisStore.options.is_audio_only = !analysisStore.options.is_audio_only"
|
||||||
class="w-10 h-5 rounded-full relative transition-colors duration-200 ease-in-out shrink-0"
|
class="w-12 h-6 rounded-full relative transition-colors duration-200 ease-in-out"
|
||||||
:class="analysisStore.options.is_audio_only ? 'bg-blue-600' : 'bg-gray-300 dark:bg-zinc-600'"
|
:class="analysisStore.options.is_audio_only ? 'bg-blue-600' : 'bg-gray-300 dark:bg-zinc-600'"
|
||||||
>
|
>
|
||||||
<span
|
<span
|
||||||
class="absolute top-1 left-1 w-3 h-3 bg-white rounded-full transition-transform duration-200"
|
class="absolute top-1 left-1 w-4 h-4 bg-white rounded-full transition-transform duration-200"
|
||||||
:class="analysisStore.options.is_audio_only ? 'translate-x-5' : 'translate-x-0'"
|
:class="analysisStore.options.is_audio_only ? 'translate-x-6' : 'translate-x-0'"
|
||||||
/>
|
/>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Quality Dropdown -->
|
<!-- Quality Dropdown -->
|
||||||
<div class="flex items-center gap-3">
|
<div class="flex items-center gap-3">
|
||||||
<span class="font-medium text-sm text-zinc-700 dark:text-gray-300">画质</span>
|
|
||||||
<div class="w-44">
|
<div class="w-44">
|
||||||
<AppSelect
|
<AppSelect
|
||||||
v-model="analysisStore.options.quality"
|
v-model="analysisStore.options.quality"
|
||||||
@@ -250,6 +405,16 @@ async function startDownload() {
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- Format Dropdown -->
|
||||||
|
<div class="flex items-center gap-3">
|
||||||
|
<div class="w-48">
|
||||||
|
<AppSelect
|
||||||
|
v-model="analysisStore.options.output_format"
|
||||||
|
:options="analysisStore.options.is_audio_only ? audioFormatOptions : videoFormatOptions"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -299,10 +464,10 @@ async function startDownload() {
|
|||||||
<p v-if="analysisStore.metadata.entries" class="text-blue-500 mt-1 font-medium">{{ analysisStore.metadata.entries.length }} 个视频 (播放列表)</p>
|
<p v-if="analysisStore.metadata.entries" class="text-blue-500 mt-1 font-medium">{{ analysisStore.metadata.entries.length }} 个视频 (播放列表)</p>
|
||||||
|
|
||||||
<!-- Options -->
|
<!-- Options -->
|
||||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-4 mt-6">
|
<div class="grid grid-cols-1 md:grid-cols-3 gap-4 mt-6">
|
||||||
<!-- Audio Only Toggle -->
|
<!-- Audio Only Toggle -->
|
||||||
<div class="flex items-center justify-between p-3 bg-gray-50 dark:bg-zinc-800 rounded-xl">
|
<div class="flex items-center justify-between p-3 bg-gray-50 dark:bg-zinc-800 rounded-xl">
|
||||||
<span class="font-medium text-sm">仅音频</span>
|
<span class="font-medium text-base">仅音频</span>
|
||||||
<button
|
<button
|
||||||
@click="analysisStore.options.is_audio_only = !analysisStore.options.is_audio_only"
|
@click="analysisStore.options.is_audio_only = !analysisStore.options.is_audio_only"
|
||||||
class="w-12 h-6 rounded-full relative transition-colors duration-200 ease-in-out"
|
class="w-12 h-6 rounded-full relative transition-colors duration-200 ease-in-out"
|
||||||
@@ -323,6 +488,14 @@ async function startDownload() {
|
|||||||
:disabled="analysisStore.options.is_audio_only"
|
:disabled="analysisStore.options.is_audio_only"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- Format Dropdown -->
|
||||||
|
<div class="relative">
|
||||||
|
<AppSelect
|
||||||
|
v-model="analysisStore.options.output_format"
|
||||||
|
:options="analysisStore.options.is_audio_only ? audioFormatOptions : videoFormatOptions"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ function formatTime(ts: number) {
|
|||||||
<div class="flex justify-between items-center mb-6">
|
<div class="flex justify-between items-center mb-6">
|
||||||
<div>
|
<div>
|
||||||
<h1 class="text-3xl font-bold text-zinc-900 dark:text-white">运行日志</h1>
|
<h1 class="text-3xl font-bold text-zinc-900 dark:text-white">运行日志</h1>
|
||||||
<p class="text-gray-500 dark:text-gray-400 mt-2">下载任务的实时输出。</p>
|
<!-- <p class="text-gray-500 dark:text-gray-400 mt-2">下载任务的实时输出。</p> -->
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="flex items-center gap-3">
|
<div class="flex items-center gap-3">
|
||||||
|
|||||||
@@ -3,12 +3,13 @@ import { ref } from 'vue'
|
|||||||
import { useSettingsStore } from '../stores/settings'
|
import { useSettingsStore } from '../stores/settings'
|
||||||
import { invoke } from '@tauri-apps/api/core'
|
import { invoke } from '@tauri-apps/api/core'
|
||||||
import { open } from '@tauri-apps/plugin-dialog'
|
import { open } from '@tauri-apps/plugin-dialog'
|
||||||
import { Folder, RefreshCw, Monitor, Sun, Moon, Terminal } from 'lucide-vue-next'
|
import { Folder, RefreshCw, Monitor, Sun, Moon, Terminal, Download, FileText, X } from 'lucide-vue-next'
|
||||||
import { format } from 'date-fns' // Import format
|
import { format } from 'date-fns' // Import format
|
||||||
|
|
||||||
const settingsStore = useSettingsStore()
|
const settingsStore = useSettingsStore()
|
||||||
const updatingYtdlp = ref(false)
|
const updatingYtdlp = ref(false)
|
||||||
const updatingQuickjs = ref(false)
|
const updatingQuickjs = ref(false)
|
||||||
|
const updatingFfmpeg = ref(false)
|
||||||
const updateStatus = ref('')
|
const updateStatus = ref('')
|
||||||
|
|
||||||
async function browsePath() {
|
async function browsePath() {
|
||||||
@@ -24,6 +25,25 @@ async function browsePath() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function browseCookies() {
|
||||||
|
const selected = await open({
|
||||||
|
multiple: false,
|
||||||
|
directory: false,
|
||||||
|
filters: [{ name: 'Text Files', extensions: ['txt', 'cookies'] }, { name: 'All Files', extensions: ['*'] }],
|
||||||
|
defaultPath: settingsStore.settings.cookies_path || undefined
|
||||||
|
})
|
||||||
|
|
||||||
|
if (selected) {
|
||||||
|
settingsStore.settings.cookies_path = selected as string
|
||||||
|
await settingsStore.save()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function clearCookies() {
|
||||||
|
settingsStore.settings.cookies_path = ''
|
||||||
|
await settingsStore.save()
|
||||||
|
}
|
||||||
|
|
||||||
async function updateYtdlp() {
|
async function updateYtdlp() {
|
||||||
updatingYtdlp.value = true
|
updatingYtdlp.value = true
|
||||||
updateStatus.value = '正在更新 yt-dlp...'
|
updateStatus.value = '正在更新 yt-dlp...'
|
||||||
@@ -52,6 +72,20 @@ async function updateQuickjs() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function updateFfmpeg() {
|
||||||
|
updatingFfmpeg.value = true
|
||||||
|
updateStatus.value = '正在更新 FFmpeg...'
|
||||||
|
try {
|
||||||
|
const res = await invoke<string>('update_ffmpeg')
|
||||||
|
updateStatus.value = res
|
||||||
|
await settingsStore.refreshVersions()
|
||||||
|
} catch (e: any) {
|
||||||
|
updateStatus.value = 'FFmpeg 错误:' + e.toString()
|
||||||
|
} finally {
|
||||||
|
updatingFfmpeg.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function setTheme(theme: 'light' | 'dark' | 'system') {
|
function setTheme(theme: 'light' | 'dark' | 'system') {
|
||||||
settingsStore.settings.theme = theme
|
settingsStore.settings.theme = theme
|
||||||
settingsStore.save()
|
settingsStore.save()
|
||||||
@@ -62,7 +96,7 @@ function setTheme(theme: 'light' | 'dark' | 'system') {
|
|||||||
<div class="max-w-3xl mx-auto p-8">
|
<div class="max-w-3xl mx-auto p-8">
|
||||||
<header class="mb-8">
|
<header class="mb-8">
|
||||||
<h1 class="text-3xl font-bold text-zinc-900 dark:text-white">设置</h1>
|
<h1 class="text-3xl font-bold text-zinc-900 dark:text-white">设置</h1>
|
||||||
<p class="text-gray-500 dark:text-gray-400 mt-2">配置您的下载偏好。</p>
|
<!-- <p class="text-gray-500 dark:text-gray-400 mt-2">配置您的下载偏好。</p> -->
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
<div class="space-y-6">
|
<div class="space-y-6">
|
||||||
@@ -83,6 +117,34 @@ function setTheme(theme: 'light' | 'dark' | 'system') {
|
|||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
<!-- Cookies Path -->
|
||||||
|
<section class="bg-white dark:bg-zinc-900 p-6 rounded-2xl shadow-sm border border-gray-200 dark:border-zinc-800">
|
||||||
|
<h2 class="text-lg font-bold mb-4 text-zinc-900 dark:text-white">Cookies 文件</h2>
|
||||||
|
<div class="flex gap-3">
|
||||||
|
<div class="flex-1 bg-gray-50 dark:bg-zinc-800 rounded-xl px-4 py-3 text-sm text-gray-600 dark:text-gray-300 font-mono border border-transparent focus-within:border-blue-500 transition-colors flex items-center justify-between group min-w-0">
|
||||||
|
<div class="truncate mr-2">
|
||||||
|
{{ settingsStore.settings.cookies_path || '未设置 (默认空)' }}
|
||||||
|
</div>
|
||||||
|
<button
|
||||||
|
v-if="settingsStore.settings.cookies_path"
|
||||||
|
@click="clearCookies"
|
||||||
|
class="text-gray-400 hover:text-red-500 opacity-0 group-hover:opacity-100 transition-all p-1 rounded-md hover:bg-gray-200 dark:hover:bg-zinc-700 shrink-0"
|
||||||
|
title="清除 Cookies 路径"
|
||||||
|
>
|
||||||
|
<X class="w-4 h-4" />
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<button
|
||||||
|
@click="browseCookies"
|
||||||
|
class="bg-gray-100 hover:bg-gray-200 dark:bg-zinc-800 dark:hover:bg-zinc-700 text-zinc-900 dark:text-white px-4 py-3 rounded-xl font-medium transition-colors flex items-center gap-2 shrink-0"
|
||||||
|
>
|
||||||
|
<FileText class="w-5 h-5" />
|
||||||
|
选择
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<p class="text-xs text-gray-400 mt-2">选填。请指定包含 cookies 的文本文件(Netscape 格式)。频繁使用 cookies 下载视频可能导致封号,慎用。</p>
|
||||||
|
</section>
|
||||||
|
|
||||||
<!-- Theme -->
|
<!-- Theme -->
|
||||||
<section class="bg-white dark:bg-zinc-900 p-6 rounded-2xl shadow-sm border border-gray-200 dark:border-zinc-800">
|
<section class="bg-white dark:bg-zinc-900 p-6 rounded-2xl shadow-sm border border-gray-200 dark:border-zinc-800">
|
||||||
<h2 class="text-lg font-bold mb-4 text-zinc-900 dark:text-white">外观</h2>
|
<h2 class="text-lg font-bold mb-4 text-zinc-900 dark:text-white">外观</h2>
|
||||||
@@ -160,6 +222,29 @@ function setTheme(theme: 'light' | 'dark' | 'system') {
|
|||||||
更新
|
更新
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- FFmpeg -->
|
||||||
|
<div class="flex items-center justify-between p-4 bg-gray-50 dark:bg-zinc-800 rounded-xl">
|
||||||
|
<div class="flex items-center gap-4">
|
||||||
|
<div class="w-10 h-10 bg-white dark:bg-zinc-700 rounded-lg flex items-center justify-center shadow-sm">
|
||||||
|
<Terminal class="w-5 h-5 text-purple-600" />
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<div class="font-medium text-zinc-900 dark:text-white">FFmpeg</div>
|
||||||
|
<div class="text-xs text-gray-500 mt-0.5 font-mono" :title="settingsStore.ffmpegVersion">
|
||||||
|
{{ ['Checking...', '未安装', 'Error'].includes(settingsStore.ffmpegVersion) ? settingsStore.ffmpegVersion : '已安装' }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<button
|
||||||
|
@click="updateFfmpeg"
|
||||||
|
:disabled="updatingFfmpeg"
|
||||||
|
class="text-blue-600 hover:bg-blue-50 dark:hover:bg-blue-900/20 px-4 py-2 rounded-lg transition-colors text-sm font-medium flex items-center gap-2 disabled:opacity-50"
|
||||||
|
>
|
||||||
|
<RefreshCw class="w-4 h-4" :class="{ 'animate-spin': updatingFfmpeg }" />
|
||||||
|
更新
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div v-if="updateStatus" class="mt-4 p-3 bg-gray-50 dark:bg-zinc-800 rounded-lg text-xs font-mono text-gray-600 dark:text-gray-400 whitespace-pre-wrap border border-gray-200 dark:border-zinc-700">
|
<div v-if="updateStatus" class="mt-4 p-3 bg-gray-50 dark:bg-zinc-800 rounded-lg text-xs font-mono text-gray-600 dark:text-gray-400 whitespace-pre-wrap border border-gray-200 dark:border-zinc-700">
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { defineConfig } from "vite";
|
import { defineConfig } from "vite";
|
||||||
import vue from "@vitejs/plugin-vue";
|
import vue from "@vitejs/plugin-vue";
|
||||||
|
import { resolve } from "path";
|
||||||
|
|
||||||
// @ts-expect-error process is a nodejs global
|
// @ts-expect-error process is a nodejs global
|
||||||
const host = process.env.TAURI_DEV_HOST;
|
const host = process.env.TAURI_DEV_HOST;
|
||||||
@@ -29,4 +30,12 @@ export default defineConfig(async () => ({
|
|||||||
ignored: ["**/src-tauri/**"],
|
ignored: ["**/src-tauri/**"],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
build: {
|
||||||
|
rollupOptions: {
|
||||||
|
input: {
|
||||||
|
main: resolve(__dirname, 'index.html'),
|
||||||
|
splashscreen: resolve(__dirname, 'splashscreen.html'),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
}));
|
}));
|
||||||
|
|||||||
Reference in New Issue
Block a user