feat: 完善媒体管理与备份迁移流程
- 视频上传生成缩略图并提供占位封面和失败原因展示 - 支持 HLS 按需重新封装 MP4,并限制临时文件生命周期与访问权限 - 完善视频、文件 API 文档、搜索、批量删除和单次转码质量参数 - 修复备份恢复与跨后端迁移遗漏缩略图、HLS 清单和分片的问题 - 将备份任务、归档和下载权限按用户隔离 - 增加仅清理当前用户数据的高危存储清空流程和二次文字确认 - 修复 S3 中文文件名元数据及 CLI 数据库连接问题 - 补充备份恢复、用户隔离、媒体资源和转码相关测试
This commit is contained in:
1 parent
9ebab8270c
commit
a64be50b73
60 files changed
+2703
-325
No files matched your search
@@ -65,8 +65,14 @@ function resetForm() {
|
||||
if (!isDebugParam(param)) continue
|
||||
if (param.type === 'file') {
|
||||
files[param.name] = null
|
||||
} else if (param.name === 'kind') {
|
||||
values[param.name] = props.endpoint.category === 'video' ? 'video' : 'file'
|
||||
} else if (param.name === 'keys') {
|
||||
values[param.name] = '["images/2026/08/example.webp"]'
|
||||
values[param.name] = props.endpoint.category === 'video'
|
||||
? '["videos/2026/10/example.mp4"]'
|
||||
: props.endpoint.category === 'file'
|
||||
? '["files/2026/10/example.pdf"]'
|
||||
: '["images/2026/08/example.webp"]'
|
||||
} else if (param.name === 'token' && props.token) {
|
||||
values[param.name] = props.token
|
||||
} else {
|
||||
@@ -84,6 +90,12 @@ function fileLabel(name: string) {
|
||||
return fileValues.value[name]?.name ?? t('api.debug.noFileSelected')
|
||||
}
|
||||
|
||||
function fileAccept() {
|
||||
if (props.endpoint.category === 'video') return 'video/*'
|
||||
if (props.endpoint.category === 'file') return undefined
|
||||
return 'image/*'
|
||||
}
|
||||
|
||||
function triggerFilePick(name: string) {
|
||||
fileInputRefs.value[name]?.click()
|
||||
}
|
||||
@@ -101,8 +113,8 @@ function isParamFilled(param: ApiDocParam) {
|
||||
if (!value) return false
|
||||
if (param.location === 'body' && param.name === 'keys') {
|
||||
try {
|
||||
const parsed = JSON.parse(value) as { keys?: unknown }
|
||||
return Array.isArray(parsed.keys) && parsed.keys.length > 0
|
||||
const parsed = JSON.parse(value) as unknown
|
||||
return Array.isArray(parsed) && parsed.length > 0
|
||||
} catch {
|
||||
return false
|
||||
}
|
||||
@@ -159,7 +171,14 @@ async function sendRequest() {
|
||||
} else if (debugBodyParams.value.some(p => p.location === 'body')) {
|
||||
headers['Content-Type'] = 'application/json'
|
||||
try {
|
||||
body = JSON.stringify(JSON.parse(paramValues.value.keys || '{}'))
|
||||
const payload: Record<string, unknown> = {}
|
||||
for (const param of debugBodyParams.value) {
|
||||
if (param.location !== 'body') continue
|
||||
const value = paramValues.value[param.name]?.trim()
|
||||
if (!value) continue
|
||||
payload[param.name] = param.name === 'keys' ? JSON.parse(value) : value
|
||||
}
|
||||
body = JSON.stringify(payload)
|
||||
} catch {
|
||||
toast.add({ title: t('api.debug.invalidJson'), color: 'error' })
|
||||
sending.value = false
|
||||
@@ -297,7 +316,7 @@ const responseScrollable = computed(() => responseBody.value.split('\n').length
|
||||
<input
|
||||
:ref="(el) => { fileInputRefs[param.name] = el as HTMLInputElement }"
|
||||
type="file"
|
||||
accept="image/*"
|
||||
:accept="fileAccept()"
|
||||
class="hidden"
|
||||
@change="onFileChange(param.name, $event)"
|
||||
>
|
||||
|
||||
@@ -20,9 +20,18 @@ const docsUrl = computed(() =>
|
||||
|
||||
const categories: { key: ApiDocCategory, labelKey: string }[] = [
|
||||
{ key: 'image', labelKey: 'api.categories.image' },
|
||||
{ key: 'video', labelKey: 'api.categories.video' },
|
||||
{ key: 'file', labelKey: 'api.categories.file' },
|
||||
{ key: 'extension', labelKey: 'api.categories.extension' },
|
||||
{ key: 'system', labelKey: 'api.categories.system' }
|
||||
]
|
||||
const openCategories = ref<Set<ApiDocCategory>>(
|
||||
new Set(
|
||||
categories
|
||||
.filter(category => category.key !== 'video' && category.key !== 'file')
|
||||
.map(category => category.key)
|
||||
)
|
||||
)
|
||||
|
||||
const filteredEndpoints = computed(() => {
|
||||
const q = search.value.trim().toLowerCase()
|
||||
@@ -38,6 +47,17 @@ function endpointsForCategory(category: ApiDocCategory) {
|
||||
return filteredEndpoints.value.filter(endpoint => endpoint.category === category)
|
||||
}
|
||||
|
||||
function isCategoryOpen(category: ApiDocCategory) {
|
||||
return openCategories.value.has(category)
|
||||
}
|
||||
|
||||
function toggleCategory(category: ApiDocCategory) {
|
||||
const next = new Set(openCategories.value)
|
||||
if (next.has(category)) next.delete(category)
|
||||
else next.add(category)
|
||||
openCategories.value = next
|
||||
}
|
||||
|
||||
function onSelect(id: string) {
|
||||
emit('select', id)
|
||||
}
|
||||
@@ -59,6 +79,15 @@ onMounted(() => {
|
||||
window.addEventListener('keydown', onGlobalKeydown)
|
||||
onUnmounted(() => window.removeEventListener('keydown', onGlobalKeydown))
|
||||
})
|
||||
|
||||
watch(search, (value) => {
|
||||
if (!value.trim()) return
|
||||
const next = new Set(openCategories.value)
|
||||
for (const category of categories) {
|
||||
if (endpointsForCategory(category.key).length) next.add(category.key)
|
||||
}
|
||||
openCategories.value = next
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -89,13 +118,24 @@ onMounted(() => {
|
||||
:key="category.key"
|
||||
class="mb-4"
|
||||
>
|
||||
<p
|
||||
<button
|
||||
v-if="endpointsForCategory(category.key).length"
|
||||
class="mb-1.5 px-2 text-xs font-medium text-muted"
|
||||
type="button"
|
||||
class="mb-1.5 flex w-full items-center justify-between rounded-md px-2 py-1 text-xs font-medium text-muted transition-colors hover:bg-muted/40 hover:text-highlighted"
|
||||
:aria-expanded="isCategoryOpen(category.key)"
|
||||
@click="toggleCategory(category.key)"
|
||||
>
|
||||
<span>{{ t(category.labelKey) }}</span>
|
||||
<UIcon
|
||||
name="i-lucide-chevron-down"
|
||||
class="size-3.5 transition-transform"
|
||||
:class="isCategoryOpen(category.key) ? '' : '-rotate-90'"
|
||||
/>
|
||||
</button>
|
||||
<ul
|
||||
v-show="isCategoryOpen(category.key)"
|
||||
class="space-y-0.5"
|
||||
>
|
||||
{{ t(category.labelKey) }}
|
||||
</p>
|
||||
<ul class="space-y-0.5">
|
||||
<li
|
||||
v-for="endpoint in endpointsForCategory(category.key)"
|
||||
:key="endpoint.id"
|
||||
|
||||
Reference in new issue
Block a user