mirror of
https://github.com/2234839/web-font.git
synced 2026-06-30 20:58:34 +08:00
自行下载 llrt
This commit is contained in:
parent
e5b6718ad9
commit
1a611e7e28
@ -109,7 +109,18 @@ const fontApiMiddleware: cMiddleware = async (req, res, next) => {
|
||||
}
|
||||
const path = `font/${font}`;
|
||||
const fontType = path.split(".").pop() as "ttf";
|
||||
const oldFontBuffer = new Uint8Array(await readFile(path)).buffer;
|
||||
let oldFontBuffer: ArrayBuffer;
|
||||
try {
|
||||
oldFontBuffer = new Uint8Array(await readFile(path)).buffer;
|
||||
} catch {
|
||||
return {
|
||||
req,
|
||||
res: new Response(`Font not found: ${font}`, {
|
||||
status: 404,
|
||||
headers: { "Content-Type": "text/plain; charset=utf-8" },
|
||||
}),
|
||||
};
|
||||
}
|
||||
|
||||
const outType = "ttf";
|
||||
const newFont = await fontSubset(oldFontBuffer, text, {
|
||||
|
||||
@ -24,6 +24,7 @@
|
||||
"@types/node": "^25.5.2",
|
||||
"tsup": "^8.5.1",
|
||||
"typescript": "^6.0.2",
|
||||
"undici": "^8.0.2",
|
||||
"vite": "^8.0.7",
|
||||
"vite-plugin-solid": "^2.11.12"
|
||||
}
|
||||
|
||||
9
pnpm-lock.yaml
generated
9
pnpm-lock.yaml
generated
@ -30,6 +30,9 @@ importers:
|
||||
typescript:
|
||||
specifier: ^6.0.2
|
||||
version: 6.0.2
|
||||
undici:
|
||||
specifier: ^8.0.2
|
||||
version: 8.0.2
|
||||
vite:
|
||||
specifier: ^8.0.7
|
||||
version: 8.0.7(@types/node@25.5.2)(esbuild@0.27.7)
|
||||
@ -982,6 +985,10 @@ packages:
|
||||
undici-types@7.18.2:
|
||||
resolution: {integrity: sha512-AsuCzffGHJybSaRrmr5eHr81mwJU3kjw6M+uprWvCXiNeN9SOGwQ3Jn8jb8m3Z6izVgknn1R0FTCEAP2QrLY/w==}
|
||||
|
||||
undici@8.0.2:
|
||||
resolution: {integrity: sha512-B9MeU5wuFhkFAuNeA19K2GDFcQXZxq33fL0nRy2Aq30wdufZbyyvxW3/ChaeipXVfy/wUweZyzovQGk39+9k2w==}
|
||||
engines: {node: '>=22.19.0'}
|
||||
|
||||
update-browserslist-db@1.2.3:
|
||||
resolution: {integrity: sha512-Js0m9cx+qOgDxo0eMiFGEueWztz+d4+M3rGlmKPT+T4IS/jP4ylw3Nwpu6cpTTP8R1MAC1kF4VbdLt3ARf209w==}
|
||||
hasBin: true
|
||||
@ -1845,6 +1852,8 @@ snapshots:
|
||||
|
||||
undici-types@7.18.2: {}
|
||||
|
||||
undici@8.0.2: {}
|
||||
|
||||
update-browserslist-db@1.2.3(browserslist@4.28.2):
|
||||
dependencies:
|
||||
browserslist: 4.28.2
|
||||
|
||||
@ -10,6 +10,15 @@ import { mkdir, writeFile, rm } from "node:fs/promises";
|
||||
import { arch, platform } from "node:os";
|
||||
import { dirname, join } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { EnvHttpProxyAgent, setGlobalDispatcher } from "undici";
|
||||
|
||||
/** 自动读取 http_proxy/https_proxy 环境变量配置全局代理 */
|
||||
const proxyUrl = process.env.https_proxy || process.env.HTTPS_PROXY
|
||||
|| process.env.http_proxy || process.env.HTTP_PROXY;
|
||||
if (proxyUrl) {
|
||||
setGlobalDispatcher(new EnvHttpProxyAgent());
|
||||
console.log(`Using proxy: ${proxyUrl}`);
|
||||
}
|
||||
|
||||
const __dirname = dirname(fileURLToPath(import.meta.url));
|
||||
const ROOT_DIR = join(__dirname, "..");
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user