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