From 309307afba1db0ee5894a69baa99ada59760e935 Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Wed, 29 Oct 2025 20:39:19 +0800 Subject: [PATCH] fix --- modules/web/middleware/data.go | 2 ++ services/context/repo.go | 1 + templates/base/head.tmpl | 2 +- templates/repo/view_content.tmpl | 2 +- web_src/js/components/ViewFileTreeStore.ts | 4 +++- 5 files changed, 8 insertions(+), 3 deletions(-) diff --git a/modules/web/middleware/data.go b/modules/web/middleware/data.go index a47da0f836..41fb1e7e6f 100644 --- a/modules/web/middleware/data.go +++ b/modules/web/middleware/data.go @@ -22,6 +22,8 @@ func GetContextData(c context.Context) reqctx.ContextData { func CommonTemplateContextData() reqctx.ContextData { return reqctx.ContextData{ + "PageTitleCommon": setting.AppName, + "IsLandingPageOrganizations": setting.LandingPageURL == setting.LandingPageOrganizations, "ShowRegistrationButton": setting.Service.ShowRegistrationButton, diff --git a/services/context/repo.go b/services/context/repo.go index 0ff1c7ea03..cfbfb33ab9 100644 --- a/services/context/repo.go +++ b/services/context/repo.go @@ -537,6 +537,7 @@ func RepoAssignment(ctx *Context) { } ctx.Data["Title"] = repo.Owner.Name + "/" + repo.Name + ctx.Data["PageTitleCommon"] = repo.Name + " - " + setting.AppName ctx.Data["Repository"] = repo ctx.Data["Owner"] = ctx.Repo.Repository.Owner ctx.Data["CanWriteCode"] = ctx.Repo.CanWrite(unit_model.TypeCode) diff --git a/templates/base/head.tmpl b/templates/base/head.tmpl index 62bc625bda..a3ea4c454d 100644 --- a/templates/base/head.tmpl +++ b/templates/base/head.tmpl @@ -2,7 +2,7 @@ - {{if .Title}}{{.Title}} - {{end}}{{if .Repository.Name}}{{.Repository.Name}} - {{end}}{{AppName}} + {{if .Title}}{{.Title}} - {{end}}{{.PageTitleCommon}} {{if .ManifestData}}{{end}} diff --git a/templates/repo/view_content.tmpl b/templates/repo/view_content.tmpl index f1cc811847..66e4fffcb9 100644 --- a/templates/repo/view_content.tmpl +++ b/templates/repo/view_content.tmpl @@ -1,6 +1,6 @@ {{$isTreePathRoot := not .TreeNames}} -
+
{{template "repo/sub_menu" .}}
diff --git a/web_src/js/components/ViewFileTreeStore.ts b/web_src/js/components/ViewFileTreeStore.ts index 2e78eb8b8b..fd37b40992 100644 --- a/web_src/js/components/ViewFileTreeStore.ts +++ b/web_src/js/components/ViewFileTreeStore.ts @@ -30,7 +30,9 @@ export function createViewFileTreeStore(props: {repoLink: string, treePath: stri const response = await GET(u.href); const elViewContent = document.querySelector('.repo-view-content'); elViewContent.innerHTML = await response.text(); - document.title = elViewContent.querySelector('.repo-view-content-data').getAttribute('data-document-title'); + const t1 = elViewContent.querySelector('.repo-view-content-data').getAttribute('data-document-title'); + const t2 = elViewContent.querySelector('.repo-view-content-data').getAttribute('data-document-title-common'); + document.title = `${t1} - ${t2}`; // follow the format in head.tmpl: ... }, async navigateTreeView(treePath: string) {