feat: export posts and sources

This commit is contained in:
2026-07-19 05:36:52 +08:00
parent 05ddafb0d9
commit 591981b7c8
8 changed files with 50 additions and 7 deletions
+2 -1
View File
@@ -2,7 +2,7 @@
import { useState } from "react";
export function WebhookControl({ sourceId, configured }: { sourceId: number; configured: boolean }) {
export function WebhookControl({ sourceId, configured, automatic = false }: { sourceId: number; configured: boolean; automatic?: boolean }) {
const [url, setUrl] = useState(""); const [error, setError] = useState(""); const [busy, setBusy] = useState(false);
async function generate() {
setBusy(true); setError("");
@@ -13,6 +13,7 @@ export function WebhookControl({ sourceId, configured }: { sourceId: number; con
finally { setBusy(false); }
}
async function copy() { if (url) await navigator.clipboard.writeText(url); }
if (automatic) return <div className="webhook-control"><p className="meta">Webhook Memos </p></div>;
return <div className="webhook-control"><p className="meta">Webhook{configured ? "已設定" : "尚未設定"}</p>
{url ? <><label className="sr-only" htmlFor={`webhook-${sourceId}`}>Webhook URL</label><input id={`webhook-${sourceId}`} readOnly value={url} onFocus={(event) => event.currentTarget.select()} /><div className="row"><button type="button" onClick={copy}> URL</button><button type="button" className="danger" onClick={generate} disabled={busy}></button></div><p className="meta"> Memos</p></> : <button type="button" onClick={generate} disabled={busy}>{busy ? "產生中…" : configured ? "重新產生 webhook URL" : "產生 webhook URL"}</button>}
{error && <p className="error">{error}</p>}