chore: init frontend with knowledge module

This commit is contained in:
2026-07-02 18:20:38 +08:00
parent fe67114be2
commit ad2e91ef30
649 changed files with 86676 additions and 1 deletions
+36
View File
@@ -0,0 +1,36 @@
import { error, readFile, rootDir, writeFile } from "../utils";
import { config } from "../config";
function getPath() {
return rootDir(`.${config.type == "admin" ? "/src" : ""}/config/proxy.ts`);
}
export async function updateProxy(data: { name: string }) {
let code = readFile(getPath());
const regex = /const\s+value\s*=\s*['"]([^'"]+)['"]/;
if (regex.test(code)) {
code = code.replace(regex, `const value = '${data.name}'`);
}
writeFile(getPath(), code);
}
export function getProxyTarget(proxy: any) {
const code = readFile(getPath());
const regex = /const\s+value\s*=\s*['"]([^'"]+)['"]/;
const match = code.match(regex);
if (match) {
const value = match[1];
try {
const { target, rewrite } = proxy[`/${value}/`];
return target + rewrite(`/${value}`);
} catch (err) {
error(`[cool-proxy] Error${value}` + getPath());
return "";
}
}
}