build: 适配管理端 flow 基路径
- 调整开发与分析环境的 base 和接口前缀为 /flow - 更新 Vite 代理配置,兼容 /flow/api 与 /flow/userCenter - 修复基路径下的 Logo 与启动加载图资源地址
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
# public path
|
# public path
|
||||||
VITE_BASE=/
|
VITE_BASE=/flow/
|
||||||
|
|
||||||
# Basic interface address SPA
|
# Basic interface address SPA
|
||||||
VITE_GLOB_API_URL=/api
|
VITE_GLOB_API_URL=/flow
|
||||||
|
|
||||||
VITE_VISUALIZER=true
|
VITE_VISUALIZER=true
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
# 端口号
|
# 端口号
|
||||||
VITE_PORT=5090
|
VITE_PORT=5090
|
||||||
|
|
||||||
VITE_BASE=/
|
VITE_BASE=/flow/
|
||||||
|
|
||||||
# 接口地址
|
# 接口地址
|
||||||
VITE_GLOB_API_URL=http://127.0.0.1:8111
|
VITE_GLOB_API_URL=/flow
|
||||||
|
|
||||||
# 是否打开 devtools,true 为打开,false 为关闭
|
# 是否打开 devtools,true 为打开,false 为关闭
|
||||||
VITE_DEVTOOLS=false
|
VITE_DEVTOOLS=false
|
||||||
|
|||||||
@@ -20,13 +20,17 @@ export default defineConfig(async () => {
|
|||||||
],
|
],
|
||||||
server: {
|
server: {
|
||||||
proxy: {
|
proxy: {
|
||||||
'/api': {
|
'/flow/api': {
|
||||||
changeOrigin: true,
|
changeOrigin: true,
|
||||||
rewrite: (path) => path.replace(/^\/api/, ''),
|
rewrite: (path) => path.replace(/^\/flow/, ''),
|
||||||
// mock代理目标地址
|
target: 'http://127.0.0.1:8111',
|
||||||
target: 'http://localhost:5320/api',
|
|
||||||
ws: true,
|
ws: true,
|
||||||
},
|
},
|
||||||
|
'/flow/userCenter': {
|
||||||
|
changeOrigin: true,
|
||||||
|
rewrite: (path) => path.replace(/^\/flow/, ''),
|
||||||
|
target: 'http://127.0.0.1:8111',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ async function viteInjectAppLoadingPlugin(
|
|||||||
const { version } = await readPackageJSON(process.cwd());
|
const { version } = await readPackageJSON(process.cwd());
|
||||||
const envRaw = isBuild ? 'prod' : 'dev';
|
const envRaw = isBuild ? 'prod' : 'dev';
|
||||||
const cacheName = `'${env.VITE_APP_NAMESPACE}-${version}-${envRaw}-preferences-theme'`;
|
const cacheName = `'${env.VITE_APP_NAMESPACE}-${version}-${envRaw}-preferences-theme'`;
|
||||||
|
const appBase = JSON.stringify(ensureTrailingSlash(env.VITE_BASE || '/'));
|
||||||
|
|
||||||
// 获取缓存的主题
|
// 获取缓存的主题
|
||||||
// 保证黑暗主题下,刷新页面时,loading也是黑暗主题
|
// 保证黑暗主题下,刷新页面时,loading也是黑暗主题
|
||||||
@@ -29,7 +30,7 @@ async function viteInjectAppLoadingPlugin(
|
|||||||
document.documentElement.classList.toggle('dark', /dark/.test(theme));
|
document.documentElement.classList.toggle('dark', /dark/.test(theme));
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (/dark/.test(theme)) {
|
if (/dark/.test(theme)) {
|
||||||
document.querySelector('#__app-loading__ img').src = '/logoDark.svg';
|
document.querySelector('#__app-loading__ img').src = ${appBase} + 'logoDark.svg';
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
@@ -68,4 +69,8 @@ async function getLoadingRawByHtmlTemplate(loadingTemplate: string) {
|
|||||||
return await fsp.readFile(appLoadingPath, 'utf8');
|
return await fsp.readFile(appLoadingPath, 'utf8');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function ensureTrailingSlash(path: string) {
|
||||||
|
return path.endsWith('/') ? path : `${path}/`;
|
||||||
|
}
|
||||||
|
|
||||||
export { viteInjectAppLoadingPlugin };
|
export { viteInjectAppLoadingPlugin };
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
import type { Preferences } from './types';
|
import type { Preferences } from './types';
|
||||||
|
|
||||||
|
const assetBase = import.meta.env.BASE_URL || '/';
|
||||||
|
|
||||||
const defaultPreferences: Preferences = {
|
const defaultPreferences: Preferences = {
|
||||||
app: {
|
app: {
|
||||||
accessMode: 'frontend',
|
accessMode: 'frontend',
|
||||||
@@ -65,10 +67,10 @@ const defaultPreferences: Preferences = {
|
|||||||
logo: {
|
logo: {
|
||||||
enable: true,
|
enable: true,
|
||||||
fit: 'contain',
|
fit: 'contain',
|
||||||
source: '/logo.svg',
|
source: `${assetBase}logo.svg`,
|
||||||
sourceDark: '/logoDark.svg',
|
sourceDark: `${assetBase}logoDark.svg`,
|
||||||
sourceMini: '/logoMini.svg',
|
sourceMini: `${assetBase}logoMini.svg`,
|
||||||
sourceMiniDark: '/logoMiniDark.svg',
|
sourceMiniDark: `${assetBase}logoMiniDark.svg`,
|
||||||
},
|
},
|
||||||
navigation: {
|
navigation: {
|
||||||
accordion: true,
|
accordion: true,
|
||||||
|
|||||||
Reference in New Issue
Block a user