Skip to content

Commit 8b63ad2

Browse files
authoredNov 1, 2023
Merge pull request tangly1024#1608 from tangly1024/feat/random-img-api
随机图片支持
2 parents cd4b45a + e24b8cf commit 8b63ad2

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed
 

‎lib/notion/mapImage.js

+4-7
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,10 @@ const mapImgUrl = (img, block, type = 'block', from) => {
6767
ret = BLOG.NOTION_HOST + '/image/' + encodeURIComponent(ret) + '?table=' + type + '&id=' + block.id
6868
}
6969

70-
// UnSplash 随机图片接口优化
71-
if (ret.includes('source.unsplash.com/random')) {
72-
// 检查原始URL是否已经包含参数
73-
const separator = ret.includes('?') ? '&' : '?'
74-
// 拼接唯一识别参数,防止请求的图片被缓存
75-
ret = `${ret}${separator}random=${block.id}`
76-
}
70+
// 随机图片接口优化 防止因url一致而随机结果相同
71+
const separator = ret.includes('?') ? '&' : '?'
72+
// 拼接唯一识别参数,防止请求的图片被缓存
73+
ret = `${ret.trim()}${separator}t=${block.id}`
7774

7875
// 文章封面
7976
if (from === 'pageCoverThumbnail') {

0 commit comments

Comments
 (0)
Please sign in to comment.