style(console): redesign route cards for narrow screens

The card was one flex row whose badges, filter chips, targets and five
hand-drawn icon buttons squeezed the route name on small screens. It is
now a grid driven by a container query: name and actions share the top
line, the filter summary (clamped to two lines) and targets follow, and
the tags wrap below; from 40rem the tags move up beside the title.

Targets of the same platform collapse into one tag with a count, long
ids truncate instead of widening the page, and the actions use lucide
icons with accessible labels.
This commit is contained in:
翅膀 committed 2026-10-17 01:47:38 +08:00
1 parent 76eb2e445c
commit 2eac368602
4 files changed
+204 -247

No files matched your search

+1 -1
View File
@@ -108,7 +108,7 @@
<p v-if="groupRoutesError" class="err">{{ groupRoutesError }}</p>
<section class="space-y-2.5">
<section class="route-list">
<RouteCard
v-for="(r, i) in groupRoutes"
:key="r.id"
+138 -186
View File
@@ -1,203 +1,131 @@
<template>
<RcCard variant="outline" padding="none" :class="cardClass">
<div class="route-card-main">
<div class="route-card-header">
<div class="route-row">
<div class="route-lead">
<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">
<RcBadge
v-for="(tg, i) in route.targets"
:key="i"
size="xs"
class="route-badge"
:class="
tg.platform === 'telegram'
? 'route-badge-tg'
: tg.platform === 'feishu'
? 'route-badge-fs'
: 'route-badge-dc'
"
>
<span
class="route-badge-dot"
:class="
tg.platform === 'telegram'
? 'bg-info'
: tg.platform === 'feishu'
? 'bg-warn'
: 'bg-accent'
"
></span>
{{
tg.platform === "telegram"
? "Telegram"
: tg.platform === "feishu"
? t("route.feishu")
: "Discord"
}}
</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>
<span v-else class="dot" :class="route.enabled ? 'ok' : 'bad'"></span>
</div>
<div class="flex flex-wrap items-center gap-3">
<div class="route-card-filters">
<span v-if="summary" class="route-chip">
<span class="route-chip-val">{{ summary }}</span>
</span>
<span v-else class="route-chip route-chip-empty">
<span class="route-chip-type">{{ t("route.noFilters") }}</span>
</span>
</div>
<div class="route-title">
<span class="route-name">{{ displayName }}</span>
<span class="route-id">{{ route.id }}</span>
</div>
<div v-if="hasTags" class="route-tags">
<RcBadge
v-for="p in platforms"
:key="p.platform"
size="xs"
class="route-badge"
:class="`route-badge-${p.platform}`"
>
<span class="route-badge-dot"></span>
{{ platformLabel(p.platform) }}<template v-if="p.count > 1"> ×{{ p.count }}</template>
</RcBadge>
<RcBadge
v-if="route.discordRoleIds?.length"
size="xs"
class="route-badge route-badge-role"
:title="route.discordRoleIds.join(', ')"
>@roles</RcBadge
>
<RcBadge v-if="route.fallback" size="xs" class="route-badge route-badge-fallback">{{
t("route.fallback")
}}</RcBadge>
<RcBadge v-if="route.stop" size="xs" class="route-badge route-badge-stop">{{
t("route.stop")
}}</RcBadge>
</div>
<div v-if="!readonly" class="route-actions">
<RcButton
type="button"
variant="ghost"
size="icon"
class="h-8 w-8 text-muted hover:text-text"
:disabled="atFirst"
:title="t('route.moveUp')"
:aria-label="t('route.moveUp')"
@click="emit('move', route, -1)"
>
<ChevronUp :size="15" />
</RcButton>
<RcButton
type="button"
variant="ghost"
size="icon"
class="h-8 w-8 text-muted hover:text-text"
:disabled="atLast"
:title="t('route.moveDown')"
:aria-label="t('route.moveDown')"
@click="emit('move', route, 1)"
>
<ChevronDown :size="15" />
</RcButton>
<RcButton
type="button"
variant="ghost"
size="icon"
class="h-8 w-8 text-muted hover:text-text"
:title="t('routeEditor.editTitle')"
:aria-label="t('routeEditor.editTitle')"
@click="emit('edit', route)"
>
<Pencil :size="15" />
</RcButton>
<RcButton
type="button"
variant="ghost"
color="error"
size="icon"
class="h-8 w-8 text-muted hover:text-bad"
:title="t('routes.delete')"
:aria-label="t('routes.delete')"
@click="emit('delete', route)"
>
<Trash2 :size="15" />
</RcButton>
</div>
<div class="route-body">
<p class="route-summary" :class="{ 'is-empty': !summary }" :title="summary || undefined">
{{ summary || t("route.noFilters") }}
</p>
<div v-if="route.targets.length" class="route-card-targets">
<div v-for="(tg, i) in route.targets" :key="i" class="route-target">
<div class="route-target-row">
<span class="route-target-label">
<template v-if="tg.platform === 'telegram' || tg.platform === 'feishu'">{{
t("route.chat")
}}</template>
<template v-else-if="tg.threadId">{{ t("route.thread") }}</template>
<template v-else>{{ t("route.channel") }}</template>
</span>
<code class="route-target-id">
<template v-if="tg.platform === 'telegram' || tg.platform === 'feishu'">{{
tg.chatId
}}</template>
<template v-else-if="tg.threadId">{{ tg.threadId }}</template>
<template v-else>{{ tg.channelId }}</template>
</code>
</div>
</div>
<span v-for="(tg, i) in route.targets" :key="i" class="route-target-row">
<span class="route-target-label">
<template v-if="tg.platform === 'telegram' || tg.platform === 'feishu'">{{
t("route.chat")
}}</template>
<template v-else-if="tg.threadId">{{ t("route.thread") }}</template>
<template v-else>{{ t("route.channel") }}</template>
</span>
<code class="route-target-id">
<template v-if="tg.platform === 'telegram' || tg.platform === 'feishu'">{{
tg.chatId
}}</template>
<template v-else-if="tg.threadId">{{ tg.threadId }}</template>
<template v-else>{{ tg.channelId }}</template>
</code>
</span>
</div>
</div>
</div>
<div v-if="!readonly" class="route-card-actions">
<RcButton
type="button"
variant="ghost"
size="icon"
class="route-action-btn"
:disabled="atFirst"
:title="t('route.moveUp')"
@click="$emit('move', route, -1)"
>
<svg
width="14"
height="14"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="m18 15-6-6-6 6" />
</svg>
</RcButton>
<RcButton
type="button"
variant="ghost"
size="icon"
class="route-action-btn"
:disabled="atLast"
:title="t('route.moveDown')"
@click="$emit('move', route, 1)"
>
<svg
width="14"
height="14"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="m6 9 6 6 6-6" />
</svg>
</RcButton>
<RcButton
type="button"
variant="ghost"
size="icon"
class="route-action-btn"
:title="t('routeEditor.editTitle')"
@click="$emit('edit', route)"
>
<svg
width="14"
height="14"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<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>
</RcButton>
<RcButton
type="button"
variant="destructive"
size="icon"
class="route-action-btn route-action-btn-danger"
:title="t('routeEditor.close')"
@click="$emit('delete', route)"
>
<svg
width="14"
height="14"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="M18 6 6 18" />
<path d="m6 6 12 12" />
</svg>
</RcButton>
</div>
</RcCard>
</template>
<script setup lang="ts">
import type { FilterNode, Route } from "~/types";
import { ChevronDown, ChevronUp, Pencil, Trash2 } from "lucide-vue-next";
import type { FilterNode, Route, RouteTarget } from "~/types";
import { describeNode } from "~/composables/useFilterNode";
type Platform = NonNullable<RouteTarget["platform"]>;
const { t } = useI18n();
const props = defineProps<{
@@ -207,11 +135,6 @@ const props = defineProps<{
readonly?: boolean;
}>();
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;
@@ -219,8 +142,37 @@ const emit = defineEmits<{
(e: "move", route: Route, dir: -1 | 1): void;
}>();
const displayName = computed(() => props.route.name || t("route.untitled"));
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"}`);
/** One tag per platform (in target order) with how many targets use it. */
const platforms = computed(() => {
const counts = new Map<Platform, number>();
for (const tg of props.route.targets) {
const platform: Platform = tg.platform ?? "discord";
counts.set(platform, (counts.get(platform) ?? 0) + 1);
}
return [...counts].map(([platform, count]) => ({ platform, count }));
});
const hasTags = computed(
() =>
platforms.value.length > 0 ||
!!props.route.discordRoleIds?.length ||
!!props.route.fallback ||
!!props.route.stop,
);
function platformLabel(platform: Platform): string {
if (platform === "telegram") return "Telegram";
if (platform === "feishu") return t("route.feishu");
return "Discord";
}
function onToggle(enabled: boolean): void {
const next = { ...props.route, enabled };
emit("toggle", next);
emit("toggle", { ...props.route, enabled });
}
</script>