import { axios, Page, PageResult } from "timi-web"; import { File, Repository, RepositoryView } from "@/types/Repository"; import { ActionLogView } from "@/types/Common.ts"; const BASE_URI = "/git/repository"; const API_HOST = import.meta.env.VITE_API; async function view(name: string): Promise { return axios.get(`${BASE_URI}/${name}`); } async function page(page: Page): Promise> { return axios.post(`${BASE_URI}/list`, page); } async function pagePush(name: string, branch: string, page: Page): Promise> { return axios.post(`${BASE_URI}/${name}:${branch}/log/push`, page); } async function listFile(name: string, branch: string, path: string): Promise { return axios.get(`${BASE_URI}/${name}:${branch}/file/list${path}`); } 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 { return axios({ url: rawURL, method: "GET", responseType: "arraybuffer" }); } async function fileRaw(name: string, branch: string, path: string): Promise { return fileRawByURL(fileRawURL(name, branch, path)); } async function fileMimeType(name: string, branch: string, path: string): Promise { 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`); } async function pageLog(page: Page): Promise> { return axios.post(`${BASE_URI}/log`, page); } export default { view, page, pagePush, listFile, fileRaw, fileRawURL, fileRawByURL, fileMimeType, downloadArchive, pageLog };