更新
This commit is contained in:
+34
-3
@@ -12,9 +12,9 @@
|
||||
|
||||
<div class="workspace-column">
|
||||
<main class="workspace">
|
||||
<EncodePage v-if="currentView === 'encode'" @taskAdded="onTaskAdded" />
|
||||
<RemuxPage v-if="currentView === 'remux'" @taskAdded="onTaskAdded" />
|
||||
<BurnPage v-if="currentView === 'burn'" @taskAdded="onTaskAdded" />
|
||||
<EncodePage v-if="currentView === 'encode'" :gpuInfo="gpuInfo" @taskAdded="onTaskAdded" />
|
||||
<RemuxPage v-if="currentView === 'remux'" :gpuInfo="gpuInfo" @taskAdded="onTaskAdded" />
|
||||
<BurnPage v-if="currentView === 'burn'" :gpuInfo="gpuInfo" @taskAdded="onTaskAdded" />
|
||||
<SettingsPage v-if="currentView === 'settings'" />
|
||||
<LogPage v-show="currentView === 'logs'" ref="logPageRef" />
|
||||
</main>
|
||||
@@ -41,12 +41,15 @@ import type { Task, Progress } from './types'
|
||||
const currentView = ref('encode')
|
||||
const theme = ref<'dark'|'light'>('light')
|
||||
const tasks = ref<Task[]>([])
|
||||
const gpuInfo = ref<any[]>([])
|
||||
|
||||
const logPageRef = ref<InstanceType<typeof LogPage> | 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<string, any> = {}
|
||||
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) {
|
||||
|
||||
Reference in New Issue
Block a user