diff --git a/app.go b/app.go index fa59f7e..421e476 100644 --- a/app.go +++ b/app.go @@ -3,6 +3,7 @@ package main import ( "context" "ffmpeg-gui/internal/ffmpeg" + "ffmpeg-gui/internal/gpu" "ffmpeg-gui/internal/hwaccel" "ffmpeg-gui/internal/media" "ffmpeg-gui/internal/platform" @@ -106,6 +107,14 @@ func (a *App) GetHardwareEncoders() ([]hwaccel.HWEncoder, error) { return a.hwDetect.DetectEncoders() } +// GetGPUInfo returns detected GPU models and their encoder capabilities. +func (a *App) GetGPUInfo() []gpu.GPUInfo { + if a.exec == nil { + return nil + } + return gpu.DetectGPUs(a.exec) +} + // GetAccelerators returns detected hardware acceleration methods. func (a *App) GetAccelerators() ([]hwaccel.Accelerator, error) { if a.hwDetect == nil { @@ -200,7 +209,7 @@ func (a *App) SelectInputFile() (string, error) { // SelectOutputFile opens a save file dialog. func (a *App) SelectOutputFile(defaultName string) (string, error) { return runtime.SaveFileDialog(a.ctx, runtime.SaveDialogOptions{ - Title: "选择输出文件", + Title: "选择输出文件", DefaultFilename: defaultName, Filters: []runtime.FileFilter{ {DisplayName: "MP4 (*.mp4)", Pattern: "*.mp4"}, diff --git a/build.bat b/build.bat new file mode 100644 index 0000000..6777dd3 --- /dev/null +++ b/build.bat @@ -0,0 +1,42 @@ +@echo off +chcp 65001 >nul +echo === FFmpeg GUI Build Script === +echo. + +cd /d "%~dp0" + +echo [1/3] Installing frontend dependencies... +cd frontend +call npm install +if %errorlevel% neq 0 ( + echo ERROR: npm install failed + pause + exit /b %errorlevel% +) + +echo [2/3] Building frontend... +call npm run build +if %errorlevel% neq 0 ( + echo ERROR: frontend build failed + pause + exit /b %errorlevel% +) +cd .. + +echo [3/3] Cleaning icon cache... +if exist "build\windows\icon.ico" del /q "build\windows\icon.ico" +if exist "*-res.syso" del /q "*-res.syso" + +echo [4/4] Building Wails application... +wails build -clean -platform windows/amd64 +if %errorlevel% neq 0 ( + echo ERROR: wails build failed + pause + exit /b %errorlevel% +) + +echo. +echo === Build complete! === +echo Output: build\bin\ffmpeg-gui.exe +echo. +pause diff --git a/build/appicon.png b/build/appicon.png new file mode 100644 index 0000000..849e12f Binary files /dev/null and b/build/appicon.png differ diff --git a/frontend/src/App.vue b/frontend/src/App.vue index 530613a..ecaf48f 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -12,9 +12,9 @@
- - - + + +
@@ -41,12 +41,15 @@ import type { Task, Progress } from './types' const currentView = ref('encode') const theme = ref<'dark'|'light'>('light') const tasks = ref([]) +const gpuInfo = ref([]) const logPageRef = ref | null>(null) onMounted(() => { + document.addEventListener('contextmenu', e => e.preventDefault()) document.documentElement.setAttribute('data-theme', theme.value) loadTasks() + loadGPUInfo() onTaskUpdated((task: Task) => { const found = tasks.value.find(t => t.id === task.id) @@ -90,6 +93,34 @@ async function loadTasks() { try { tasks.value = await api.getTasks() } catch { /* not connected */ } } +async function loadGPUInfo() { + try { + const app = (window as any).go?.main?.App + if (app?.GetGPUInfo) { + gpuInfo.value = await app.GetGPUInfo() || [] + } else { + const encs = await api.getHardwareEncoders() + gpuInfo.value = groupByVendor(encs) + } + } catch { + try { + const encs = await api.getHardwareEncoders() + gpuInfo.value = groupByVendor(encs) + } catch { gpuInfo.value = [] } + } +} + +function groupByVendor(encs: any[]): any[] { + const groups: Record = {} + for (const e of encs) { + if (!groups[e.type]) { + groups[e.type] = { name: e.type, vendor: e.type, encoders: [] } + } + groups[e.type].encoders.push({ name: e.name, codec: e.codec, label: e.label, available: e.available }) + } + return [...Object.values(groups), { name: 'CPU', vendor: 'cpu', encoders: [{ name:'libx264',codec:'h264',label:'H.264',available:true },{ name:'libx265',codec:'hevc',label:'HEVC',available:true }]}] +} + function onTaskAdded() { loadTasks() } async function handleCancel(id: string) { diff --git a/frontend/src/assets/icon/app-logo.svg b/frontend/src/assets/icon/app-logo.svg new file mode 100644 index 0000000..2fa37f2 --- /dev/null +++ b/frontend/src/assets/icon/app-logo.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/frontend/src/components/Header.vue b/frontend/src/components/Header.vue index 9ae83c6..cb84a1b 100644 --- a/frontend/src/components/Header.vue +++ b/frontend/src/components/Header.vue @@ -1,11 +1,7 @@