mirror of
https://github.com/pipipi-pikachu/PPTist.git
synced 2025-04-15 02:20:00 +08:00
Merge branch 'zenoven-feat-optimize-font'
This commit is contained in:
commit
6cafd88270
@ -6,7 +6,8 @@
|
|||||||
"serve": "vue-cli-service serve",
|
"serve": "vue-cli-service serve",
|
||||||
"build": "vue-cli-service build",
|
"build": "vue-cli-service build",
|
||||||
"test:unit": "vue-cli-service test:unit",
|
"test:unit": "vue-cli-service test:unit",
|
||||||
"lint": "vue-cli-service lint"
|
"lint": "vue-cli-service lint",
|
||||||
|
"build:fonts": "node scripts/build-fonts"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@icon-park/vue-next": "^1.4.0",
|
"@icon-park/vue-next": "^1.4.0",
|
||||||
|
45
scripts/build-fonts.js
Normal file
45
scripts/build-fonts.js
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
// 自动获取 src\assets\fonts 路径下的字体文件列表,并替换相关的 SCSS 变量
|
||||||
|
|
||||||
|
/* eslint-disable no-console */
|
||||||
|
|
||||||
|
const fs = require('fs')
|
||||||
|
const path = require('path')
|
||||||
|
|
||||||
|
const assetsPath = path.join(__dirname, '../src/assets')
|
||||||
|
const fontVarPath = path.join(assetsPath, 'styles/font.scss')
|
||||||
|
const fontsPath = path.join(assetsPath, 'fonts')
|
||||||
|
|
||||||
|
const scssFontListVar = '$fontList'
|
||||||
|
|
||||||
|
const replaceSCSSVariable = (names) => {
|
||||||
|
fs.readFile(fontVarPath, 'utf-8', (errs, content) => {
|
||||||
|
if (errs) {
|
||||||
|
console.error(errs)
|
||||||
|
process.exit(1)
|
||||||
|
}
|
||||||
|
const reg = new RegExp(`(\\${scssFontListVar}:\\s*)(.*)(;.*)`, 'g')
|
||||||
|
const newContent = content.replace(reg, `$1${names}$3`)
|
||||||
|
fs.writeFile(fontVarPath, newContent, errs => {
|
||||||
|
if (errs) {
|
||||||
|
console.error(errs)
|
||||||
|
process.exit(1)
|
||||||
|
}
|
||||||
|
console.log('自动生成自定义字体列表完成')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
fs.readdir(fontsPath, { withFileTypes: true }, (errs, files) => {
|
||||||
|
if (errs) {
|
||||||
|
console.error(errs)
|
||||||
|
process.exit(1)
|
||||||
|
}
|
||||||
|
const woff2Fonts = files.filter(({ name }) => name.endsWith('.woff2'))
|
||||||
|
const fontList = woff2Fonts.map(({ name }) => name.replace('.woff2', ''))
|
||||||
|
|
||||||
|
const names = fontList.reduce((result, name, i) => {
|
||||||
|
if (i === 0) return `'${name}'`
|
||||||
|
return `${result}, '${name}'`
|
||||||
|
}, '')
|
||||||
|
replaceSCSSVariable(names)
|
||||||
|
})
|
Binary file not shown.
BIN
src/assets/fonts/仓耳小丸子.woff2
Normal file
BIN
src/assets/fonts/仓耳小丸子.woff2
Normal file
Binary file not shown.
Binary file not shown.
BIN
src/assets/fonts/优设标题黑.woff2
Normal file
BIN
src/assets/fonts/优设标题黑.woff2
Normal file
Binary file not shown.
Binary file not shown.
BIN
src/assets/fonts/字制区喜脉体.woff2
Normal file
BIN
src/assets/fonts/字制区喜脉体.woff2
Normal file
Binary file not shown.
Binary file not shown.
BIN
src/assets/fonts/峰广明锐体.woff2
Normal file
BIN
src/assets/fonts/峰广明锐体.woff2
Normal file
Binary file not shown.
BIN
src/assets/fonts/得意黑.woff2
Normal file
BIN
src/assets/fonts/得意黑.woff2
Normal file
Binary file not shown.
Binary file not shown.
BIN
src/assets/fonts/摄图摩登小方体.woff2
Normal file
BIN
src/assets/fonts/摄图摩登小方体.woff2
Normal file
Binary file not shown.
Binary file not shown.
BIN
src/assets/fonts/站酷快乐体.woff2
Normal file
BIN
src/assets/fonts/站酷快乐体.woff2
Normal file
Binary file not shown.
Binary file not shown.
BIN
src/assets/fonts/素材集市康康体.woff2
Normal file
BIN
src/assets/fonts/素材集市康康体.woff2
Normal file
Binary file not shown.
Binary file not shown.
BIN
src/assets/fonts/素材集市酷方体.woff2
Normal file
BIN
src/assets/fonts/素材集市酷方体.woff2
Normal file
Binary file not shown.
Binary file not shown.
BIN
src/assets/fonts/途牛类圆体.woff2
Normal file
BIN
src/assets/fonts/途牛类圆体.woff2
Normal file
Binary file not shown.
Binary file not shown.
BIN
src/assets/fonts/锐字真言体.woff2
Normal file
BIN
src/assets/fonts/锐字真言体.woff2
Normal file
Binary file not shown.
@ -1,40 +1,9 @@
|
|||||||
@font-face {
|
$fontList: '仓耳小丸子', '优设标题黑', '字制区喜脉体', '峰广明锐体', '得意黑', '摄图摩登小方体', '站酷快乐体', '素材集市康康体', '素材集市酷方体', '途牛类圆体', '锐字真言体';
|
||||||
font-family: '仓耳小丸子';
|
|
||||||
src: url(../fonts/仓耳小丸子.ttf);
|
@each $font in $fontList {
|
||||||
}
|
@font-face {
|
||||||
@font-face {
|
font-display: swap;
|
||||||
font-family: '优设标题黑';
|
font-family: $font;
|
||||||
src: url(../fonts/优设标题黑.ttf);
|
src: url('../fonts/#{$font}.woff2') format('woff2');
|
||||||
}
|
}
|
||||||
@font-face {
|
|
||||||
font-family: '峰广明锐体';
|
|
||||||
src: url(../fonts/峰广明锐体.ttf);
|
|
||||||
}
|
|
||||||
@font-face {
|
|
||||||
font-family: '摄图摩登小方体';
|
|
||||||
src: url(../fonts/摄图摩登小方体.ttf);
|
|
||||||
}
|
|
||||||
@font-face {
|
|
||||||
font-family: '站酷快乐体';
|
|
||||||
src: url(../fonts/站酷快乐体.ttf);
|
|
||||||
}
|
|
||||||
@font-face {
|
|
||||||
font-family: '字制区喜脉体';
|
|
||||||
src: url(../fonts/字制区喜脉体.ttf);
|
|
||||||
}
|
|
||||||
@font-face {
|
|
||||||
font-family: '素材集市康康体';
|
|
||||||
src: url(../fonts/素材集市康康体.ttf);
|
|
||||||
}
|
|
||||||
@font-face {
|
|
||||||
font-family: '素材集市酷方体';
|
|
||||||
src: url(../fonts/素材集市酷方体.ttf);
|
|
||||||
}
|
|
||||||
@font-face {
|
|
||||||
font-family: '途牛类圆体';
|
|
||||||
src: url(../fonts/途牛类圆体.ttf);
|
|
||||||
}
|
|
||||||
@font-face {
|
|
||||||
font-family: '锐字真言体';
|
|
||||||
src: url(../fonts/锐字真言体.ttf);
|
|
||||||
}
|
}
|
@ -30,6 +30,7 @@ export const SYS_FONTS = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
export const WEB_FONTS = [
|
export const WEB_FONTS = [
|
||||||
|
{ label: '得意黑', value: '得意黑' },
|
||||||
{ label: '仓耳小丸子', value: '仓耳小丸子' },
|
{ label: '仓耳小丸子', value: '仓耳小丸子' },
|
||||||
{ label: '优设标题黑', value: '优设标题黑' },
|
{ label: '优设标题黑', value: '优设标题黑' },
|
||||||
{ label: '峰广明锐体', value: '峰广明锐体' },
|
{ label: '峰广明锐体', value: '峰广明锐体' },
|
||||||
|
Loading…
x
Reference in New Issue
Block a user