|
1 | 1 | <script setup lang="ts"> |
2 | 2 | import { |
3 | 3 | Activity, |
| 4 | + Check, |
4 | 5 | Copy, |
5 | 6 | Eye, |
6 | 7 | EyeOff, |
@@ -34,6 +35,7 @@ const stats = computed(() => (app as any)?.stats || { |
34 | 35 | }) |
35 | 36 | const recentActivity = ref<any[]>([]) |
36 | 37 | const showApiKey = ref(false) |
| 38 | +const isApiKeyCopied = ref(false) |
37 | 39 |
|
38 | 40 | // Methods |
39 | 41 | function _initializeRecentActivity() { |
@@ -78,8 +80,15 @@ function formatTime(timestamp: Date) { |
78 | 80 |
|
79 | 81 | async function copyApiKey() { |
80 | 82 | try { |
81 | | - await navigator.clipboard.writeText((app as any)?.apiKey || '') |
82 | | - // TODO: Show success toast |
| 83 | + await navigator.clipboard.writeText((app as any).value?.apiKey || '') |
| 84 | +
|
| 85 | + push.success('API key copied to clipboard!') |
| 86 | +
|
| 87 | + isApiKeyCopied.value = true |
| 88 | +
|
| 89 | + setTimeout(() => { |
| 90 | + isApiKeyCopied.value = false |
| 91 | + }, 2000) |
83 | 92 | } |
84 | 93 | catch (error) { |
85 | 94 | console.error('Failed to copy API key:', error) |
@@ -158,21 +167,23 @@ onMounted(() => { |
158 | 167 | </CardHeader> |
159 | 168 | <CardContent> |
160 | 169 | <div class="flex items-center space-x-2"> |
161 | | - <Input |
162 | | - :model-value="showApiKey ? app.apiKey : '•'.repeat(32)" |
163 | | - readonly |
164 | | - class="font-mono" |
165 | | - /> |
| 170 | + <Input :model-value="showApiKey ? app.apiKey : '•'.repeat(32)" readonly class="font-mono" /> |
166 | 171 | <Button variant="outline" size="icon" @click="showApiKey = !showApiKey"> |
167 | 172 | <Eye v-if="!showApiKey" class="h-4 w-4" /> |
168 | 173 | <EyeOff v-else class="h-4 w-4" /> |
169 | 174 | </Button> |
170 | | - <Button variant="outline" size="icon" @click="copyApiKey"> |
171 | | - <Copy class="h-4 w-4" /> |
| 175 | + <Button |
| 176 | + variant="outline" size="icon" :class="isApiKeyCopied ? 'text-green-600 border-green-600' : ''" |
| 177 | + @click="copyApiKey" |
| 178 | + > |
| 179 | + <Check v-if="isApiKeyCopied" class="h-4 w-4" /> |
| 180 | + <Copy v-else class="h-4 w-4" /> |
172 | 181 | </Button> |
173 | 182 | </div> |
174 | 183 | <p class="text-xs text-muted-foreground mt-2"> |
175 | | - Use as: <code class="bg-muted px-1 rounded">Authorization: ApiKey {{ app.apiKey?.substring(0, 8) }}...</code> |
| 184 | + Use as: <code class="bg-muted px-1 rounded"> |
| 185 | + Authorization: ApiKey {{ app.apiKey?.substring(0, 8) }}... |
| 186 | + </code> |
176 | 187 | </p> |
177 | 188 | </CardContent> |
178 | 189 | </Card> |
|
0 commit comments