support preview img,audio,video for FileDetail.vue
This commit is contained in:
@ -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
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user