|
| 1 | +<script setup lang="ts"> |
| 2 | +import { ref } from 'vue' |
| 3 | +import { useI18n } from 'vue-i18n' |
| 4 | +import { useRouter } from 'vue-router' |
| 5 | +import { toast } from 'vue-sonner' |
| 6 | +import KeySelector from '@/components/KeySelector.vue' |
| 7 | +import { Button } from '@/components/ui/button' |
| 8 | +import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card' |
| 9 | +import { useKeysStore } from '@/stores' |
| 10 | +import { useAppStore } from '@/stores/app' |
| 11 | +import LogoSvg from '/logo.svg?raw' |
| 12 | +
|
| 13 | +const { t } = useI18n() |
| 14 | +const router = useRouter() |
| 15 | +
|
| 16 | +const query = new URLSearchParams(window.location.search) |
| 17 | +
|
| 18 | +const selectedKey = ref<string>('') |
| 19 | +const appStore = useAppStore() |
| 20 | +const keysStore = useKeysStore() |
| 21 | +
|
| 22 | +async function registerAction(granted: boolean) { |
| 23 | + const appId = query.get('appId') |
| 24 | +
|
| 25 | + if (!appId) { |
| 26 | + toast.error(t('missingAppId')) |
| 27 | + return |
| 28 | + } |
| 29 | +
|
| 30 | + await appStore.toggleAppAuthorization(appId, granted, selectedKey.value) |
| 31 | + router.replace('/') |
| 32 | +} |
| 33 | +</script> |
| 34 | + |
| 35 | +<template> |
| 36 | + <div class="min-h-screen flex items-center justify-center p-6 bg-gradient-to-br from-background to-muted/20"> |
| 37 | + <Card class="w-full max-w-2xl shadow-lg"> |
| 38 | + <CardHeader class="text-center space-y-4 pb-8"> |
| 39 | + <div class="flex justify-center"> |
| 40 | + <div class="rounded-2xl bg-primary p-3 text-primary-foreground shadow-md"> |
| 41 | + <div class="h-10 w-10" v-html="LogoSvg" /> |
| 42 | + </div> |
| 43 | + </div> |
| 44 | + <div> |
| 45 | + <CardTitle class="text-3xl font-bold"> |
| 46 | + {{ t('appPermissionRequest') }} |
| 47 | + </CardTitle> |
| 48 | + <CardDescription class="text-base mt-2"> |
| 49 | + {{ t('appPermissionDescription') }} |
| 50 | + </CardDescription> |
| 51 | + </div> |
| 52 | + </CardHeader> |
| 53 | + |
| 54 | + <CardContent class="space-y-6"> |
| 55 | + <div class="space-y-4 bg-muted/30 rounded-lg p-6"> |
| 56 | + <div class="flex items-baseline gap-3"> |
| 57 | + <span class="text-sm font-medium text-muted-foreground min-w-20">{{ t('appName') }}</span> |
| 58 | + <span class="text-lg font-semibold">{{ query.get('appName') || '-' }}</span> |
| 59 | + </div> |
| 60 | + <div class="flex items-baseline gap-3"> |
| 61 | + <span class="text-sm font-medium text-muted-foreground min-w-20">{{ t('appDescription') }}</span> |
| 62 | + <span class="text-base">{{ query.get('appDescription') || '-' }}</span> |
| 63 | + </div> |
| 64 | + </div> |
| 65 | + |
| 66 | + <KeySelector v-model="selectedKey" compact /> |
| 67 | + |
| 68 | + <div class="flex gap-3 pt-4"> |
| 69 | + <Button |
| 70 | + variant="outline" |
| 71 | + size="lg" |
| 72 | + class="flex-1" |
| 73 | + @click="registerAction(false)" |
| 74 | + > |
| 75 | + {{ t('deny') }} |
| 76 | + </Button> |
| 77 | + <Button |
| 78 | + variant="default" |
| 79 | + size="lg" |
| 80 | + class="flex-1" |
| 81 | + :disabled="!selectedKey || keysStore.keys.length === 0" |
| 82 | + @click="registerAction(true)" |
| 83 | + > |
| 84 | + {{ t('approve') }} |
| 85 | + </Button> |
| 86 | + </div> |
| 87 | + </CardContent> |
| 88 | + </Card> |
| 89 | + </div> |
| 90 | +</template> |
| 91 | + |
| 92 | +<i18n lang="yaml"> |
| 93 | +en-US: |
| 94 | + missingAppId: Missing application ID |
| 95 | + appPermissionRequest: Application Authorization |
| 96 | + appPermissionDescription: This application is requesting access to use your AI provider keys |
| 97 | + appName: App Name |
| 98 | + appDescription: Description |
| 99 | + deny: Deny |
| 100 | + approve: Approve |
| 101 | +
|
| 102 | +zh-CN: |
| 103 | + missingAppId: 缺少应用ID |
| 104 | + appPermissionRequest: 应用授权请求 |
| 105 | + appPermissionDescription: 该应用请求使用您的 AI 提供商密钥 |
| 106 | + appName: 应用名称 |
| 107 | + appDescription: 应用描述 |
| 108 | + deny: 拒绝 |
| 109 | + approve: 同意 |
| 110 | +</i18n> |
0 commit comments