update graduation download

This commit is contained in:
ClasWen 2024-06-15 00:39:55 +08:00
parent 2dca76ca72
commit 9e9f35407e

View file

@ -6,16 +6,16 @@ const id = ref<string>("")
type FileRecord = {
id: string
status: "processing" | "done"
status: "processing" | "ready" | "not_found"
}
const fileStatus = ref<FileRecord | undefined>()
const getFileStatus = async (id: string): Promise<FileRecord> => {
// TODO
// return (await fetch(`http://localhost:3000/api/graduation/${id}`)) as any
return {
id: undefined,
status: "processing",
try {
const res: FileRecord = await fetch(`https://api.nbtca.space/static/graduation/${id}/info.json`).then(res => res.json())
return res
} catch (error) {
return { id, status: "not_found" }
}
}
const setStatus = async () => {
@ -40,21 +40,45 @@ onMounted(() => {
2024 毕业典礼拍摄
</div>
<div class="mt-6 min-w-40 w-3/4 text-center">
<div class="h-24">
<div v-if="id == undefined">
<div class="">
<div v-if="id == undefined || fileStatus?.status == 'not_found'">
<div class="text-md md:text-lg">我们没有找到相应的文件请确认链接是否正确</div>
</div>
<div v-else-if="fileStatus?.status == 'processing'">
<div class="text-md md:text-lg">我们正在处理你的照片这可能需要1-2请稍后再来试试</div>
</div>
<div v-else-if="fileStatus?.status == 'done'">
<div v-else-if="fileStatus?.status == 'ready'" class="h-40">
<div class="text-md md:text-lg ">文件已经处理完成你可以点击下方链接下载</div>
<div class="mt-4">
<a :href="`http://localhost:3000/api/graduation/${id}?download=true`" class="text-blue-500 hover:underline">下载文件</a>
<div class="mt-6">
<a
:href="`https://api.nbtca.space/static/graduation/${id}/${id}.zip`"
class="text-white hover:no-underline bg-blue-500 hover:bg-blue-600 p-1.5 px-2 rounded-full text-sm inline-flex items-center gap-1"
>
<svg width="29" height="29" viewBox="0 0 29 29" fill="none" xmlns="http://www.w3.org/2000/svg">
<g clip-path="url(#clip0_2207_37351)">
<path
d="M13.9741 25.9204C20.5132 25.9204 25.9272 20.4947 25.9272 13.9673C25.9272 7.42822 20.5015 2.01416 13.9624 2.01416C7.43506 2.01416 2.021 7.42822 2.021 13.9673C2.021 20.4947 7.44678 25.9204 13.9741 25.9204ZM13.9741 23.9283C8.44288 23.9283 4.02491 19.4986 4.02491 13.9673C4.02491 8.43604 8.43116 4.00635 13.9624 4.00635C19.4937 4.00635 23.9351 8.43604 23.9351 13.9673C23.9351 19.4986 19.5054 23.9283 13.9741 23.9283Z"
fill="white"
fill-opacity="0.85"
/>
<path
d="M13.9741 8.00244C13.4702 8.00244 13.0952 8.36572 13.0952 8.88135V14.7408L13.189 17.2134L12.0171 15.8072L10.6226 14.4009C10.4585 14.2369 10.2476 14.1431 10.0015 14.1431C9.52099 14.1431 9.15771 14.5064 9.15771 14.9869C9.15771 15.233 9.22802 15.4439 9.38037 15.5962L13.2944 19.4869C13.5288 19.7212 13.728 19.8267 13.9741 19.8267C14.2319 19.8267 14.4429 19.7095 14.6655 19.4869L18.5679 15.5962C18.7202 15.4439 18.814 15.233 18.814 14.9869C18.814 14.5064 18.439 14.1431 17.9585 14.1431C17.7007 14.1431 17.4898 14.2251 17.3374 14.4009L15.9546 15.8072L14.7593 17.2251L14.853 14.7408V8.88135C14.853 8.36572 14.4898 8.00244 13.9741 8.00244Z"
fill="white"
fill-opacity="0.85"
/>
</g>
<defs>
<clipPath id="clip0_2207_37351">
<rect width="23.9062" height="23.918" fill="white" transform="translate(2.021 2.01416)" />
</clipPath>
</defs>
</svg>
下载文件
</a>
</div>
</div>
</div>
<div class="text-sm mt-12">
<div class="mt-12">
<div>如果你有任何问题可以通过邮件联系我们</div>
<div>
<a :href="mailto" class="flex items-center gap-1 justify-center mt-1">