perf(worker-hall): 优化百单大厅加载与渲染性能
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user