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}`); } async function fileRaw(name: string, branch: string, path: string): Promise { return axios({ url: `${BASE_URI}/${name}:${branch}/file/raw${path}`, method: "GET", responseType: "arraybuffer" }); } 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, downloadArchive, pageLog };