随机图片接口优化

This commit is contained in:
tangly1024.com
2023-08-08 15:22:58 +08:00
parent 2749b73e08
commit 23e23a8a8e
2 changed files with 10 additions and 2 deletions

View File

@@ -65,6 +65,14 @@ const mapImgUrl = (img, block, type = 'block', from) => {
ret = BLOG.NOTION_HOST + '/image/' + encodeURIComponent(ret) + '?table=' + type + '&id=' + block.id
}
// UnSplash 随机图片接口优化
if (ret.includes('source.unsplash.com/random')) {
// 检查原始URL是否已经包含参数
const separator = ret.includes('?') ? '&' : '?'
// 拼接唯一识别参数,防止请求的图片被缓存
ret = `${ret}${separator}random=${block.id}`
}
// 文章封面
if (from === 'pageCoverThumbnail') {
ret = compressImage(ret)