上传标签
This commit is contained in:
1 parent
6494ad2918
commit
832261739f
8 files changed
+120
-20
No files matched your search
@@ -17,9 +17,11 @@ const {
|
||||
autoCopyMarkdown,
|
||||
copyFormat,
|
||||
clientWebpQuality,
|
||||
lastTagIds,
|
||||
transcodeToHls,
|
||||
loadPreferences
|
||||
} = useUploadPreferences(props.kind)
|
||||
const { items: tagItems, fetchTags } = useTags()
|
||||
|
||||
/** 视频床 / 文件床没有图片压缩相关选项 */
|
||||
const isImageKind = computed(() => props.kind === 'image')
|
||||
@@ -76,6 +78,7 @@ onMounted(() => {
|
||||
loadPreferences()
|
||||
void loadUserSettings()
|
||||
void loadTranscodeSettings()
|
||||
void fetchTags()
|
||||
})
|
||||
</script>
|
||||
|
||||
@@ -108,7 +111,7 @@ onMounted(() => {
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-1 flex-col justify-center p-5 sm:p-6">
|
||||
<div class="flex flex-1 flex-col justify-start overflow-y-auto p-5 sm:p-6">
|
||||
<div
|
||||
class="grid gap-5"
|
||||
:class="gridClass"
|
||||
@@ -269,6 +272,19 @@ onMounted(() => {
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mt-5 space-y-3 border-t border-default pt-5">
|
||||
<h3 class="text-sm font-semibold">
|
||||
{{ t('preferences.uploadTags') }}
|
||||
</h3>
|
||||
<p class="text-xs leading-relaxed text-muted">
|
||||
{{ t('preferences.uploadTagsHint') }}
|
||||
</p>
|
||||
<TagAssignPanel
|
||||
v-model="lastTagIds"
|
||||
:tags="tagItems"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -310,6 +310,13 @@ export function buildApiDocs(ctx: ApiDocsContext): ApiDocEndpoint[] {
|
||||
location: 'form-data',
|
||||
required: false,
|
||||
descriptionKey: 'api.params.videoUpload.token'
|
||||
},
|
||||
{
|
||||
name: 'tagNames',
|
||||
type: 'string',
|
||||
location: 'form-data',
|
||||
required: false,
|
||||
descriptionKey: 'api.params.upload.tagNames'
|
||||
}
|
||||
],
|
||||
curl: `curl -X POST "${baseUrl}/api/videos/upload" \\
|
||||
@@ -317,7 +324,8 @@ export function buildApiDocs(ctx: ApiDocsContext): ApiDocEndpoint[] {
|
||||
-F "video=@./demo.mp4" \\
|
||||
-F "transcode=1" \\
|
||||
-F "transcodePreset=compress" \\
|
||||
-F "transcodeBitratePercent=80"`,
|
||||
-F "transcodeBitratePercent=80" \\
|
||||
-F 'tagNames=["博客","视频"]'`,
|
||||
responseExample: `{
|
||||
"success": true,
|
||||
"items": [
|
||||
@@ -329,7 +337,11 @@ export function buildApiDocs(ctx: ApiDocsContext): ApiDocEndpoint[] {
|
||||
"size": 10485760,
|
||||
"uploadedAt": "2026-10-17T03:00:00.000Z",
|
||||
"markdown": "[demo.mp4](https://pic.example.com/videos/2026/10/abc123.mp4)",
|
||||
"thumbUrl": "https://pic.example.com/videos/2026/10/abc123.webp"
|
||||
"thumbUrl": "https://pic.example.com/videos/2026/10/abc123.webp",
|
||||
"tags": [
|
||||
{ "id": 3, "name": "博客", "color": "#22c55e" },
|
||||
{ "id": 8, "name": "视频", "color": "#3b82f6" }
|
||||
]
|
||||
}
|
||||
],
|
||||
"errors": [],
|
||||
@@ -619,11 +631,19 @@ export function buildApiDocs(ctx: ApiDocsContext): ApiDocEndpoint[] {
|
||||
location: 'form-data',
|
||||
required: false,
|
||||
descriptionKey: 'api.params.fileUpload.token'
|
||||
},
|
||||
{
|
||||
name: 'tagNames',
|
||||
type: 'string',
|
||||
location: 'form-data',
|
||||
required: false,
|
||||
descriptionKey: 'api.params.upload.tagNames'
|
||||
}
|
||||
],
|
||||
curl: `curl -X POST "${baseUrl}/api/files/upload" \\
|
||||
${auth} \\
|
||||
-F "file=@./report.pdf"`,
|
||||
-F "file=@./report.pdf" \\
|
||||
-F 'tagNames=["文档","归档"]'`,
|
||||
responseExample: `{
|
||||
"success": true,
|
||||
"items": [
|
||||
@@ -634,7 +654,11 @@ export function buildApiDocs(ctx: ApiDocsContext): ApiDocEndpoint[] {
|
||||
"contentType": "application/pdf",
|
||||
"size": 5242880,
|
||||
"uploadedAt": "2026-10-17T03:00:00.000Z",
|
||||
"markdown": "[report.pdf](https://pic.example.com/files/2026/10/abc123.pdf)"
|
||||
"markdown": "[report.pdf](https://pic.example.com/files/2026/10/abc123.pdf)",
|
||||
"tags": [
|
||||
{ "id": 4, "name": "文档", "color": "#f59e0b" },
|
||||
{ "id": 9, "name": "归档", "color": "#64748b" }
|
||||
]
|
||||
}
|
||||
],
|
||||
"errors": [],
|
||||
|
||||
@@ -54,8 +54,10 @@ export function useMediaUpload(kind: UploadMediaKind) {
|
||||
autoCopyMarkdown,
|
||||
copyFormat,
|
||||
transcodeToHls,
|
||||
lastTagIds,
|
||||
loadPreferences
|
||||
} = useUploadPreferences(kind)
|
||||
const { items: tagItems, fetchTags } = useTags()
|
||||
|
||||
const uploading = ref(false)
|
||||
const progressItems = ref<UploadProgressItem[]>([])
|
||||
@@ -232,6 +234,15 @@ export function useMediaUpload(kind: UploadMediaKind) {
|
||||
if (kind === 'video' && transcodeToHls.value) {
|
||||
formData.append('transcode', '1')
|
||||
}
|
||||
if (lastTagIds.value.length) {
|
||||
await fetchTags()
|
||||
const names = lastTagIds.value
|
||||
.map(id => tagItems.value.find(tag => tag.id === id)?.name)
|
||||
.filter((name): name is string => Boolean(name))
|
||||
if (names.length) {
|
||||
formData.append('tagNames', JSON.stringify(names))
|
||||
}
|
||||
}
|
||||
|
||||
progressItems.value = progressItems.value.map(item => ({
|
||||
...item,
|
||||
|
||||
Reference in new issue
Block a user