Skip to content

Commit d9f9bfa

Browse files
feat(channels): 可用渠道模型卡片支持一键复制模型名
卡片根元素由 button 改为 div + 拉伸按钮模式,避免按钮内嵌套 交互元素;新增复制按钮(relative 层叠于拉伸按钮之上),复用 useClipboard 与 copy/check 图标切换反馈。 Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
1 parent f5a5830 commit d9f9bfa

3 files changed

Lines changed: 34 additions & 7 deletions

File tree

‎frontend/src/components/channels/AvailableModelCard.vue‎

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
<template>
2-
<button
3-
type="button"
4-
class="group flex min-h-16 w-full cursor-pointer items-center gap-3 rounded-xl border border-gray-200 bg-white px-3 py-2.5 text-left shadow-sm transition-[border-color,background-color,box-shadow] duration-200 hover:border-gray-300 hover:bg-gray-50 hover:shadow-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary-500/60 dark:border-dark-700 dark:bg-dark-900/45 dark:hover:border-dark-600 dark:hover:bg-dark-800/70"
5-
:aria-label="t('availableChannels.viewModelDetails', { model: model.name })"
6-
:aria-expanded="expanded"
7-
@click="$emit('select')"
2+
<div
3+
class="group relative flex min-h-16 w-full cursor-pointer items-center gap-3 rounded-xl border border-gray-200 bg-white px-3 py-2.5 text-left shadow-sm transition-[border-color,background-color,box-shadow] duration-200 hover:border-gray-300 hover:bg-gray-50 hover:shadow-md dark:border-dark-700 dark:bg-dark-900/45 dark:hover:border-dark-600 dark:hover:bg-dark-800/70"
84
>
5+
<button
6+
type="button"
7+
class="absolute inset-0 rounded-xl focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary-500/60"
8+
:aria-label="t('availableChannels.viewModelDetails', { model: model.name })"
9+
:aria-expanded="expanded"
10+
@click="$emit('select')"
11+
/>
912
<span class="flex h-10 w-10 shrink-0 items-center justify-center rounded-xl bg-gray-50 ring-1 ring-inset ring-gray-200 dark:bg-dark-800 dark:ring-dark-700">
1013
<ModelIcon :model="model.name" size="20px" />
1114
</span>
@@ -48,6 +51,19 @@
4851
</span>
4952
</span>
5053

54+
<button
55+
type="button"
56+
class="relative flex h-7 w-7 shrink-0 items-center justify-center rounded-lg transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary-500/60"
57+
:class="copied
58+
? 'text-emerald-500 dark:text-emerald-400'
59+
: 'text-gray-300 hover:bg-gray-100 hover:text-gray-600 dark:text-dark-600 dark:hover:bg-dark-700 dark:hover:text-dark-300'"
60+
:title="t('availableChannels.copyModel', { model: model.name })"
61+
:aria-label="t('availableChannels.copyModel', { model: model.name })"
62+
@click="copyModelName"
63+
>
64+
<Icon :name="copied ? 'check' : 'copy'" size="sm" />
65+
</button>
66+
5167
<Icon
5268
name="chevronRight"
5369
size="sm"
@@ -56,7 +72,7 @@
5672
expanded ? 'rotate-90' : '',
5773
]"
5874
/>
59-
</button>
75+
</div>
6076
</template>
6177

6278
<script setup lang="ts">
@@ -66,6 +82,7 @@ import Icon from '@/components/icons/Icon.vue'
6682
import ModelIcon from '@/components/common/ModelIcon.vue'
6783
import type { UserSupportedModel } from '@/api/channels'
6884
import type { MonitorStatus } from '@/api/channelMonitor'
85+
import { useClipboard } from '@/composables/useClipboard'
6986
import { availableModelPriceSummary } from '@/utils/availableModelPricing'
7087
7188
export interface AvailableModelMonitorSummary {
@@ -97,6 +114,12 @@ const props = withDefaults(
97114
defineEmits<{ (event: 'select'): void }>()
98115
99116
const { t } = useI18n()
117+
const { copied, copyToClipboard } = useClipboard()
118+
119+
function copyModelName(): void {
120+
void copyToClipboard(props.model.name, t('availableChannels.copiedModel', { model: props.model.name }))
121+
}
122+
100123
const priceSummary = computed(() =>
101124
availableModelPriceSummary(
102125
props.model,

‎frontend/src/i18n/locales/en.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3680,6 +3680,8 @@ export default {
36803680
noGroups: "No accessible groups",
36813681
noPricing: "Pricing not configured",
36823682
viewModelDetails: "View details for {model}",
3683+
copyModel: "Copy {model}",
3684+
copiedModel: "Copied {model}",
36833685
monitor: {
36843686
unmonitored: "Not monitored",
36853687
sources: "{count} monitors",

‎frontend/src/i18n/locales/zh.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3607,6 +3607,8 @@ export default {
36073607
noGroups: "暂无可访问分组",
36083608
noPricing: "未配置定价",
36093609
viewModelDetails: "查看 {model} 详情",
3610+
copyModel: "复制 {model}",
3611+
copiedModel: "已复制 {model}",
36103612
monitor: {
36113613
unmonitored: "未配置监控",
36123614
sources: "{count} 个监控源",

0 commit comments

Comments
 (0)