|
102 | 102 | <h3>{{ t("API_CHECKER_SUBTITLE") }}</h3>
|
103 | 103 |
|
104 | 104 | <form @submit.prevent="handleSubmit" id="apiForm">
|
105 |
| - <textarea |
106 |
| - v-model="apiInfo" |
107 |
| - id="api_info" |
108 |
| - name="api_info" |
109 |
| - :placeholder="t('API_INFO_PLACEHOLDER')" |
110 |
| - ></textarea> |
| 105 | + <div style="position: relative; margin-bottom: 10px;"> |
| 106 | + <textarea |
| 107 | + v-model="apiInfo" |
| 108 | + id="api_info" |
| 109 | + name="api_info" |
| 110 | + :placeholder="t('API_INFO_PLACEHOLDER')" |
| 111 | + ></textarea> |
| 112 | + <a-button |
| 113 | + type="primary" |
| 114 | + size="small" |
| 115 | + @click="handlePaste" |
| 116 | + style="position: absolute; right: 4px; top: 14px; padding: 0 8px; height: 24px;" |
| 117 | + > |
| 118 | + <template #icon> |
| 119 | + <CopyOutlined style="font-size: 14px;" /> |
| 120 | + </template> |
| 121 | + {{ t('PASTE') }} |
| 122 | + </a-button> |
| 123 | + </div> |
111 | 124 |
|
112 | 125 | <input
|
113 | 126 | type="text"
|
@@ -2174,7 +2187,7 @@ function saveToLocal() {
|
2174 | 2187 | // 添加新的缓存项到列表
|
2175 | 2188 | existingList.push(newCacheItem);
|
2176 | 2189 |
|
2177 |
| - // 更新本地缓存列表 |
| 2190 | + // 新本地缓存表 |
2178 | 2191 | localCacheList.value = existingList;
|
2179 | 2192 | localStorage.setItem("localCacheList", JSON.stringify(existingList));
|
2180 | 2193 |
|
@@ -2652,6 +2665,43 @@ function handleCustomDialogCancel() {
|
2652 | 2665 | customDialogPrompt.value = "";
|
2653 | 2666 | customDialogResult.value = null;
|
2654 | 2667 | }
|
| 2668 | +
|
| 2669 | +// 添加粘贴处理函数 |
| 2670 | +async function handlePaste() { |
| 2671 | + try { |
| 2672 | + const text = await navigator.clipboard.readText(); |
| 2673 | + // 先设置文本值 |
| 2674 | + apiInfo.value = text; |
| 2675 | + |
| 2676 | + // 手动解析 URL 和 API Key |
| 2677 | + let urlPattern = /(https?:\/\/[^\s,。、!,;;\n]+)/; |
| 2678 | + let keyPattern = /(sk-[a-zA-Z0-9]+)/; |
| 2679 | +
|
| 2680 | + let urlMatch = text.match(urlPattern); |
| 2681 | + let keyMatch = text.match(keyPattern); |
| 2682 | +
|
| 2683 | + if (urlMatch) { |
| 2684 | + let cleanUrl = urlMatch[0]; |
| 2685 | + // 去除末尾的斜杠和其他字符 |
| 2686 | + cleanUrl = cleanUrl.replace(/\/+$/, ''); |
| 2687 | + // 如果包含点号,则使用点号之前的部分 |
| 2688 | + if (cleanUrl.includes('.')) { |
| 2689 | + apiUrl.value = cleanUrl; |
| 2690 | + } else { |
| 2691 | + apiUrl.value = urlMatch[0]; |
| 2692 | + } |
| 2693 | + } |
| 2694 | + |
| 2695 | + if (keyMatch) { |
| 2696 | + apiKey.value = keyMatch[0]; |
| 2697 | + } |
| 2698 | + |
| 2699 | + message.success(t('PASTE_SUCCESS')); |
| 2700 | + } catch (err) { |
| 2701 | + console.error('粘贴失败:', err); |
| 2702 | + message.error(t('PASTE_FAILED')); |
| 2703 | + } |
| 2704 | +} |
2655 | 2705 | </script>
|
2656 | 2706 |
|
2657 | 2707 | <style scoped>
|
@@ -3498,7 +3548,7 @@ body.dark-mode .field-value {
|
3498 | 3548 | z-index: 10;
|
3499 | 3549 | }
|
3500 | 3550 |
|
3501 |
| -/* 根据主题切换背景色 */ |
| 3551 | +/* 根据主题换背景色 */ |
3502 | 3552 | body.dark-mode {
|
3503 | 3553 | --overlay-background-color: rgba(0, 0, 0, 0.3);
|
3504 | 3554 | }
|
|
0 commit comments