mirror of
https://gitee.com/yiming_chang/vue-pure-admin.git
synced 2024-12-02 11:17:39 +08:00
20 lines
445 B
TypeScript
20 lines
445 B
TypeScript
type ProxyItem = [string, string];
|
|
|
|
type ProxyList = ProxyItem[];
|
|
|
|
const regExps = (value: string, reg: string): string => {
|
|
return value.replace(new RegExp(reg, "g"), "");
|
|
};
|
|
|
|
export function createProxy(list: ProxyList = []) {
|
|
const ret: any = {};
|
|
for (const [prefix, target] of list) {
|
|
ret[prefix] = {
|
|
target: target,
|
|
changeOrigin: true,
|
|
rewrite: (path: string) => regExps(path, prefix)
|
|
};
|
|
}
|
|
return ret;
|
|
}
|