mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2026-03-02 16:50:27 +00:00
Refactor font handling and theme config, switch to CodeMirror editor
Replaces Monaco editor with CodeMirror in the frontend, removing related dependencies and configuration. Refactors font management to support multiple formats (woff, woff2, ttf, otf) and dynamic font switching, including backend API and frontend theme config UI. Adds gzip compression middleware to backend. Updates theme config to allow font selection and custom font upload, and improves theme preview and color customization UI. Cleans up unused code and improves sidebar and terminal font sizing responsiveness.
This commit is contained in:
@@ -176,17 +176,35 @@ export class WebUiConfigWrapper {
|
||||
return [];
|
||||
}
|
||||
|
||||
// 判断字体是否存在(webui.woff)
|
||||
// 判断字体是否存在(支持多种格式)
|
||||
async CheckWebUIFontExist (): Promise<boolean> {
|
||||
const fontsPath = resolve(webUiPathWrapper.configPath, './fonts');
|
||||
const fontPath = await this.GetWebUIFontPath();
|
||||
if (!fontPath) return false;
|
||||
return await fs
|
||||
.access(resolve(fontsPath, './webui.woff'), constants.F_OK)
|
||||
.access(fontPath, constants.F_OK)
|
||||
.then(() => true)
|
||||
.catch(() => false);
|
||||
}
|
||||
|
||||
// 获取webui字体文件路径
|
||||
GetWebUIFontPath (): string {
|
||||
// 获取webui字体文件路径(支持多种格式)
|
||||
async GetWebUIFontPath (): Promise<string | null> {
|
||||
const fontsPath = resolve(webUiPathWrapper.configPath, './fonts');
|
||||
const extensions = ['.woff', '.woff2', '.ttf', '.otf'];
|
||||
for (const ext of extensions) {
|
||||
const fontPath = resolve(fontsPath, `webui${ext}`);
|
||||
const exists = await fs
|
||||
.access(fontPath, constants.F_OK)
|
||||
.then(() => true)
|
||||
.catch(() => false);
|
||||
if (exists) {
|
||||
return fontPath;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// 同步版本,用于 multer 配置
|
||||
GetWebUIFontPathSync (): string {
|
||||
return resolve(webUiPathWrapper.configPath, './fonts/webui.woff');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user