mirror of
https://github.com/go-gitea/gitea.git
synced 2025-07-23 13:55:53 +02:00
fix
This commit is contained in:
parent
6f2de3ea5e
commit
31835f4638
@ -27,7 +27,7 @@ function childrenLoader(sidebarEl: HTMLElement) {
|
|||||||
const fileTree = sidebarEl.querySelector('#view-file-tree');
|
const fileTree = sidebarEl.querySelector('#view-file-tree');
|
||||||
const apiBaseUrl = fileTree.getAttribute('data-api-base-url');
|
const apiBaseUrl = fileTree.getAttribute('data-api-base-url');
|
||||||
const refTypeNameSubURL = fileTree.getAttribute('data-current-ref-type-name-sub-url');
|
const refTypeNameSubURL = fileTree.getAttribute('data-current-ref-type-name-sub-url');
|
||||||
const response = await GET(`${apiBaseUrl}/tree/${refTypeNameSubURL}/${encodeURIComponent(path ?? '')}?recursive=${recursive ?? false}`);
|
const response = await GET(encodeURI(`${apiBaseUrl}/tree/${refTypeNameSubURL}/${path ?? ''}?recursive=${recursive ?? false}`));
|
||||||
const json = await response.json();
|
const json = await response.json();
|
||||||
if (json instanceof Array) {
|
if (json instanceof Array) {
|
||||||
return json.map((i) => ({
|
return json.map((i) => ({
|
||||||
@ -78,8 +78,8 @@ export function initViewFileTreeSidebar() {
|
|||||||
|
|
||||||
fileTree.classList.remove('is-loading');
|
fileTree.classList.remove('is-loading');
|
||||||
const fileTreeView = createApp(ViewFileTree, {files, selectedItem, loadChildren: childrenLoader(el), loadContent: (path: string) => {
|
const fileTreeView = createApp(ViewFileTree, {files, selectedItem, loadChildren: childrenLoader(el), loadContent: (path: string) => {
|
||||||
selectedItem.value = getSelectedPath(refString, `${baseUrl}/src${refString}/${path}`);
|
window.history.pushState(null, null, encodeURI(`${baseUrl}/src${refString}/${path}`));
|
||||||
window.history.pushState(null, null, `${baseUrl}/src${refString}/${encodeURIComponent(path)}`);
|
selectedItem.value = path;
|
||||||
loadContent(el);
|
loadContent(el);
|
||||||
}});
|
}});
|
||||||
fileTreeView.mount(fileTree);
|
fileTreeView.mount(fileTree);
|
||||||
@ -94,7 +94,7 @@ export function initViewFileTreeSidebar() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function getSelectedPath(ref: string, url?: string) {
|
function getSelectedPath(ref: string) {
|
||||||
const path = url ?? (new URL(window.location.href).pathname);
|
const path = decodeURI(new URL(window.location.href).pathname);
|
||||||
return path.substring(path.indexOf(ref) + ref.length + 1);
|
return path.substring(path.indexOf(ref) + ref.length + 1);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user