feat(projects): 1.0 beta

This commit is contained in:
Soybean
2023-11-17 08:45:00 +08:00
parent 1ea4817f6a
commit e918a2c0f5
499 changed files with 15918 additions and 24708 deletions

View File

@@ -1,8 +0,0 @@
import dayjs from 'dayjs';
/** 项目构建时间 */
const PROJECT_BUILD_TIME = JSON.stringify(dayjs().format('YYYY-MM-DD HH:mm:ss'));
export const viteDefine = {
PROJECT_BUILD_TIME
};

View File

@@ -1,2 +1 @@
export * from './define';
export * from './proxy';

View File

@@ -1,20 +1,38 @@
import type { ProxyOptions } from 'vite';
import { createServiceConfig, createProxyPattern } from '../../env.config';
/**
* 设置网络代理
* @param isOpenProxy - 是否开启代理
* @param envConfig - env环境配置
* set http proxy
* @param env - the current env
*/
export function createViteProxy(isOpenProxy: boolean, envConfig: ServiceEnvConfigWithProxyPattern) {
if (!isOpenProxy) return undefined;
export function createViteProxy(env: Env.ImportMeta) {
const isEnableHttpProxy = env.VITE_HTTP_PROXY === 'Y';
const proxy: Record<string, string | ProxyOptions> = {
[envConfig.proxyPattern]: {
target: envConfig.url,
if (!isEnableHttpProxy) return undefined;
const { baseURL, otherBaseURL } = createServiceConfig(env);
const defaultProxyPattern = createProxyPattern();
const proxy: Record<string, ProxyOptions> = {
[defaultProxyPattern]: {
target: baseURL,
changeOrigin: true,
rewrite: path => path.replace(new RegExp(`^${envConfig.proxyPattern}`), '')
rewrite: path => path.replace(new RegExp(`^${defaultProxyPattern}`), '')
}
};
const otherURLEntries = Object.entries(otherBaseURL);
for (const [key, url] of otherURLEntries) {
const proxyPattern = createProxyPattern(key);
proxy[proxyPattern] = {
target: url,
changeOrigin: true,
rewrite: path => path.replace(new RegExp(`^${proxyPattern}`), '')
};
}
return proxy;
}