feature: Digitization Workstation UI

This commit is contained in:
voltsrage
2026-06-27 12:15:43 +08:00
parent 88e70b3dbe
commit e22d33b654
55 changed files with 6411 additions and 143 deletions
@@ -0,0 +1,40 @@
import { computed, watch, onUnmounted, type Ref } from 'vue'
import { useIntervalFn } from '@vueuse/core'
import { useBatchStore } from '../stores/batches'
const PRESIGNED_URL_TTL_MS = 15 * 60 * 1000
const REFRESH_BUFFER_MS = 60_000
export function usePresignedUrl(batchId: Ref<string | undefined>) {
const batchStore = useBatchStore()
const documentUrl = computed(() => batchStore.documentUrl)
async function refreshUrl(): Promise<void> {
if (batchId.value) {
await batchStore.getBatch(batchId.value)
}
}
const { pause, resume } = useIntervalFn(
() => { void refreshUrl() },
PRESIGNED_URL_TTL_MS - REFRESH_BUFFER_MS,
{ immediate: false }
)
watch(
batchId,
async (id) => {
pause()
if (id) {
await refreshUrl()
resume()
}
},
{ immediate: true }
)
onUnmounted(pause)
return { documentUrl, refreshUrl }
}