🔥 大致完成

This commit is contained in:
崮生 2020-03-20 10:27:31 +08:00
parent 41cfe37adb
commit 7496e426d0
6 changed files with 519 additions and 23 deletions

View File

@ -1,4 +1,13 @@
#
# web font
## 问题
使用 svelte https://github.com/DeMoorJasper/parcel-plugin-svelte 通过这个插件使用 parcel 然后报 new 的错 需要限制 编译的版本在package.json browserslist 字段限制一下版本就好
## 启动
```bash
npm i
npm run build
npm run start
```

454
package-lock.json generated
View File

@ -2144,6 +2144,121 @@
"resolved": "https://registry.npm.taobao.org/aproba/download/aproba-1.2.0.tgz",
"integrity": "sha1-aALmJk79GMeQobDVF/DyYnvyyUo="
},
"archiver": {
"version": "0.11.0",
"resolved": "https://registry.npm.taobao.org/archiver/download/archiver-0.11.0.tgz",
"integrity": "sha1-mBd9p6bAGSt/J5jzDNbquKvXZpA=",
"requires": {
"async": "~0.9.0",
"buffer-crc32": "~0.2.1",
"glob": "~3.2.6",
"lazystream": "~0.1.0",
"lodash": "~2.4.1",
"readable-stream": "~1.0.26",
"tar-stream": "~0.4.0",
"zip-stream": "~0.4.0"
},
"dependencies": {
"glob": {
"version": "3.2.11",
"resolved": "https://registry.npm.taobao.org/glob/download/glob-3.2.11.tgz?cache=0&sync_timestamp=1573078121947&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fglob%2Fdownload%2Fglob-3.2.11.tgz",
"integrity": "sha1-Spc/Y1uRkPcV0QmH1cAP0oFevj0=",
"requires": {
"inherits": "2",
"minimatch": "0.3"
}
},
"lazystream": {
"version": "0.1.0",
"resolved": "https://registry.npm.taobao.org/lazystream/download/lazystream-0.1.0.tgz",
"integrity": "sha1-GyXWPHcqTCDwpe0KnXf0hLbhaSA=",
"requires": {
"readable-stream": "~1.0.2"
}
},
"lodash": {
"version": "2.4.2",
"resolved": "https://registry.npm.taobao.org/lodash/download/lodash-2.4.2.tgz?cache=0&sync_timestamp=1577793955950&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Flodash%2Fdownload%2Flodash-2.4.2.tgz",
"integrity": "sha1-+t2DS5aDBz2hebPq5tnA0VBT9z4="
},
"lru-cache": {
"version": "2.7.3",
"resolved": "https://registry.npm.taobao.org/lru-cache/download/lru-cache-2.7.3.tgz",
"integrity": "sha1-bUUk6LlV+V1PW1iFHOId1y+06VI="
},
"minimatch": {
"version": "0.3.0",
"resolved": "https://registry.npm.taobao.org/minimatch/download/minimatch-0.3.0.tgz",
"integrity": "sha1-J12O2qxPG7MyZHIInnlJyDlGmd0=",
"requires": {
"lru-cache": "2",
"sigmund": "~1.0.0"
}
},
"readable-stream": {
"version": "1.0.34",
"resolved": "https://registry.npm.taobao.org/readable-stream/download/readable-stream-1.0.34.tgz",
"integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=",
"requires": {
"core-util-is": "~1.0.0",
"inherits": "~2.0.1",
"isarray": "0.0.1",
"string_decoder": "~0.10.x"
}
}
}
},
"archiver-utils": {
"version": "2.1.0",
"resolved": "https://registry.npm.taobao.org/archiver-utils/download/archiver-utils-2.1.0.tgz",
"integrity": "sha1-6KRg6UtpPD49oYKgmMpihbqSSeI=",
"requires": {
"glob": "^7.1.4",
"graceful-fs": "^4.2.0",
"lazystream": "^1.0.0",
"lodash.defaults": "^4.2.0",
"lodash.difference": "^4.5.0",
"lodash.flatten": "^4.4.0",
"lodash.isplainobject": "^4.0.6",
"lodash.union": "^4.6.0",
"normalize-path": "^3.0.0",
"readable-stream": "^2.0.0"
},
"dependencies": {
"isarray": {
"version": "1.0.0",
"resolved": "https://registry.npm.taobao.org/isarray/download/isarray-1.0.0.tgz",
"integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE="
},
"normalize-path": {
"version": "3.0.0",
"resolved": "https://registry.npm.taobao.org/normalize-path/download/normalize-path-3.0.0.tgz",
"integrity": "sha1-Dc1p/yOhybEf0JeDFmRKA4ghamU="
},
"readable-stream": {
"version": "2.3.7",
"resolved": "https://registry.npm.taobao.org/readable-stream/download/readable-stream-2.3.7.tgz",
"integrity": "sha1-Hsoc9xGu+BTAT2IlKjamL2yyO1c=",
"requires": {
"core-util-is": "~1.0.0",
"inherits": "~2.0.3",
"isarray": "~1.0.0",
"process-nextick-args": "~2.0.0",
"safe-buffer": "~5.1.1",
"string_decoder": "~1.1.1",
"util-deprecate": "~1.0.1"
}
},
"string_decoder": {
"version": "1.1.1",
"resolved": "https://registry.npm.taobao.org/string_decoder/download/string_decoder-1.1.1.tgz",
"integrity": "sha1-nPFhG6YmhdcDCunkujQUnDrwP8g=",
"requires": {
"safe-buffer": "~5.1.0"
}
}
}
},
"archy": {
"version": "1.0.0",
"resolved": "https://registry.npm.taobao.org/archy/download/archy-1.0.0.tgz",
@ -2368,6 +2483,11 @@
"integrity": "sha1-bIw/uCfdQ+45GPJ7gngqt2WKb9k=",
"dev": true
},
"async": {
"version": "0.9.2",
"resolved": "https://registry.npm.taobao.org/async/download/async-0.9.2.tgz",
"integrity": "sha1-rqdNXmHB+JlhO/ZL2mbUx48v0X0="
},
"async-done": {
"version": "1.3.2",
"resolved": "https://registry.npm.taobao.org/async-done/download/async-done-1.3.2.tgz",
@ -2692,6 +2812,27 @@
"file-uri-to-path": "1.0.0"
}
},
"bl": {
"version": "0.9.5",
"resolved": "https://registry.npm.taobao.org/bl/download/bl-0.9.5.tgz?cache=0&sync_timestamp=1584503205663&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fbl%2Fdownload%2Fbl-0.9.5.tgz",
"integrity": "sha1-wGt5evCF6gC8Unr8jvzxHeIjIFQ=",
"requires": {
"readable-stream": "~1.0.26"
},
"dependencies": {
"readable-stream": {
"version": "1.0.34",
"resolved": "https://registry.npm.taobao.org/readable-stream/download/readable-stream-1.0.34.tgz",
"integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=",
"requires": {
"core-util-is": "~1.0.0",
"inherits": "~2.0.1",
"isarray": "0.0.1",
"string_decoder": "~0.10.x"
}
}
}
},
"bluebird": {
"version": "3.7.2",
"resolved": "https://registry.npm.taobao.org/bluebird/download/bluebird-3.7.2.tgz",
@ -2954,6 +3095,11 @@
}
}
},
"buffer-crc32": {
"version": "0.2.13",
"resolved": "https://registry.npm.taobao.org/buffer-crc32/download/buffer-crc32-0.2.13.tgz",
"integrity": "sha1-DTM+PwDqxQqhRUq9MO+MKl2ackI="
},
"buffer-equal": {
"version": "1.0.0",
"resolved": "https://registry.npm.taobao.org/buffer-equal/download/buffer-equal-1.0.0.tgz",
@ -3546,6 +3692,29 @@
"resolved": "https://registry.npm.taobao.org/component-emitter/download/component-emitter-1.3.0.tgz",
"integrity": "sha1-FuQHD7qK4ptnnyIVhT7hgasuq8A="
},
"compress-commons": {
"version": "0.1.6",
"resolved": "https://registry.npm.taobao.org/compress-commons/download/compress-commons-0.1.6.tgz",
"integrity": "sha1-DHQIcP3ljLpRbwrAyCLjOguF36M=",
"requires": {
"buffer-crc32": "~0.2.1",
"crc32-stream": "~0.3.1",
"readable-stream": "~1.0.26"
},
"dependencies": {
"readable-stream": {
"version": "1.0.34",
"resolved": "https://registry.npm.taobao.org/readable-stream/download/readable-stream-1.0.34.tgz",
"integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=",
"requires": {
"core-util-is": "~1.0.0",
"inherits": "~2.0.1",
"isarray": "0.0.1",
"string_decoder": "~0.10.x"
}
}
}
},
"concat-map": {
"version": "0.0.1",
"resolved": "https://registry.npm.taobao.org/concat-map/download/concat-map-0.0.1.tgz",
@ -3747,6 +3916,47 @@
"parse-json": "^4.0.0"
}
},
"crc": {
"version": "3.8.0",
"resolved": "https://registry.npm.taobao.org/crc/download/crc-3.8.0.tgz",
"integrity": "sha1-rWAmnCyFb4wpnixMwN5FVpFAVsY=",
"requires": {
"buffer": "^5.1.0"
},
"dependencies": {
"buffer": {
"version": "5.5.0",
"resolved": "https://registry.npm.taobao.org/buffer/download/buffer-5.5.0.tgz",
"integrity": "sha1-nDyqPWI8M90cfvWEuJuIv5ybwc4=",
"requires": {
"base64-js": "^1.0.2",
"ieee754": "^1.1.4"
}
}
}
},
"crc32-stream": {
"version": "0.3.4",
"resolved": "https://registry.npm.taobao.org/crc32-stream/download/crc32-stream-0.3.4.tgz",
"integrity": "sha1-c7wltF+sHbZjIjGnv86JJ+nwZVI=",
"requires": {
"buffer-crc32": "~0.2.1",
"readable-stream": "~1.0.24"
},
"dependencies": {
"readable-stream": {
"version": "1.0.34",
"resolved": "https://registry.npm.taobao.org/readable-stream/download/readable-stream-1.0.34.tgz",
"integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=",
"requires": {
"core-util-is": "~1.0.0",
"inherits": "~2.0.1",
"isarray": "0.0.1",
"string_decoder": "~0.10.x"
}
}
}
},
"create-ecdh": {
"version": "4.0.3",
"resolved": "https://registry.npm.taobao.org/create-ecdh/download/create-ecdh-4.0.3.tgz",
@ -5431,6 +5641,11 @@
}
}
},
"fs-constants": {
"version": "1.0.0",
"resolved": "https://registry.npm.taobao.org/fs-constants/download/fs-constants-1.0.0.tgz",
"integrity": "sha1-a+Dem+mYzhavivwkSXue6bfM2a0="
},
"fs-extra": {
"version": "8.1.0",
"resolved": "https://registry.npm.taobao.org/fs-extra/download/fs-extra-8.1.0.tgz",
@ -8091,6 +8306,26 @@
"resolved": "https://registry.npm.taobao.org/lodash.debounce/download/lodash.debounce-4.0.8.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Flodash.debounce%2Fdownload%2Flodash.debounce-4.0.8.tgz",
"integrity": "sha1-gteb/zCmfEAF/9XiUVMArZyk168="
},
"lodash.defaults": {
"version": "4.2.0",
"resolved": "https://registry.npm.taobao.org/lodash.defaults/download/lodash.defaults-4.2.0.tgz",
"integrity": "sha1-0JF4cW/+pN3p5ft7N/bwgCJ0WAw="
},
"lodash.difference": {
"version": "4.5.0",
"resolved": "https://registry.npm.taobao.org/lodash.difference/download/lodash.difference-4.5.0.tgz",
"integrity": "sha1-nMtOUF1Ia5FlE0V3KIWi3yf9AXw="
},
"lodash.flatten": {
"version": "4.4.0",
"resolved": "https://registry.npm.taobao.org/lodash.flatten/download/lodash.flatten-4.4.0.tgz",
"integrity": "sha1-8xwiIlqWMtK7+OSt2+8kCqdlph8="
},
"lodash.isplainobject": {
"version": "4.0.6",
"resolved": "https://registry.npm.taobao.org/lodash.isplainobject/download/lodash.isplainobject-4.0.6.tgz",
"integrity": "sha1-fFJqUtibRcRcxpC4gWO+BJf1UMs="
},
"lodash.memoize": {
"version": "4.1.2",
"resolved": "https://registry.npm.taobao.org/lodash.memoize/download/lodash.memoize-4.1.2.tgz",
@ -8106,6 +8341,11 @@
"resolved": "https://registry.npm.taobao.org/lodash.toarray/download/lodash.toarray-4.4.0.tgz",
"integrity": "sha1-JMS/zWsvuji/0FlNsRedjptlZWE="
},
"lodash.union": {
"version": "4.6.0",
"resolved": "https://registry.npm.taobao.org/lodash.union/download/lodash.union-4.6.0.tgz",
"integrity": "sha1-SLtQiECfFvGCFmZkHETdGqrjzYg="
},
"lodash.uniq": {
"version": "4.5.0",
"resolved": "https://registry.npm.taobao.org/lodash.uniq/download/lodash.uniq-4.5.0.tgz",
@ -11357,6 +11597,11 @@
"integrity": "sha1-1rkYHBpI05cyTISHHvvPxz/AZUs=",
"dev": true
},
"sigmund": {
"version": "1.0.1",
"resolved": "https://registry.npm.taobao.org/sigmund/download/sigmund-1.0.1.tgz",
"integrity": "sha1-P/IfGYytIXX587eBhT/ZTQ0ZtZA="
},
"signal-exit": {
"version": "3.0.2",
"resolved": "https://registry.npm.taobao.org/signal-exit/download/signal-exit-3.0.2.tgz",
@ -12204,6 +12449,17 @@
"yallist": "^3.0.3"
}
},
"tar-stream": {
"version": "0.4.7",
"resolved": "https://registry.npm.taobao.org/tar-stream/download/tar-stream-0.4.7.tgz?cache=0&sync_timestamp=1583830284236&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Ftar-stream%2Fdownload%2Ftar-stream-0.4.7.tgz",
"integrity": "sha1-Hx0s6evHtCdlJDyg6PG3v9oKrc0=",
"requires": {
"bl": "^0.9.0",
"end-of-stream": "^1.0.0",
"readable-stream": "^1.0.27-1",
"xtend": "^4.0.0"
}
},
"terser": {
"version": "4.6.7",
"resolved": "https://registry.npm.taobao.org/terser/download/terser-4.6.7.tgz",
@ -13619,6 +13875,204 @@
"resolved": "https://registry.npm.taobao.org/yn/download/yn-3.1.1.tgz",
"integrity": "sha1-HodAGgnXZ8HV6rJqbkwYUYLS61A=",
"dev": true
},
"zip-a-folder": {
"version": "0.0.12",
"resolved": "https://registry.npm.taobao.org/zip-a-folder/download/zip-a-folder-0.0.12.tgz",
"integrity": "sha1-c9BUYcN8LV+GssB0M1fXXidOUdk=",
"requires": {
"archiver": "^3.1.1"
},
"dependencies": {
"archiver": {
"version": "3.1.1",
"resolved": "https://registry.npm.taobao.org/archiver/download/archiver-3.1.1.tgz",
"integrity": "sha1-nbeBnU2vYK7BD+hrFsuSWM7WbqA=",
"requires": {
"archiver-utils": "^2.1.0",
"async": "^2.6.3",
"buffer-crc32": "^0.2.1",
"glob": "^7.1.4",
"readable-stream": "^3.4.0",
"tar-stream": "^2.1.0",
"zip-stream": "^2.1.2"
}
},
"async": {
"version": "2.6.3",
"resolved": "https://registry.npm.taobao.org/async/download/async-2.6.3.tgz",
"integrity": "sha1-1yYl4jRKNlbjo61Pp0n6gymdgv8=",
"requires": {
"lodash": "^4.17.14"
}
},
"bl": {
"version": "4.0.2",
"resolved": "https://registry.npm.taobao.org/bl/download/bl-4.0.2.tgz?cache=0&sync_timestamp=1584503205663&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fbl%2Fdownload%2Fbl-4.0.2.tgz",
"integrity": "sha1-UrcekIhRXQYG2d2cx6pI3B+Y5zo=",
"requires": {
"buffer": "^5.5.0",
"inherits": "^2.0.4",
"readable-stream": "^3.4.0"
},
"dependencies": {
"inherits": {
"version": "2.0.4",
"resolved": "https://registry.npm.taobao.org/inherits/download/inherits-2.0.4.tgz",
"integrity": "sha1-D6LGT5MpF8NDOg3tVTY6rjdBa3w="
}
}
},
"buffer": {
"version": "5.5.0",
"resolved": "https://registry.npm.taobao.org/buffer/download/buffer-5.5.0.tgz",
"integrity": "sha1-nDyqPWI8M90cfvWEuJuIv5ybwc4=",
"requires": {
"base64-js": "^1.0.2",
"ieee754": "^1.1.4"
}
},
"compress-commons": {
"version": "2.1.1",
"resolved": "https://registry.npm.taobao.org/compress-commons/download/compress-commons-2.1.1.tgz",
"integrity": "sha1-lBDZpTTPhDXj+7t8bOSN4twvBhA=",
"requires": {
"buffer-crc32": "^0.2.13",
"crc32-stream": "^3.0.1",
"normalize-path": "^3.0.0",
"readable-stream": "^2.3.6"
},
"dependencies": {
"readable-stream": {
"version": "2.3.7",
"resolved": "https://registry.npm.taobao.org/readable-stream/download/readable-stream-2.3.7.tgz",
"integrity": "sha1-Hsoc9xGu+BTAT2IlKjamL2yyO1c=",
"requires": {
"core-util-is": "~1.0.0",
"inherits": "~2.0.3",
"isarray": "~1.0.0",
"process-nextick-args": "~2.0.0",
"safe-buffer": "~5.1.1",
"string_decoder": "~1.1.1",
"util-deprecate": "~1.0.1"
}
},
"safe-buffer": {
"version": "5.1.2",
"resolved": "https://registry.npm.taobao.org/safe-buffer/download/safe-buffer-5.1.2.tgz",
"integrity": "sha1-mR7GnSluAxN0fVm9/St0XDX4go0="
},
"string_decoder": {
"version": "1.1.1",
"resolved": "https://registry.npm.taobao.org/string_decoder/download/string_decoder-1.1.1.tgz",
"integrity": "sha1-nPFhG6YmhdcDCunkujQUnDrwP8g=",
"requires": {
"safe-buffer": "~5.1.0"
}
}
}
},
"crc32-stream": {
"version": "3.0.1",
"resolved": "https://registry.npm.taobao.org/crc32-stream/download/crc32-stream-3.0.1.tgz",
"integrity": "sha1-yubu7QA7DkTXOdJ53lrmOxcbToU=",
"requires": {
"crc": "^3.4.4",
"readable-stream": "^3.4.0"
}
},
"isarray": {
"version": "1.0.0",
"resolved": "https://registry.npm.taobao.org/isarray/download/isarray-1.0.0.tgz",
"integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE="
},
"normalize-path": {
"version": "3.0.0",
"resolved": "https://registry.npm.taobao.org/normalize-path/download/normalize-path-3.0.0.tgz",
"integrity": "sha1-Dc1p/yOhybEf0JeDFmRKA4ghamU="
},
"readable-stream": {
"version": "3.6.0",
"resolved": "https://registry.npm.taobao.org/readable-stream/download/readable-stream-3.6.0.tgz",
"integrity": "sha1-M3u9o63AcGvT4CRCaihtS0sskZg=",
"requires": {
"inherits": "^2.0.3",
"string_decoder": "^1.1.1",
"util-deprecate": "^1.0.1"
}
},
"safe-buffer": {
"version": "5.2.0",
"resolved": "https://registry.npm.taobao.org/safe-buffer/download/safe-buffer-5.2.0.tgz",
"integrity": "sha1-t02uxJsRSPiMZLaNSbHoFcHy9Rk="
},
"string_decoder": {
"version": "1.3.0",
"resolved": "https://registry.npm.taobao.org/string_decoder/download/string_decoder-1.3.0.tgz",
"integrity": "sha1-QvEUWUpGzxqOMLCoT1bHjD7awh4=",
"requires": {
"safe-buffer": "~5.2.0"
}
},
"tar-stream": {
"version": "2.1.2",
"resolved": "https://registry.npm.taobao.org/tar-stream/download/tar-stream-2.1.2.tgz?cache=0&sync_timestamp=1583830284236&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Ftar-stream%2Fdownload%2Ftar-stream-2.1.2.tgz",
"integrity": "sha1-bV7xp+V4OpX/cLabl0VaWWjcEyU=",
"requires": {
"bl": "^4.0.1",
"end-of-stream": "^1.4.1",
"fs-constants": "^1.0.0",
"inherits": "^2.0.3",
"readable-stream": "^3.1.1"
}
},
"zip-stream": {
"version": "2.1.3",
"resolved": "https://registry.npm.taobao.org/zip-stream/download/zip-stream-2.1.3.tgz",
"integrity": "sha1-JsxL25NkGoWQ3QcRLh93rxdYhls=",
"requires": {
"archiver-utils": "^2.1.0",
"compress-commons": "^2.1.1",
"readable-stream": "^3.4.0"
}
}
}
},
"zip-folder": {
"version": "1.0.0",
"resolved": "https://registry.npm.taobao.org/zip-folder/download/zip-folder-1.0.0.tgz",
"integrity": "sha1-cKd0T9F4mi/rQa00GbMun9h5V7I=",
"requires": {
"archiver": "^0.11.0"
}
},
"zip-stream": {
"version": "0.4.1",
"resolved": "https://registry.npm.taobao.org/zip-stream/download/zip-stream-0.4.1.tgz",
"integrity": "sha1-TqeVqM4Z6fq0mjHR0IdyFBWfA6M=",
"requires": {
"compress-commons": "~0.1.0",
"lodash": "~2.4.1",
"readable-stream": "~1.0.26"
},
"dependencies": {
"lodash": {
"version": "2.4.2",
"resolved": "https://registry.npm.taobao.org/lodash/download/lodash-2.4.2.tgz?cache=0&sync_timestamp=1577793955950&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Flodash%2Fdownload%2Flodash-2.4.2.tgz",
"integrity": "sha1-+t2DS5aDBz2hebPq5tnA0VBT9z4="
},
"readable-stream": {
"version": "1.0.34",
"resolved": "https://registry.npm.taobao.org/readable-stream/download/readable-stream-1.0.34.tgz",
"integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=",
"requires": {
"core-util-is": "~1.0.0",
"inherits": "~2.0.1",
"isarray": "0.0.1",
"string_decoder": "~0.10.x"
}
}
}
}
}
}

