fix: debug 分享卡片生成问题
This commit is contained in:
@@ -106,6 +106,12 @@ const drawLabel = (ctx: any, x: number, y: number, width: number, height: number
|
||||
ctx.restore()
|
||||
}
|
||||
|
||||
/** 给图片 URL 加随机参数,避免同一链接二次加载不触发 onload */
|
||||
function with_cache_bust(url: string): string {
|
||||
const sep = url.includes('?') ? '&' : '?';
|
||||
return `${url}${sep}_t=${Date.now()}_${Math.random().toString(36).slice(2)}`;
|
||||
}
|
||||
|
||||
// 工具函数 - OffscreenCanvas 下加载图片(使用 offscreen.createImage)
|
||||
const loadImage = (src: string): Promise<any> => {
|
||||
return new Promise((resolve, reject) => {
|
||||
@@ -117,7 +123,7 @@ const loadImage = (src: string): Promise<any> => {
|
||||
const img = off.createImage()
|
||||
img.onload = () => resolve(img)
|
||||
img.onerror = reject
|
||||
img.src = src
|
||||
img.src = with_cache_bust(src)
|
||||
} catch (e) {
|
||||
reject(e)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user