Sfoglia il codice sorgente

🤓 feat: When adding or editing channels, add the function of clicking the added model to copy its name

Merge pull request #1648 from AAEE86/alpha
同語 6 mesi fa
parent
commit
af18dec46b

+ 3 - 1
i18n/zh-cn.json

@@ -1050,5 +1050,7 @@
   "已绑定的邮箱账户": "已绑定的邮箱账户",
   "已绑定的 Telegram 账户": "已绑定的 Telegram 账户",
   "新额度": "新额度",
-  "需要添加的额度(支持负数)": "需要添加的额度(支持负数)"
+  "需要添加的额度(支持负数)": "需要添加的额度(支持负数)",
+  "点击复制模型名称": "点击复制模型名称",
+  "已复制:{{name}}": "已复制:{{name}}"
 }

+ 25 - 0
web/src/components/table/channels/modals/EditChannelModal.jsx

@@ -1485,6 +1485,31 @@ const EditChannelModal = (props) => {
                     optionList={modelOptions}
                     style={{ width: '100%' }}
                     onChange={(value) => handleInputChange('models', value)}
+                    renderSelectedItem={(optionNode) => {
+                      const modelName = String(optionNode?.value ?? '');
+                      return {
+                        isRenderInTag: true,
+                        content: (
+                          <span
+                            className="cursor-pointer select-none"
+                            role="button"
+                            tabIndex={0}
+                            title={t('点击复制模型名称')}
+                            onClick={async (e) => {
+                              e.stopPropagation();
+                              const ok = await copy(modelName);
+                              if (ok) {
+                                showSuccess(t('已复制:{{name}}', { name: modelName }));
+                              } else {
+                                showError(t('复制失败'));
+                              }
+                            }}
+                          >
+                            {optionNode.label || modelName}
+                          </span>
+                        ),
+                      };
+                    }}
                     extraText={(
                       <Space wrap>
                         <Button size='small' type='primary' onClick={() => handleInputChange('models', basicModels)}>

+ 3 - 1
web/src/i18n/locales/en.json

@@ -1995,5 +1995,7 @@
   "跟随系统主题设置": "Follow system theme",
   "当前跟随系统": "Currently following system",
   "深色": "Dark",
-  "浅色": "Light"
+  "浅色": "Light",
+  "点击复制模型名称": "Click to copy model name",
+  "已复制:{{name}}": "Copied: {{name}}"
 }