服务器配置
This commit is contained in:
1 parent
a1b4a63552
commit
fa7c8244b0
33 files changed
+1882
-363
No files matched your search
@@ -0,0 +1,40 @@
|
||||
interface UploadPolicy {
|
||||
allowedMimeTypes: string[]
|
||||
allowedVideoExtensions: string[]
|
||||
forbiddenFileExtensions: string[]
|
||||
}
|
||||
|
||||
const policy = ref<UploadPolicy | null>(null)
|
||||
const loading = ref(false)
|
||||
let pending: Promise<UploadPolicy> | null = null
|
||||
|
||||
export function useUploadPolicy() {
|
||||
async function load(force = false): Promise<UploadPolicy> {
|
||||
if (policy.value && !force) return policy.value
|
||||
if (pending && !force) return pending
|
||||
|
||||
loading.value = true
|
||||
pending = $fetch<UploadPolicy>('/api/upload-policy', {
|
||||
credentials: 'include'
|
||||
})
|
||||
.then((data) => {
|
||||
policy.value = {
|
||||
allowedMimeTypes: [...data.allowedMimeTypes],
|
||||
allowedVideoExtensions: [...data.allowedVideoExtensions],
|
||||
forbiddenFileExtensions: [...data.forbiddenFileExtensions]
|
||||
}
|
||||
return policy.value
|
||||
})
|
||||
.finally(() => {
|
||||
loading.value = false
|
||||
pending = null
|
||||
})
|
||||
return pending
|
||||
}
|
||||
|
||||
return {
|
||||
policy,
|
||||
loading,
|
||||
load
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user