feat(front): add FilePreviewView and FileShareHandle components for improved file preview and sharing options

This commit is contained in:
keven1024
2025-04-24 15:26:49 +08:00
parent 1618f23d39
commit 31b91b12de
3 changed files with 27 additions and 18 deletions

View File

@@ -0,0 +1,50 @@
<script setup lang="ts">
import SwitchField from '../Field/SwitchField.vue';
import InputField from '../Field/InputField.vue';
import SelectField from '../Field/SelectField.vue';
import FormButton from '../Field/FormButton.vue';
const props = defineProps<{
hide: () => void
file: File
onFileHandle: ({ data, type }: { data: any, type: string }) => void
}>()
</script>
<template>
<VeeForm v-slot="{ values }" :initialValues="{ download_nums: 1, expire_time: 1440 }">
<div class="flex flex-col gap-3">
<h2 class="text-lg font-bold">分享选项</h2>
<div class="flex flex-row items-center gap-2 text-sm">
<SelectField name="download_nums" label="下载次数" :options="[
{ label: '1次下载', value: 1 },
{ label: '2次下载', value: 2 },
{ label: '3次下载', value: 3 },
{ label: '5次下载', value: 4 },
{ label: '10次下载', value: 5 },
]" />
<SelectField name="expire_time" label="过期时间" :options="[
{ label: '5分钟', value: 5 },
{ label: '1小时', value: 60 },
{ label: '1天', value: 1440 },
{ label: '3天', value: 4320 },
]" />
后过期
</div>
<div class="flex flex-row gap-3 min-h-9">
<SwitchField name="has_password" label="密码保护" />
<InputField v-if="!!values.has_password" name="password" placeholder="请输入密码" />
</div>
<div class="flex flex-row gap-3 min-h-9">
<SwitchField name="has_download_notify" label="下载通知" />
<InputField v-if="!!values.has_download_notify" name="download_notify_email" placeholder="请输入邮箱" />
</div>
<FormButton @click="(form) => {
onFileHandle({ data: form?.values?.value, type: 'file-share' })
hide()
}">提交</FormButton>
</div>
</VeeForm>
</template>