6b245c628c
Add complete project scaffold for Gitpub Desktop (Tauri + Rust backend and vanilla HTML/CSS/JS frontend). Includes frontend entry (index.html), styles (base/components CSS), app logic and modules (app.js, gitea-api.js, tauri-api.js, state.js, storage.js), static assets and component READMEs, README.md, VSCode recommendations, and project config (package.json, package-lock.json). Also adds src-tauri skeleton (Cargo.toml, main.rs, lib.rs, build.rs, tauri.conf.json), application icons, and .gitignore files. Provides MVP plumbing for server setup and management, repository dashboard, local repo opening, and Git operations via Tauri invoke (clone/pull/push/status/branch).
38 lines
930 B
JavaScript
38 lines
930 B
JavaScript
import { loadSettings, saveSettings } from "./storage.js";
|
|
|
|
const state = {
|
|
settings: loadSettings(),
|
|
selectedRepoPath: "",
|
|
selectedRepoName: "",
|
|
repoSearch: "",
|
|
localRepoPathInput: "",
|
|
cloneUrlInput: "",
|
|
cloneDestinationInput: "",
|
|
commitMessage: "",
|
|
};
|
|
|
|
export function getState() {
|
|
return state;
|
|
}
|
|
|
|
export function setSettings(nextSettings) {
|
|
state.settings = nextSettings;
|
|
saveSettings(state.settings);
|
|
}
|
|
|
|
export function updateSettings(patch) {
|
|
setSettings({ ...state.settings, ...patch });
|
|
}
|
|
|
|
export function addRecentRepo(path) {
|
|
if (!path) return;
|
|
const current = state.settings.recentRepositories.filter((item) => item !== path);
|
|
const next = [path, ...current].slice(0, 15);
|
|
updateSettings({ recentRepositories: next });
|
|
}
|
|
|
|
export function getActiveServer() {
|
|
const { activeServerId, servers } = state.settings;
|
|
return servers.find((server) => server.id === activeServerId) ?? null;
|
|
}
|