Skip to content

Commit 9a381dc

Browse files
committed
fix: load cache image mistakely
1 parent 937dbdb commit 9a381dc

File tree

5 files changed

+11
-6
lines changed

5 files changed

+11
-6
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ Click the menu button in the top-right corner of the image. If the block is reco
5151

5252
## Changelog
5353

54+
+ v0.1.6
55+
+ Fix: load cache image mistakely
5456
+ v0.1.5
5557
+ Fix: avoid CSS5 ligh-dark style rendering fail in some browsers
5658
+ v0.1.4

README_zh_CN.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@
5050

5151
## 更新日志
5252

53+
+ v0.1.6
54+
+ 修复缺陷:错误地加载到浏览器缓存图像
5355
+ v0.1.5
5456
+ 修复缺陷:避免使用CSS5的light-dark样式导致部分浏览器显示异常
5557
+ v0.1.4

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "siyuan-embed-drawio",
3-
"version": "0.1.5",
3+
"version": "0.1.6",
44
"type": "module",
55
"description": "This is a plugin for siyuan",
66
"author": "",

plugin.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "siyuan-embed-drawio",
33
"author": "Yuxin Zhao",
44
"url": "https://github.com/YuxinZhaozyx/siyuan-embed-drawio",
5-
"version": "0.1.5",
5+
"version": "0.1.6",
66
"minAppVersion": "3.3.0",
77
"disabledInPublish": true,
88
"backends": [

src/index.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ export default class DrawioPlugin extends Plugin {
132132
}
133133

134134
public async getDrawioImage(imageURL: string): Promise<string> {
135-
const response = await fetch(imageURL);
135+
const response = await fetch(imageURL, { cache: 'reload' });
136136
if (!response.ok) return "";
137137
const svgContent = await response.text();
138138
return svgContent;
@@ -242,9 +242,10 @@ export default class DrawioPlugin extends Plugin {
242242
messageKey: 'allChangesSaved',
243243
modified: false
244244
});
245-
const timestamp = Date.now();
246-
document.querySelectorAll(`img[data-src='${imageInfo.imageURL}']`).forEach(imageElement => {
247-
(imageElement as HTMLImageElement).src = imageInfo.imageURL + "?t=" + timestamp; // 重载图片,加时间戳以避免浏览器缓存图片
245+
fetch(imageInfo.imageURL, { cache: 'reload' }).then(() => {
246+
document.querySelectorAll(`img[data-src='${imageInfo.imageURL}']`).forEach(imageElement => {
247+
(imageElement as HTMLImageElement).src = imageInfo.imageURL;
248+
});
248249
});
249250
});
250251
}

0 commit comments

Comments
 (0)