Compare commits

..

5 Commits

Author SHA1 Message Date
Julian Freeman
f164569e89 fix product name 2025-12-25 18:32:09 -04:00
Julian Freeman
f4bdb85841 fix ffmpeg download 2025-12-25 18:20:45 -04:00
Julian Freeman
36bd5061a4 add splash screen 2025-12-08 18:59:48 -04:00
Julian Freeman
dde9ed7718 fix ffmpeg update status 2025-12-08 18:49:14 -04:00
Julian Freeman
8ae5f4f66c ensure ffmpeg 2025-12-08 18:22:49 -04:00
16 changed files with 128 additions and 20 deletions

View File

@@ -3,8 +3,3 @@
A simple Youtube downloader.
Generated by Gemini CLI.
## Problems
1. windows 上打包后运行命令会出现黑窗,而且还是会出现找不到 js-runtimes 的问题,但是 quickjs 是正常下载了
2. macos 上未测试

View File

@@ -1,7 +1,7 @@
{
"name": "stream-capture",
"private": true,
"version": "0.1.0",
"version": "1.0.1",
"type": "module",
"scripts": {
"dev": "vite",

12
splashscreen.html Normal file
View 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>

2
src-tauri/Cargo.lock generated
View File

@@ -3971,7 +3971,7 @@ checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
[[package]]
name = "stream-capture"
version = "0.1.0"
version = "1.0.1"
dependencies = [
"anyhow",
"chrono",

View File

@@ -1,6 +1,6 @@
[package]
name = "stream-capture"
version = "0.1.0"
version = "1.0.1"
description = "A Tauri App"
authors = ["you"]
edition = "2021"

View File

@@ -2,7 +2,7 @@
"$schema": "../gen/schemas/desktop-schema.json",
"identifier": "default",
"description": "Capability for the main window",
"windows": ["main"],
"windows": ["main", "splashscreen"],
"permissions": [
"core:default",
"opener:default",

View File

@@ -308,17 +308,19 @@ pub async fn download_ffmpeg(app: &AppHandle) -> Result<PathBuf> {
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();
if lname.contains("win64") && lname.ends_with(".zip") {
// 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
// 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())) {
if name.to_lowercase().ends_with(".zip") {
let lname = name.to_lowercase();
if lname.ends_with(".zip") && !lname.contains("shared") {
download_url = Some(url.to_string());
break;
}
@@ -341,7 +343,8 @@ pub async fn download_ffmpeg(app: &AppHandle) -> Result<PathBuf> {
if file.is_dir() { continue; }
let name = file.name().to_string();
let filename_only = name.split('/').last().unwrap_or("");
if filename_only.eq_ignore_ascii_case("ffmpeg.exe") || filename_only.ends_with(".dll") {
// 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;
@@ -495,6 +498,21 @@ pub async fn ensure_binaries(app: &AppHandle) -> Result<()> {
.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(())
}

View File

@@ -111,6 +111,16 @@ pub fn delete_history_item(app: AppHandle, id: String) -> Result<(), 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]
pub fn open_in_explorer(app: AppHandle, path: String) -> Result<(), String> {
let path_to_open = if Path::new(&path).exists() {

View File

@@ -24,6 +24,7 @@ pub fn run() {
commands::get_history,
commands::clear_history,
commands::delete_history_item,
commands::close_splash,
commands::open_in_explorer
])
.run(tauri::generate_context!())

View File

@@ -1,7 +1,7 @@
{
"$schema": "https://schema.tauri.app/config/2",
"productName": "stream-capture",
"version": "0.1.0",
"productName": "StreamCapture",
"version": "1.0.1",
"identifier": "top.volan.stream-capture",
"build": {
"beforeDevCommand": "pnpm dev",
@@ -12,9 +12,22 @@
"app": {
"windows": [
{
"title": "流萤 - 视频下载 v1.0.0",
"label": "main",
"title": "流萤 - 视频下载 v1.0.1",
"width": 1300,
"height": 900
"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": {

View File

@@ -1,4 +1,3 @@
// filepath: src/App.vue
<script setup lang="ts">
import { onMounted } from 'vue'
import { RouterView, RouterLink, useRoute } from 'vue-router'

44
src/splash/App.vue Normal file
View 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
View File

@@ -0,0 +1,5 @@
import { createApp } from 'vue'
import App from './App.vue'
import '../style.css'
createApp(App).mount('#app')

View File

@@ -18,7 +18,7 @@ export const useSettingsStore = defineStore('settings', () => {
const ytdlpVersion = ref('Checking...')
const quickjsVersion = ref('Checking...')
const ffmpegVersion = ref('Checking...')
const ffmpegVersion = ref('Checking...')
const isInitializing = ref(true)
async function loadSettings() {

View File

@@ -184,7 +184,9 @@ function setTheme(theme: 'light' | 'dark' | 'system') {
</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">{{ settingsStore.ffmpegVersion === '未安装' ? '未安装' : '已安装' }}</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

View File

@@ -1,5 +1,6 @@
import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import { resolve } from "path";
// @ts-expect-error process is a nodejs global
const host = process.env.TAURI_DEV_HOST;
@@ -29,4 +30,12 @@ export default defineConfig(async () => ({
ignored: ["**/src-tauri/**"],
},
},
build: {
rollupOptions: {
input: {
main: resolve(__dirname, 'index.html'),
splashscreen: resolve(__dirname, 'splashscreen.html'),
},
},
},
}));