feat: add thumbnail timeout and low-memory warning

This commit is contained in:
tianmo committed 2026-10-17 16:19:18 +08:00
1 parent 7b2fae6335
commit 76328fa058
10 files changed
+196 -17

No files matched your search

+21
View File
@@ -31,6 +31,11 @@ const gridClass = computed(() => {
})
const { t } = useI18n()
const {
lowMemory,
memoryBytes,
load: loadTranscodeSettings
} = useTranscodeSettings()
const {
userSettings,
@@ -52,6 +57,12 @@ const clientQualityLevel = computed(() => {
return t('preferences.qualityLow')
})
const memoryGb = computed(() => (
memoryBytes.value > 0
? (memoryBytes.value / (1024 * 1024 * 1024)).toFixed(1)
: '—'
))
function setCopyFormat(value: 'url' | 'markdown' | 'html' | 'bbcode') {
copyFormat.value = value
}
@@ -64,6 +75,7 @@ function onClientQualityInput(event: Event) {
onMounted(() => {
loadPreferences()
void loadUserSettings()
void loadTranscodeSettings()
})
</script>
@@ -170,6 +182,15 @@ onMounted(() => {
{{ t('preferences.videoProcessing') }}
</h3>
<UAlert
v-if="lowMemory"
color="warning"
variant="subtle"
icon="i-lucide-triangle-alert"
:title="t('preferences.lowMemoryTranscodeTitle')"
:description="t('preferences.lowMemoryTranscodeHint', { memory: memoryGb })"
/>
<label class="flex cursor-pointer items-start gap-2.5">
<UCheckbox
v-model="transcodeToHls"
@@ -1,13 +1,34 @@
<script setup lang="ts">
const { transcodeToHls, loadPreferences } = useUploadPreferences('video')
const { t } = useI18n()
const {
lowMemory,
memoryBytes,
load: loadTranscodeSettings
} = useTranscodeSettings()
const memoryGb = computed(() => (
memoryBytes.value > 0
? (memoryBytes.value / (1024 * 1024 * 1024)).toFixed(1)
: '—'
))
onMounted(() => {
loadPreferences()
void loadTranscodeSettings()
})
</script>
<template>
<UAlert
v-if="lowMemory"
color="warning"
variant="subtle"
icon="i-lucide-triangle-alert"
:title="t('preferences.lowMemoryTranscodeTitle')"
:description="t('preferences.lowMemoryTranscodeHint', { memory: memoryGb })"
class="my-4"
/>
<SettingsToggleRow
v-model="transcodeToHls"
:title="t('preferences.transcodeToHls')"
+13
View File
@@ -8,6 +8,9 @@ interface TranscodeSettingsResponse {
minBitratePercent: number
maxBitratePercent: number
presets: string[]
memoryBytes: number
lowMemoryThresholdBytes: number
lowMemory: boolean
}
/** 服务端转码参数:并发任务数与单任务 CPU 核心数(仅管理员可改) */
@@ -27,6 +30,9 @@ export function useTranscodeSettings() {
const maxBitratePercent = ref(100)
const loaded = ref(false)
const hydrated = ref(false)
const memoryBytes = ref(0)
const lowMemoryThresholdBytes = ref(2 * 1024 * 1024 * 1024)
const lowMemory = ref(false)
let saveTimer: ReturnType<typeof setTimeout> | null = null
@@ -41,6 +47,10 @@ export function useTranscodeSettings() {
if (data.presets?.length) presets.value = data.presets
maxConcurrency.value = data.maxConcurrency
maxThreads.value = data.maxThreads
memoryBytes.value = data.memoryBytes ?? 0
lowMemoryThresholdBytes.value = data.lowMemoryThresholdBytes
?? 2 * 1024 * 1024 * 1024
lowMemory.value = data.lowMemory === true
loaded.value = true
nextTick(() => {
hydrated.value = true
@@ -108,6 +118,9 @@ export function useTranscodeSettings() {
presets,
maxConcurrency,
maxThreads,
memoryBytes,
lowMemoryThresholdBytes,
lowMemory,
loaded,
load
}