feat(ui): migrate to @recloudstudio/ui, add theme toggle and polish console UX

This commit is contained in:
RhenCloud committed 2026-10-03 22:54:32 +08:00
1 parent a899e16604
commit fbbff669a3
45 files changed
+1489 -1343

No files matched your search

+40 -168
View File
@@ -1,6 +1,5 @@
<script setup lang="ts">
import type { DeliveryMetrics, Group, Route, SendRecord } from "~/types";
import { collectEvents } from "~/composables/useFilterNode";
import type { DeliveryMetrics, Group, SendRecord } from "~/types";
const props = defineProps<{
groups: Group[];
@@ -14,39 +13,6 @@ const props = defineProps<{
const { t } = useI18n();
const router = useRouter();
const routesByGroup = ref<Record<string, Route[]>>({});
const routesLoading = ref(false);
const allRoutes = computed(() => {
const out: Array<Route & { group?: Group }> = [];
for (const g of props.groups) {
for (const r of routesByGroup.value[g.id] ?? []) out.push({ ...r, group: g });
}
return out;
});
async function loadRoutes() {
if (!props.groups.length) return;
routesLoading.value = true;
const entries = await Promise.all(
props.groups.map(async (g) => {
try {
const data = await apiFetch<{ routes?: Route[] }>(
`/admin/api/groups/${encodeURIComponent(g.id)}/routes`,
);
return [g.id, data.routes ?? []] as const;
} catch {
return [g.id, []] as const;
}
}),
);
routesByGroup.value = Object.fromEntries(entries);
routesLoading.value = false;
}
onMounted(loadRoutes);
watch(() => props.groups, loadRoutes);
const kpis = computed(() => {
const m = props.metrics;
const total = m?.total ?? 0;
@@ -102,24 +68,13 @@ function fmtTime(ts: number): string {
if (d < 86_400_000) return `${Math.round(d / 3_600_000)}h`;
return `${Math.round(d / 86_400_000)}d`;
}
function platformLabel(p?: string): string {
if (p === "telegram") return "TG";
if (p === "feishu") return "FS";
if (p === "discord") return "DC";
return "—";
}
function routeEvents(r: Route): string[] {
return collectEvents(r.ast ?? { all: r.filters });
}
</script>
<template>
<div class="space-y-6">
<!-- KPI cards -->
<section class="grid grid-cols-2 gap-4 xl:grid-cols-4">
<div v-for="k in kpis" :key="k.label" class="rounded border border-border bg-surface p-5">
<RcCard v-for="k in kpis" :key="k.label" variant="outline" padding="md" class="p-5">
<div class="text-[11px] font-bold uppercase tracking-[1.5px] text-faint">{{ k.label }}</div>
<div
class="mt-2 text-2xl font-extrabold tracking-tight [font-variant-numeric:tabular-nums]"
@@ -127,132 +82,49 @@ function routeEvents(r: Route): string[] {
>
{{ metricsLoading ? "—" : k.value }}
</div>
</div>
</RcCard>
</section>
<div class="grid grid-cols-1 gap-6 xl:grid-cols-3">
<!-- Routes overview -->
<section class="rounded border border-border bg-surface xl:col-span-2">
<div class="flex items-center justify-between border-b border-border px-5 py-4">
<h2 class="text-sm font-bold tracking-tight">{{ t("overview.routes") }}</h2>
<span class="text-xs text-faint [font-variant-numeric:tabular-nums]">{{
allRoutes.length
}}</span>
</div>
<!-- Recent send logs -->
<RcCard variant="outline" padding="none">
<div class="flex items-center justify-between border-b border-border px-5 py-4">
<h2 class="text-sm font-bold tracking-tight">{{ t("overview.recent") }}</h2>
<RcButton variant="link" size="xs" @click="router.replace('/admin/logs')">
{{ t("overview.viewAll") }}
</RcButton>
</div>
<div v-if="routesLoading" class="px-5 py-12 text-center text-faint">
{{ t("status.loading") }}
</div>
<div v-else-if="!allRoutes.length" class="px-5 py-12 text-center text-muted">
<p class="mb-3">{{ t("routes.emptyGroup") }}</p>
<button class="btn btn-accent btn-sm" @click="router.replace('/admin/groups')">
{{ t("routes.createFirst") }}
</button>
</div>
<div v-if="logsLoading" class="flex justify-center px-5 py-12 text-faint">
<RcSpinner size="sm" />
</div>
<RcEmptyState v-else-if="!logs.length" :title="t('metrics.empty')" class="px-5 py-12" />
<div v-else class="overflow-x-auto">
<table class="w-full min-w-[560px] text-left text-[13px]">
<thead>
<tr
class="border-b border-border text-[10px] font-bold uppercase tracking-[1.2px] text-faint"
<ul v-else class="divide-y divide-border">
<li
v-for="log in logs.slice(0, 10)"
:key="log.id ?? `${log.ts}-${log.target}`"
class="flex items-center gap-3 px-5 py-3"
>
<span class="dot" :class="log.ok ? 'ok' : 'bad'" />
<div class="min-w-0 flex-1">
<div class="flex items-center gap-2">
<RcBadge
variant="soft"
size="xs"
class="uppercase tracking-wide"
:class="eventBadge(log.event)"
>
<th class="px-5 py-2.5">Route</th>
<th class="px-3 py-2.5">Group</th>
<th class="px-3 py-2.5">Events</th>
<th class="px-3 py-2.5">Targets</th>
<th class="px-5 py-2.5 text-right">State</th>
</tr>
</thead>
<tbody>
<tr
v-for="r in allRoutes.slice(0, 8)"
:key="r.id"
class="cursor-pointer border-b border-border transition-colors last:border-0 hover:bg-surface-2"
@click="router.replace('/admin/groups')"
>
<td class="px-5 py-3">
<div class="font-semibold text-text">{{ r.name || r.id }}</div>
<div class="font-mono text-[11px] text-faint">{{ r.id }}</div>
</td>
<td class="px-3 py-3 text-muted">{{ r.group?.name || "—" }}</td>
<td class="px-3 py-3">
<div class="flex flex-wrap gap-1">
<span
v-for="ev in routeEvents(r).slice(0, 2)"
:key="ev"
class="rounded-full bg-accent-dim px-2 py-0.5 text-[10px] font-bold uppercase tracking-wide text-accent"
>
{{ ev }}
</span>
<span v-if="routeEvents(r).length > 2" class="text-[10px] text-faint">
+{{ routeEvents(r).length - 2 }}
</span>
</div>
</td>
<td class="px-3 py-3">
<div class="flex items-center gap-1">
<span
v-for="tg in r.targets.slice(0, 3)"
:key="tg.channelId ?? tg.chatId ?? platformLabel(tg.platform)"
class="rounded border border-border bg-surface-2 px-1.5 py-0.5 font-mono text-[10px] text-muted"
>
{{ platformLabel(tg.platform) }}
</span>
<span v-if="r.targets.length > 3" class="text-[10px] text-faint">
+{{ r.targets.length - 3 }}
</span>
</div>
</td>
<td class="px-5 py-3 text-right">
<span class="dot" :class="r.enabled ? 'ok' : 'bad'" />
</td>
</tr>
</tbody>
</table>
</div>
</section>
<!-- Recent send logs -->
<section class="rounded border border-border bg-surface">
<div class="flex items-center justify-between border-b border-border px-5 py-4">
<h2 class="text-sm font-bold tracking-tight">{{ t("overview.recent") }}</h2>
<button class="text-xs font-semibold text-accent" @click="router.replace('/admin/logs')">
{{ t("overview.viewAll") }}
</button>
</div>
<div v-if="logsLoading" class="px-5 py-12 text-center text-faint">
{{ t("status.loading") }}
</div>
<div v-else-if="!logs.length" class="px-5 py-12 text-center text-faint">
{{ t("metrics.empty") }}
</div>
<ul v-else class="divide-y divide-border">
<li
v-for="log in logs.slice(0, 10)"
:key="log.id ?? `${log.ts}-${log.target}`"
class="flex items-center gap-3 px-5 py-3"
>
<span class="dot" :class="log.ok ? 'ok' : 'bad'" />
<div class="min-w-0 flex-1">
<div class="flex items-center gap-2">
<span
class="rounded-full px-2 py-0.5 text-[10px] font-bold uppercase tracking-wide"
:class="eventBadge(log.event)"
>
{{ log.event }}
</span>
<span class="truncate text-[12px] text-muted">{{ log.repo || log.target }}</span>
</div>
<div class="mt-0.5 truncate font-mono text-[11px] text-faint">{{ log.target }}</div>
{{ log.event }}
</RcBadge>
<span class="truncate text-[12px] text-muted">{{ log.repo || log.target }}</span>
</div>
<span class="text-[11px] font-medium text-faint [font-variant-numeric:tabular-nums]">
{{ fmtTime(log.ts) }}
</span>
</li>
</ul>
</section>
</div>
<div class="mt-0.5 truncate font-mono text-[11px] text-faint">{{ log.target }}</div>
</div>
<span class="text-[11px] font-medium text-faint [font-variant-numeric:tabular-nums]">
{{ fmtTime(log.ts) }}
</span>
</li>
</ul>
</RcCard>
</div>
</template>
+30
View File
@@ -0,0 +1,30 @@
<template>
<img
src="/logo.svg"
:width="size"
:height="size"
alt="WebHooker"
class="app-logo"
:style="{ width: `${size}px`, height: `${size}px` }"
/>
</template>
<script setup lang="ts">
withDefaults(
defineProps<{
size?: number;
}>(),
{
size: 32,
},
);
</script>
<style scoped>
.app-logo {
display: inline-block;
flex-shrink: 0;
vertical-align: middle;
border-radius: 22%;
}
</style>
+23 -4
View File
@@ -1,13 +1,32 @@
<template>
<div class="toasts">
<div class="recloud-toasts" aria-live="polite" aria-atomic="true">
<TransitionGroup name="toast">
<div v-for="t in toasts" :key="t.id" class="toast" :class="t.kind" @click="dismiss(t.id)">
{{ t.msg }}
</div>
<RcCard
v-for="t in toasts"
:key="t.id"
:variant="t.kind === 'bad' ? 'soft' : 'outline'"
padding="sm"
class="recloud-toast"
:class="t.kind"
role="status"
@click="dismiss(t.id)"
>
<component :is="t.kind === 'bad' ? CircleAlert : CircleCheck" :size="18" />
<span>{{ t.msg }}</span>
<X :size="15" class="toast-close" />
</RcCard>
</TransitionGroup>
</div>
</template>
<script setup lang="ts">
import { CircleAlert, CircleCheck, X } from "lucide-vue-next";
const { toasts, dismiss } = useToasts();
</script>
<style scoped>
.recloud-toasts { position: fixed; z-index: 70; right: 1rem; bottom: 1rem; display: grid; width: min(calc(100vw - 2rem), 390px); gap: .65rem; }
.recloud-toast { display: flex; align-items: center; gap: .7rem; cursor: pointer; box-shadow: 0 16px 38px rgb(var(--wh-text) / .14); } .recloud-toast :deep(.rc-card-body) { display: flex; width: 100%; align-items: center; gap: .7rem; padding: .1rem; } .recloud-toast :deep(svg) { flex: none; color: rgb(var(--wh-ok)); } .recloud-toast.bad :deep(svg) { color: rgb(var(--wh-bad)); } .recloud-toast span { flex: 1; font-size: .8rem; font-weight: 700; } .recloud-toast .toast-close { color: rgb(var(--wh-faint)); }
.toast-enter-active, .toast-leave-active { transition: opacity 180ms ease, transform 180ms ease; } .toast-enter-from, .toast-leave-to { opacity: 0; transform: translateX(16px); }
</style>
+20 -15
View File
@@ -4,25 +4,25 @@
<span class="kpi-label">{{ t("audit.title") }}</span>
<div class="log-filters">
<label class="filter-label">{{ t("audit.filterGroup") }}</label>
<select
<RcSelect
class="filter-select"
:value="selectedGroupId"
:model-value="selectedGroupId || 'all'"
:options="groupOptions"
:disabled="loading"
@change="onGroupFilter"
>
<option value="">{{ t("audit.allGroups") }}</option>
<option v-for="g in groups" :key="g.id" :value="g.id">
{{ g.name || g.id }}
</option>
</select>
@update:model-value="onGroupFilter"
/>
</div>
<button class="btn btn-ghost btn-sm" :disabled="loading" @click="refresh">
<RcButton variant="ghost" size="sm" :disabled="loading" @click="refresh">
{{ t("audit.refresh") }}
</button>
</RcButton>
</div>
<p v-if="error" class="err">{{ error }}</p>
<p v-else-if="!loading && !entries.length" class="empty-log">{{ t("audit.empty") }}</p>
<RcEmptyState
v-else-if="!loading && !entries.length"
:title="t('audit.empty')"
class="empty-log"
/>
<div class="log-list">
<article v-for="e in entries" :key="e.id ?? e.ts" class="log-entry">
@@ -57,7 +57,7 @@ import type { AuditEntry, Group } from "~/types";
const { t } = useI18n();
defineProps<{
const props = defineProps<{
entries: AuditEntry[];
loading: boolean;
error: string;
@@ -74,8 +74,13 @@ function refresh(): void {
emit("refresh");
}
function onGroupFilter(e: Event): void {
emit("update:selectedGroupId", (e.target as HTMLSelectElement).value);
const groupOptions = computed(() => [
{ label: t("audit.allGroups"), value: "all" },
...props.groups.map((g) => ({ label: g.name || g.id, value: g.id })),
]);
function onGroupFilter(value: string): void {
emit("update:selectedGroupId", value === "all" ? "" : value);
emit("filter");
}
</script>
+108 -155
View File
@@ -1,122 +1,65 @@
<template>
<div class="flex min-h-screen bg-bg text-text">
<!-- Sidebar -->
<aside
class="sticky top-0 z-30 flex h-screen w-[240px] flex-shrink-0 flex-col border-r border-border bg-surface max-lg:hidden"
>
<div class="flex items-center gap-3 px-5 py-5">
<div class="brand-mark" aria-hidden="true">
<svg
viewBox="0 0 64 64"
class="h-[22px] w-[22px]"
fill="none"
stroke="currentColor"
stroke-width="6"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="M41 23 V35.5 A10.5 10.5 0 0 1 20 35.5 L28 25.5" />
<circle cx="41" cy="18" r="4.5" fill="currentColor" stroke="none" />
</svg>
</div>
<div>
<div class="text-sm font-extrabold tracking-tight">WebHooker</div>
<div class="text-[10px] font-semibold uppercase tracking-[2px] text-faint">
{{ t("app.tagline") }}
</div>
</div>
</div>
<nav class="flex-1 space-y-0.5 px-3">
<div class="console-shell">
<aside class="console-sidebar">
<NuxtLink class="console-brand" to="/">
<AppLogo :size="32" />
<span><strong>WebHooker</strong><small>{{ t("app.tagline") }}</small></span>
</NuxtLink>
<p class="console-nav-label">{{ t("app.tagline") }}</p>
<nav class="console-nav">
<button
v-for="n in nav"
:key="n.id"
class="flex w-full items-center gap-3 rounded-[8px] px-3 py-2 text-[13px] font-semibold transition-colors"
:class="
n.id === activeNav
? 'bg-accent-dim text-accent'
: 'text-muted hover:bg-surface-2 hover:text-text'
"
class="console-nav-item"
:class="{ active: n.id === activeNav }"
@click="switchView(n.id)"
>
<span
class="h-1.5 w-1.5 rounded-full"
:class="n.id === activeNav ? 'bg-accent' : 'bg-border-strong'"
/>
<component :is="navIcon(n.id)" :size="17" :stroke-width="1.8" />
{{ n.label }}
</button>
</nav>
<div class="border-t border-border px-3 py-4">
<a
class="block rounded-[8px] px-3 py-2 text-[13px] font-semibold text-muted transition-colors hover:bg-surface-2"
href="/admin/logout"
>
{{ t("app.signOut") }}
</a>
<div class="console-sidebar-footer">
<a href="/admin/logout"><LogOut :size="16" />{{ t("app.signOut") }}</a>
</div>
</aside>
<!-- Main column -->
<div class="flex min-w-0 flex-1 flex-col">
<header
class="sticky top-0 z-20 flex items-center justify-between gap-4 border-b border-border px-6 py-3"
style="background: var(--header-bg); backdrop-filter: blur(12px)"
>
<div class="console-main">
<header class="console-topbar">
<div>
<h1 class="text-[15px] font-extrabold tracking-tight">{{ pageTitle }}</h1>
<p v-if="needLogin" class="text-[11px] text-faint">{{ t("login.title") }}</p>
<p v-else class="text-[11px] text-faint">
{{ loadingAny ? t("status.loading") : t("status.connected") }}
</p>
<p class="console-kicker">WebHooker / {{ activeNav }}</p>
<h1>{{ pageTitle }}</h1>
</div>
<div class="flex items-center gap-2">
<button v-if="view === 'overview'" class="btn btn-ghost btn-sm" @click="refreshOverview">
{{ t("metrics.refresh") }}
</button>
<button class="btn btn-ghost btn-sm" @click="toggle">{{ t("app.langToggle") }}</button>
<button
<div class="console-actions">
<RcBadge v-if="!needLogin && loadingAny" variant="soft" size="sm" dot class="console-status">
{{ t("status.loading") }}
</RcBadge>
<RcButton v-if="view === 'overview'" variant="ghost" size="sm" @click="refreshOverview"><RefreshCw :size="15" />{{ t("metrics.refresh") }}</RcButton>
<ThemeToggle />
<RcButton variant="ghost" size="sm" @click="toggle"><Languages :size="15" />{{ t("app.langToggle") }}</RcButton>
<RcButton
v-if="!needLogin && selectedGroup && canEditRoutes(selectedGroup.id)"
class="btn btn-accent btn-sm"
@click="openNew"
>
{{ t("app.newRoute") }}
</button>
<button
><Plus :size="16" />{{ t("app.newRoute") }}</RcButton>
<RcButton
v-if="!needLogin && !selectedGroup && view === 'groups' && isSuper"
class="btn btn-accent btn-sm"
@click="openNewGroup"
>
{{ t("app.newGroup") }}
</button>
><Plus :size="16" />{{ t("app.newGroup") }}</RcButton>
</div>
</header>
<!-- Mobile nav -->
<nav class="flex gap-1 overflow-x-auto border-b border-border px-4 py-2 lg:hidden">
<button
v-for="n in nav"
:key="n.id"
class="whitespace-nowrap rounded-[7px] px-3 py-1.5 text-[13px] font-semibold transition-colors"
:class="n.id === activeNav ? 'bg-accent-dim text-accent' : 'text-muted'"
@click="switchView(n.id)"
>
{{ n.label }}
</button>
</nav>
<div class="console-mobile-nav"><RcTabs :model-value="activeNav" :items="mobileNav" @update:model-value="switchView($event as View)" /></div>
<main class="mx-auto w-full max-w-[1180px] px-6 pb-24 pt-6 max-sm:px-4">
<div v-if="needLogin" class="login">
<div class="login-card">
<main class="console-content">
<div v-if="needLogin" class="console-login">
<RcCard variant="outline" padding="lg" class="console-login-card">
<template #header><LockKeyhole :size="24" /></template>
<h2>{{ t("login.title") }}</h2>
<p v-if="forbidden">{{ t("login.forbidden") }}</p>
<p v-else>{{ t("login.prompt") }}</p>
<a class="btn btn-accent btn-lg" href="/admin/login">{{ t("login.button") }}</a>
</div>
<p>{{ forbidden ? t("login.forbidden") : t("login.prompt") }}</p>
<a href="/admin/login"><RcButton size="lg"><LogIn :size="17" />{{ t("login.button") }}</RcButton></a>
</RcCard>
</div>
<template v-else>
<!-- Overview dashboard -->
<AdminHome
v-if="view === 'overview'"
:key="refreshKey"
@@ -128,22 +71,13 @@
:metrics-loading="metricsLoading"
/>
<!-- Group detail view -->
<template v-else-if="selectedGroup">
<section class="toolbar">
<div class="crumbs">
<button class="btn btn-ghost btn-sm" @click="exitGroup">
{{ t("group.back") }}
</button>
<span class="kpi-label">{{
t("group.routesIn", { name: selectedGroup.name })
}}</span>
<span class="kpi">{{ groupRoutes.length }}</span>
</div>
<div class="status">
<span class="dot" :class="groupRoutesLoading ? '' : 'ok'"></span>
<span>{{ groupRoutesLoading ? t("status.loading") : t("status.connected") }}</span>
<section class="console-context-bar">
<div>
<RcButton variant="ghost" size="sm" @click="exitGroup"><ArrowLeft :size="15" />{{ t("group.back") }}</RcButton>
<p>{{ t("group.routesIn", { name: selectedGroup.name }) }}</p>
</div>
<RcBadge :variant="groupRoutesLoading ? 'soft' : 'success'" size="sm" dot>{{ groupRoutes.length }}</RcBadge>
</section>
<p v-if="groupRoutesError" class="err">{{ groupRoutesError }}</p>
@@ -164,15 +98,10 @@
/>
</section>
<section v-if="!groupRoutesLoading && !groupRoutes.length" class="empty">
<p>{{ t("routes.emptyGroup") }}</p>
<button
v-if="canEditRoutes(selectedGroup.id)"
class="btn btn-accent"
@click="openNew"
>
{{ t("routes.createFirst") }}
</button>
<section v-if="!groupRoutesLoading && !groupRoutes.length" class="console-empty">
<RcEmptyState :title="t('routes.emptyGroup')">
<RcButton v-if="canEditRoutes(selectedGroup.id)" @click="openNew"><Plus :size="16" />{{ t("routes.createFirst") }}</RcButton>
</RcEmptyState>
</section>
<MembersPanel
@@ -189,48 +118,39 @@
/>
</template>
<!-- Top-level views -->
<template v-else-if="view === 'groups'">
<section class="toolbar">
<div>
<span class="kpi-label">{{ t("kpi.groups") }}</span>
<span class="kpi">{{ groups.length }}</span>
</div>
<div class="status">
<span class="dot" :class="groupsLoading ? '' : 'ok'"></span>
<span>{{ groupsLoading ? t("status.loading") : t("status.connected") }}</span>
</div>
<section class="console-context-bar">
<div><p>{{ t("kpi.groups") }}</p><strong>{{ groups.length }}</strong></div>
<RcBadge v-if="groupsLoading" variant="soft" size="sm" dot>{{ t("status.loading") }}</RcBadge>
</section>
<p v-if="groupsError" class="err">{{ groupsError }}</p>
<section class="routes">
<article
<RcCard
v-for="(g, i) in groups"
:key="g.id"
class="card cursor-pointer"
variant="outline"
:hoverable="true"
padding="md"
class="console-group-card"
:style="{ animationDelay: i * 45 + 'ms' }"
@click="enterGroup(g)"
>
<div class="card-head">
<div class="card-title">
<template #header><div class="card-head"><div class="card-title">
<span class="route-name">{{ g.name || t("route.untitled") }}</span>
<span class="route-id">{{ g.id }}</span>
<span v-if="roleOf(g.id)" class="badge lang">{{
t("role.badge", { role: t("roles." + roleOf(g.id)) })
}}</span>
<RcBadge v-if="roleOf(g.id)" variant="brand" size="xs">{{ t("role.badge", { role: t("roles." + roleOf(g.id)) }) }}</RcBadge>
</div>
<div v-if="canEditGroup(g.id)" class="card-actions" @click.stop>
<button
class="icon-btn"
<RcButton
variant="ghost" size="icon"
:title="t('groupEditor.editTitle')"
@click="openEditGroup(g)"
>
✎
</button>
<button class="icon-btn danger" @click="onDeleteGroup(g)">✕</button>
><Pencil :size="15" /></RcButton>
<RcButton variant="ghost" color="error" size="icon" @click="onDeleteGroup(g)"><Trash2 :size="15" /></RcButton>
</div>
</div>
</div></template>
<div class="target">
<span
><b>{{ t("groups.members") }}</b
@@ -245,27 +165,17 @@
}}</code></span
>
</div>
<div class="group-open mt-2.5 text-right text-xs font-medium text-accent">
{{ t("groups.open") }}
</div>
</article>
<template #footer><span class="console-open"><ArrowRight :size="15" />{{ t("groups.open") }}</span></template>
</RcCard>
</section>
<section v-if="!groupsLoading && !groups.length" class="empty">
<p>{{ t("groups.empty") }}</p>
<button v-if="isSuper" class="btn btn-accent" @click="openNewGroup">
{{ t("groups.createFirst") }}
</button>
<section v-if="!groupsLoading && !groups.length" class="console-empty">
<RcEmptyState :title="t('groups.empty')"><RcButton v-if="isSuper" @click="openNewGroup"><Plus :size="16" />{{ t("groups.createFirst") }}</RcButton></RcEmptyState>
</section>
</template>
<template v-else-if="view === 'logs'">
<section class="toolbar">
<div class="status">
<span class="dot" :class="logsLoading ? '' : 'ok'"></span>
<span>{{ logsLoading ? t("status.loading") : t("status.connected") }}</span>
</div>
</section>
<section v-if="logsLoading" class="console-context-bar"><RcBadge variant="soft" size="sm" dot>{{ t("status.loading") }}</RcBadge></section>
<SendLogs
:logs="logs"
:loading="logsLoading"
@@ -328,6 +238,23 @@
</template>
<script setup lang="ts">
import {
Activity,
ArrowLeft,
ArrowRight,
ClipboardList,
Gauge,
Languages,
Layers3,
LockKeyhole,
LogIn,
LogOut,
Pencil,
Plus,
RefreshCw,
ShieldCheck,
Trash2,
} from "lucide-vue-next";
import type { Group, Route } from "~/types";
import { useAuditApi } from "~/composables/useAudit";
import WebhookPanel from "~/components/WebhookPanel.vue";
@@ -370,6 +297,19 @@ const nav = computed(() => [
{ id: "metrics" as View, label: t("tab.metrics"), path: "/admin/metrics" },
]);
const mobileNav = computed(() => nav.value.map(({ id, label }) => ({ value: id, label, icon: navIcon(id) })));
function navIcon(id: View) {
const icons = {
overview: Gauge,
groups: Layers3,
logs: Activity,
audit: ClipboardList,
metrics: ShieldCheck,
} satisfies Record<View, typeof Gauge>;
return icons[id];
}
const activeNav = computed<View>(() => view.value ?? "overview");
const pageTitle = computed(() => {
@@ -652,3 +592,16 @@ async function onDeleteGroup(group: Group): Promise<void> {
}
}
</script>
<style scoped>
.console-shell { display: grid; grid-template-columns: 264px minmax(0, 1fr); min-height: 100vh; background: rgb(var(--wh-bg)); color: rgb(var(--wh-text)); }
.console-sidebar { position: sticky; top: 0; display: flex; height: 100vh; flex-direction: column; border-right: 1px solid rgb(var(--wh-border)); background: linear-gradient(165deg, rgb(var(--wh-surface)), rgb(var(--wh-surface-2))); padding: 1.25rem .85rem; }
.console-brand { display: flex; align-items: center; gap: .7rem; padding: .45rem .55rem 1.75rem; color: rgb(var(--wh-text)); text-decoration: none; } .console-brand :deep(svg) { color: rgb(var(--wh-accent)); } .console-brand span { display: grid; gap: .1rem; } .console-brand strong { font-size: 1rem; letter-spacing: -.04em; } .console-brand small, .console-nav-label, .console-kicker { color: rgb(var(--wh-faint)); font-size: .62rem; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.console-nav-label { margin: 0 .65rem .45rem; } .console-nav { display: grid; gap: .2rem; } .console-nav-item { display: flex; align-items: center; gap: .7rem; width: 100%; border: 0; border-radius: .65rem; background: transparent; padding: .7rem; color: rgb(var(--wh-muted)); font: inherit; font-size: .82rem; font-weight: 700; text-align: left; transition: background-color 150ms ease, color 150ms ease; cursor: pointer; } .console-nav-item:hover { background: rgb(var(--wh-surface-2)); color: rgb(var(--wh-text)); } .console-nav-item.active { background: rgb(var(--wh-accent)); color: white; box-shadow: 0 8px 18px rgb(var(--wh-accent) / .2); }
.console-sidebar-footer { display: grid; gap: .9rem; margin-top: auto; padding: .9rem .55rem .25rem; border-top: 1px solid rgb(var(--wh-border)); } .console-sidebar-footer a { display: inline-flex; align-items: center; gap: .55rem; color: rgb(var(--wh-muted)); font-size: .8rem; font-weight: 700; text-decoration: none; } .console-sidebar-footer a:hover { color: rgb(var(--wh-bad)); }
.console-main { min-width: 0; } .console-topbar { position: sticky; top: 0; z-index: 20; display: flex; min-height: 76px; align-items: center; justify-content: space-between; gap: 1rem; border-bottom: 1px solid rgb(var(--wh-border)); background: color-mix(in srgb, rgb(var(--wh-bg)) 87%, transparent); padding: .8rem clamp(1rem, 3vw, 2.5rem); backdrop-filter: blur(18px); } .console-topbar h1 { margin: .1rem 0 0; font-size: 1.15rem; letter-spacing: -.035em; } .console-kicker { margin: 0; } .console-actions { display: flex; align-items: center; justify-content: flex-end; gap: .45rem; } .console-status { white-space: nowrap; }
.console-mobile-nav { display: none; } .console-content { width: min(100% - 2rem, 1240px); margin: 0 auto; padding: clamp(1.25rem, 3vw, 2.5rem) 0 5rem; } .console-login { display: grid; min-height: 62vh; place-items: center; } .console-login-card { width: min(100%, 430px); text-align: center; } .console-login-card :deep(.rc-card-header) { justify-content: center; color: rgb(var(--wh-accent)); } .console-login-card h2 { margin: .35rem 0 .65rem; font-size: 1.35rem; letter-spacing: -.035em; } .console-login-card p { margin: 0 0 1.4rem; color: rgb(var(--wh-muted)); }
.console-context-bar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; padding: .8rem 1rem; border: 1px solid rgb(var(--wh-border)); border-radius: .85rem; background: rgb(var(--wh-surface) / .6); } .console-context-bar > div { display: flex; align-items: center; gap: .8rem; } .console-context-bar p { margin: 0; color: rgb(var(--wh-muted)); font-size: .8rem; font-weight: 700; } .console-context-bar strong { font-size: 1.25rem; letter-spacing: -.04em; } .console-empty { padding: 4rem 1rem; } .console-group-card { cursor: pointer; } .console-open { display: inline-flex; align-items: center; gap: .35rem; color: rgb(var(--wh-accent)); font-size: .75rem; font-weight: 800; }
@media (max-width: 900px) { .console-shell { display: block; } .console-sidebar { display: none; } .console-mobile-nav { display: block; border-bottom: 1px solid rgb(var(--wh-border)); padding: .5rem 1rem; overflow-x: auto; } .console-mobile-nav :deep(.rc-tabs) { min-width: max-content; } }
@media (max-width: 620px) { .console-topbar { align-items: flex-start; flex-direction: column; } .console-actions { width: 100%; justify-content: flex-start; overflow-x: auto; padding-bottom: .05rem; } .console-status { display: none; } .console-content { width: min(100% - 1.25rem, 1240px); } }
</style>
+30 -29
View File
@@ -15,6 +15,9 @@ const emit = defineEmits<{ (e: "remove"): void }>();
const { t } = useI18n();
const NODE_KINDS = ["all", "any"] as const;
const filterTypeOptions = computed(() => FILTER_TYPES.map((value) => ({ label: t("filter." + value), value })));
const filterOpOptions = computed(() => FILTER_OPS.map((value) => ({ label: t("filterOp." + value), value })));
const nodeKindOptions = computed(() => NODE_KINDS.map((value) => ({ label: t("filterNode." + value), value })));
function addChild(kind: "leaf" | "all" | "any" | "not"): void {
props.node.children.push(blankNode(kind));
@@ -33,25 +36,22 @@ function unwrapNot(): void {
<template>
<div class="node-editor" :class="{ 'node-nested': depth > 0 }">
<div v-if="node.kind === 'leaf'" class="leaf-row">
<select v-model="node.leaf.type" class="node-select">
<option v-for="ft in FILTER_TYPES" :key="ft" :value="ft">{{ t("filter." + ft) }}</option>
</select>
<RcSelect v-model="node.leaf.type" class="node-select" :options="filterTypeOptions" />
<input
<RcInput
v-if="node.leaf.type === 'field'"
v-model="node.leaf.path"
class="input node-path"
:placeholder="t('routeEditor.pathPlaceholder')"
/>
<select
<RcSelect
v-if="node.leaf.type !== 'keyword'"
v-model="node.leaf.op"
class="node-select"
:options="filterOpOptions"
:title="t('routeEditor.op')"
>
<option v-for="op in FILTER_OPS" :key="op" :value="op">{{ t("filterOp." + op) }}</option>
</select>
/>
<TagInput
v-if="node.leaf.type === 'keyword' || node.leaf.op !== 'exists'"
@@ -60,46 +60,45 @@ function unwrapNot(): void {
:placeholder="t('routeEditor.valuesPlaceholder')"
/>
<label class="inline node-exclude" :title="t('routeEditor.not')">
<input v-model="node.leaf.exclude" type="checkbox" />
<span>{{ t("routeEditor.not") }}</span>
</label>
<RcCheckbox v-model="node.leaf.exclude" class="node-exclude" :label="t('routeEditor.not')" :title="t('routeEditor.not')" />
<button
<RcButton
v-if="deletable"
type="button"
variant="destructive"
size="icon"
class="icon-btn danger"
:title="t('routeEditor.remove')"
@click="emit('remove')"
>
✕
</button>
</RcButton>
</div>
<div v-else-if="node.kind === 'all' || node.kind === 'any'" class="node-group">
<div class="node-group-head">
<select v-model="node.kind" class="node-combo">
<option v-for="k in NODE_KINDS" :key="k" :value="k">{{ t("filterNode." + k) }}</option>
</select>
<RcSelect v-model="node.kind" class="node-combo" :options="nodeKindOptions" />
<div class="node-actions">
<button type="button" class="btn btn-ghost node-add" @click="addChild('leaf')">
<RcButton type="button" variant="ghost" size="xs" class="node-add" @click="addChild('leaf')">
+ {{ t("routeEditor.addLeaf") }}
</button>
<button type="button" class="btn btn-ghost node-add" @click="addChild('all')">
</RcButton>
<RcButton type="button" variant="ghost" size="xs" class="node-add" @click="addChild('all')">
+ {{ t("routeEditor.addGroup") }}
</button>
<button type="button" class="btn btn-ghost node-add" @click="addChild('not')">
</RcButton>
<RcButton type="button" variant="ghost" size="xs" class="node-add" @click="addChild('not')">
+ {{ t("routeEditor.addNot") }}
</button>
<button
</RcButton>
<RcButton
v-if="deletable"
type="button"
variant="destructive"
size="icon"
class="icon-btn danger"
:title="t('routeEditor.remove')"
@click="emit('remove')"
>
✕
</button>
</RcButton>
</div>
</div>
<div class="node-children">
@@ -119,18 +118,20 @@ function unwrapNot(): void {
<div class="node-group-head">
<span class="node-combo node-combo-label">{{ t("filterNode.not") }}</span>
<div class="node-actions">
<button type="button" class="btn btn-ghost node-add" @click="unwrapNot">
<RcButton type="button" variant="ghost" size="xs" class="node-add" @click="unwrapNot">
{{ t("filterNode.unwrap") }}
</button>
<button
</RcButton>
<RcButton
v-if="deletable"
type="button"
variant="destructive"
size="icon"
class="icon-btn danger"
:title="t('routeEditor.remove')"
@click="emit('remove')"
>
✕
</button>
</RcButton>
</div>
</div>
<div class="node-children">
+256 -235
View File
@@ -1,240 +1,235 @@
<template>
<Teleport to="body">
<Transition name="fade">
<div v-if="open" class="overlay" @click.self="close"></div>
</Transition>
<Transition name="slide">
<aside v-if="open" class="editor" role="dialog" aria-modal="true">
<div class="editor-head">
<div class="editor-heading">
<span class="editor-eyebrow">{{ t("groupEditor.eyebrow") }}</span>
<h2>{{ isEdit ? t("groupEditor.editTitle") : t("groupEditor.newTitle") }}</h2>
<RcDialog
:open="open"
:title="isEdit ? t('groupEditor.editTitle') : t('groupEditor.newTitle')"
class="editor-dialog flex flex-col gap-0 max-h-[calc(100dvh-2rem)] overflow-hidden p-0 max-w-2xl"
@update:open="onOpenChange"
>
<template #header>
<div class="editor-head">
<div class="editor-heading">
<span class="editor-eyebrow">{{ t("groupEditor.eyebrow") }}</span>
<h2>{{ isEdit ? t("groupEditor.editTitle") : t("groupEditor.newTitle") }}</h2>
</div>
</div>
</template>
<form class="editor-body" @submit.prevent="save">
<section class="editor-section">
<h3 class="editor-section-title">{{ t("groupEditor.sectionBasic") }}</h3>
<div class="row2">
<div class="field">
<label>{{ t("groupEditor.name") }}</label>
<RcInput
v-model="form.name"
type="text"
:placeholder="t('groupEditor.namePlaceholder')"
required
/>
</div>
<div class="field">
<label>{{ t("groupEditor.id") }}</label>
<RcInput
v-model="form.id"
type="text"
:placeholder="t('groupEditor.idPlaceholder')"
required
/>
<div class="hint">
{{ isEdit ? t("groupEditor.renameHint") : t("groupEditor.idHint") }}
</div>
</div>
<button class="icon-btn" :title="t('groupEditor.close')" @click="close">✕</button>
</div>
<form class="editor-body" @submit.prevent="save">
<section class="editor-section">
<h3 class="editor-section-title">{{ t("groupEditor.sectionBasic") }}</h3>
<div class="row2">
<div class="field">
<label>{{ t("groupEditor.name") }}</label>
<input
v-model="form.name"
type="text"
class="input"
:placeholder="t('groupEditor.namePlaceholder')"
required
/>
</div>
<div class="field">
<label>{{ t("groupEditor.id") }}</label>
<input
v-model="form.id"
type="text"
class="input"
:placeholder="t('groupEditor.idPlaceholder')"
required
/>
<div class="hint">
{{ isEdit ? t("groupEditor.renameHint") : t("groupEditor.idHint") }}
</div>
</div>
</div>
</section>
<section class="editor-section">
<h3 class="editor-section-title">{{ t("groupEditor.sectionPreferences") }}</h3>
<div class="row2">
<div class="field">
<label>{{ t("groupEditor.language") }}</label>
<input
v-model="form.lang"
type="text"
class="input"
:placeholder="t('groupEditor.langPlaceholder')"
/>
<div class="hint">{{ t("groupEditor.langHint") }}</div>
</div>
<div class="field">
<label
>{{ t("groupEditor.emoji") }}
<span class="lbl-note">{{ t("groupEditor.emojiNote") }}</span></label
>
<label class="inline">
<input v-model="form.emoji" type="checkbox" />
<span>{{ t("groupEditor.emojiLabel") }}</span>
</label>
</div>
</div>
<div class="field">
<label
>{{ t("groupEditor.forgeSources") }}
<span class="lbl-note">{{ t("groupEditor.forgeSourcesNote") }}</span></label
>
<div v-for="(s, i) in form.forgeSources" :key="i" class="forge-source-row">
<input
v-model="s.host"
type="text"
class="input f-host"
:placeholder="t('groupEditor.forgeSourcesHost')"
/>
<select v-model="s.type" class="select forge-type">
<option value="github">GitHub</option>
<option value="gitea">Gitea</option>
</select>
<button
type="button"
class="icon-btn danger"
@click="form.forgeSources.splice(i, 1)"
>
✕
</button>
<input
v-model="s.name"
type="text"
class="input f-name"
:placeholder="t('groupEditor.forgeSourcesName')"
/>
</div>
<button type="button" class="btn btn-ghost add-filter" @click="addForgeSource">
{{ t("groupEditor.forgeSourcesAdd") }}
</button>
<div class="hint">{{ t("groupEditor.forgeSourcesHint") }}</div>
</div>
</section>
<section class="editor-section">
<h3 class="editor-section-title">{{ t("groupEditor.sectionAccess") }}</h3>
<div class="field">
<label
>{{ t("groupEditor.membersNote") }}
<span class="lbl-note">{{ t("groupEditor.membersHint") }}</span></label
>
<p class="hint">
{{ t("groupEditor.membersGoPanel") }}
</p>
</div>
<div v-if="superAdmin" class="field">
<label
>{{ t("groupEditor.owners") }}
<span class="lbl-note">{{ t("groupEditor.ownersNote") }}</span></label
>
<input
v-model="form.owners"
type="text"
class="input"
:placeholder="t('groupEditor.ownersPlaceholder')"
/>
<div class="hint">{{ t("groupEditor.ownersHint") }}</div>
</div>
<div v-else class="field">
<label
>{{ t("groupEditor.owners") }}
<span class="lbl-note">{{ t("groupEditor.ownersSuperOnly") }}</span></label
>
<input v-model="ownersReadonly" type="text" class="input opacity-60" disabled />
</div>
</section>
<section class="editor-section">
<h3 class="editor-section-title">{{ t("groupEditor.sectionProviders") }}</h3>
<div class="field">
<label
>{{ t("groupEditor.providers") }}
<span class="lbl-note">{{ t("groupEditor.providersNote") }}</span></label
>
<div class="flex flex-wrap gap-4">
<label class="inline">
<input
type="checkbox"
:checked="form.providers.includes('github')"
@change="toggleProvider('github', $event)"
/>
<span>GitHub</span>
</label>
<label class="inline">
<input
type="checkbox"
:checked="form.providers.includes('gitea')"
@change="toggleProvider('gitea', $event)"
/>
<span>Gitea</span>
</label>
</div>
<div class="hint">{{ t("groupEditor.providersHint") }}</div>
</div>
<div class="field">
<label
>{{ t("groupEditor.installationId") }}
<span class="lbl-note">{{ t("groupEditor.installationIdNote") }}</span></label
>
<input
v-model="form.installationId"
type="text"
class="input"
inputmode="numeric"
:placeholder="t('groupEditor.installationIdPlaceholder')"
/>
<div class="hint">{{ t("groupEditor.installationIdHint") }}</div>
</div>
</section>
<section class="editor-section">
<h3 class="editor-section-title">{{ t("groupEditor.sectionLog") }}</h3>
<div class="field">
<label
>{{ t("groupEditor.logTarget") }}
<span class="lbl-note">{{ t("groupEditor.logTargetNote") }}</span></label
>
<select v-model="form.logPlatform" class="select">
<option value="">{{ t("groupEditor.logDisabled") }}</option>
<option value="discord">Discord</option>
<option value="telegram">Telegram</option>
<option value="feishu">{{ t("groupEditor.logFeishu") }}</option>
</select>
<template v-if="form.logPlatform === 'discord'">
<input
v-model="form.logChannelId"
type="text"
class="input mt-2"
:placeholder="t('routeEditor.channelPlaceholder')"
/>
<input
v-model="form.logThreadId"
type="text"
class="input mt-2"
:placeholder="t('routeEditor.threadPlaceholder')"
/>
</template>
<template
v-else-if="form.logPlatform === 'telegram' || form.logPlatform === 'feishu'"
>
<input
v-model="form.logChatId"
type="text"
class="input mt-2"
:placeholder="t('routeEditor.chatPlaceholder')"
/>
<input
v-if="form.logPlatform === 'telegram'"
v-model="form.logTopicId"
type="text"
class="input mt-2"
:placeholder="t('routeEditor.topicPlaceholder')"
/>
</template>
<div class="hint">{{ t("groupEditor.logTargetHint") }}</div>
</div>
</section>
<div class="err">{{ formError }}</div>
</form>
<div class="editor-foot">
<button class="btn btn-ghost" type="button" @click="close">
{{ t("groupEditor.cancel") }}
</button>
<button class="btn btn-accent" type="button" :disabled="saving" @click="save">
{{ t("groupEditor.save") }}
</button>
</section>
<section class="editor-section">
<h3 class="editor-section-title">{{ t("groupEditor.sectionPreferences") }}</h3>
<div class="row2">
<div class="field">
<label>{{ t("groupEditor.language") }}</label>
<RcInput
v-model="form.lang"
type="text"
:placeholder="t('groupEditor.langPlaceholder')"
/>
<div class="hint">{{ t("groupEditor.langHint") }}</div>
</div>
<div class="field">
<label
>{{ t("groupEditor.emoji") }}
<span class="lbl-note">{{ t("groupEditor.emojiNote") }}</span></label
>
<RcSwitch v-model="form.emoji" :label="t('groupEditor.emojiLabel')" />
</div>
</div>
</aside>
</Transition>
</Teleport>
<div class="field">
<label
>{{ t("groupEditor.forgeSources") }}
<span class="lbl-note">{{ t("groupEditor.forgeSourcesNote") }}</span></label
>
<div v-for="(s, i) in form.forgeSources" :key="i" class="forge-source-row">
<RcInput
v-model="s.host"
type="text"
class="[grid-area:host]"
:placeholder="t('groupEditor.forgeSourcesHost')"
/>
<RcSelect
v-model="s.type"
class="w-[110px] [grid-area:type]"
:options="[
{ label: 'GitHub', value: 'github' },
{ label: 'Gitea', value: 'gitea' },
]"
/>
<RcButton
type="button"
variant="destructive"
size="icon"
class="[grid-area:del] justify-self-end"
@click="form.forgeSources.splice(i, 1)"
>
✕
</RcButton>
<RcInput
v-model="s.name"
type="text"
class="[grid-area:name]"
:placeholder="t('groupEditor.forgeSourcesName')"
/>
</div>
<RcButton type="button" variant="ghost" class="add-filter" @click="addForgeSource">
{{ t("groupEditor.forgeSourcesAdd") }}
</RcButton>
<div class="hint">{{ t("groupEditor.forgeSourcesHint") }}</div>
</div>
</section>
<section class="editor-section">
<h3 class="editor-section-title">{{ t("groupEditor.sectionAccess") }}</h3>
<div class="field">
<label
>{{ t("groupEditor.membersNote") }}
<span class="lbl-note">{{ t("groupEditor.membersHint") }}</span></label
>
<p class="hint">
{{ t("groupEditor.membersGoPanel") }}
</p>
</div>
<div v-if="superAdmin" class="field">
<label
>{{ t("groupEditor.owners") }}
<span class="lbl-note">{{ t("groupEditor.ownersNote") }}</span></label
>
<RcTagInput
v-model="owners"
separator=","
:placeholder="t('groupEditor.ownersPlaceholder')"
/>
<div class="hint">{{ t("groupEditor.ownersHint") }}</div>
</div>
<div v-else class="field">
<label
>{{ t("groupEditor.owners") }}
<span class="lbl-note">{{ t("groupEditor.ownersSuperOnly") }}</span></label
>
<RcInput v-model="ownersReadonly" type="text" class="opacity-60" disabled />
</div>
</section>
<section class="editor-section">
<h3 class="editor-section-title">{{ t("groupEditor.sectionProviders") }}</h3>
<div class="field">
<label
>{{ t("groupEditor.providers") }}
<span class="lbl-note">{{ t("groupEditor.providersNote") }}</span></label
>
<div class="flex flex-wrap gap-4">
<RcCheckbox
:model-value="form.providers.includes('github')"
label="GitHub"
@update:model-value="toggleProvider('github', $event)"
/>
<RcCheckbox
:model-value="form.providers.includes('gitea')"
label="Gitea"
@update:model-value="toggleProvider('gitea', $event)"
/>
</div>
<div class="hint">{{ t("groupEditor.providersHint") }}</div>
</div>
<div class="field">
<label
>{{ t("groupEditor.installationId") }}
<span class="lbl-note">{{ t("groupEditor.installationIdNote") }}</span></label
>
<RcInput
v-model="form.installationId"
type="text"
inputmode="numeric"
:placeholder="t('groupEditor.installationIdPlaceholder')"
/>
<div class="hint">{{ t("groupEditor.installationIdHint") }}</div>
</div>
</section>
<section class="editor-section">
<h3 class="editor-section-title">{{ t("groupEditor.sectionLog") }}</h3>
<div class="field">
<label
>{{ t("groupEditor.logTarget") }}
<span class="lbl-note">{{ t("groupEditor.logTargetNote") }}</span></label
>
<RcSelect
:model-value="form.logPlatform || 'none'"
:options="[
{ label: t('groupEditor.logDisabled'), value: 'none' },
{ label: 'Discord', value: 'discord' },
{ label: 'Telegram', value: 'telegram' },
{ label: t('groupEditor.logFeishu'), value: 'feishu' },
]"
@update:model-value="form.logPlatform = ($event === 'none' ? '' : $event) as '' | 'discord' | 'telegram' | 'feishu'"
/>
<template v-if="form.logPlatform === 'discord'">
<RcInput
v-model="form.logChannelId"
type="text"
class="mt-2"
:placeholder="t('routeEditor.channelPlaceholder')"
/>
<RcInput
v-model="form.logThreadId"
type="text"
class="mt-2"
:placeholder="t('routeEditor.threadPlaceholder')"
/>
</template>
<template v-else-if="form.logPlatform === 'telegram' || form.logPlatform === 'feishu'">
<RcInput
v-model="form.logChatId"
type="text"
class="mt-2"
:placeholder="t('routeEditor.chatPlaceholder')"
/>
<RcInput
v-if="form.logPlatform === 'telegram'"
v-model="form.logTopicId"
type="text"
class="mt-2"
:placeholder="t('routeEditor.topicPlaceholder')"
/>
</template>
<div class="hint">{{ t("groupEditor.logTargetHint") }}</div>
</div>
</section>
<div class="err">{{ formError }}</div>
</form>
<template #footer>
<div class="editor-foot">
<RcButton variant="ghost" type="button" @click="close">
{{ t("groupEditor.cancel") }}
</RcButton>
<RcButton variant="primary" type="button" :loading="saving" @click="save">
{{ t("groupEditor.save") }}
</RcButton>
</div>
</template>
</RcDialog>
</template>
<script setup lang="ts">
@@ -273,12 +268,21 @@ const form = reactive({
logChatId: "",
logTopicId: "",
});
const owners = computed({
get: () =>
form.owners
.split(",")
.map((owner) => owner.trim())
.filter(Boolean),
set: (values: string[]) => {
form.owners = values.join(", ");
},
});
function addForgeSource(): void {
form.forgeSources.push({ host: "", type: "github" });
}
function toggleProvider(p: "github" | "gitea", e: Event): void {
const checked = (e.target as HTMLInputElement).checked;
function toggleProvider(p: "github" | "gitea", checked: boolean): void {
form.providers = checked
? [...new Set([...form.providers, p])]
: form.providers.filter((x) => x !== p);
@@ -313,6 +317,10 @@ function close(): void {
emit("close");
}
function onOpenChange(open: boolean): void {
if (!open) close();
}
function save(): void {
formError.value = "";
const id = form.id.trim();
@@ -394,3 +402,16 @@ function save(): void {
});
}
</script>
<style scoped>
:deep(.editor-foot) {
display: flex;
justify-content: flex-end;
gap: 0.5rem;
border-top: 1px solid rgb(var(--wh-border));
background: rgb(var(--wh-surface));
padding: 1rem 1.5rem;
box-shadow: 0 -8px 24px -16px rgba(15, 23, 42, 0.18);
}
</style>
+34 -49
View File
@@ -1,44 +1,27 @@
<template>
<div class="mx-auto max-w-[760px] px-5 pb-20 pt-12">
<header class="mb-7 flex flex-wrap items-center justify-between gap-4">
<NuxtLink
class="text-base font-extrabold tracking-[-0.01em] text-text no-underline"
:to="q('/terms')"
>Web<span class="text-accent">Hooker</span></NuxtLink
>
<nav class="flex gap-2">
<NuxtLink
class="rounded-full border border-transparent px-3.5 py-1.5 text-[13px] text-muted no-underline transition-colors hover:text-text"
:class="active === 'terms' ? 'border-accent-border bg-accent-dim text-accent' : ''"
:to="q('/terms')"
>
{{ t("服务条款", "Terms") }}
</NuxtLink>
<NuxtLink
class="rounded-full border border-transparent px-3.5 py-1.5 text-[13px] text-muted no-underline transition-colors hover:text-text"
:class="active === 'privacy' ? 'border-accent-border bg-accent-dim text-accent' : ''"
:to="q('/privacy')"
>
{{ t("隐私政策", "Privacy") }}
<main class="legal-shell">
<header class="legal-header">
<NuxtLink class="legal-brand" :to="q('/')"><AppLogo :size="28" /><span>WebHooker</span></NuxtLink>
<nav aria-label="Legal navigation">
<NuxtLink v-for="item in links" :key="item.key" :to="q(item.path)">
<RcBadge :variant="active === item.key ? 'brand' : 'subtle'" size="sm">{{ item.label }}</RcBadge>
</NuxtLink>
</nav>
</header>
<article
class="rounded-xl border border-border bg-surface px-10 py-9 shadow-[0_1px_3px_var(--shadow)]"
>
<h1 class="mb-1.5 text-[26px] font-extrabold tracking-[-0.02em]">{{ title }}</h1>
<p class="mb-6 text-[13px] text-muted">{{ t("最后更新", "Last updated") }}: {{ updated }}</p>
<div class="legal-body" v-html="body" />
</article>
<footer class="mt-6 flex flex-wrap items-center justify-between gap-3">
<span class="text-[13px] text-muted">WebHooker · GitHub → Discord</span>
<NuxtLink
class="rounded-full border border-border bg-surface px-3.5 py-1.5 text-[13px] text-muted no-underline transition-colors hover:text-text"
:to="altLink"
>{{ lang === "zh" ? "English" : "中文" }}</NuxtLink
>
<section class="legal-heading">
<p>{{ t("WebHooker 服务规范", "WebHooker service policy") }}</p>
<h1>{{ title }}</h1>
<span>{{ t("最后更新", "Last updated") }} · {{ updated }}</span>
</section>
<RcCard variant="outline" padding="lg" class="legal-card"><article class="legal-body" v-html="body" /></RcCard>
<footer class="legal-footer">
<NuxtLink :to="q('/')">{{ t("返回首页", "Back to home") }}</NuxtLink>
<div class="legal-footer-actions">
<ThemeToggle show-label />
<NuxtLink :to="altLink">{{ lang === "zh" ? "English" : "中文" }}</NuxtLink>
</div>
</footer>
</div>
</main>
</template>
<script setup lang="ts">
@@ -46,23 +29,25 @@ import { computed } from "vue";
import { pickLang, type Lang } from "~/utils/legal";
const props = defineProps<{ active: "terms" | "privacy"; title: string; body: string }>();
const route = useRoute();
const config = useRuntimeConfig();
const lang = computed<Lang>(() => pickLang(String(route.query.lang ?? "")));
const altLang = computed(() => (lang.value === "zh" ? "en" : "zh"));
const updated = computed(() => "2026-08-01");
const updated = "2026-08-01";
const t = (zh: string, en: string): string => (lang.value === "zh" ? zh : en);
const q = (p: string): string => `${p}?lang=${lang.value}`;
const altLink = computed(() =>
q(props.active === "terms" ? "/terms" : "/privacy").replace(
`lang=${lang.value}`,
`lang=${altLang.value}`,
),
);
const q = (path: string): string => `${path}?lang=${lang.value}`;
const links = computed(() => [
{ key: "terms" as const, path: "/terms", label: t("服务条款", "Terms") },
{ key: "privacy" as const, path: "/privacy", label: t("隐私政策", "Privacy") },
]);
const altLink = computed(() => `${props.active === "terms" ? "/terms" : "/privacy"}?lang=${altLang.value}`);
useHead({ title: `${props.title} · WebHooker` });
void config;
</script>
<style scoped>
.legal-shell { position: relative; z-index: 1; width: min(100% - 2rem, 860px); margin: 0 auto; padding: 2rem 0 4rem; } .legal-header, .legal-footer { display: flex; align-items: center; justify-content: space-between; gap: 1rem; } .legal-brand { display: inline-flex; align-items: center; gap: .6rem; color: rgb(var(--wh-text)); font-size: 1rem; font-weight: 800; text-decoration: none; letter-spacing: -.035em; } .legal-brand :deep(svg) { color: rgb(var(--wh-accent)); } nav { display: flex; gap: .35rem; } nav a { text-decoration: none; }
.legal-heading { max-width: 640px; padding: clamp(4rem, 11vw, 7rem) 0 clamp(2rem, 6vw, 3.5rem); } .legal-heading p { margin: 0 0 .75rem; color: rgb(var(--wh-accent)); font-size: .72rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; } .legal-heading h1 { margin: 0; font-size: clamp(2.4rem, 7vw, 4rem); letter-spacing: -.06em; line-height: 1; } .legal-heading span { display: block; margin-top: 1rem; color: rgb(var(--wh-faint)); font-size: .78rem; }
.legal-card { box-shadow: 0 24px 60px rgb(var(--wh-text) / .06); } .legal-body :deep(h2) { margin: 2.25rem 0 .75rem; font-size: 1.1rem; letter-spacing: -.02em; } .legal-body :deep(h2:first-child) { margin-top: 0; } .legal-body :deep(p), .legal-body :deep(li) { color: rgb(var(--wh-body-text)); line-height: 1.8; } .legal-body :deep(a) { color: rgb(var(--wh-accent)); } .legal-body :deep(ul) { padding-left: 1.25rem; }
.legal-footer { margin-top: 1.5rem; color: rgb(var(--wh-muted)); font-size: .78rem; } .legal-footer-actions { display: flex; align-items: center; gap: .75rem; } .legal-footer a { color: inherit; text-decoration: none; } .legal-footer a:hover { color: rgb(var(--wh-accent)); }
@media (max-width: 520px) { .legal-shell { width: min(100% - 1.5rem, 860px); } .legal-header { align-items: flex-start; flex-direction: column; } }
</style>
+34 -35
View File
@@ -1,5 +1,5 @@
<template>
<section class="members-panel">
<RcCard variant="outline" padding="md" class="members-panel">
<div class="panel-head">
<h3>{{ t("members.title") }}</h3>
<span class="lbl-note">{{ t("members.note") }}</span>
@@ -10,46 +10,42 @@
<ul class="member-list">
<li v-for="m in members" :key="m.login.toLowerCase()" class="member-row">
<span class="member-login">{{ m.login }}</span>
<select
<RcSelect
v-if="canEdit"
class="filter-select"
:value="m.role"
:model-value="m.role"
:options="roleOptions"
:disabled="saving"
@change="onRoleChange(m, $event)"
>
<option value="owner">{{ t("roles.owner") }}</option>
<option value="admin">{{ t("roles.admin") }}</option>
<option value="viewer">{{ t("roles.viewer") }}</option>
</select>
<span v-else class="role-pill" :class="m.role">{{ t("roles." + m.role) }}</span>
<button
@update:model-value="onRoleChange(m, $event)"
/>
<RcBadge v-else size="xs" class="role-pill" :class="m.role">{{ t("roles." + m.role) }}</RcBadge>
<RcButton
v-if="canEdit"
type="button"
variant="destructive"
size="icon"
class="icon-btn danger"
:disabled="saving"
:title="t('members.remove')"
@click="removeMember(m)"
>
✕
</button>
</RcButton>
</li>
</ul>
<div v-if="canEdit" class="member-add">
<input
<RcInput
v-model="newLogin"
type="text"
:placeholder="t('members.addPlaceholder')"
class="text-input"
@keydown.enter.prevent="addMember"
/>
<select v-model="newRole" class="filter-select">
<option value="owner">{{ t("roles.owner") }}</option>
<option value="admin">{{ t("roles.admin") }}</option>
<option value="viewer">{{ t("roles.viewer") }}</option>
</select>
<button class="btn btn-accent btn-sm" :disabled="saving" @click="addMember">
<RcSelect v-model="newRole" class="filter-select" :options="roleOptions" />
<RcButton type="button" size="sm" :disabled="saving" @click="addMember">
{{ t("members.addBtn") }}
</button>
</RcButton>
</div>
<div v-if="canEdit" class="invite-box">
@@ -58,30 +54,27 @@
<span class="lbl-note">{{ t("members.inviteNote") }}</span>
</h4>
<div class="invite-create">
<select v-model="inviteRole" class="filter-select">
<option value="admin">{{ t("roles.admin") }}</option>
<option value="viewer">{{ t("roles.viewer") }}</option>
</select>
<button class="btn btn-accent btn-sm" :disabled="saving || inviting" @click="createInvite">
<RcSelect v-model="inviteRole" class="filter-select" :options="inviteRoleOptions" />
<RcButton type="button" size="sm" :disabled="saving || inviting" @click="createInvite">
{{ t("members.createInvite") }}
</button>
</RcButton>
</div>
<ul v-if="invites.length" class="invite-list">
<li v-for="inv in invites" :key="inv.token" class="invite-row">
<code class="invite-token">{{ shortToken(inv.token) }}</code>
<span class="role-pill" :class="inv.role">{{ t("roles." + inv.role) }}</span>
<RcBadge size="xs" class="role-pill" :class="inv.role">{{ t("roles." + inv.role) }}</RcBadge>
<span class="invite-exp">{{ fmtExp(inv.expiresAt) }}</span>
<button class="btn btn-ghost btn-sm" @click="copyInvite(inv)">
<RcButton type="button" variant="ghost" size="sm" @click="copyInvite(inv)">
{{ copied === inv.token ? t("members.copied") : t("members.copyLink") }}
</button>
<button class="icon-btn danger" @click="revoke(inv)">{{ t("members.revoke") }}</button>
</RcButton>
<RcButton type="button" variant="destructive" size="sm" class="icon-btn danger" @click="revoke(inv)">{{ t("members.revoke") }}</RcButton>
</li>
</ul>
<p v-else class="empty-log">{{ t("members.noInvites") }}</p>
</div>
<div class="err">{{ formError }}</div>
</section>
</RcCard>
</template>
<script setup lang="ts">
@@ -103,6 +96,12 @@ const inviteRole = ref<"admin" | "viewer">("admin");
const inviting = ref(false);
const formError = ref("");
const { copied, copy } = useCopy(2000);
const roleOptions = computed(() => [
{ label: t("roles.owner"), value: "owner" },
{ label: t("roles.admin"), value: "admin" },
{ label: t("roles.viewer"), value: "viewer" },
]);
const inviteRoleOptions = computed(() => roleOptions.value.filter((option) => option.value !== "owner"));
watch(
() => props.group,
@@ -122,13 +121,13 @@ function ownerCount(): number {
return members.value.filter((m) => m.role === "owner").length;
}
function onRoleChange(m: GroupMember, e: Event): void {
const role = (e.target as HTMLSelectElement).value as GroupRole;
if (role === "viewer" && m.role === "owner" && ownerCount() === 1) {
function onRoleChange(m: GroupMember, role: string): void {
const nextRole = role as GroupRole;
if (nextRole === "viewer" && m.role === "owner" && ownerCount() === 1) {
formError.value = t("members.errLastOwner");
return;
}
m.role = role;
m.role = nextRole;
emitSave();
}
+36 -26
View File
@@ -3,7 +3,7 @@ import type { DeliveryMetrics, Group, MetricsBreakdown } from "~/types";
const { t } = useI18n();
defineProps<{
const props = defineProps<{
metrics: DeliveryMetrics | null;
loading: boolean;
error: string;
@@ -19,6 +19,11 @@ const emit = defineEmits<{
const sortBy = ref<"total" | "failed" | "rate">("total");
const groupOptions = computed(() => [
{ label: t("metrics.allGroups"), value: "all" },
...props.groups.map((g) => ({ label: g.name || g.id, value: g.id })),
]);
function pct(value: number): string {
return `${(value * 100).toFixed(1)}%`;
}
@@ -28,8 +33,8 @@ function pctOf(count: number, total: number): string {
return `${((count / total) * 100).toFixed(0)}%`;
}
function onGroupFilter(e: Event): void {
emit("update:selectedGroupId", (e.target as HTMLSelectElement).value);
function onGroupFilter(value: string): void {
emit("update:selectedGroupId", value === "all" ? "" : value);
emit("filter");
}
@@ -113,40 +118,38 @@ function cycleSort(): void {
<span class="kpi-label">{{ t("metrics.title") }}</span>
<div class="log-filters">
<label class="filter-label">{{ t("metrics.filterGroup") }}</label>
<select
<RcSelect
class="filter-select"
:value="selectedGroupId"
:model-value="selectedGroupId || 'all'"
:options="groupOptions"
:disabled="loading"
@change="onGroupFilter"
>
<option value="">{{ t("metrics.allGroups") }}</option>
<option v-for="g in groups" :key="g.id" :value="g.id">
{{ g.name || g.id }}
</option>
</select>
@update:model-value="onGroupFilter"
/>
</div>
<button class="btn btn-ghost btn-sm" :disabled="loading" @click="emit('refresh')">
<RcButton variant="ghost" size="sm" :disabled="loading" @click="emit('refresh')">
{{ t("metrics.refresh") }}
</button>
</RcButton>
</div>
<p v-if="error" class="err">{{ error }}</p>
<p v-else-if="!loading && !metrics" class="empty-log">{{ t("metrics.empty") }}</p>
<RcEmptyState v-else-if="!loading && !metrics" :title="t('metrics.empty')" class="empty-log" />
<template v-else-if="metrics">
<div class="metric-kpis">
<div
<RcCard
v-for="k in summary(metrics)"
:key="k.label"
variant="outline"
padding="md"
class="metric-kpi"
:class="TONE[k.tone] ?? ''"
>
<span class="metric-kpi-value">{{ k.value }}</span>
<span class="metric-kpi-label">{{ k.label }}</span>
</div>
</RcCard>
</div>
<article v-if="metrics.byPlatform.length" class="metric-block">
<RcCard v-if="metrics.byPlatform.length" variant="outline" padding="md" class="metric-block">
<h3 class="metric-block-title">{{ t("metrics.byPlatform") }}</h3>
<div
v-for="r in rows(metrics.byPlatform, (r) => r.platform ?? 'unknown')"
@@ -170,12 +173,14 @@ function cycleSort(): void {
</div>
<span class="metric-total">{{ r.total }}</span>
</div>
</article>
</RcCard>
<article v-if="metrics.byEvent.length" class="metric-block">
<RcCard v-if="metrics.byEvent.length" variant="outline" padding="md" class="metric-block">
<div class="metric-block-head">
<h3 class="metric-block-title">{{ t("metrics.byEvent") }}</h3>
<button class="metric-sort-toggle" @click="cycleSort">{{ sortLabel() }}</button>
<RcButton variant="ghost" size="xs" class="metric-sort-toggle" @click="cycleSort">{{
sortLabel()
}}</RcButton>
</div>
<div
v-for="r in rows(metrics.byEvent, (r) => r.event ?? 'unknown')"
@@ -199,9 +204,9 @@ function cycleSort(): void {
</div>
<span class="metric-total">{{ r.total }}</span>
</div>
</article>
</RcCard>
<article v-if="metrics.byStatus.length" class="metric-block">
<RcCard v-if="metrics.byStatus.length" variant="outline" padding="md" class="metric-block">
<h3 class="metric-block-title">{{ t("metrics.byStatus") }}</h3>
<div class="metric-status-row">
<span
@@ -216,9 +221,14 @@ function cycleSort(): void {
{{ s.status }} · {{ s.count }}
</span>
</div>
</article>
</RcCard>
<article v-if="metrics.recentFailures.length" class="metric-block">
<RcCard
v-if="metrics.recentFailures.length"
variant="outline"
padding="md"
class="metric-block"
>
<h3 class="metric-block-title">{{ t("metrics.recentFailures") }}</h3>
<div
v-for="f in metrics.recentFailures"
@@ -232,7 +242,7 @@ function cycleSort(): void {
<span class="log-time">{{ f.target }}</span>
</div>
</div>
</article>
</RcCard>
</template>
</div>
</template>
+32 -25
View File
@@ -1,20 +1,18 @@
<template>
<article class="route-card" :class="{ disabled: !route.enabled }">
<RcCard variant="outline" padding="none" :class="cardClass">
<div class="route-card-main">
<div class="route-card-header">
<label v-if="!readonly" class="switch">
<input type="checkbox" :checked="route.enabled" @change="onToggle" />
<span class="track"></span>
</label>
<RcSwitch v-if="!readonly" :model-value="route.enabled" size="sm" @update:model-value="onToggle" />
<span v-if="readonly" class="dot" :class="route.enabled ? 'ok' : 'bad'"></span>
<div class="route-card-title">
<span class="route-name">{{ route.name || t("route.untitled") }}</span>
<span class="route-id">{{ route.id }}</span>
</div>
<div class="route-card-badges">
<span
<RcBadge
v-for="(tg, i) in route.targets"
:key="i"
size="xs"
class="route-badge"
:class="
tg.platform === 'telegram'
@@ -41,14 +39,10 @@
? t("route.feishu")
: "Discord"
}}
</span>
<span v-if="route.fallback" class="route-badge route-badge-fallback">{{
t("route.fallback")
}}</span>
<span v-if="route.stop" class="route-badge route-badge-stop">{{ t("route.stop") }}</span>
<span v-if="route.discordRoleIds?.length" class="route-badge route-badge-role"
>@roles</span
>
</RcBadge>
<RcBadge v-if="route.fallback" variant="warning" size="xs" class="route-badge route-badge-fallback">{{ t("route.fallback") }}</RcBadge>
<RcBadge v-if="route.stop" variant="destructive" size="xs" class="route-badge route-badge-stop">{{ t("route.stop") }}</RcBadge>
<RcBadge v-if="route.discordRoleIds?.length" size="xs" class="route-badge route-badge-role">@roles</RcBadge>
</div>
</div>
@@ -84,7 +78,10 @@
</div>
<div v-if="!readonly" class="route-card-actions">
<button
<RcButton
type="button"
variant="ghost"
size="icon"
class="route-action-btn"
:disabled="atFirst"
:title="t('route.moveUp')"
@@ -102,8 +99,11 @@
>
<path d="m18 15-6-6-6 6" />
</svg>
</button>
<button
</RcButton>
<RcButton
type="button"
variant="ghost"
size="icon"
class="route-action-btn"
:disabled="atLast"
:title="t('route.moveDown')"
@@ -121,8 +121,11 @@
>
<path d="m6 9 6 6 6-6" />
</svg>
</button>
<button
</RcButton>
<RcButton
type="button"
variant="ghost"
size="icon"
class="route-action-btn"
:title="t('routeEditor.editTitle')"
@click="$emit('edit', route)"
@@ -140,8 +143,11 @@
<path d="M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z" />
<path d="m15 5 4 4" />
</svg>
</button>
<button
</RcButton>
<RcButton
type="button"
variant="destructive"
size="icon"
class="route-action-btn route-action-btn-danger"
:title="t('routeEditor.close')"
@click="$emit('delete', route)"
@@ -159,9 +165,9 @@
<path d="M18 6 6 18" />
<path d="m6 6 12 12" />
</svg>
</button>
</RcButton>
</div>
</article>
</RcCard>
</template>
<script setup lang="ts">
@@ -181,6 +187,7 @@ const summary = computed(() => {
const node: FilterNode = props.route.ast ?? { all: props.route.filters };
return describeNode(node, t);
});
const cardClass = computed(() => `route-card${props.route.enabled ? "" : " disabled"}`);
const emit = defineEmits<{
(e: "toggle", route: Route): void;
(e: "edit", route: Route): void;
@@ -188,8 +195,8 @@ const emit = defineEmits<{
(e: "move", route: Route, dir: -1 | 1): void;
}>();
function onToggle(event: Event): void {
const next = { ...props.route, enabled: (event.target as HTMLInputElement).checked };
function onToggle(enabled: boolean): void {
const next = { ...props.route, enabled };
emit("toggle", next);
}
</script>
+254 -230
View File
@@ -29,6 +29,16 @@ const emit = defineEmits<{ (e: "close"): void; (e: "save", route: Route): void }
const { t } = useI18n();
const isEdit = computed(() => props.route != null);
const discordRoles = computed({
get: () =>
form.discordRolesText
.split(",")
.map((role) => role.trim())
.filter(Boolean),
set: (roles: string[]) => {
form.discordRolesText = roles.join(", ");
},
});
const filterError = ref("");
const targetError = ref("");
const formError = ref("");
@@ -188,6 +198,10 @@ function close(): void {
emit("close");
}
function onOpenChange(open: boolean): void {
if (!open) close();
}
async function runTest(): Promise<void> {
testError.value = "";
testResult.value = null;
@@ -315,237 +329,247 @@ watch(
</script>
<template>
<Teleport to="body">
<Transition name="fade">
<div v-if="open" class="overlay" @click.self="close" />
</Transition>
<Transition name="slide">
<aside v-if="open" class="editor" role="dialog" aria-modal="true">
<div class="editor-head">
<div class="editor-heading">
<span class="editor-eyebrow">{{ t("routeEditor.eyebrow") }}</span>
<h2>{{ isEdit ? t("routeEditor.editTitle") : t("routeEditor.newTitle") }}</h2>
<RcDialog
:open="open"
:title="isEdit ? t('routeEditor.editTitle') : t('routeEditor.newTitle')"
class="editor-dialog flex flex-col gap-0 max-h-[calc(100dvh-2rem)] overflow-hidden p-0 max-w-3xl"
@update:open="onOpenChange"
>
<template #header>
<div class="editor-head">
<div class="editor-heading">
<span class="editor-eyebrow">{{ t("routeEditor.eyebrow") }}</span>
<h2>{{ isEdit ? t("routeEditor.editTitle") : t("routeEditor.newTitle") }}</h2>
</div>
</div>
</template>
<form class="editor-body" @submit.prevent="save">
<section class="editor-section">
<h3 class="editor-section-title">{{ t("routeEditor.sectionBasic") }}</h3>
<div v-if="!isEdit" class="templates">
<RcButton
v-for="tmpl in ROUTE_TEMPLATES"
:key="tmpl.id"
type="button"
variant="ghost"
size="sm"
:class="form.id === tmpl.id ? 'template-chip active' : 'template-chip'"
@click="applyTemplate(tmpl)"
>
{{ t(tmpl.nameKey) }}
</RcButton>
</div>
<div class="field">
<label>{{ t("routeEditor.name") }}</label>
<RcInput v-model="form.name" :placeholder="t('routeEditor.namePlaceholder')" required />
</div>
<div class="field">
<label>{{ t("routeEditor.id") }}</label>
<RcInput v-model="form.id" placeholder="my-route" required />
<div class="hint">{{ t("routeEditor.idHint") }}</div>
</div>
</section>
<section class="editor-section">
<h3 class="editor-section-title">{{ t("routeEditor.sectionOptions") }}</h3>
<div class="field inline">
<RcSwitch v-model="form.enabled" :label="t('routeEditor.enabled')" />
</div>
<div class="field inline">
<RcCheckbox v-model="form.fallback" :label="t('routeEditor.fallback')" />
<span class="lbl-note">{{ t("routeEditor.fallbackHint") }}</span>
</div>
<div class="field inline">
<RcCheckbox v-model="form.stop" :label="t('routeEditor.stop')" />
<span class="lbl-note">{{ t("routeEditor.stopHint") }}</span>
</div>
<div class="field">
<label>{{ t("routeEditor.discordRoles") }}</label>
<RcTagInput
v-model="discordRoles"
separator=","
:placeholder="t('routeEditor.discordRolesPlaceholder')"
/>
<div class="hint">{{ t("routeEditor.discordRolesHint") }}</div>
</div>
</section>
<section class="editor-section">
<h3 class="editor-section-title">{{ t("routeEditor.sectionFilters") }}</h3>
<div class="field">
<label>{{ t("routeEditor.filters") }}</label>
</div>
<div class="field">
<FilterNodeEditor :node="root" />
</div>
<div v-if="filterError" class="err">{{ filterError }}</div>
</section>
<section class="editor-section">
<h3 class="editor-section-title">{{ t("routeEditor.testMatch") }}</h3>
<div class="field">
<RcInput v-model="testEvent" :placeholder="t('routeEditor.testEvent')" />
</div>
<div class="field">
<RcTextarea
v-model="testPayload"
class="test-payload"
:rows="6"
:placeholder="t('routeEditor.testPayloadPlaceholder')"
/>
</div>
<div class="field">
<RcButton type="button" variant="ghost" :loading="testing" @click="runTest">
{{ testing ? "…" : t("routeEditor.testRun") }}
</RcButton>
</div>
<div v-if="testResult" class="test-result" :class="{ ok: testResult.matched }">
<span class="test-badge">
{{
testResult.matched ? t("routeEditor.testMatched") : t("routeEditor.testNotMatched")
}}
</span>
<span class="test-explanation">{{ testResult.explanation }}</span>
</div>
<div v-if="testError" class="err">{{ testError }}</div>
</section>
<section v-if="groupId" class="editor-section">
<h3 class="editor-section-title">{{ t("routeEditor.fragments") }}</h3>
<div class="fragments-presets">
<span class="hint">{{ t("routeEditor.fragmentsPresets") }}</span>
<div v-for="preset in FRAGMENT_PRESETS" :key="preset.id" class="fragment-row">
<span class="fragment-name">{{ t(preset.nameKey) }}</span>
<RcButton
type="button"
variant="ghost"
size="sm"
class="fragment-action"
@click="insertNode(preset.node)"
>
{{ t("routeEditor.fragmentsInsert") }}
</RcButton>
</div>
<button class="icon-btn" :title="t('routeEditor.close')" @click="close">✕</button>
</div>
<form class="editor-body" @submit.prevent="save">
<section class="editor-section">
<h3 class="editor-section-title">{{ t("routeEditor.sectionBasic") }}</h3>
<div v-if="!isEdit" class="templates">
<button
v-for="tmpl in ROUTE_TEMPLATES"
:key="tmpl.id"
type="button"
class="template-chip"
:class="{ active: form.id === tmpl.id }"
@click="applyTemplate(tmpl)"
>
{{ t(tmpl.nameKey) }}
</button>
</div>
<div class="field">
<label>{{ t("routeEditor.name") }}</label>
<input
v-model="form.name"
class="input"
:placeholder="t('routeEditor.namePlaceholder')"
required
/>
</div>
<div class="field">
<label>{{ t("routeEditor.id") }}</label>
<input v-model="form.id" class="input" placeholder="my-route" required />
<div class="hint">{{ t("routeEditor.idHint") }}</div>
</div>
</section>
<section class="editor-section">
<h3 class="editor-section-title">{{ t("routeEditor.sectionOptions") }}</h3>
<div class="field inline">
<input v-model="form.enabled" type="checkbox" />
<span>{{ t("routeEditor.enabled") }}</span>
</div>
<div class="field inline">
<input v-model="form.fallback" type="checkbox" />
<span>
{{ t("routeEditor.fallback") }}
<span class="lbl-note">{{ t("routeEditor.fallbackHint") }}</span>
</span>
</div>
<div class="field inline">
<input v-model="form.stop" type="checkbox" />
<span>
{{ t("routeEditor.stop") }}
<span class="lbl-note">{{ t("routeEditor.stopHint") }}</span>
</span>
</div>
<div class="field">
<label>{{ t("routeEditor.discordRoles") }}</label>
<input
v-model="form.discordRolesText"
class="input"
:placeholder="t('routeEditor.discordRolesPlaceholder')"
/>
<div class="hint">{{ t("routeEditor.discordRolesHint") }}</div>
</div>
</section>
<section class="editor-section">
<h3 class="editor-section-title">{{ t("routeEditor.sectionFilters") }}</h3>
<div class="field">
<label>{{ t("routeEditor.filters") }}</label>
</div>
<div class="field">
<FilterNodeEditor :node="root" />
</div>
<div v-if="filterError" class="err">{{ filterError }}</div>
</section>
<section class="editor-section">
<h3 class="editor-section-title">{{ t("routeEditor.testMatch") }}</h3>
<div class="field">
<input v-model="testEvent" class="input" :placeholder="t('routeEditor.testEvent')" />
</div>
<div class="field">
<textarea
v-model="testPayload"
class="input test-payload"
rows="6"
:placeholder="t('routeEditor.testPayloadPlaceholder')"
/>
</div>
<div class="field">
<button type="button" class="btn btn-ghost" :disabled="testing" @click="runTest">
{{ testing ? "…" : t("routeEditor.testRun") }}
</button>
</div>
<div v-if="testResult" class="test-result" :class="{ ok: testResult.matched }">
<span class="test-badge">
{{
testResult.matched
? t("routeEditor.testMatched")
: t("routeEditor.testNotMatched")
}}
</span>
<span class="test-explanation">{{ testResult.explanation }}</span>
</div>
<div v-if="testError" class="err">{{ testError }}</div>
</section>
<section v-if="groupId" class="editor-section">
<h3 class="editor-section-title">{{ t("routeEditor.fragments") }}</h3>
<div class="fragments-presets">
<span class="hint">{{ t("routeEditor.fragmentsPresets") }}</span>
<div v-for="preset in FRAGMENT_PRESETS" :key="preset.id" class="fragment-row">
<span class="fragment-name">{{ t(preset.nameKey) }}</span>
<button
type="button"
class="btn btn-ghost fragment-action"
@click="insertNode(preset.node)"
>
{{ t("routeEditor.fragmentsInsert") }}
</button>
</div>
</div>
<div class="fragments-list">
<div v-if="!fragments.length" class="hint">{{ t("routeEditor.fragmentsEmpty") }}</div>
<div v-for="frag in fragments" :key="frag.id" class="fragment-row">
<span class="fragment-name">{{ frag.name }}</span>
<button
type="button"
class="btn btn-ghost fragment-action"
@click="insertFragment(frag)"
>
{{ t("routeEditor.fragmentsInsert") }}
</button>
<button
type="button"
class="icon-btn danger"
:title="t('routeEditor.fragmentsDelete')"
@click="deleteFragment(frag)"
>
✕
</button>
</div>
</div>
<div class="field fragment-save">
<input
v-model="fragmentName"
class="input"
:placeholder="t('routeEditor.fragmentsNamePlaceholder')"
/>
<button type="button" class="btn btn-ghost" @click="saveAsFragment">
{{ t("routeEditor.fragmentsSave") }}
</button>
</div>
<div v-if="fragmentError" class="err">{{ fragmentError }}</div>
</section>
<section class="editor-section">
<h3 class="editor-section-title">{{ t("routeEditor.sectionTargets") }}</h3>
<div v-for="(tg, i) in form.targets" :key="i" class="target-row">
<select v-model="tg.platform" class="tg-select">
<option value="discord">Discord</option>
<option value="telegram">Telegram</option>
<option value="feishu">{{ t("routeEditor.platformFeishu") }}</option>
</select>
<template v-if="tg.platform === 'discord'">
<input
v-model="tg.channelId"
class="input tg-in1"
:placeholder="t('routeEditor.channelPlaceholder')"
/>
<input
v-model="tg.threadId"
class="input tg-in2"
:placeholder="t('routeEditor.threadPlaceholder')"
/>
</template>
<template v-else-if="tg.platform === 'telegram'">
<input
v-model="tg.chatId"
class="input tg-in1"
:placeholder="t('routeEditor.chatPlaceholder')"
/>
<input
v-model="tg.topicId"
class="input tg-in2"
:placeholder="t('routeEditor.topicPlaceholder')"
/>
</template>
<template v-else>
<input
v-model="tg.chatId"
class="input tg-in1"
:placeholder="t('routeEditor.feishuChatPlaceholder')"
/>
</template>
<button
type="button"
class="icon-btn danger tg-del"
:title="t('routeEditor.remove')"
@click="form.targets.splice(i, 1)"
>
✕
</button>
</div>
<button type="button" class="btn btn-ghost add-filter" @click="addTarget">
{{ t("routeEditor.addTarget") }}
</button>
<div v-if="targetError" class="err">{{ targetError }}</div>
</section>
<div v-if="formError" class="err">{{ formError }}</div>
</form>
<div class="editor-foot">
<button class="btn btn-ghost" @click="close">{{ t("routeEditor.cancel") }}</button>
<button class="btn btn-accent" :disabled="saving" @click="save">
{{ t("routeEditor.save") }}
</button>
<div class="fragments-list">
<div v-if="!fragments.length" class="hint">{{ t("routeEditor.fragmentsEmpty") }}</div>
<div v-for="frag in fragments" :key="frag.id" class="fragment-row">
<span class="fragment-name">{{ frag.name }}</span>
<RcButton
type="button"
variant="ghost"
size="sm"
class="fragment-action"
@click="insertFragment(frag)"
>
{{ t("routeEditor.fragmentsInsert") }}
</RcButton>
<RcButton
type="button"
variant="destructive"
size="icon"
:title="t('routeEditor.fragmentsDelete')"
@click="deleteFragment(frag)"
>
✕
</RcButton>
</div>
</div>
</aside>
</Transition>
</Teleport>
<div class="field fragment-save">
<RcInput
v-model="fragmentName"
:placeholder="t('routeEditor.fragmentsNamePlaceholder')"
/>
<RcButton type="button" variant="ghost" @click="saveAsFragment">
{{ t("routeEditor.fragmentsSave") }}
</RcButton>
</div>
<div v-if="fragmentError" class="err">{{ fragmentError }}</div>
</section>
<section class="editor-section">
<h3 class="editor-section-title">{{ t("routeEditor.sectionTargets") }}</h3>
<div v-for="(tg, i) in form.targets" :key="i" class="target-row">
<RcSelect
v-model="tg.platform"
class="[grid-area:select]"
:options="[
{ label: 'Discord', value: 'discord' },
{ label: 'Telegram', value: 'telegram' },
{ label: t('routeEditor.platformFeishu'), value: 'feishu' },
]"
/>
<template v-if="tg.platform === 'discord'">
<RcInput
v-model="tg.channelId"
class="[grid-area:in1]"
:placeholder="t('routeEditor.channelPlaceholder')"
/>
<RcInput
v-model="tg.threadId"
class="[grid-area:in2]"
:placeholder="t('routeEditor.threadPlaceholder')"
/>
</template>
<template v-else-if="tg.platform === 'telegram'">
<RcInput
v-model="tg.chatId"
class="[grid-area:in1]"
:placeholder="t('routeEditor.chatPlaceholder')"
/>
<RcInput
v-model="tg.topicId"
class="[grid-area:in2]"
:placeholder="t('routeEditor.topicPlaceholder')"
/>
</template>
<template v-else>
<RcInput
v-model="tg.chatId"
class="[grid-area:in1]"
:placeholder="t('routeEditor.feishuChatPlaceholder')"
/>
</template>
<RcButton
type="button"
variant="destructive"
size="icon"
class="[grid-area:del] justify-self-end"
:title="t('routeEditor.remove')"
@click="form.targets.splice(i, 1)"
>
✕
</RcButton>
</div>
<RcButton type="button" variant="ghost" class="add-filter" @click="addTarget">
{{ t("routeEditor.addTarget") }}
</RcButton>
<div v-if="targetError" class="err">{{ targetError }}</div>
</section>
<div v-if="formError" class="err">{{ formError }}</div>
</form>
<template #footer>
<div class="editor-foot">
<RcButton variant="ghost" @click="close">{{ t("routeEditor.cancel") }}</RcButton>
<RcButton variant="primary" :loading="saving" @click="save">
{{ t("routeEditor.save") }}
</RcButton>
</div>
</template>
</RcDialog>
</template>
<style scoped>
:deep(.editor-foot) {
display: flex;
justify-content: flex-end;
gap: 0.5rem;
border-top: 1px solid rgb(var(--wh-border));
background: rgb(var(--wh-surface));
padding: 1rem 1.5rem;
box-shadow: 0 -8px 24px -16px rgba(15, 23, 42, 0.18);
}
</style>
+39 -36
View File
@@ -4,25 +4,21 @@
<span class="kpi-label">{{ t("logs.lastSends", { n: logs.length }) }}</span>
<div class="log-filters">
<label class="filter-label">{{ t("logs.filterGroup") }}</label>
<select
<RcSelect
class="filter-select"
:value="selectedGroupId"
:model-value="selectedGroupId || 'all'"
:options="groupOptions"
:disabled="loading"
@change="onGroupFilter"
>
<option value="">{{ t("logs.allGroups") }}</option>
<option v-for="g in groups" :key="g.id" :value="g.id">
{{ g.name || g.id }}
</option>
</select>
@update:model-value="onGroupFilter"
/>
</div>
<button class="btn btn-ghost btn-sm" :disabled="loading" @click="refresh">
<RcButton variant="ghost" size="sm" :disabled="loading" @click="refresh">
{{ t("logs.refresh") }}
</button>
</RcButton>
</div>
<p v-if="error" class="err">{{ error }}</p>
<p v-else-if="!loading && !logs.length" class="empty-log">{{ t("logs.empty") }}</p>
<RcEmptyState v-else-if="!loading && !logs.length" :title="t('logs.empty')" class="empty-log" />
<div class="log-list">
<article
@@ -55,30 +51,28 @@
</article>
</div>
<div v-if="detailOpen" class="modal-overlay" @click.self="closeDetail">
<div class="log-detail">
<div class="detail-head">
<h3>{{ t("logs.detailTitle") }}</h3>
<button class="icon-btn" @click="closeDetail">✕</button>
</div>
<RcDialog
:open="detailOpen"
:title="t('logs.detailTitle')"
class="log-detail"
@update:open="onDetailOpenChange"
>
<div v-if="detailLoading" class="flex justify-center py-8"><RcSpinner size="sm" /></div>
<p v-else-if="detailError" class="err">{{ detailError }}</p>
<p v-if="detailLoading" class="empty-log">{{ t("status.loading") }}</p>
<p v-else-if="detailError" class="err">{{ detailError }}</p>
<dl v-else-if="detail" class="detail-grid">
<template v-for="row in detailRows" :key="row.label">
<dt>{{ row.label }}</dt>
<dd>
<pre v-if="row.block" class="log-block">{{ row.value }}</pre>
<code v-else-if="row.code">{{ row.value }}</code>
<span v-else>{{ row.value }}</span>
</dd>
</template>
</dl>
<dl v-else-if="detail" class="detail-grid">
<template v-for="row in detailRows" :key="row.label">
<dt>{{ row.label }}</dt>
<dd>
<pre v-if="row.block" class="log-block">{{ row.value }}</pre>
<code v-else-if="row.code">{{ row.value }}</code>
<span v-else>{{ row.value }}</span>
</dd>
</template>
</dl>
<p v-else class="err">{{ t("logs.detailMissing") }}</p>
</div>
</div>
<p v-else class="err">{{ t("logs.detailMissing") }}</p>
</RcDialog>
</div>
</template>
@@ -106,6 +100,11 @@ const detail = ref<SendRecord | null>(null);
const detailLoading = ref(false);
const detailError = ref("");
const groupOptions = computed(() => [
{ label: t("logs.allGroups"), value: "all" },
...props.groups.map((g) => ({ label: g.name || g.id, value: g.id })),
]);
const detailRows = computed(() => {
const l = detail.value;
if (!l) return [] as Array<{ label: string; value: string; code?: boolean; block?: boolean }>;
@@ -142,8 +141,8 @@ function refresh(): void {
emit("refresh");
}
function onGroupFilter(e: Event): void {
emit("update:selectedGroupId", (e.target as HTMLSelectElement).value);
function onGroupFilter(value: string): void {
emit("update:selectedGroupId", value === "all" ? "" : value);
emit("filter");
}
@@ -166,4 +165,8 @@ function closeDetail(): void {
detailOpen.value = false;
detail.value = null;
}
function onDetailOpenChange(open: boolean): void {
if (!open) closeDetail();
}
</script>
+8 -61
View File
@@ -1,68 +1,15 @@
<script setup lang="ts">
import { ref } from "vue";
const props = defineProps<{ modelValue: string[]; placeholder?: string }>();
const emit = defineEmits<{ (e: "update:modelValue", value: string[]): void }>();
const text = ref("");
function add(value: string) {
const v = value.trim();
if (!v) return;
if (props.modelValue.includes(v)) return;
emit("update:modelValue", [...props.modelValue, v]);
}
function onKeydown(e: KeyboardEvent) {
if (e.key === "Enter" || e.key === ",") {
e.preventDefault();
add(text.value);
text.value = "";
} else if (e.key === "Backspace" && text.value === "" && props.modelValue.length > 0) {
emit("update:modelValue", props.modelValue.slice(0, -1));
}
}
function onBlur() {
if (text.value) {
add(text.value);
text.value = "";
}
}
function remove(index: number) {
const next = [...props.modelValue];
next.splice(index, 1);
emit("update:modelValue", next);
}
</script>
<template>
<div
class="flex flex-wrap items-center gap-1 rounded-md border border-border bg-surface/60 px-2 py-1.5 focus-within:border-accent"
>
<span
v-for="(v, i) in modelValue"
:key="`${v}-${i}`"
class="inline-flex items-center gap-1 rounded bg-accent/15 px-2 py-0.5 text-xs text-accent"
>
{{ v }}
<button
type="button"
class="text-accent/70 hover:text-accent"
:aria-label="'remove'"
@click="remove(i)"
>
&times;
</button>
</span>
<input
v-model="text"
type="text"
class="min-w-[8rem] flex-1 bg-transparent text-sm text-text outline-none placeholder:text-text/40"
:placeholder="placeholder"
@keydown="onKeydown"
@blur="onBlur"
/>
</div>
<RcTagInput
:model-value="props.modelValue"
:placeholder="props.placeholder"
separator=","
unique
size="sm"
@update:model-value="emit('update:modelValue', $event)"
/>
</template>
+79
View File
@@ -0,0 +1,79 @@
<template>
<button
type="button"
class="theme-toggle-btn"
:title="label"
:aria-label="label"
@click="cycleTheme"
>
<component :is="currentIcon" :size="size" />
<span v-if="showLabel" class="theme-label">{{ shortLabel }}</span>
</button>
</template>
<script setup lang="ts">
import { Laptop, Moon, Sun } from "lucide-vue-next";
import { computed } from "vue";
import { useTheme } from "~/composables/useTheme";
const props = withDefaults(
defineProps<{
size?: number;
showLabel?: boolean;
compact?: boolean;
}>(),
{
size: 16,
showLabel: false,
compact: false,
},
);
const { theme, cycleTheme } = useTheme();
const currentIcon = computed(() => {
if (theme.value === "light") return Sun;
if (theme.value === "dark") return Moon;
return Laptop;
});
const label = computed(() => {
if (theme.value === "light") return "浅色模式 (点击切换为深色)";
if (theme.value === "dark") return "深色模式 (点击切换为跟随系统)";
return "跟随系统 (点击切换为浅色)";
});
const shortLabel = computed(() => {
if (theme.value === "light") return "浅色";
if (theme.value === "dark") return "深色";
return "自动";
});
</script>
<style scoped>
.theme-toggle-btn {
display: inline-flex;
align-items: center;
justify-content: center;
gap: 0.35rem;
padding: 0.4rem 0.55rem;
border-radius: 9999px;
border: 1px solid rgb(var(--wh-border));
background: rgb(var(--wh-surface));
color: rgb(var(--wh-muted));
font-size: 0.75rem;
font-weight: 600;
cursor: pointer;
transition: all 150ms ease;
}
.theme-toggle-btn:hover {
border-color: rgb(var(--wh-accent));
color: rgb(var(--wh-text));
background: rgb(var(--wh-surface-2));
}
.theme-label {
font-size: 0.75rem;
}
</style>
+16 -12
View File
@@ -1,5 +1,5 @@
<template>
<section class="members-panel webhook-panel">
<RcCard variant="outline" padding="md" class="members-panel webhook-panel">
<div class="panel-head">
<h3>{{ t("webhook.title") }}</h3>
<span class="lbl-note">{{ t("webhook.note") }}</span>
@@ -11,9 +11,9 @@
<div class="wh-row">
<span class="wh-label">{{ t("webhook.url") }}</span>
<code class="wh-value">{{ info.url }}</code>
<button class="btn btn-ghost btn-sm" @click="copy(info.url, 'url')">
<RcButton type="button" variant="ghost" size="sm" @click="copy(info.url, 'url')">
{{ copied === "url" ? t("webhook.copied") : t("webhook.copy") }}
</button>
</RcButton>
</div>
<div class="wh-row">
@@ -21,28 +21,32 @@
<code class="wh-value">{{
info.secret ? info.secret : info.hasSecret ? maskedSecret : t("webhook.noSecret")
}}</code>
<button
<RcButton
v-if="info.secret"
class="btn btn-ghost btn-sm"
type="button"
variant="ghost"
size="sm"
@click="copy(info.secret!, 'secret')"
>
{{ copied === "secret" ? t("webhook.copied") : t("webhook.copy") }}
</button>
</RcButton>
</div>
<p v-if="info.hasSecret && !info.secret" class="hint">{{ t("webhook.secretHidden") }}</p>
<div class="wh-actions">
<button class="btn btn-accent btn-sm" :disabled="busy" @click="onRegenerate">
<RcButton type="button" size="sm" :disabled="busy" @click="onRegenerate">
{{ info.hasSecret ? t("webhook.regenerate") : t("webhook.generate") }}
</button>
<button
</RcButton>
<RcButton
v-if="info.hasSecret"
class="btn btn-ghost btn-sm"
type="button"
variant="ghost"
size="sm"
:disabled="busy"
@click="onDisable"
>
{{ t("webhook.disable") }}
</button>
</RcButton>
</div>
<details class="wh-usage">
@@ -55,7 +59,7 @@
</template>
<div class="err">{{ error }}</div>
</section>
</RcCard>
</template>
<script setup lang="ts">