From 23e23a8a8e13acb992bd248e42c635d7185db78c Mon Sep 17 00:00:00 2001 From: "tangly1024.com" Date: Tue, 8 Aug 2023 15:22:58 +0800 Subject: [PATCH] =?UTF-8?q?=E9=9A=8F=E6=9C=BA=E5=9B=BE=E7=89=87=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/Ackee.js | 4 ++-- lib/notion/mapImage.js | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/components/Ackee.js b/components/Ackee.js index dd9467f0..8a002bc1 100644 --- a/components/Ackee.js +++ b/components/Ackee.js @@ -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, { diff --git a/lib/notion/mapImage.js b/lib/notion/mapImage.js index 8fbfbb1c..951f5d2a 100644 --- a/lib/notion/mapImage.js +++ b/lib/notion/mapImage.js @@ -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)