From c2ebe3724f55f8eef4c07ac984e59506edb9919c Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Mon, 3 Aug 2026 12:40:02 +0800 Subject: [PATCH] refactor: introduce trString for frontend (#38741) Co-authored-by: silverwind Co-authored-by: delvh --- modules/public/vitedev.go | 6 +++--- modules/web/router.go | 3 ++- .../js/components/ActionRunSummaryView.vue | 7 ++++--- web_src/js/components/RepoActionView.vue | 3 ++- .../js/components/RepoBranchTagSelector.vue | 6 ++++-- web_src/js/components/WorkflowGraph.vue | 4 ++-- web_src/js/features/heatmap.ts | 3 ++- web_src/js/features/pull-view-file.ts | 6 +++--- web_src/js/features/repo-branch.ts | 3 ++- web_src/js/modules/fomantic/dropdown.ts | 3 ++- web_src/js/modules/i18n.test.ts | 9 ++++++++- web_src/js/modules/i18n.ts | 19 +++++++++++++++++-- 12 files changed, 51 insertions(+), 21 deletions(-) diff --git a/modules/public/vitedev.go b/modules/public/vitedev.go index b9bb1dbe82..bf35f1bf8e 100644 --- a/modules/public/vitedev.go +++ b/modules/public/vitedev.go @@ -89,7 +89,7 @@ func getViteDevProxy() *httputil.ReverseProxy { func ViteDevMiddleware(next http.Handler) http.Handler { markLongPolling := routing.MarkLongPolling() return http.HandlerFunc(func(resp http.ResponseWriter, req *http.Request) { - if !isViteDevRequest(req) { + if !IsViteDevRequest(req) { next.ServeHTTP(resp, req) return } @@ -149,9 +149,9 @@ func viteDevSourceURL(srcPath string) string { return setting.AppSubURL + "/" + srcPath } -// isViteDevRequest returns true if the request should be proxied to the Vite dev server. +// IsViteDevRequest returns true if the request should be proxied to the Vite dev server. // Ref: Vite source packages/vite/src/node/constants.ts and packages/vite/src/shared/constants.ts -func isViteDevRequest(req *http.Request) bool { +func IsViteDevRequest(req *http.Request) bool { if req.Header.Get("Upgrade") == "websocket" { wsProtocol := req.Header.Get("Sec-WebSocket-Protocol") return wsProtocol == "vite-hmr" || wsProtocol == "vite-ping" diff --git a/modules/web/router.go b/modules/web/router.go index 66d6ae8e0c..03b4cf03e2 100644 --- a/modules/web/router.go +++ b/modules/web/router.go @@ -10,6 +10,7 @@ import ( "strings" "gitea.dev/modules/htmlutil" + "gitea.dev/modules/public" "gitea.dev/modules/reqctx" "gitea.dev/modules/setting" "gitea.dev/modules/web/middleware" @@ -256,7 +257,7 @@ func (r *Router) normalizeRequestPath(resp http.ResponseWriter, req *http.Reques normalizedPath = "/" + remainingPath } else if normalizedPath == setting.AppSubURL { normalizedPath = "/" - } else if !strings.HasPrefix(normalizedPath+"/", "/v2/") { + } else if !strings.HasPrefix(normalizedPath+"/", "/v2/") && !public.IsViteDevRequest(req) { // do not respond to other requests, to simulate a real sub-path environment resp.Header().Add("Content-Type", "text/html; charset=utf-8") resp.WriteHeader(http.StatusNotFound) diff --git a/web_src/js/components/ActionRunSummaryView.vue b/web_src/js/components/ActionRunSummaryView.vue index c8764d4bc2..efd2c79e9b 100644 --- a/web_src/js/components/ActionRunSummaryView.vue +++ b/web_src/js/components/ActionRunSummaryView.vue @@ -1,7 +1,8 @@