perf(worker-hall): 优化百单大厅加载与渲染性能

This commit is contained in:
yml2213
2026-10-24 20:41:58 +08:00
parent 72a758fd7c
commit 7fdef88ba6
11 changed files with 617 additions and 321 deletions
@@ -219,15 +219,15 @@ export function getMaxUploadSizeBytes() {
* 之后任何不重签的地方过一会儿必然打不开(客服看到裂图),要每一处读取都记得重签才不会出错。
* 现在链接就是稳定的普通链接(对象 key 带随机段,不可枚举),存下来过多久都能看。
*/
export function buildFileUrl(objectKey: string) {
return buildUnsignedFileUrl(normalizeObjectKey(objectKey))
export function buildFileUrl(objectKey: string, variant = '') {
return buildUnsignedFileUrl(normalizeObjectKey(objectKey), variant)
}
/** 把库里历史存的(带签名/带有效期的)链接归一化成普通链接;非文件链接原样返回。 */
export function refreshStoredFileUrl(value: unknown, fallbackObjectKey = '') {
export function refreshStoredFileUrl(value: unknown, fallbackObjectKey = '', variant = '') {
const rawUrl = String(value || '').trim()
const objectKey = extractObjectKeyFromFileUrl(rawUrl) || String(fallbackObjectKey || '').trim()
return objectKey ? buildFileUrl(objectKey) : rawUrl
return objectKey ? buildFileUrl(objectKey, variant) : rawUrl
}
/** @deprecated 用 refreshStoredFileUrl;两者现在完全等价(都只做归一化,不再重签)。 */
@@ -299,8 +299,10 @@ function mapUploadedFile(
}
}
function buildUnsignedFileUrl(objectKey: string) {
return `/api/v1/files/object?key=${encodeURIComponent(normalizeObjectKey(objectKey))}`
function buildUnsignedFileUrl(objectKey: string, variant = '') {
const normalizedVariant = normalizeVariant(variant)
const variantQuery = normalizedVariant ? `&variant=${encodeURIComponent(normalizedVariant)}` : ''
return `/api/v1/files/object?key=${encodeURIComponent(normalizeObjectKey(objectKey))}${variantQuery}`
}
export function extractObjectKeyFromFileUrl(value: string) {