增加环境变量VITE_OUT_URL

This commit is contained in:
2026-03-12 15:16:18 +08:00
parent 1cd7a43bc5
commit f269c42a58
5 changed files with 13 additions and 4 deletions
+2 -1
View File
@@ -19,7 +19,8 @@ window['$CONFIG_VAR'] = {
"VITE_GLOB_API_URL": "${VITE_GLOB_API_URL:-http://default-api.com}", "VITE_GLOB_API_URL": "${VITE_GLOB_API_URL:-http://default-api.com}",
"VITE_GLOB_DOMAIN_URL": "${VITE_GLOB_DOMAIN_URL:-http://default-domain.com}", "VITE_GLOB_DOMAIN_URL": "${VITE_GLOB_DOMAIN_URL:-http://default-domain.com}",
"VITE_GLOB_ST_DOMAIN_URL": "${VITE_GLOB_ST_DOMAIN_URL:-http://default-domain.com}", "VITE_GLOB_ST_DOMAIN_URL": "${VITE_GLOB_ST_DOMAIN_URL:-http://default-domain.com}",
"VITE_GLOB_API_URL_PREFIX": "${VITE_GLOB_API_URL_PREFIX:-}" "VITE_GLOB_API_URL_PREFIX": "${VITE_GLOB_API_URL_PREFIX:-}",
"VITE_OUT_URL": "${VITE_OUT_URL:-}"
}; };
// 冻结对象(可选,模拟生产行为) // 冻结对象(可选,模拟生产行为)
+5 -3
View File
@@ -41,9 +41,11 @@
import { getAllParentPath } from '/@/router/helper/menuHelper'; import { getAllParentPath } from '/@/router/helper/menuHelper';
import { usePermission } from '/@/hooks/web/usePermission'; import { usePermission } from '/@/hooks/web/usePermission';
import { defHttp } from '/@/utils/http/axios'; import { defHttp } from '/@/utils/http/axios';
import { getEnvInfo } from '/@/utils/getEnv'; // import { getEnvInfo } from '/@/utils/getEnv';
import { getToken } from '/@/utils/auth'; import { getToken } from '/@/utils/auth';
import { useLoading } from '/@/components/Loading'; import { useLoading } from '/@/components/Loading';
import { useGlobSetting } from '/@/hooks/setting';
const { viteOutUrl } = useGlobSetting();
export default defineComponent({ export default defineComponent({
name: 'BasicMenu', name: 'BasicMenu',
@@ -128,7 +130,7 @@
async function handleMenuClick({ item, key }: { item: any; key: string; keyPath: string[] }) { async function handleMenuClick({ item, key }: { item: any; key: string; keyPath: string[] }) {
if (item.title === '健康银行') { if (item.title === '健康银行') {
open(); open();
const url = getEnvInfo().VITE_GLOB_API_URL; const url = viteOutUrl;
await defHttp await defHttp
.get({ .get({
url: '/health-system/api/sys/encryptInfo', url: '/health-system/api/sys/encryptInfo',
@@ -142,7 +144,7 @@
}) })
.then((res) => { .then((res) => {
console.log(res); console.log(res);
window.open(`${getEnvInfo().VITE_OUT_URL}${res.encryptData}`, '_blank'); window.open(`${viteOutUrl}${res.encryptData}`, '_blank');
close(); close();
}) })
.catch(() => { .catch(() => {
+2
View File
@@ -17,6 +17,7 @@ export const useGlobSetting = (): Readonly<GlobConfig> => {
VITE_GLOB_ONLINE_VIEW_URL, VITE_GLOB_ONLINE_VIEW_URL,
VITE_GLOB_ST_DOMAIN_URL, VITE_GLOB_ST_DOMAIN_URL,
VITE_PLATFORM, VITE_PLATFORM,
VITE_OUT_URL,
} = getAppEnvConfig(); } = getAppEnvConfig();
if (!/[a-zA-Z\_]*/.test(VITE_GLOB_APP_SHORT_NAME)) { if (!/[a-zA-Z\_]*/.test(VITE_GLOB_APP_SHORT_NAME)) {
@@ -40,6 +41,7 @@ export const useGlobSetting = (): Readonly<GlobConfig> => {
viewUrl: VITE_GLOB_ONLINE_VIEW_URL, viewUrl: VITE_GLOB_ONLINE_VIEW_URL,
stDomainUrl: VITE_GLOB_ST_DOMAIN_URL, stDomainUrl: VITE_GLOB_ST_DOMAIN_URL,
vitePlatform: VITE_PLATFORM, vitePlatform: VITE_PLATFORM,
viteOutUrl: VITE_OUT_URL,
}; };
window._CONFIG['domianURL'] = VITE_GLOB_DOMAIN_URL; window._CONFIG['domianURL'] = VITE_GLOB_DOMAIN_URL;
return glob as Readonly<GlobConfig>; return glob as Readonly<GlobConfig>;
+2
View File
@@ -34,6 +34,7 @@ export function getAppEnvConfig() {
VITE_GLOB_ONLINE_VIEW_URL, VITE_GLOB_ONLINE_VIEW_URL,
VITE_GLOB_ST_DOMAIN_URL, VITE_GLOB_ST_DOMAIN_URL,
VITE_PLATFORM, VITE_PLATFORM,
VITE_OUT_URL,
} = ENV; } = ENV;
if (!/^[a-zA-Z\_]*$/.test(VITE_GLOB_APP_SHORT_NAME)) { if (!/^[a-zA-Z\_]*$/.test(VITE_GLOB_APP_SHORT_NAME)) {
// warn( // warn(
@@ -55,6 +56,7 @@ export function getAppEnvConfig() {
VITE_GLOB_ONLINE_VIEW_URL, VITE_GLOB_ONLINE_VIEW_URL,
VITE_GLOB_ST_DOMAIN_URL, VITE_GLOB_ST_DOMAIN_URL,
VITE_PLATFORM, VITE_PLATFORM,
VITE_OUT_URL,
}; };
} }
+2
View File
@@ -155,6 +155,7 @@ export interface GlobConfig {
// Project abbreviation // Project abbreviation
shortName: string; shortName: string;
vitePlatform?: string; vitePlatform?: string;
viteOutUrl?: string;
} }
export interface GlobEnvConfig { export interface GlobEnvConfig {
// Site title // Site title
@@ -180,4 +181,5 @@ export interface GlobEnvConfig {
VITE_GLOB_ONLINE_VIEW_URL?: string; VITE_GLOB_ONLINE_VIEW_URL?: string;
VITE_GLOB_ST_DOMAIN_URL?: string; VITE_GLOB_ST_DOMAIN_URL?: string;
VITE_PLATFORM?: string; VITE_PLATFORM?: string;
VITE_OUT_URL?: string;
} }