mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-26 12:27:06 +00:00 
			
		
		
		
	Skip frontend ROOT_URL check on installation page, remove unnecessary global var (#19291)
Skip `checkAppUrl` message on installation page because the ROOT_URL is not determined yet Move global var `supportedDbTypeNames` into `install.Init` as a local var
This commit is contained in:
		| @@ -42,20 +42,18 @@ const ( | |||||||
| 	tplPostInstall base.TplName = "post-install" | 	tplPostInstall base.TplName = "post-install" | ||||||
| ) | ) | ||||||
|  |  | ||||||
| var supportedDbTypeNames []map[string]string // use a slice to keep order | // getSupportedDbTypeNames returns a slice for supported database types and names. The slice is used to keep the order | ||||||
| func getDbTypeNames() []map[string]string { | func getSupportedDbTypeNames() (dbTypeNames []map[string]string) { | ||||||
| 	if supportedDbTypeNames == nil { |  | ||||||
| 	for _, t := range setting.SupportedDatabaseTypes { | 	for _, t := range setting.SupportedDatabaseTypes { | ||||||
| 			supportedDbTypeNames = append(supportedDbTypeNames, map[string]string{"type": t, "name": setting.DatabaseTypeNames[t]}) | 		dbTypeNames = append(dbTypeNames, map[string]string{"type": t, "name": setting.DatabaseTypeNames[t]}) | ||||||
| 	} | 	} | ||||||
| 	} | 	return dbTypeNames | ||||||
| 	return supportedDbTypeNames |  | ||||||
| } | } | ||||||
|  |  | ||||||
| // Init prepare for rendering installation page | // Init prepare for rendering installation page | ||||||
| func Init(next http.Handler) http.Handler { | func Init(next http.Handler) http.Handler { | ||||||
| 	rnd := templates.HTMLRenderer() | 	rnd := templates.HTMLRenderer() | ||||||
|  | 	dbTypeNames := getSupportedDbTypeNames() | ||||||
| 	return http.HandlerFunc(func(resp http.ResponseWriter, req *http.Request) { | 	return http.HandlerFunc(func(resp http.ResponseWriter, req *http.Request) { | ||||||
| 		if setting.InstallLock { | 		if setting.InstallLock { | ||||||
| 			resp.Header().Add("Refresh", "1; url="+setting.AppURL+"user/login") | 			resp.Header().Add("Refresh", "1; url="+setting.AppURL+"user/login") | ||||||
| @@ -74,7 +72,7 @@ func Init(next http.Handler) http.Handler { | |||||||
| 				"i18n":          locale, | 				"i18n":          locale, | ||||||
| 				"Title":         locale.Tr("install.install"), | 				"Title":         locale.Tr("install.install"), | ||||||
| 				"PageIsInstall": true, | 				"PageIsInstall": true, | ||||||
| 				"DbTypeNames":   getDbTypeNames(), | 				"DbTypeNames":   dbTypeNames, | ||||||
| 				"AllLangs":      translation.AllLangs(), | 				"AllLangs":      translation.AllLangs(), | ||||||
| 				"PageStartTime": startTime, | 				"PageStartTime": startTime, | ||||||
|  |  | ||||||
|   | |||||||
| @@ -358,6 +358,9 @@ export function checkAppUrl() { | |||||||
|   if (curUrl.startsWith(appUrl)) { |   if (curUrl.startsWith(appUrl)) { | ||||||
|     return; |     return; | ||||||
|   } |   } | ||||||
|  |   if (document.querySelector('.page-content.install')) { | ||||||
|  |     return; // no need to show the message on the installation page | ||||||
|  |   } | ||||||
|   showGlobalErrorMessage(`Your ROOT_URL in app.ini is ${appUrl} but you are visiting ${curUrl} |   showGlobalErrorMessage(`Your ROOT_URL in app.ini is ${appUrl} but you are visiting ${curUrl} | ||||||
| You should set ROOT_URL correctly, otherwise the web may not work correctly.`); | You should set ROOT_URL correctly, otherwise the web may not work correctly.`); | ||||||
| } | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 wxiaoguang
					wxiaoguang