File tree Expand file tree Collapse file tree 5 files changed +11
-7
lines changed Expand file tree Collapse file tree 5 files changed +11
-7
lines changed Original file line number Diff line number Diff line change 66 < meta name ="viewport " content ="width=device-width, initial-scale=1.0 " />
77 < meta name ="color-scheme " content ="light dark " />
88 < title > %VITE_APP_TITLE%</ title >
9+ < script src ="/runtime.config.js "> </ script >
910 </ head >
1011 < body >
1112 < div id ="app "> </ div >
Original file line number Diff line number Diff line change 11window . config = {
22 VITE_BUILD_PREFIX : '' ,
3+ VITE_SERVICE_BASE_URL : '' ,
4+ VITE_OTHER_SERVICE_BASE_URL : '' ,
35}
Original file line number Diff line number Diff line change @@ -221,7 +221,7 @@ const local: App.I18n.Schema = {
221221 projectNews : {
222222 title : 'Project News' ,
223223 moreNews : 'More News' ,
224- desc1 : 'Loic Duong created the open source project vue-naive-admin on May 28, 2021 !' ,
224+ desc1 : 'Loic Duong created the open source project vue-naive-admin on May 28, 2024 !' ,
225225 desc2 : 'Loic Duong submitted a bug to vue-naive-admin, the multi-tab bar will not adapt.' ,
226226 desc3 : 'Loic Duong is ready to do sufficient preparation for the release of vue-naive-admin!' ,
227227 desc4 : 'Loic Duong is busy writing project documentation for vue-naive-admin!' ,
Original file line number Diff line number Diff line change 1- export function getEnvVariable ( name : Env . Runtime , env ?: Env . ImportMeta ) : CommonType . NullableString {
2- return window . config ?. [ name ] || ( env ? env [ name ] : import . meta. env [ name ] )
1+ export function getEnvVariable ( name : Env . Runtime , env ?: Env . ImportMeta ) : string {
2+ return typeof window === 'undefined'
3+ ? env ?. [ name ] || import . meta. env [ name ]
4+ : window . config ?. [ name ] || env ?. [ name ] || import . meta. env [ name ]
35}
Original file line number Diff line number Diff line change 11import json5 from 'json5'
2+ import { getEnvVariable } from './env'
23
34/**
45 * Create service config by current env
56 *
67 * @param env The current env
78 */
89export function createServiceConfig ( env : Env . ImportMeta ) {
9- const { VITE_SERVICE_BASE_URL , VITE_OTHER_SERVICE_BASE_URL } = env
10-
1110 let other = { } as Record < App . Service . OtherBaseURLKey , string >
1211 try {
13- other = json5 . parse ( VITE_OTHER_SERVICE_BASE_URL )
12+ other = json5 . parse ( getEnvVariable ( ' VITE_OTHER_SERVICE_BASE_URL' , env ) )
1413 }
1514 catch {
1615 console . error ( 'VITE_OTHER_SERVICE_BASE_URL is not a valid json5 string' )
1716 }
1817
1918 const httpConfig : App . Service . SimpleServiceConfig = {
20- baseURL : VITE_SERVICE_BASE_URL ,
19+ baseURL : getEnvVariable ( ' VITE_SERVICE_BASE_URL' , env ) ,
2120 other,
2221 }
2322
You can’t perform that action at this time.
0 commit comments