This commit is contained in:
marcus.hinz
2026-07-03 20:46:26 +02:00
parent 8b9eeb44e2
commit 70e4898259
15 changed files with 1876 additions and 373 deletions
-95
View File
@@ -1,95 +0,0 @@
<script setup lang="ts">
import { ref } from 'vue'
import viteLogo from '../assets/vite.svg'
import heroImg from '../assets/hero.png'
import vueLogo from '../assets/vue.svg'
const count = ref(0)
</script>
<template>
<section id="center">
<div class="hero">
<img :src="heroImg" class="base" width="170" height="179" alt="" />
<img :src="vueLogo" class="framework" alt="Vue logo" />
<img :src="viteLogo" class="vite" alt="Vite logo" />
</div>
<div>
<h1>Get started</h1>
<p>Edit <code>src/App.vue</code> and save to test <code>HMR</code></p>
</div>
<button type="button" class="counter" @click="count++">
Count is {{ count }}
</button>
</section>
<div class="ticks"></div>
<section id="next-steps">
<div id="docs">
<svg class="icon" role="presentation" aria-hidden="true">
<use href="/icons.svg#documentation-icon"></use>
</svg>
<h2>Documentation</h2>
<p>Your questions, answered</p>
<ul>
<li>
<a href="https://vite.dev/" target="_blank">
<img class="logo" :src="viteLogo" alt="" />
Explore Vite
</a>
</li>
<li>
<a href="https://vuejs.org/" target="_blank">
<img class="button-icon" :src="vueLogo" alt="" />
Learn more
</a>
</li>
</ul>
</div>
<div id="social">
<svg class="icon" role="presentation" aria-hidden="true">
<use href="/icons.svg#social-icon"></use>
</svg>
<h2>Connect with us</h2>
<p>Join the Vite community</p>
<ul>
<li>
<a href="https://github.com/vitejs/vite" target="_blank">
<svg class="button-icon" role="presentation" aria-hidden="true">
<use href="/icons.svg#github-icon"></use>
</svg>
GitHub
</a>
</li>
<li>
<a href="https://chat.vite.dev/" target="_blank">
<svg class="button-icon" role="presentation" aria-hidden="true">
<use href="/icons.svg#discord-icon"></use>
</svg>
Discord
</a>
</li>
<li>
<a href="https://x.com/vite_js" target="_blank">
<svg class="button-icon" role="presentation" aria-hidden="true">
<use href="/icons.svg#x-icon"></use>
</svg>
X.com
</a>
</li>
<li>
<a href="https://bsky.app/profile/vite.dev" target="_blank">
<svg class="button-icon" role="presentation" aria-hidden="true">
<use href="/icons.svg#bluesky-icon"></use>
</svg>
Bluesky
</a>
</li>
</ul>
</div>
</section>
<div class="ticks"></div>
<section id="spacer"></section>
</template>
+344
View File
@@ -0,0 +1,344 @@
<script setup lang="ts">
import { computed, onMounted, ref } from "vue";
import { invoke } from "@tauri-apps/api/core";
interface Pool {
name: string;
credentialType: string;
projects: string[];
}
const pools = ref<Pool[]>([]);
const error = ref("");
const busy = ref(false);
type Mode = "oauth" | "apikey";
const dialog = ref<{ mode: Mode; editing: boolean } | null>(null);
const dName = ref("");
const dKey = ref("");
const dialogTitle = computed(() => {
if (!dialog.value) return "";
if (dialog.value.mode === "oauth") return "Neuen oAuth-Pool anlegen";
if (dialog.value.editing) return `API-Key ändern ${dName.value}`;
return "Neuen API-Key-Pool anlegen";
});
function openNew(mode: Mode) {
dName.value = "";
dKey.value = "";
error.value = "";
dialog.value = { mode, editing: false };
}
function openEditKey(pool: string) {
dName.value = pool;
dKey.value = "";
error.value = "";
dialog.value = { mode: "apikey", editing: true };
}
function closeDialog() {
if (busy.value) return;
dialog.value = null;
}
async function refresh() {
try {
pools.value = await invoke<Pool[]>("list_pools");
error.value = "";
} catch (e) {
error.value = String(e);
}
}
async function submit() {
const d = dialog.value;
if (!d) return;
busy.value = true;
error.value = "";
try {
if (d.mode === "oauth") {
await invoke("create_oauth_pool", { name: dName.value });
} else if (d.editing) {
await invoke("set_apikey", { pool: dName.value, key: dKey.value });
} else {
await invoke("create_apikey_pool", { name: dName.value, key: dKey.value });
}
dialog.value = null;
await refresh();
} catch (e) {
error.value = String(e);
} finally {
busy.value = false;
}
}
const deleteName = ref<string | null>(null);
function askDelete(pool: string) {
error.value = "";
deleteName.value = pool;
}
async function confirmDelete() {
const name = deleteName.value;
if (!name) return;
busy.value = true;
error.value = "";
try {
await invoke("delete_pool", { name });
deleteName.value = null;
await refresh();
} catch (e) {
error.value = String(e);
} finally {
busy.value = false;
}
}
async function relogin(pool: string) {
busy.value = true;
error.value = "";
try {
await invoke("oauth_login", { pool });
await refresh();
} catch (e) {
error.value = String(e);
} finally {
busy.value = false;
}
}
async function renew(pool: string) {
busy.value = true;
error.value = "";
try {
await invoke("oauth_refresh", { pool });
} catch (e) {
error.value = String(e);
} finally {
busy.value = false;
}
}
onMounted(refresh);
</script>
<template>
<div class="toolbar">
<button class="primary" :disabled="busy" @click="openNew('oauth')">
+ oAuth
</button>
<button class="primary" :disabled="busy" @click="openNew('apikey')">
+ apiKey
</button>
</div>
<p v-if="error" class="error">{{ error }}</p>
<table v-if="pools.length">
<thead>
<tr>
<th>Pool</th>
<th>Typ</th>
<th class="actions-col">Aktionen</th>
</tr>
</thead>
<tbody>
<tr v-for="p in pools" :key="p.name">
<td><strong>{{ p.name }}</strong></td>
<td>
<span class="badge" :class="p.credentialType">{{ p.credentialType }}</span>
</td>
<td class="actions-col">
<template v-if="p.credentialType === 'oauth'">
<button :disabled="busy" @click="relogin(p.name)">Neu anmelden</button>
<button :disabled="busy" @click="renew(p.name)">Token erneuern</button>
</template>
<template v-else>
<button :disabled="busy" @click="openEditKey(p.name)">Key ändern</button>
</template>
<button
v-if="!p.projects.length"
class="danger"
:disabled="busy"
@click="askDelete(p.name)"
>
Löschen
</button>
<span v-else class="assigned" :title="p.projects.join(', ')">
zugeordnet: {{ p.projects.join(", ") }}
</span>
</td>
</tr>
</tbody>
</table>
<p v-else class="empty">Noch keine Pools angelegt.</p>
<div v-if="dialog" class="modal-backdrop" @click.self="closeDialog">
<form class="modal" @submit.prevent="submit">
<h2>{{ dialogTitle }}</h2>
<label v-if="!dialog.editing">
<span>Name</span>
<input v-model="dName" placeholder="z. B. Mx9Privat" autofocus required />
</label>
<label v-if="dialog.mode === 'apikey'">
<span>API-Key</span>
<input
v-model="dKey"
type="password"
placeholder="sk-ant-api03-…"
:autofocus="dialog.editing"
required
/>
</label>
<p v-if="dialog.mode === 'oauth'" class="hint">
Nach Login starten öffnet sich der Browser zur Anmeldung gegen dein Abo.
</p>
<p v-if="busy && dialog.mode === 'oauth'" class="hint busy">
Warte auf die Anmeldung im Browser
</p>
<div class="modal-actions">
<button type="button" :disabled="busy" @click="closeDialog">Abbrechen</button>
<button type="submit" class="primary" :disabled="busy">
{{ dialog.mode === "oauth" ? "Login starten" : "Speichern" }}
</button>
</div>
</form>
</div>
<div v-if="deleteName" class="modal-backdrop" @click.self="deleteName = null">
<div class="modal">
<h2>Pool löschen</h2>
<p class="hint">
Pool <strong>{{ deleteName }}</strong> und seine Credential-Datei werden
gelöscht. Das lässt sich nicht rückgängig machen.
</p>
<div class="modal-actions">
<button type="button" :disabled="busy" @click="deleteName = null">
Abbrechen
</button>
<button class="danger" :disabled="busy" @click="confirmDelete">
Löschen
</button>
</div>
</div>
</div>
</template>
<style scoped>
.toolbar {
display: flex;
gap: 0.5rem;
margin-bottom: 1.25rem;
}
.primary {
background: #4a4af0;
border-color: #4a4af0;
color: #fff;
}
.primary:hover:not(:disabled) {
background: #5b5bf5;
}
button:disabled {
opacity: 0.5;
cursor: default;
}
.actions-col {
text-align: right;
white-space: nowrap;
}
.actions-col button {
margin-left: 0.4rem;
}
.danger {
color: #ff6b6b;
border-color: #ff6b6b55;
}
.danger:hover:not(:disabled) {
background: #ff6b6b22;
}
.assigned {
color: #888;
font-size: 0.8rem;
}
.badge {
display: inline-block;
padding: 0.1rem 0.5rem;
border-radius: 999px;
font-size: 0.75rem;
border: 1px solid #444;
color: #cfcfd6;
}
.badge.oauth {
border-color: #3ecf6a55;
color: #3ecf6a;
}
.badge.apikey {
border-color: #f0a84a55;
color: #f0a84a;
}
.empty {
color: #888;
}
.modal-backdrop {
position: fixed;
inset: 0;
background: rgba(0, 0, 0, 0.55);
display: flex;
align-items: center;
justify-content: center;
z-index: 10;
}
.modal {
display: flex;
flex-direction: column;
gap: 0.9rem;
background: #23232a;
border: 1px solid #3a3a44;
border-radius: 12px;
padding: 1.5rem;
min-width: 24rem;
box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}
.modal h2 {
font-size: 1rem;
margin: 0;
}
.modal label {
display: flex;
flex-direction: column;
gap: 0.3rem;
}
.modal label span {
font-size: 0.8rem;
color: #999;
}
.modal input {
width: 100%;
}
.hint {
margin: 0;
font-size: 0.8rem;
color: #999;
}
.hint.busy {
color: #4a9af5;
}
.modal-actions {
display: flex;
gap: 0.5rem;
justify-content: flex-end;
margin-top: 0.25rem;
}
</style>
+148
View File
@@ -0,0 +1,148 @@
<script setup lang="ts">
import { onMounted, onUnmounted, ref } from "vue";
import { invoke } from "@tauri-apps/api/core";
interface Project {
name: string;
path: string;
pool: string | null;
running: boolean;
}
interface Pool {
name: string;
credentialFile: string;
credentialType: string;
}
const projects = ref<Project[]>([]);
const pools = ref<Pool[]>([]);
const error = ref("");
async function refresh() {
try {
projects.value = await invoke<Project[]>("list_projects");
pools.value = await invoke<Pool[]>("list_pools");
error.value = "";
} catch (e) {
error.value = String(e);
}
}
async function start(project: Project) {
try {
await invoke("start_project", { project: project.name });
await refresh();
} catch (e) {
error.value = String(e);
}
}
interface PendingRestart {
name: string;
from: string | null;
to: string;
}
const pending = ref<PendingRestart | null>(null);
const restarting = ref(false);
async function assign(project: Project, event: Event) {
const pool = (event.target as HTMLSelectElement).value;
const from = project.pool;
try {
await invoke("assign_pool", { project: project.name, pool });
if (project.running && pool !== from) {
pending.value = { name: project.name, from, to: pool };
}
await refresh();
} catch (e) {
error.value = String(e);
}
}
async function restartNow() {
const p = pending.value!;
restarting.value = true;
try {
await invoke("restart_project", { project: p.name });
pending.value = null;
await refresh();
} catch (e) {
error.value = String(e);
pending.value = null;
}
restarting.value = false;
}
let timer: number;
onMounted(() => {
refresh();
timer = window.setInterval(refresh, 3000);
});
onUnmounted(() => window.clearInterval(timer));
</script>
<template>
<p v-if="error" class="error">{{ error }}</p>
<table>
<thead>
<tr>
<th></th>
<th>Projekt</th>
<th>Pool</th>
<th></th>
</tr>
</thead>
<tbody>
<tr v-for="p in projects" :key="p.name">
<td>
<span class="dot" :class="{ on: p.running }"></span>
</td>
<td>
<strong>{{ p.name }}</strong>
<small>{{ p.path }}</small>
</td>
<td>
<select :value="p.pool ?? ''" @change="assign(p, $event)">
<option value="" disabled> kein Pool </option>
<option v-for="pool in pools" :key="pool.name" :value="pool.name">
{{ pool.name }}
</option>
</select>
</td>
<td>
<button @click="start(p)">
{{ p.running ? "Aktivieren" : "Starten" }}
</button>
</td>
</tr>
</tbody>
</table>
<div v-if="pending" class="overlay">
<div class="dialog">
<h3>{{ pending.name }} läuft noch</h3>
<p>
Der Pool-Wechsel ist gespeichert. Die laufende Session arbeitet aber
weiter im alten Pool der neue gilt erst ab dem nächsten Start.
</p>
<div class="pools">
<span class="chip">{{ pending.from ?? "kein Pool" }}</span>
<span class="arrow"></span>
<span class="chip new">{{ pending.to }}</span>
</div>
<p class="hint">
Der Neustart beendet die laufende Session. Der automatische
commit+push von claude-sync nach Sessionende entfällt dabei
Ghostty fragt bei laufendem Prozess vor dem Beenden noch einmal nach.
</p>
<div class="actions">
<button @click="pending = null">Weiterlaufen lassen</button>
<button class="primary" :disabled="restarting" @click="restartNow">
{{ restarting ? "Starte neu " : "Jetzt neu starten" }}
</button>
</div>
</div>
</div>
</template>