fix: card content font

This commit is contained in:
zzc
2026-01-22 14:56:32 +08:00
parent 0181066b34
commit 9f5c5d2d1f

View File

@@ -290,10 +290,17 @@ const fontList = [
}, },
]; ];
const selectedFont = ref(fontList[0]); const selectedFont = ref(fontList[0]);
const loadedFonts = ref(new Set()); // 记录已加载的字体
const changeFont = (font) => { const changeFont = (font) => {
if (font.url) { // 1. 如果是默认字体或已加载过的字体,直接应用
uni.showLoading({ title: "加载字体中" }); if (!font.url || loadedFonts.value.has(font.family)) {
selectedFont.value = font;
return;
}
// 2. 否则加载字体
uni.showLoading({ title: "加载字体中", mask: true });
uni.loadFontFace({ uni.loadFontFace({
global: true, global: true,
family: font.family, family: font.family,
@@ -301,6 +308,7 @@ const changeFont = (font) => {
scopes: ["webview", "native"], scopes: ["webview", "native"],
success: () => { success: () => {
selectedFont.value = font; selectedFont.value = font;
loadedFonts.value.add(font.family); // 标记为已加载
uni.hideLoading(); uni.hideLoading();
}, },
fail: (err) => { fail: (err) => {
@@ -311,9 +319,6 @@ const changeFont = (font) => {
uni.showToast({ title: "字体加载失败", icon: "none" }); uni.showToast({ title: "字体加载失败", icon: "none" });
}, },
}); });
} else {
selectedFont.value = font;
}
}; };
const greetingLib = ref([]); const greetingLib = ref([]);