mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-22 15:09:43 +00:00
[feat] 支持随机图片 url 统一配置
This commit is contained in:
@@ -68,6 +68,26 @@ const mapImgUrl = (img, block, type = 'block', from) => {
|
||||
}
|
||||
|
||||
if (!isEmoji(ret) && ret.indexOf('notion.so/images/page-cover') < 0) {
|
||||
if (BLOG.RANDOM_IMAGE_URL) {
|
||||
// 只有配置了随机图片接口,才会替换图片
|
||||
const texts = BLOG.RANDOM_IMAGE_REPLACE_TEXT
|
||||
let isReplace = false;
|
||||
if (texts) {
|
||||
const textArr = texts.split(',')
|
||||
// 判断是否包含替换的文本
|
||||
textArr.forEach(text => {
|
||||
if (ret.indexOf(text) > -1) {
|
||||
isReplace = true
|
||||
}
|
||||
})
|
||||
} else {
|
||||
isReplace = true
|
||||
}
|
||||
|
||||
if (isReplace) {
|
||||
ret = BLOG.RANDOM_IMAGE_URL
|
||||
}
|
||||
}
|
||||
// 随机图片接口优化 防止因url一致而随机结果相同
|
||||
const separator = ret.includes('?') ? '&' : '?'
|
||||
// 拼接唯一识别参数,防止请求的图片被缓存
|
||||
|
||||
Reference in New Issue
Block a user