mirror of
https://github.com/go-gitea/gitea.git
synced 2025-07-22 21:35:21 +02:00
fix
This commit is contained in:
parent
dccffe2497
commit
a0f69ec1a1
@ -4,6 +4,7 @@
|
|||||||
package repo
|
package repo
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
"code.gitea.io/gitea/modules/base"
|
"code.gitea.io/gitea/modules/base"
|
||||||
@ -58,7 +59,7 @@ func Tree(ctx *context.Context) {
|
|||||||
recursive := ctx.FormBool("recursive")
|
recursive := ctx.FormBool("recursive")
|
||||||
|
|
||||||
if ctx.Repo.RefFullName == "" {
|
if ctx.Repo.RefFullName == "" {
|
||||||
ctx.Error(http.StatusBadRequest, "RefFullName", "ref_name is invalid")
|
ctx.ServerError("RefFullName", errors.New("ref_name is invalid"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ const doLoadChildren = async () => {
|
|||||||
collapsed.value = !collapsed.value;
|
collapsed.value = !collapsed.value;
|
||||||
if (!collapsed.value && props.loadChildren) {
|
if (!collapsed.value && props.loadChildren) {
|
||||||
isLoading.value = true;
|
isLoading.value = true;
|
||||||
const _children = await props.loadChildren(props.item);
|
const _children = await props.loadChildren(props.item.path);
|
||||||
children.value = _children;
|
children.value = _children;
|
||||||
isLoading.value = false;
|
isLoading.value = false;
|
||||||
}
|
}
|
||||||
@ -33,11 +33,11 @@ const doLoadChildren = async () => {
|
|||||||
|
|
||||||
const doLoadDirContent = () => {
|
const doLoadDirContent = () => {
|
||||||
doLoadChildren();
|
doLoadChildren();
|
||||||
props.loadContent(props.item);
|
props.loadContent(props.item.path);
|
||||||
};
|
};
|
||||||
|
|
||||||
const doLoadFileContent = () => {
|
const doLoadFileContent = () => {
|
||||||
props.loadContent(props.item);
|
props.loadContent(props.item.path);
|
||||||
};
|
};
|
||||||
|
|
||||||
const doGotoSubModule = () => {
|
const doGotoSubModule = () => {
|
||||||
|
@ -10,7 +10,7 @@ import {initTargetPdfViewer} from '../render/pdf.ts';
|
|||||||
import {initTargetButtons} from './common-button.ts';
|
import {initTargetButtons} from './common-button.ts';
|
||||||
import {initTargetCopyContent} from './copycontent.ts';
|
import {initTargetCopyContent} from './copycontent.ts';
|
||||||
|
|
||||||
async function toggleSidebar(visibility, isSigned) {
|
async function toggleSidebar(visibility: boolean, isSigned: boolean) {
|
||||||
const sidebarEl = document.querySelector('.repo-view-file-tree-sidebar');
|
const sidebarEl = document.querySelector('.repo-view-file-tree-sidebar');
|
||||||
const showBtnEl = document.querySelector('.show-tree-sidebar-button');
|
const showBtnEl = document.querySelector('.show-tree-sidebar-button');
|
||||||
const containerClassList = sidebarEl.parentElement.classList;
|
const containerClassList = sidebarEl.parentElement.classList;
|
||||||
@ -29,11 +29,11 @@ async function toggleSidebar(visibility, isSigned) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async function loadChildren(item, recursive?: boolean) {
|
async function loadChildren(path: string, recursive?: boolean) {
|
||||||
const fileTree = document.querySelector('#view-file-tree');
|
const fileTree = document.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}/${item ? item.path : ''}?recursive=${recursive ?? false}`);
|
const response = await GET(`${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) => ({
|
||||||
@ -90,12 +90,12 @@ export async function initViewFileTreeSidebar() {
|
|||||||
|
|
||||||
const selectedItem = ref(treePath);
|
const selectedItem = ref(treePath);
|
||||||
|
|
||||||
const files = await loadChildren({path: treePath}, true);
|
const files = await loadChildren(treePath, true);
|
||||||
|
|
||||||
fileTree.classList.remove('is-loading');
|
fileTree.classList.remove('is-loading');
|
||||||
const fileTreeView = createApp(ViewFileTree, {files, selectedItem, loadChildren, loadContent: (item) => {
|
const fileTreeView = createApp(ViewFileTree, {files, selectedItem, loadChildren, loadContent: (path: string) => {
|
||||||
window.history.pushState(null, null, `${baseUrl}/src${refString}/${item.path}`);
|
window.history.pushState(null, null, `${baseUrl}/src${refString}/${path}`);
|
||||||
selectedItem.value = item.path;
|
selectedItem.value = path;
|
||||||
loadContent();
|
loadContent();
|
||||||
}});
|
}});
|
||||||
fileTreeView.mount(fileTree);
|
fileTreeView.mount(fileTree);
|
||||||
@ -106,7 +106,7 @@ export async function initViewFileTreeSidebar() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function extractPath(url) {
|
function extractPath(url: string) {
|
||||||
// Create a URL object
|
// Create a URL object
|
||||||
const urlObj = new URL(url);
|
const urlObj = new URL(url);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user