Merge branch 'main' of github.com:ChatGPTNextWeb/ChatGPT-Next-Web into ChatGPTNextWeb-main

This commit is contained in:
ayman-makki
2024-10-04 13:44:30 +01:00
159 changed files with 19561 additions and 3377 deletions

25
app/masks/build.ts Normal file
View File

@@ -0,0 +1,25 @@
import fs from "fs";
import path from "path";
import { CN_MASKS } from "./cn";
import { TW_MASKS } from "./tw";
import { EN_MASKS } from "./en";
import { type BuiltinMask } from "./typing";
const BUILTIN_MASKS: Record<string, BuiltinMask[]> = {
cn: CN_MASKS,
tw: TW_MASKS,
en: EN_MASKS,
};
const dirname = path.dirname(__filename);
fs.writeFile(
dirname + "/../../public/masks.json",
JSON.stringify(BUILTIN_MASKS, null, 4),
function (error) {
if (error) {
console.error("[Build] failed to build masks", error);
}
},
);

View File

@@ -1,7 +1,4 @@
import { Mask } from "../store/mask";
import { CN_MASKS } from "./cn";
import { TW_MASKS } from "./tw";
import { EN_MASKS } from "./en";
import { type BuiltinMask } from "./typing";
export { type BuiltinMask } from "./typing";
@@ -22,6 +19,20 @@ export const BUILTIN_MASK_STORE = {
},
};
export const BUILTIN_MASKS: BuiltinMask[] = [...EN_MASKS].map((m) =>
BUILTIN_MASK_STORE.add(m),
);
export const BUILTIN_MASKS: BuiltinMask[] = [];
if (typeof window != "undefined") {
// run in browser skip in next server
fetch("/masks.json")
.then((res) => res.json())
.catch((error) => {
console.error("[Fetch] failed to fetch masks", error);
return { cn: [], tw: [], en: [] };
})
.then((masks) => {
const { cn = [], tw = [], en = [] } = masks;
return [...en].map((m) => {
BUILTIN_MASKS.push(BUILTIN_MASK_STORE.add(m));
});
});
}