feat: 初始化项目

This commit is contained in:
dengtongyu committed 2025-05-27 14:55:54 +08:00
commit 40c1dffb79
73 files changed
+11449

No files matched your search

+70
View File
@@ -0,0 +1,70 @@
type enforceType = "post" | "pre";
const enforceValue: enforceType = "post";
const setCrossoriginUseCredentials = () => {
return {
name: "set-crossorigin",
enforce: enforceValue,
transformIndexHtml(html: string) {
return html.replace(/crossorigin/g, "crossorigin=\"use-credentials\"");
}
};
};
const injectHtmlVars = (env: Record<string, string>) => {
return {
name: "inject-html-vars",
enforce: enforceValue,
transformIndexHtml(html: string) {
let str = html;
for (const key in env) {
if (Object.prototype.hasOwnProperty.call(env, key)) {
const element = env[key];
const reg = new RegExp(`%${key}%`, "g");
str = str.replace(reg, element);
}
}
return str;
}
};
};
const proxyConfig = (env: Record<string, string>) => {
const { NODE_PROXY_TARGET } = env;
const proxyTarget = NODE_PROXY_TARGET || "";
const proxyTable = {
"/zuul": {
target: proxyTarget,
changeOrigin: true
},
"/media/": {
target: proxyTarget,
changeOrigin: true
},
"/zwwxgzt": {
target: proxyTarget,
changeOrigin: true
},
"/midjs": {
target: proxyTarget,
changeOrigin: true
},
"/irc": {
target: proxyTarget,
changeOrigin: true
}
};
return proxyTable;
};
export default {
setCrossoriginUseCredentials,
injectHtmlVars,
proxyConfig
};
export {
setCrossoriginUseCredentials,
injectHtmlVars,
proxyConfig
};