|
|
@@ -101,6 +101,30 @@ export const useProjectStore = defineStore('project', () => {
|
|
|
}
|
|
|
)
|
|
|
|
|
|
+ watch(
|
|
|
+ () => project.value?.resources.fonts,
|
|
|
+ (fonts?: FontResource[]) => {
|
|
|
+ // 动态加载全部字体
|
|
|
+ const fontPromises = fonts?.map((font) => {
|
|
|
+ const fontFace = new FontFace(
|
|
|
+ font.fileName,
|
|
|
+ `url('local:///${projectPath.value + font.path}')`.replaceAll('\\', '/')
|
|
|
+ )
|
|
|
+ return fontFace.load()
|
|
|
+ })
|
|
|
+
|
|
|
+ if (fontPromises) {
|
|
|
+ Promise.all(fontPromises)
|
|
|
+ .then((loadedFonts) => {
|
|
|
+ console.log('已加载字体:', loadedFonts)
|
|
|
+ loadedFonts.forEach((font) => document.fonts.add(font))
|
|
|
+ console.log('所有字体已加载并可用')
|
|
|
+ })
|
|
|
+ .catch((err) => console.error('字体加载失败:', err))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ )
|
|
|
+
|
|
|
// 当前激活元素map
|
|
|
const activeWidgetMap = computed(() => {
|
|
|
return activeWidgets.value.reduce((acc, cur) => {
|