Przeglądaj źródła

加载字体修改

luxf 1 tydzień temu
rodzic
commit
076aa5409e
3 zmienionych plików z 15 dodań i 5 usunięć
  1. 13 3
      main.js
  2. 0 1
      pages/news/components/news-item.vue
  3. 2 1
      utils/font.js

+ 13 - 3
main.js

@@ -111,11 +111,21 @@ Vue.prototype.showConfirmDialog = function(message, title) {
 }
 
 Vue.prototype.loadFontFace = function(fontFamily) {
-	let fontUrl = ''
+	const fontUrls = {
+		'Poppins': 'https://oss.starify.cn/test/Poppins-Regular.ttf'
+	}
 	if (fontFamily === 'Poppins') {
-		fontUrl = 'https://oss.starify.cn/test/Poppins-SemiBold.ttf'
+		// 开发者工具没有该字体
+		wx.getSystemInfo({
+		  success(res) {
+		    if (res.platform === 'devtools') {
+					loadCloudFontFace(fontUrls[fontFamily], fontFamily + '.ttf', fontFamily)
+		    }
+		  }
+		})
+	} else {
+		loadCloudFontFace(fontUrls[fontFamily], fontFamily + '.ttf', fontFamily)
 	}
-	loadCloudFontFace(fontUrl, fontFamily + '.ttf', fontFamily)
 }
 
 App.mpType = 'app'

+ 0 - 1
pages/news/components/news-item.vue

@@ -26,7 +26,6 @@
 		},
 		methods: {
 			onClickDetail(item) {
-				console.log(this.type)
 				if (this.type === 'exhibitor')  {
 					this.navigateTo('https://mp-test-onlinecatelogue.matchexpo.cn/Selis-responds-to-Guangzhou-s-inquiry-on-M7-accident-identification-the-owner-does-not-recognize-the-analysis-conclusion-that-the-case-has-entered-the-judicial-procedure')
 				} else {

+ 2 - 1
utils/font.js

@@ -31,7 +31,8 @@ function loadFontFace(fontFamily, filePath) {
 					console.log(fontFamily + '加载成功:' + res.status)
 				},
 				fail: function(res) {
-					console.log(fontFamily + '加载失败' + res)
+					// console.log(res)
+					// console.log(fontFamily + '加载失败')
 				},
 			})
 		}