View File

@ -6,7 +6,7 @@
"license": "MIT",
"scripts": {
"prebuild": "rimraf dist",
"build": "nest build",
"build": "nest build && parcel build ./static/index.html",
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
"start:web": "parcel ./static/index.html",
"start": "nest start",
@ -33,7 +33,9 @@
"rimraf": "^3.0.0",
"rxjs": "^6.5.3",
"svelte": "^3.20.1",
"tailwindcss": "^1.2.0"
"tailwindcss": "^1.2.0",
"zip-a-folder": "0.0.12",
"zip-folder": "^1.0.0"
},
"devDependencies": {
"@nestjs/cli": "^6.9.0",

View File

@ -1,13 +1,15 @@
import { Injectable } from '@nestjs/common';
import Fontmin from 'fontmin';
const { zip } = require('zip-a-folder');
import { join } from 'path';
import { config } from './config';
@Injectable()
export class AppService {
getHello(): string {
return 'Hello World!';
}
font_min(text:string,font:string) {
font_min(text: string, font: string) {
const srcPath = `./src/font/${font}.ttf`; // 字体源文件
const outPath = `asset/font/${Date.now()}/`;
const destPath = `./${outPath}`; // 输出路径
@ -22,7 +24,7 @@ export class AppService {
.use(Fontmin.ttf2eot()) // eot 转换插件
.use(Fontmin.ttf2woff()) // woff 转换插件
.use(Fontmin.ttf2svg()) // svg 转换插件
.use(Fontmin.css({ fontPath: `http://127.0.0.1:3000/${outPath}` })) // css 生成插件
.use(Fontmin.css({ fontPath: `${config.web_font_path}${outPath}` })) // css 生成插件
.dest(destPath); // 输出配置
// 执行
@ -37,6 +39,10 @@ export class AppService {
(f.history[f.history.length - 1] as string).endsWith('.css'),
)
.map(f => f._contents.toString());
zip(
join(__dirname, '../../', destPath),
join(__dirname, '../../', destPath, 'asset.zip'),
);
// resolve({code:0,fil:files.map(f=>f._contents.toString())}); // 成功
// resolve({code:0,files}); // 成功
resolve(css); // 成功

3
src/config.ts Normal file
View File

@ -0,0 +1,3 @@
export const config={
web_font_path:"http://127.0.0.1:3000/"
}

View File

@ -1,11 +1,11 @@
<script>
import { writable } from 'svelte/store';
import { get_font,get_font_list } from './req';
import { get_font, get_font_list } from './req';
/** 可用的字体列表 {id:number,name:string:selected:undefined | boolen,css:undefined|string}*/
$: font_list =[ ]
get_font_list().then(r=>{
font_list=r.map(ttf=>({name:ttf.replace(/\.ttf$/,'')}))
})
$: font_list = [];
get_font_list().then(r => {
font_list = r.map(ttf => ({ name: ttf.replace(/\.ttf$/, '') }));
});
/** 选择的文字 */
let text = '';
$: selected_font = font_list.filter(font => font.selected);
@ -13,17 +13,26 @@
selected_font.forEach(font => {
get_font(font.name, text)
.then(r => {
const family = r.match(/font-family: "(.*)"/)[1]
const family = r.match(/font-family: "(.*)"/)[1];
font.css = r;
font.family=family
font.family = family;
font.zip=r.match(/(asset\/font\/\d+\/)/)[0]+'asset.zip'
/** 因为要触发其他更新则必须对这个变量重新赋值 */
font_list=font_list
font_list = font_list;
})
.catch(e => {
console.log(e);
});
});
}
function copy(str) {
var input = document.getElementById("copy_box");
input.value=str
input.focus();
input.setSelectionRange(0, -1); // 全选
document.execCommand("copy")
alert(`复制成功\n${str}`)
}
</script>
<style>
@ -35,7 +44,12 @@
}
</style>
<div class=" flex justify-evenly">
{#each font_list as font, i}
{@html "<style>"+font.css+'.'+font.name+"{font-family:"+font.family+"}</style>"}
{/each}
<h1 class="text-lg text-center mb-3">web font 字体裁剪工具</h1>
<textarea id="copy_box" class="w-0 h-0 fixed -m-24" />
<div class="flex justify-evenly">
<textarea
bind:value={text}
class="border flex-1 m-1"
@ -46,22 +60,30 @@
{#each font_list as font, i}
<div
on:click={e => (font.selected = !font.selected)}
class="c-label {font.selected ? 'c-label-selected' : ''}">
class="c-label {font.selected ? 'c-label-selected' : ''}
{font.name}">
{font.name}
</div>
{/each}
</div>
</div>
<div on:click={generate_font}>生成字体</div>
<div class="flex">
<div on:click={generate_font} class="bg-red-200 text-red-600 rounded-md px-1 hover:bg-red-400 hover:text-white duration-75">
生成字体
</div>
</div>
{#each selected_font as font, i}
<div class={font.name}>
<div style="font-family:{font.family};font-size:2rem">{text}</div>
<div style="font-size:.6rem;text-align: right;">{font.name}</div>
<div style="font-size:2rem">{text}</div>
<div class="flex justify-end items-center text-xs">
{#if font.css}
<a class="text-blue-400 underline" href="/{font.zip}">下载压缩资源</a>
<div class="c-label mx-1 text-xs" on:click={copy(font.css)}>复制css</div>
{/if}
<div>{font.name}</div>
</div>
</div>
{/each}
{#each font_list as font, i}
{@html `<style>${font.css}</style>`}
{/each}