mirror of
https://github.com/go-gitea/gitea
synced 2025-11-07 14:58:14 +00:00
Update tab title when navigating file tree (#35757)
Fix #35749. --------- Signed-off-by: silverwind <me@silverwind.io> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: silverwind <me@silverwind.io>
This commit is contained in:
@@ -25,9 +25,16 @@ export function createViewFileTreeStore(props: {repoLink: string, treePath: stri
|
||||
},
|
||||
|
||||
async loadViewContent(url: string) {
|
||||
url = url.includes('?') ? url.replace('?', '?only_content=true') : `${url}?only_content=true`;
|
||||
const response = await GET(url);
|
||||
document.querySelector('.repo-view-content').innerHTML = await response.text();
|
||||
const u = new URL(url, window.origin);
|
||||
u.searchParams.set('only_content', 'true');
|
||||
const response = await GET(u.href);
|
||||
const elViewContent = document.querySelector('.repo-view-content');
|
||||
elViewContent.innerHTML = await response.text();
|
||||
const elViewContentData = elViewContent.querySelector('.repo-view-content-data');
|
||||
if (!elViewContentData) return; // if error occurs, there is no such element
|
||||
const t1 = elViewContentData.getAttribute('data-document-title');
|
||||
const t2 = elViewContentData.getAttribute('data-document-title-common');
|
||||
document.title = `${t1} - ${t2}`; // follow the format in head.tmpl: <head><title>...</title></head>
|
||||
},
|
||||
|
||||
async navigateTreeView(treePath: string) {
|
||||
|
||||
Reference in New Issue
Block a user