support preview img,audio,video for FileDetail.vue

This commit is contained in:
Timi
2025-07-11 20:07:37 +08:00
parent 54b2d27b81
commit d885beb56d
4 changed files with 427 additions and 224 deletions

View File

@ -21,14 +21,26 @@ async function listFile(name: string, branch: string, path: string): Promise<Fil
return axios.get(`${BASE_URI}/${name}:${branch}/file/list${path}`);
}
async function fileRaw(name: string, branch: string, path: string): Promise<ArrayBuffer> {
function fileRawURL(name: string, branch: string, path: string): string {
return `${API_HOST}${BASE_URI}/${name}:${branch}/file/raw${path}`;
}
async function fileRawByURL(rawURL: string): Promise<ArrayBuffer> {
return axios({
url: `${BASE_URI}/${name}:${branch}/file/raw${path}`,
url: rawURL,
method: "GET",
responseType: "arraybuffer"
});
}
async function fileRaw(name: string, branch: string, path: string): Promise<ArrayBuffer> {
return fileRawByURL(fileRawURL(name, branch, path));
}
async function fileMimeType(name: string, branch: string, path: string): Promise<string> {
return axios.get(`${BASE_URI}/${name}:${branch}/file/mime${path}`);
}
function downloadArchive(name: string, branch: string) {
window.open(`${API_HOST}${BASE_URI}/${name}:${branch}/archive`);
}
@ -43,6 +55,9 @@ export default {
pagePush,
listFile,
fileRaw,
fileRawURL,
fileRawByURL,
fileMimeType,
downloadArchive,
pageLog
};