mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-14 07:26:52 +00:00
随机图片接口优化
This commit is contained in:
@@ -57,7 +57,7 @@ const handleAckee = async function(pathname, environment, options = {}) {
|
||||
await loadExternalResource(BLOG.ANALYTICS_ACKEE_TRACKER, 'js')
|
||||
const ackeeTracker = window.ackeeTracker
|
||||
|
||||
const instance = ackeeTracker.create(environment.server, options)
|
||||
const instance = ackeeTracker?.create(environment.server, options)
|
||||
|
||||
if (instance == null) {
|
||||
console.warn('Skipped record creation because useAckee has been called in a non-browser environment')
|
||||
@@ -73,7 +73,7 @@ const handleAckee = async function(pathname, environment, options = {}) {
|
||||
return
|
||||
}
|
||||
|
||||
const attributes = ackeeTracker.attributes(options.detailed)
|
||||
const attributes = ackeeTracker?.attributes(options.detailed)
|
||||
const url = new URL(pathname, location)
|
||||
|
||||
return instance.record(environment.domainId, {
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user