update:替换网络图片

This commit is contained in:
2026-09-22 10:00:26 +08:00
parent e98e5129d2
commit 7093d3e4e5
90 changed files with 286 additions and 289 deletions
+10 -13
View File
@@ -451,7 +451,7 @@ export const generateShareImage = async (canvasId, data) => {
hasPoint ? 756 : 402
);
renderText(ctx, "扫码打卡", 13, "#FFA118", 142, hasPoint ? 777 : 422);
const pointImg = await loadCanvasImage(canvas, "../static/point.png");
const pointImg = await loadCanvasImage(canvas, "https://static.shelingxingqiu.com/shootmini/static/point.png");
ctx.drawImage(pointImg, 120, hasPoint ? 765 : 410, 18, 14);
// 2D 即时绘制,无需 ctx.draw()
} catch (e) {
@@ -635,7 +635,7 @@ export function renderScores(ctx, arrows = [], bgImg) {
);
} else {
ctx.drawImage(
"/static/score-bg.png",
"https://static.shelingxingqiu.com/shootmini/static/score-bg.png",
16 + (i % 9) * 30,
290 + Math.ceil((i + 1) / 9) * 30,
27,
@@ -657,7 +657,7 @@ export function renderScores(ctx, arrows = [], bgImg) {
ctx.drawImage(bgImg, 24 + rowIndex * 42, i > 5 ? 362 : 320, 38, 38);
} else {
ctx.drawImage(
"/static/score-bg.png",
"https://static.shelingxingqiu.com/shootmini/static/score-bg.png",
24 + rowIndex * 42,
i > 5 ? 362 : 320,
38,
@@ -708,10 +708,7 @@ export async function sharePractiseData(canvasId, type, user, data) {
// 头像与段位框属于装饰图片,缺失时使用兜底或跳过,避免阻断分享。
const loadProfileImage = async (src, fallbackSrc = "", label = "") => {
const normalizedSrc =
typeof src === "string" && src.startsWith("../static/")
? src.slice(2)
: src;
const normalizedSrc = typeof src === "string" ? src : "";
if (normalizedSrc) {
try {
const path = await loadImage(normalizedSrc);
@@ -725,20 +722,20 @@ export async function sharePractiseData(canvasId, type, user, data) {
const avatarImgPromise = loadProfileImage(
user?.avatar,
"/static/user-icon.png",
"https://static.shelingxingqiu.com/shootmini/static/user-icon.png",
"avatar"
);
const lvlImgPromise = loadProfileImage(user?.lvlImage, "", "level");
let titleImageSrc = "/static/first-try-title.png";
let titleImageSrc = "https://static.shelingxingqiu.com/shootmini/static/first-try-title.png";
if (type == 2) {
titleImageSrc = "/static/practise-one-title.png";
titleImageSrc = "https://static.shelingxingqiu.com/shootmini/static/practise-one-title.png";
} else if (type == 3) {
titleImageSrc = "/static/practise-two-title.png";
titleImageSrc = "https://static.shelingxingqiu.com/shootmini/static/practise-two-title.png";
}
const titleImgPromise = loadCanvasImage(canvas, titleImageSrc);
const scoreBgImgPromise = loadCanvasImage(canvas, "/static/score-bg.png");
const qrCodeImgPromise = loadCanvasImage(canvas, "/static/qr-code.png");
const scoreBgImgPromise = loadCanvasImage(canvas, "https://static.shelingxingqiu.com/shootmini/static/score-bg.png");
const qrCodeImgPromise = loadCanvasImage(canvas, "https://static.shelingxingqiu.com/shootmini/static/qr-code.png");
const [avatarImg, lvlImg, titleImg, scoreBgImg, qrCodeImg] =
await Promise.all([