f0358dbdfe
Implements a read-only repository viewer for remote Gitea repos and local clones. Adds UI/CSS for viewer panels, breadcrumb/branch controls, file table, code/Markdown preview, and readme rendering (frontend/css/components.css, frontend/js/app.js). Extends app state and wiring (state.js, app.js) with viewer actions, branch/content loading, local/remote navigation, and preview helpers (base64 decoding, markdown rendering, syntax highlighting, 256 KB preview limit). Adds Gitea API helpers to fetch repo branches and contents (frontend/js/gitea-api.js) and Tauri JS bindings for local repo operations (tauri-api.js). Implements Rust backend commands to list branches, tree entries, and file contents (with size/binary checks and helper utilities) and wires them into the Tauri command registry (src-tauri/src/lib.rs). Also updates README to mention the new read-only viewer.
67 lines
1.6 KiB
JavaScript
67 lines
1.6 KiB
JavaScript
const invoke = window.__TAURI__?.core?.invoke;
|
|
|
|
function ensureInvoke() {
|
|
if (!invoke) {
|
|
throw new Error("Tauri invoke API is not available.");
|
|
}
|
|
}
|
|
|
|
export async function runGitClone(repoUrl, destinationPath, gitPath) {
|
|
ensureInvoke();
|
|
return invoke("git_clone", {
|
|
repoUrl,
|
|
destinationPath,
|
|
gitPath: gitPath || null,
|
|
});
|
|
}
|
|
|
|
export async function runGitPull(repoPath, gitPath) {
|
|
ensureInvoke();
|
|
return invoke("git_pull", { repoPath, gitPath: gitPath || null });
|
|
}
|
|
|
|
export async function runGitPush(repoPath, gitPath) {
|
|
ensureInvoke();
|
|
return invoke("git_push", { repoPath, gitPath: gitPath || null });
|
|
}
|
|
|
|
export async function runGitStatus(repoPath, gitPath) {
|
|
ensureInvoke();
|
|
return invoke("git_status", { repoPath, gitPath: gitPath || null });
|
|
}
|
|
|
|
export async function runGitBranch(repoPath, gitPath) {
|
|
ensureInvoke();
|
|
return invoke("git_branch", { repoPath, gitPath: gitPath || null });
|
|
}
|
|
|
|
export async function listLocalRepoBranches(repoPath, gitPath) {
|
|
ensureInvoke();
|
|
return invoke("local_repo_branches", { repoPath, gitPath: gitPath || null });
|
|
}
|
|
|
|
export async function listLocalRepoTree(repoPath, reference, path, gitPath) {
|
|
ensureInvoke();
|
|
return invoke("local_repo_tree", {
|
|
repoPath,
|
|
reference,
|
|
path: path || "",
|
|
gitPath: gitPath || null,
|
|
});
|
|
}
|
|
|
|
export async function readLocalRepoFile(repoPath, reference, path, gitPath) {
|
|
ensureInvoke();
|
|
return invoke("local_repo_file", {
|
|
repoPath,
|
|
reference,
|
|
path,
|
|
gitPath: gitPath || null,
|
|
});
|
|
}
|
|
|
|
export async function testGiteaConnection(payload) {
|
|
ensureInvoke();
|
|
return invoke("test_gitea_connection", payload);
|
|
}
|