Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(desktop): 补齐 API key 输入的明文切换 (#1315)
zhanghengxdfc18318411d0
diff --git a/apps/desktop/src/renderer/__tests__/addProviderWizardPresetEntry.test.tsx b/apps/desktop/src/renderer/__tests__/addProviderWizardPresetEntry.test.tsxindex 9bb6713aa4..b1c8cde25a 100644--- a/apps/desktop/src/renderer/__tests__/addProviderWizardPresetEntry.test.tsx+++ b/apps/desktop/src/renderer/__tests__/addProviderWizardPresetEntry.test.tsx@@ -5,6 +5,8 @@* 1. entry={kind:'preset',presetId}:presets 异步载入后直达表单步(step 2,* 名称预填预设名),一次性消费。* 2. presetId 在目录里不存在 → 回落目录第一步,不假装直达。+ * 3. API Key 输入默认遮罩,但必须能显形核对——粘错 key / 多余空格 / 前缀不对+ * 在遮罩下查不出来。向导曾漏掉这个切换,只有编辑弹窗有(见 SettingsTextInput)。*/import { cleanup, fireEvent, render, screen, waitFor } from '@testing-library/react';@@ -176,6 +178,34 @@ describe('AddProviderWizard — preset 直达', () => {expect(screen.queryByPlaceholderText('settings.providers.wizard.searchPlaceholder')).toBeNull();});+ it('API Key 默认遮罩,eye 能切明文再切回(粘贴后核对)', async () => {+ renderWizard('deepseek');++ const keyInput = await screen.findByPlaceholderText('sk-…');+ expect(keyInput.getAttribute('type')).toBe('password');+ // 密钥框要挡住密码管理器建议与拼写红线(普通文本字段则保留浏览器默认,不禁用)。+ expect(keyInput.getAttribute('autocomplete')).toBe('off');+ expect(keyInput.getAttribute('spellcheck')).toBe('false');++ // 遮罩态按钮语义是「显示密钥」,点击后翻转为「隐藏密钥」。+ fireEvent.click(screen.getByLabelText('settings.apiKey.showKey'));+ expect(keyInput.getAttribute('type')).toBe('text');++ fireEvent.click(screen.getByLabelText('settings.apiKey.hideKey'));+ expect(keyInput.getAttribute('type')).toBe('password');+ });++ it('密钥框底色是 DESIGN.md §4 的 --surface-elevated,不是 settings 的 ivory', async () => {+ renderWizard('deepseek');++ // 共享化时把底色顺手换成 --settings-input-bg 会退化:该 token 解析到+ // --surface-card-ivory,而 ProvidersSection 的卡片本身就是这个值,行内密钥框会与卡片+ // 同色、只剩边框。DESIGN.md §4 input/text 规定 fill = --surface-elevated。+ const cls = (await screen.findByPlaceholderText('sk-…')).className;+ expect(cls).toContain('bg-[var(--surface-elevated)]');+ expect(cls).not.toContain('bg-[var(--settings-input-bg)]');+ });+it('OAuth 授权步提供「改用 API Key 接入」→ 切到官方 API 预设表单', async () => {render(React.createElement(AddProviderWizard, {diff --git a/apps/desktop/src/renderer/components/settings/AddProviderWizard.tsx b/apps/desktop/src/renderer/components/settings/AddProviderWizard.tsxindex 5afc76bef1..394b54976c 100644--- a/apps/desktop/src/renderer/components/settings/AddProviderWizard.tsx+++ b/apps/desktop/src/renderer/components/settings/AddProviderWizard.tsx@@ -30,6 +30,7 @@ import { isChatGptConnectionConnected, useCodexAuth } from '@/hooks/useCodexAuthimport { useProviderOAuthDeviceCode } from '@/hooks/useProviderOAuthDeviceCode';import { hasProviderLogo, ProviderLogoMark } from '@/components/icons/ProviderLogoMark';import { OAuthDeviceCodeCard } from './OAuthDeviceCodeCard';+import { SettingsTextInput } from './SettingsTextInput';import {isLoopbackProviderUrl,@@ -1231,18 +1232,7 @@ export function AddProviderWizard({<label className="text-12 font-medium" style={{ color: 'var(--text-secondary)' }}>{t('settings.providers.custom.fields.apiKey')}</label>- <input- type="password"- value={apiKey}- onChange={(e) => setApiKey(e.target.value)}- autoComplete="off"- className="h-9 rounded-full border px-4 font-mono text-13 outline-none focus:ring-2 focus:ring-[var(--focus-ring)]"- style={{- borderColor: 'var(--border-default)',- backgroundColor: 'var(--surface-elevated)',- color: 'var(--settings-section-title)',- }}- />+ <SettingsTextInput value={apiKey} onChange={setApiKey} size="md" mono secret /></div></div>)}@@ -1270,18 +1260,13 @@ export function AddProviderWizard({<label className="text-12 font-medium" style={{ color: 'var(--text-secondary)' }}>{t('settings.providers.custom.fields.apiKey')}</label>- <input- type="password"+ <SettingsTextInputvalue={apiKey}- onChange={(e) => setApiKey(e.target.value)}+ onChange={setApiKey}placeholder="sk-…"- autoComplete="off"- className="h-9 rounded-full border px-4 font-mono text-13 outline-none focus:ring-2 focus:ring-[var(--focus-ring)]"- style={{- borderColor: 'var(--border-default)',- backgroundColor: 'var(--surface-elevated)',- color: 'var(--settings-section-title)',- }}+ size="md"+ mono+ secret/></div>) : (diff --git a/apps/desktop/src/renderer/components/settings/CustomProviderDialog.tsx b/apps/desktop/src/renderer/components/settings/CustomProviderDialog.tsxindex 3181da5fcd..8d8c05d774 100644--- a/apps/desktop/src/renderer/components/settings/CustomProviderDialog.tsx+++ b/apps/desktop/src/renderer/components/settings/CustomProviderDialog.tsx@@ -7,23 +7,16 @@** 「提供商 ID」内部句柄由显示名自动 slug 派生 + 去重,对用户隐藏(密钥名/文件名不能含 . 或 /)。* 配置经 maker IPC 入 localDb;密钥按 runtime 经 safeStorage 存(见 lib/customProviders)。- * 编辑态密钥遮罩、留空 = 不改;id 不可改。颜色全走主题 token。+ * 编辑态回填已存密钥(默认遮罩,eye 可显形核对)、留空 = 不改;id 不可改。颜色全走主题 token。+ *+ * 本弹窗的输入统一传 `surface="ivory"`:面板是白色(`--surface-elevated`),ivory 底给出 fill+ * 抬升,这是收敛进 SettingsTextInput 之前就有的底色,原样保留。共享组件的默认底色是+ * DESIGN.md §4 规定的 `--surface-elevated`(压在 ivory settings 卡上的输入必须用它)。*/import { useCallback, useEffect, useRef, useState } from 'react';import { useTranslation } from 'react-i18next';-import {- Check,- ChevronDown,- Eye,- EyeOff,- Plug,- Plus,- RefreshCw,- Sparkles,- Trash2,- X,-} from 'lucide-react';+import { Check, ChevronDown, Plug, Plus, RefreshCw, Sparkles, Trash2, X } from 'lucide-react';import { cn } from '@/lib/utils';import { toast } from '@/lib/toast';@@ -61,6 +54,7 @@ import type {ProviderRuntimeModelConfig,ProviderWireProtocol,} from '@cindy/model-providers';+import { SettingsTextInput } from './SettingsTextInput';const AGENTS: AgentKind[] = ['claude-code', 'codex'];@@ -169,43 +163,6 @@ function isCommittableWindowText(text: string): boolean {return parsed > 0n && parsed <= BigInt(Number.MAX_SAFE_INTEGER);}-function TextInput({- value,- onChange,- onBlur,- placeholder,- type = 'text',- trailing,-}: {- value: string;- onChange: (v: string) => void;- onBlur?: () => void;- placeholder?: string;- type?: string;- trailing?: React.ReactNode;-}) {- return (- <div className="relative">- <input- type={type}- value={value}- onChange={(e) => onChange(e.target.value)}- onBlur={onBlur}- placeholder={placeholder}- className={cn(- // 单行输入按设计规范走药丸圆角(DESIGN.md §4-5:9999px,明令禁止 10px)。- 'h-[40px] w-full rounded-full pl-[12px] text-14 outline-none transition-colors',- trailing ? 'pr-9' : 'pr-[12px]',- 'text-[var(--settings-input-text)] placeholder:text-[var(--settings-input-placeholder)]',- 'border border-[var(--settings-input-border)] bg-[var(--settings-input-bg)] focus:border-[var(--settings-input-border-focus)]',- )}- style={{ userSelect: 'text', WebkitUserSelect: 'text' }}- />- {trailing}- </div>- );-}-/*** 预设模板下拉——统一的 Popover 菜单(与外观设置 FamilyDropdown 同款样式)。* 不用原生 <select>:其展开菜单由系统绘制,不吃主题 token,视觉与应用内其它下拉不一致。@@ -315,7 +272,6 @@ export function CustomProviderDialog({const [activeTab, setActiveTab] = useState<AgentKind>(() => (initial && VISIBLE_AGENTS.find((a) => initial.runtimes[a])) || 'claude-code',);- const [showKey, setShowKey] = useState(false);const [hasKey, setHasKey] = useState<Record<AgentKind, boolean>>({'claude-code': false,codex: false,@@ -1006,7 +962,8 @@ export function CustomProviderDialog({{/* 显示名称(共享) */}<div className="flex flex-col gap-[7px]"><FieldLabel>{t('settings.providers.custom.fields.name')}</FieldLabel>- <TextInput+ <SettingsTextInput+ surface="ivory"value={name}onChange={setName}placeholder={t('settings.providers.custom.fields.namePlaceholder')}@@ -1086,7 +1043,8 @@ export function CustomProviderDialog({<FieldLabel>{t(`settings.providers.custom.authMode.fields.${field}`)}</FieldLabel>- <TextInput+ <SettingsTextInput+ surface="ivory"value={oauthFields[field]}onChange={(v) => setOauthFields((prev) => ({ ...prev, [field]: v }))}placeholder={ph}@@ -1195,7 +1153,8 @@ export function CustomProviderDialog({{/* 基础 URL */}<div className="flex flex-col gap-[7px]"><FieldLabel>{t('settings.providers.custom.fields.baseUrl')}</FieldLabel>- <TextInput+ <SettingsTextInput+ surface="ivory"value={f.baseUrl}onChange={(v) => patch(activeTab, (x) => ({ ...x, baseUrl: v }))}placeholder={t('settings.providers.custom.fields.baseUrlPlaceholder')}@@ -1205,7 +1164,8 @@ export function CustomProviderDialog({{/* 精确推理路径:给非标准兼容端点使用;留空仍按所选协议推导。 */}<div className="flex flex-col gap-[7px]"><FieldLabel>{t('settings.providers.custom.fields.requestPath')}</FieldLabel>- <TextInput+ <SettingsTextInput+ surface="ivory"value={f.requestPath}onChange={(v) => patch(activeTab, (x) => ({ ...x, requestPath: v }))}placeholder={@@ -1238,23 +1198,13 @@ export function CustomProviderDialog({</span>)}</div>- <TextInput+ <SettingsTextInput+ surface="ivory"value={f.apiKey}onChange={(v) => patch(activeTab, (x) => ({ ...x, apiKey: v }))}placeholder={keyPlaceholder}- type={showKey ? 'text' : 'password'}- trailing={- <button- type="button"- onClick={() => setShowKey((v) => !v)}- className="absolute right-[12px] top-1/2 -translate-y-1/2 text-[var(--settings-eye-icon)] transition-colors hover:text-[var(--settings-eye-icon-hover)]"- aria-label={- showKey ? t('settings.apiKey.hideKey') : t('settings.apiKey.showKey')- }- >- {showKey ? <Eye size={16} /> : <EyeOff size={16} />}- </button>- }+ mono+ secret/><span className="text-12 text-[var(--text-tertiary)]">{t('settings.providers.custom.fields.apiKeyHelp')}@@ -1291,7 +1241,8 @@ export function CustomProviderDialog({{f.models.map((m, i) => (<div key={i} className="flex items-center gap-2"><div className="flex-1">- <TextInput+ <SettingsTextInput+ surface="ivory"value={m.id}onChange={(v) =>patch(activeTab, (x) => ({@@ -1305,7 +1256,8 @@ export function CustomProviderDialog({/></div><div className="flex-1">- <TextInput+ <SettingsTextInput+ surface="ivory"value={m.name}onChange={(v) =>patch(activeTab, (x) => ({@@ -1324,7 +1276,8 @@ export function CustomProviderDialog({只接受正整数(允许逗号/下划线/空格做分隔),其它字符直接拒绝本次变更(保持原值)——绝不剥字符再拼数字,-5 / 1e6 /262144.9 这类输入不得被静默纠正成另一个合法值(review P1)。 */}- <TextInput+ <SettingsTextInput+ surface="ivory"value={windowDrafts[`${activeTab}:${i}`]?? (m.contextWindow != null ? String(m.contextWindow) : '')@@ -1426,7 +1379,8 @@ export function CustomProviderDialog({{f.headers.map((h, i) => (<div key={i} className="flex items-center gap-2"><div className="flex-1">- <TextInput+ <SettingsTextInput+ surface="ivory"value={h.name}onChange={(v) =>patch(activeTab, (x) => ({@@ -1438,7 +1392,8 @@ export function CustomProviderDialog({/></div><div className="flex-1">- <TextInput+ <SettingsTextInput+ surface="ivory"value={h.value}onChange={(v) =>patch(activeTab, (x) => ({diff --git a/apps/desktop/src/renderer/components/settings/ProvidersSection.tsx b/apps/desktop/src/renderer/components/settings/ProvidersSection.tsxindex 771e933e28..b28121353b 100644--- a/apps/desktop/src/renderer/components/settings/ProvidersSection.tsx+++ b/apps/desktop/src/renderer/components/settings/ProvidersSection.tsx@@ -54,6 +54,7 @@ import {import { CustomProviderDialog } from './CustomProviderDialog';import { AddProviderWizard, type WizardEntry } from './AddProviderWizard';import { OAuthDeviceCodeCard } from './OAuthDeviceCodeCard';+import { SettingsTextInput } from './SettingsTextInput';import { buildUnionRows, UnifiedModelList } from './UnifiedModelList';import { AnthropicMark } from '@/components/icons/AnthropicMark';import { OpenAIMark } from '@/components/icons/OpenAIMark';@@ -604,18 +605,14 @@ function ImageApiKeyRow({</>) : (<>- <input- type="password"+ <SettingsTextInputvalue={draftKey}- onChange={(e) => setDraftKey(e.target.value)}- autoComplete="off"+ onChange={setDraftKey}placeholder={t('settings.providers.imagesKey.placeholder')}- className="h-8 min-w-0 flex-1 rounded-full border px-3 font-mono text-12 outline-none focus:ring-2 focus:ring-[var(--focus-ring)]"- style={{- borderColor: 'var(--border-default)',- backgroundColor: 'var(--surface-elevated)',- color: 'var(--settings-section-title)',- }}+ size="sm"+ mono+ secret+ className="min-w-0 flex-1"/><PillButtonlabel={t('settings.providers.imagesKey.save')}@@ -836,7 +833,9 @@ function GenericOAuthHeader({* 内置 API-key 供应商详情头(如 Gemini 图像来源,2026-07 图像多来源)。* 连接态 = key 已存(provider-service builtinApiKeyConnected);「更换」重写 key,* 「断开」删除 key(safeStorage),断开后左栏行按既有契约消失、重连入口回向导。- * key 全程掩码,不回显明文。+ * **已存 key 永不回显**:它是 MAIN_ONLY 键,renderer 只能查存在性/写/删(见+ * ImageApiKeyRow 注释),架构上拿不到明文。输入框的明文切换只显形用户本次输入的+ * 草稿(草稿本就在 renderer state 里),不构成凭证下放。*/function BuiltinApiKeyHeader({provider,@@ -922,18 +921,14 @@ function BuiltinApiKeyHeader({const detail = editing ? (<div className="flex items-center gap-2 pt-2">- <input- type="password"+ <SettingsTextInputvalue={draftKey}- onChange={(e) => setDraftKey(e.target.value)}- autoComplete="off"+ onChange={setDraftKey}placeholder={t('settings.providers.builtinApiKey.keyPlaceholder')}- className="h-8 min-w-0 flex-1 rounded-full border px-3 font-mono text-12 outline-none focus:ring-2 focus:ring-[var(--focus-ring)]"- style={{- borderColor: 'var(--border-default)',- backgroundColor: 'var(--surface-elevated)',- color: 'var(--settings-section-title)',- }}+ size="sm"+ mono+ secret+ className="min-w-0 flex-1"/><PillButtonlabel={t('settings.providers.builtinApiKey.saveKey')}diff --git a/apps/desktop/src/renderer/components/settings/SettingsTextInput.tsx b/apps/desktop/src/renderer/components/settings/SettingsTextInput.tsxnew file mode 100644index 0000000000..4d1f382192--- /dev/null+++ b/apps/desktop/src/renderer/components/settings/SettingsTextInput.tsx@@ -0,0 +1,160 @@+/**+ * SettingsTextInput —— 设置页统一的单行文本 / 密钥输入框。+ *+ * 收敛背景:设置页各处原本各写一份私有 TextInput(高度 32 / 36 / 40 / 42px 混杂),+ * 密钥字段的「明文切换」只在 CustomProviderDialog 做了——同一个 API key 在「添加供应商」+ * 向导里看不见、在编辑弹窗里看得见。本组件以 CustomProviderDialog 那份为基线(它是唯一+ * 走 DESIGN.md §4-5 药丸圆角的实现),把 eye 显形收进 `secret`,调用点不再各自手写+ * showKey state + 按钮。+ *+ * `secret` 只显形**用户本次输入的草稿**(草稿本就在 renderer state 里)。已存密钥要不要+ * 回显由调用方决定:内置 API-key 走 MAIN_ONLY 的 builtinApiKey* IPC,renderer 架构上读不到+ * 明文,回显无从谈起;自定义供应商的 key 由调用方显式读回。本组件不触碰凭证读取边界。+ *+ * 尺寸:DESIGN.md §4 锁定单行输入的 radius(9999px)与颜色 token,未锁高度,因此保留+ * sm / md / lg 三档以贴合各调用点既有版式。radius 与 `--settings-input-*` token 不可变。+ */+import { useState } from 'react';+import { Eye, EyeOff } from 'lucide-react';+import { useTranslation } from 'react-i18next';++import { cn } from '@/lib/utils';++export type SettingsTextInputSize = 'sm' | 'md' | 'lg';+export type SettingsTextInputSurface = 'elevated' | 'ivory';++/**+ * 底色:默认 `elevated` = DESIGN.md §4 `input/text` 规定的 fill(`--surface-elevated`)。+ *+ * `ivory` 是给「输入压在白色弹窗面板上」的调用点保留的既有底色(`--settings-input-bg`,+ * 解析到 `--surface-card-ivory`)。这份 ivory 在设计文档里没有任何背书,属 colors.ts 的+ * 无文档漂移;它在白面板上能给出 fill 抬升,所以不在本 PR 里翻成白色,但也不能当默认——+ * settings 卡片本身就是 ivory(`--settings-theme-card-bg`),ivory 输入压在 ivory 卡上会和+ * 背景同色,填充对比度归零。settings 域这处 ivory / elevated 的收口是独立议题。+ */+const SURFACE_STYLES: Record<SettingsTextInputSurface, string> = {+ elevated: 'bg-[var(--surface-elevated)]',+ ivory: 'bg-[var(--settings-input-bg)]',+};++/** 各档的框体几何 + 无 trailing 时的右内边距(有 trailing 时统一让位给按钮)。 */+const SIZE_STYLES: Record<+ SettingsTextInputSize,+ { box: string; paddingLeft: string; paddingRight: string; trailingPaddingRight: string }+> = {+ sm: {+ box: 'h-8 text-12',+ paddingLeft: 'pl-3',+ paddingRight: 'pr-3',+ trailingPaddingRight: 'pr-8',+ },+ md: {+ box: 'h-9 text-13',+ paddingLeft: 'pl-4',+ paddingRight: 'pr-4',+ trailingPaddingRight: 'pr-9',+ },+ lg: {+ box: 'h-[40px] text-14',+ paddingLeft: 'pl-[12px]',+ paddingRight: 'pr-[12px]',+ trailingPaddingRight: 'pr-9',+ },+};++/** eye 按钮:小号框用小图标 / 更贴边,避免挤压 32px 行高。 */+const EYE_STYLES: Record<SettingsTextInputSize, { iconSize: number; offset: string }> = {+ sm: { iconSize: 14, offset: 'right-[10px]' },+ md: { iconSize: 16, offset: 'right-[12px]' },+ lg: { iconSize: 16, offset: 'right-[12px]' },+};++export function SettingsTextInput({+ value,+ onChange,+ onBlur,+ placeholder,+ type = 'text',+ size = 'lg',+ surface = 'elevated',+ mono = false,+ secret = false,+ trailing,+ className,+}: {+ value: string;+ onChange: (v: string) => void;+ onBlur?: () => void;+ placeholder?: string;+ /** `secret` 为真时由组件接管(明文 / 遮罩切换),此处传值无效。 */+ type?: string;+ size?: SettingsTextInputSize;+ /** 底色档:默认 §4 规定的 `--surface-elevated`;`ivory` 见 SURFACE_STYLES 注释。 */+ surface?: SettingsTextInputSurface;+ /** 等宽字体——密钥、ID 这类需要逐字核对的值。 */+ mono?: boolean;+ /** 密钥字段:遮罩输入 + 自带明文切换按钮。 */+ secret?: boolean;+ /** 自定义尾随元素(需自行绝对定位)。`secret` 优先,两者不叠加。 */+ trailing?: React.ReactNode;+ /** 附加到**外层容器**(内层 input 恒为 w-full),供 flex 行传 `flex-1 min-w-0`。 */+ className?: string;+}) {+ const { t } = useTranslation();+ const [revealed, setRevealed] = useState(false);+ const sizeStyle = SIZE_STYLES[size];+ const eyeStyle = EYE_STYLES[size];++ const eyeButton = secret ? (+ <button+ type="button"+ onClick={() => setRevealed((v) => !v)}+ className={cn(+ 'absolute top-1/2 -translate-y-1/2 text-[var(--settings-eye-icon)] transition-colors hover:text-[var(--settings-eye-icon-hover)]',+ // globals.css 的 F3 全局规则把 *:focus-visible 的 outline 抹掉了(只有 input /+ // textarea 恢复),按钮不自带焦点提示——键盘用户看不出焦点落在眼睛上。按 DESIGN.md+ // 的 Focus Blue 约定补 ring(--focus-ring),写法与其它图标按钮一致。+ 'rounded-full focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--focus-ring)]',+ eyeStyle.offset,+ )}+ aria-label={revealed ? t('settings.apiKey.hideKey') : t('settings.apiKey.showKey')}+ >+ {revealed ? <Eye size={eyeStyle.iconSize} /> : <EyeOff size={eyeStyle.iconSize} />}+ </button>+ ) : null;+ const trailingNode = eyeButton ?? trailing;++ return (+ <div className={cn('relative', className)}>+ <input+ type={secret ? (revealed ? 'text' : 'password') : type}+ value={value}+ onChange={(e) => onChange(e.target.value)}+ onBlur={onBlur}+ placeholder={placeholder}+ // 只对密钥关掉:密码管理器建议和拼写红线对密钥是干扰,但普通文本字段(显示名称、+ // baseUrl、模型名、请求头)该保留浏览器的自动补全与拼写检查,不能一并禁掉。+ autoComplete={secret ? 'off' : undefined}+ spellCheck={secret ? false : undefined}+ className={cn(+ // 单行输入按设计规范走药丸圆角(DESIGN.md §4-5:9999px,明令禁止 10px)。+ 'w-full rounded-full outline-none transition-colors',+ sizeStyle.box,+ sizeStyle.paddingLeft,+ trailingNode ? sizeStyle.trailingPaddingRight : sizeStyle.paddingRight,+ mono && 'font-mono',+ 'text-[var(--settings-input-text)] placeholder:text-[var(--settings-input-placeholder)]',+ SURFACE_STYLES[surface],+ 'border border-[var(--settings-input-border)] focus:border-[var(--settings-input-border-focus)]',+ // Focus Blue 环(DESIGN.md §4 Inputs 的 focus 槽 + §「Focus Blue」的 --focus-ring):+ // 迁移进来的密钥输入原本就带 focus:ring-2,不能在收敛时丢掉——同一个表单里紧邻的+ // 名称框仍是蓝环,只留 border 变色会让上下两个框焦点表现不一致。用 opaque+ // --focus-ring 而非 --focus-ring-soft:与这些框的原值、以及相邻未迁移输入一致。+ 'focus:ring-2 focus:ring-[var(--focus-ring)]',+ )}+ style={{ userSelect: 'text', WebkitUserSelect: 'text' }}+ />+ {trailingNode}+ </div>+ );+}