From c57627e0d7a5a2513aa03d1155fbe1db7ec21217 Mon Sep 17 00:00:00 2001
From: Nevermore <15972699417@163.com>
Date: Sat, 4 Nov 2023 22:28:09 +0800
Subject: [PATCH] =?UTF-8?q?=E8=BF=98=E5=8E=9F=E6=96=87=E6=9C=AC=E8=BD=AC?=
=?UTF-8?q?=E6=9B=B2?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
README.md | 3 ++-
depoly.sh | 25 -------------------
src/main.ts | 2 --
src/utils/fonts.ts | 12 +++++++++
src/utils/localFonts.ts | 11 --------
.../ElementStylePanel/TextboxStylePanel.vue | 5 ++--
src/worker/pdf.ts | 2 +-
7 files changed, 18 insertions(+), 42 deletions(-)
delete mode 100644 depoly.sh
delete mode 100644 src/utils/localFonts.ts
diff --git a/README.md b/README.md
index b2b121ad..0fc11528 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,7 @@
# yft-design
> 基于 Canvas 的开源版"创客贴",使用 Vue3 + TypeScript + Fabric.js + Pinia + Element-Plus,支持 文字、图片、形状、线条、二维码 、条形码几种最常用的元素类型,每一种元素都拥有高度可编辑能力,缩略图显示,模板,支持导出json,svg, image文件。
-体验Demo:[https://yft.design](https://yft.design)
+
+体验Demo:[https://dromara.org/yft-design](https://dromara.org/yft-design)
体验Demo:[https://more-strive.github.io/design/](https://more-strive.github.io/design/)
![image](doc/background.gif)
diff --git a/depoly.sh b/depoly.sh
deleted file mode 100644
index c8f2a6da..00000000
--- a/depoly.sh
+++ /dev/null
@@ -1,25 +0,0 @@
-#!/usr/bin/env sh
-
-# 确保脚本抛出遇到的错误
-set -e
-
-# 生成静态文件, npm run docs:build
-npm run build
-rm -rf ../design/*
-
-# 将build生成的dist目录拷贝至上一层目录中
-cp -r ./dist/* ../design/
-
-# 进入生成的文件夹
-cd ../design
-
-# git初始化,每次初始化不影响推送
-git init
-git add -A
-git commit -m 'deploy'
-git branch -M main
-
-# 如果你想要部署到 https://USERNAME.github.io
-# git remote add origin https://github.com/more-strive/morestrive.github.io.git
-git push -u origin main
-git push -f https://github.com/more-strive/design.git main
diff --git a/src/main.ts b/src/main.ts
index 29ccdecd..ef4d6392 100644
--- a/src/main.ts
+++ b/src/main.ts
@@ -1,10 +1,8 @@
import { createApp } from "vue"
import { createPinia } from "pinia"
import App from "./App.vue"
-// import ElementPlus from "element-plus"
import "@/extension/index"
-// import "element-plus/theme-chalk/index.css"
import "@icon-park/vue-next/styles/index.css"
import "@/assets/style/global.scss"
import "@/assets/style/font.scss"
diff --git a/src/utils/fonts.ts b/src/utils/fonts.ts
index 08d18a1a..3ae2d5d8 100644
--- a/src/utils/fonts.ts
+++ b/src/utils/fonts.ts
@@ -35,4 +35,16 @@ export const getSupportFonts = (fontNames: SystemFont[]) => {
}
return getDotArray(arial).join('') !== getDotArray(item.value).join('')
})
+}
+
+export async function loadFont(fontFamily: string) {
+ let font
+ try {
+ const fonts = await window.queryLocalFonts();
+ font = fonts.filter(item => item.family === fontFamily)[0]
+ } catch(e: any) {
+ console.log(`Cannot query fonts: ${e.message}`)
+ } finally {
+ return font
+ }
}
\ No newline at end of file
diff --git a/src/utils/localFonts.ts b/src/utils/localFonts.ts
deleted file mode 100644
index 602c9ba5..00000000
--- a/src/utils/localFonts.ts
+++ /dev/null
@@ -1,11 +0,0 @@
-export async function loadFont(fontFamily: string) {
- let font
- try {
- const fonts = self.queryLocalFonts();
- font = fonts.filter(item => item.family === fontFamily)[0]
- } catch(e: any) {
- console.log(`Cannot query fonts: ${e.message}`)
- } finally {
- return font
- }
-}
\ No newline at end of file
diff --git a/src/views/Editor/CanvasRight/ElementStylePanel/TextboxStylePanel.vue b/src/views/Editor/CanvasRight/ElementStylePanel/TextboxStylePanel.vue
index f94d2756..1a614c78 100644
--- a/src/views/Editor/CanvasRight/ElementStylePanel/TextboxStylePanel.vue
+++ b/src/views/Editor/CanvasRight/ElementStylePanel/TextboxStylePanel.vue
@@ -182,7 +182,7 @@ import { FontSizeLibs, LineHeightLibs, CharSpaceLibs } from '@/configs/texts'
import { WEB_FONTS } from '@/configs/fonts'
import { TextboxElement } from '@/types/canvas'
import { FontGroupOption } from '@/types/elements'
-import { loadFont } from '@/utils/localFonts'
+import { loadFont } from '@/utils/fonts'
import opentype from "opentype.js"
import ElementPosition from '../Components/ElementPosition.vue'
import ElementStroke from '../Components/ElementStroke.vue'
@@ -347,7 +347,8 @@ const handleElementCurve = async () => {
// ElMessage
let fontElement: opentype.Font | undefined
if (WEB_FONTS.filter(item => item.value === hasFontFamily.value)[0]) {
- fontElement = await opentype.load(`/src/assets/fonts/${hasFontFamily.value}.ttf`)
+ const fontURL = import.meta.env.MODE === 'production' ? `/assets/${hasFontFamily.value}.ttf` : `/src/assets/fonts/${hasFontFamily.value}.ttf`
+ fontElement = await opentype.load(fontURL)
} else {
const fontData = await loadFont(hasFontFamily.value)
if (!fontData) return
diff --git a/src/worker/pdf.ts b/src/worker/pdf.ts
index 42ae74fb..90b8781b 100644
--- a/src/worker/pdf.ts
+++ b/src/worker/pdf.ts
@@ -2,7 +2,7 @@ import { CanvasElement, TextboxElement, ImageElement, Template } from '@/types/c
import { ElementNames } from '@/types/elements'
import { isBase64, getBase64Type, getLinkType } from '@/utils/common'
import { PDFDocument, StandardFonts, rgb, PDFPage, PDFImage } from 'pdf-lib'
-import { loadFont } from '@/utils/localFonts'
+import { loadFont } from '@/utils/fonts'
import { WEB_FONTS } from '@/configs/fonts'
// self.addEventListener("message", handleMessage);