mirror of
https://github.com/zyycn/codex-proxy-rs.git
synced 2026-11-17 16:06:57 +00:00
feat(ui): adopt shared action menus and refine quota settings
Pin UI v0.12.0 and use its keyboard-accessible menus for account, API key and proxy actions. Keep quota validation on submit and align a compact inline warmup switch with each bucket title. Co-authored-by: Codex <noreply@openai.com>
This commit is contained in:
@@ -17,7 +17,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@boxicons/vue": "1.0.1",
|
||||
"@codex-proxy/ui": "github:zyycn/codex-proxy-ui#v0.11.0",
|
||||
"@codex-proxy/ui": "github:zyycn/codex-proxy-ui#v0.12.0",
|
||||
"@fontsource-variable/inter": "^5.3.0",
|
||||
"@fontsource-variable/jetbrains-mono": "^5.3.0",
|
||||
"@lucide/vue": "^1.73.0",
|
||||
|
||||
Generated
+6
-6
@@ -195,8 +195,8 @@ importers:
|
||||
specifier: 1.0.1
|
||||
version: 1.0.1(vue@3.5.45(typescript@6.0.3))
|
||||
'@codex-proxy/ui':
|
||||
specifier: github:zyycn/codex-proxy-ui#v0.11.0
|
||||
version: https://codeload.github.com/zyycn/codex-proxy-ui/tar.gz/68458e62e7fb9fadbacea75ce48522f2ba85b8b2(axios@1.21.1(debug@4.4.3))(change-case@5.4.4)(jiti@2.7.0)(postcss@8.5.30)(vite@8.3.8(@types/node@26.6.6)(jiti@2.7.0)(yaml@2.9.0))(vue@3.5.45(typescript@6.0.3))(yaml@2.9.0)
|
||||
specifier: github:zyycn/codex-proxy-ui#v0.12.0
|
||||
version: https://codeload.github.com/zyycn/codex-proxy-ui/tar.gz/8ffe8a2386603961f48e7fb12ba03be7a81539ec(axios@1.21.1(debug@4.4.3))(change-case@5.4.4)(jiti@2.7.0)(postcss@8.5.30)(vite@8.3.8(@types/node@26.6.6)(jiti@2.7.0)(yaml@2.9.0))(vue@3.5.45(typescript@6.0.3))(yaml@2.9.0)
|
||||
'@fontsource-variable/inter':
|
||||
specifier: ^5.3.0
|
||||
version: 5.3.0
|
||||
@@ -456,9 +456,9 @@ packages:
|
||||
resolution: {integrity: sha512-dlT1m5e/0yUL0kRNcQn7yGLVThkgbB0Ga/1AmfDDC/8ik6AIiSf2QLQO2zPYvefsHP0aFgxO93cVLCCfDp7kzQ==}
|
||||
engines: {node: '>= 20.12.0'}
|
||||
|
||||
'@codex-proxy/ui@https://codeload.github.com/zyycn/codex-proxy-ui/tar.gz/68458e62e7fb9fadbacea75ce48522f2ba85b8b2':
|
||||
resolution: {gitHosted: true, integrity: sha512-VSw6WQntuIQmVLY1uMCouUKYbUZyzT4zDmA7CJ/fWT/yBZwvaH+i16SAp++twYYIvKwYMBR6WmNlV7RA6zXKOw==, tarball: https://codeload.github.com/zyycn/codex-proxy-ui/tar.gz/68458e62e7fb9fadbacea75ce48522f2ba85b8b2}
|
||||
version: 0.11.0
|
||||
'@codex-proxy/ui@https://codeload.github.com/zyycn/codex-proxy-ui/tar.gz/8ffe8a2386603961f48e7fb12ba03be7a81539ec':
|
||||
resolution: {gitHosted: true, integrity: sha512-7QCwJyfOkLDKjmCGh2zwsvbFV2c1fcUlJSpDXsGg9vrZBdsbx9CQtgYwlnsuUm0Oj6wUgrZ4l3YUCBheIzQJkQ==, tarball: https://codeload.github.com/zyycn/codex-proxy-ui/tar.gz/8ffe8a2386603961f48e7fb12ba03be7a81539ec}
|
||||
version: 0.12.0
|
||||
engines: {node: '>=24'}
|
||||
peerDependencies:
|
||||
vite: ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0
|
||||
@@ -3571,7 +3571,7 @@ snapshots:
|
||||
fast-wrap-ansi: 0.2.2
|
||||
sisteransi: 1.0.5
|
||||
|
||||
'@codex-proxy/ui@https://codeload.github.com/zyycn/codex-proxy-ui/tar.gz/68458e62e7fb9fadbacea75ce48522f2ba85b8b2(axios@1.21.1(debug@4.4.3))(change-case@5.4.4)(jiti@2.7.0)(postcss@8.5.30)(vite@8.3.8(@types/node@26.6.6)(jiti@2.7.0)(yaml@2.9.0))(vue@3.5.45(typescript@6.0.3))(yaml@2.9.0)':
|
||||
'@codex-proxy/ui@https://codeload.github.com/zyycn/codex-proxy-ui/tar.gz/8ffe8a2386603961f48e7fb12ba03be7a81539ec(axios@1.21.1(debug@4.4.3))(change-case@5.4.4)(jiti@2.7.0)(postcss@8.5.30)(vite@8.3.8(@types/node@26.6.6)(jiti@2.7.0)(yaml@2.9.0))(vue@3.5.45(typescript@6.0.3))(yaml@2.9.0)':
|
||||
dependencies:
|
||||
'@ant-design/colors': 8.0.1
|
||||
'@ant-design/fast-color': 3.0.1
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
<script setup lang="ts">
|
||||
import { ZDropdown, ZIconButton } from '@codex-proxy/ui'
|
||||
import { MoreHorizontal } from '@lucide/vue'
|
||||
|
||||
defineProps<{ label: string, menuClass: string, disabled?: boolean, loading?: boolean }>()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<ZDropdown :menu-class="menuClass">
|
||||
<template #reference="{ trigger }">
|
||||
<ZIconButton v-bind="trigger" size="small" :aria-label="label" :disabled="disabled" :loading="loading" :class="trigger['aria-expanded'] ? 'bg-z-bg-text-active text-z-text' : undefined">
|
||||
<MoreHorizontal class="size-4" />
|
||||
</ZIconButton>
|
||||
</template>
|
||||
<slot />
|
||||
</ZDropdown>
|
||||
</template>
|
||||
@@ -11,7 +11,7 @@
|
||||
"empty": "No observed quota buckets",
|
||||
"invalid": "Enter a whole number from 1 to 100 or leave blank for no limit",
|
||||
"limit": "Scheduling limit",
|
||||
"warmup": "Auto warmup",
|
||||
"warmup": "Warmup",
|
||||
"model": "Warmup model",
|
||||
"modelPlaceholder": "Select model",
|
||||
"invalidModel": "Enter a valid warmup model ID",
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
"empty": "没有已观测的额度桶",
|
||||
"invalid": "请输入 1~100 的整数,留空表示不限制",
|
||||
"limit": "调度上限",
|
||||
"warmup": "自动预热",
|
||||
"warmup": "预热",
|
||||
"model": "预热模型",
|
||||
"modelPlaceholder": "选择模型",
|
||||
"invalidModel": "请输入有效的预热模型 ID",
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
"empty": "沒有已觀測的額度桶",
|
||||
"invalid": "請輸入 1~100 的整數,留空表示不限制",
|
||||
"limit": "排程上限",
|
||||
"warmup": "自動預熱",
|
||||
"warmup": "預熱",
|
||||
"model": "預熱模型",
|
||||
"modelPlaceholder": "選擇模型",
|
||||
"invalidModel": "請輸入有效的預熱模型 ID",
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
<script setup lang="ts">
|
||||
import type { Account } from '@/api'
|
||||
|
||||
import { ZIconButton, ZMenuItem, ZPopover } from '@codex-proxy/ui'
|
||||
import { ZIconButton, ZMenuItem } from '@codex-proxy/ui'
|
||||
|
||||
import { Download, KeyRound, MoreHorizontal, Pencil, Power, RefreshCw, RotateCcw, Trash2, Wifi } from '@lucide/vue'
|
||||
import { Download, KeyRound, Pencil, Power, RefreshCw, RotateCcw, Trash2, Wifi } from '@lucide/vue'
|
||||
|
||||
import { computed } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import RowActionMenu from '@/components/RowActionMenu.vue'
|
||||
|
||||
const props = defineProps<{
|
||||
account: Account
|
||||
@@ -53,81 +54,71 @@ const credentialEligible = computed(() => props.account.authenticationKind === '
|
||||
<Trash2 class="size-3.5 text-z-error" />
|
||||
</ZIconButton>
|
||||
|
||||
<ZPopover placement="bottom-end">
|
||||
<template #reference="{ open }">
|
||||
<ZIconButton size="small" :aria-label="t('accounts.actions.moreActions')" :pressed="open">
|
||||
<MoreHorizontal class="size-4" />
|
||||
</ZIconButton>
|
||||
</template>
|
||||
|
||||
<template #default="{ close }">
|
||||
<div class="w-40 p-1.5">
|
||||
<ZMenuItem
|
||||
:loading="testing"
|
||||
:disabled="testing"
|
||||
@click.stop="(close(), emit('test', account))"
|
||||
>
|
||||
<template #icon>
|
||||
<Wifi class="size-3.5 text-z-text-quaternary" />
|
||||
</template>
|
||||
{{ t('accounts.connectionTest.title') }}
|
||||
</ZMenuItem>
|
||||
<ZMenuItem
|
||||
:loading="togglingScheduling"
|
||||
:disabled="togglingScheduling"
|
||||
@click.stop="(close(), emit('toggleScheduling', account))"
|
||||
>
|
||||
<template #icon>
|
||||
<Power class="size-3.5 text-z-text-quaternary" />
|
||||
</template>
|
||||
{{ account.enabled ? t('accounts.actions.disableScheduling') : t('accounts.actions.enableScheduling') }}
|
||||
</ZMenuItem>
|
||||
<ZMenuItem
|
||||
v-if="credentialEligible"
|
||||
:loading="refreshing"
|
||||
:disabled="refreshing"
|
||||
@click.stop="(close(), emit('refresh', account.id))"
|
||||
>
|
||||
<template #loading>
|
||||
<RefreshCw class="size-3.5 animate-spin text-z-text-quaternary motion-reduce:animate-none" />
|
||||
</template>
|
||||
<template #icon>
|
||||
<RefreshCw class="size-3.5 text-z-text-quaternary" />
|
||||
</template>
|
||||
{{ t('accounts.actions.refreshToken') }}
|
||||
</ZMenuItem>
|
||||
<ZMenuItem v-if="credentialEligible" @click.stop="(close(), emit('reauthorize', account))">
|
||||
<template #icon>
|
||||
<KeyRound class="size-3.5 text-z-text-quaternary" />
|
||||
</template>
|
||||
{{ t('accounts.actions.reauthorize') }}
|
||||
</ZMenuItem>
|
||||
<ZMenuItem
|
||||
v-if="account.provider === 'openai' && account.authenticationKind === 'oauth'"
|
||||
:loading="downloadingCatalog"
|
||||
:disabled="downloadingCatalog"
|
||||
@click.stop="(close(), emit('downloadModelCatalog', account))"
|
||||
>
|
||||
<template #loading>
|
||||
<RefreshCw class="size-3.5 animate-spin text-z-text-quaternary motion-reduce:animate-none" />
|
||||
</template>
|
||||
<template #icon>
|
||||
<Download class="size-3.5 text-z-text-quaternary" />
|
||||
</template>
|
||||
{{ t('accounts.actions.downloadModelCatalog') }}
|
||||
</ZMenuItem>
|
||||
<ZMenuItem
|
||||
:loading="recovering"
|
||||
:disabled="recovering"
|
||||
@click.stop="(close(), emit('recover', account.id))"
|
||||
>
|
||||
<template #icon>
|
||||
<RotateCcw class="size-3.5 text-z-text-quaternary" />
|
||||
</template>
|
||||
{{ t('accounts.actions.restoreState') }}
|
||||
</ZMenuItem>
|
||||
</div>
|
||||
</template>
|
||||
</ZPopover>
|
||||
<RowActionMenu :label="t('accounts.actions.moreActions')" menu-class="w-40 p-1.5">
|
||||
<ZMenuItem
|
||||
:loading="testing"
|
||||
:disabled="testing"
|
||||
@click.stop="emit('test', account)"
|
||||
>
|
||||
<template #icon>
|
||||
<Wifi class="size-3.5 text-z-text-quaternary" />
|
||||
</template>
|
||||
{{ t('accounts.connectionTest.title') }}
|
||||
</ZMenuItem>
|
||||
<ZMenuItem
|
||||
:loading="togglingScheduling"
|
||||
:disabled="togglingScheduling"
|
||||
@click.stop="emit('toggleScheduling', account)"
|
||||
>
|
||||
<template #icon>
|
||||
<Power class="size-3.5 text-z-text-quaternary" />
|
||||
</template>
|
||||
{{ account.enabled ? t('accounts.actions.disableScheduling') : t('accounts.actions.enableScheduling') }}
|
||||
</ZMenuItem>
|
||||
<ZMenuItem
|
||||
v-if="credentialEligible"
|
||||
:loading="refreshing"
|
||||
:disabled="refreshing"
|
||||
@click.stop="emit('refresh', account.id)"
|
||||
>
|
||||
<template #loading>
|
||||
<RefreshCw class="size-3.5 animate-spin text-z-text-quaternary motion-reduce:animate-none" />
|
||||
</template>
|
||||
<template #icon>
|
||||
<RefreshCw class="size-3.5 text-z-text-quaternary" />
|
||||
</template>
|
||||
{{ t('accounts.actions.refreshToken') }}
|
||||
</ZMenuItem>
|
||||
<ZMenuItem v-if="credentialEligible" @click.stop="emit('reauthorize', account)">
|
||||
<template #icon>
|
||||
<KeyRound class="size-3.5 text-z-text-quaternary" />
|
||||
</template>
|
||||
{{ t('accounts.actions.reauthorize') }}
|
||||
</ZMenuItem>
|
||||
<ZMenuItem
|
||||
v-if="account.provider === 'openai' && account.authenticationKind === 'oauth'"
|
||||
:loading="downloadingCatalog"
|
||||
:disabled="downloadingCatalog"
|
||||
@click.stop="emit('downloadModelCatalog', account)"
|
||||
>
|
||||
<template #loading>
|
||||
<RefreshCw class="size-3.5 animate-spin text-z-text-quaternary motion-reduce:animate-none" />
|
||||
</template>
|
||||
<template #icon>
|
||||
<Download class="size-3.5 text-z-text-quaternary" />
|
||||
</template>
|
||||
{{ t('accounts.actions.downloadModelCatalog') }}
|
||||
</ZMenuItem>
|
||||
<ZMenuItem
|
||||
:loading="recovering"
|
||||
:disabled="recovering"
|
||||
@click.stop="emit('recover', account.id)"
|
||||
>
|
||||
<template #icon>
|
||||
<RotateCcw class="size-3.5 text-z-text-quaternary" />
|
||||
</template>
|
||||
{{ t('accounts.actions.restoreState') }}
|
||||
</ZMenuItem>
|
||||
</RowActionMenu>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
<script setup lang="ts">
|
||||
import type { FormRule } from '@codex-proxy/ui'
|
||||
import type { Account, AccountQuotaBucketSettings } from '@/api'
|
||||
import { ZButton, ZDialog, ZFormItem, ZInput, ZSelect, ZSwitch } from '@codex-proxy/ui'
|
||||
import { ZButton, ZDialog, ZForm, ZFormItem, ZInput, ZSelect, ZSwitch } from '@codex-proxy/ui'
|
||||
import { SlidersHorizontal } from '@lucide/vue'
|
||||
import { computed, ref, shallowRef } from 'vue'
|
||||
import { computed, ref, shallowRef, useId, useTemplateRef } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { batchUpdateAccounts, getAccountModels, getAccountQuota } from '@/api'
|
||||
import { quotaWindowLabel } from '@/components/account/account-usage-window/presenter'
|
||||
@@ -21,6 +22,8 @@ const props = defineProps<{ account: Account }>()
|
||||
const emit = defineEmits<{ accountUpdated: [account: Account] }>()
|
||||
const { t } = useI18n({ useScope: 'global' })
|
||||
const open = shallowRef(false)
|
||||
const formId = useId()
|
||||
const formRef = useTemplateRef<InstanceType<typeof ZForm>>('formElement')
|
||||
const draft = ref<BucketDraft[]>([])
|
||||
const { loading, run } = useAsyncAction()
|
||||
const { loading: loadingModels, run: loadModels } = useAsyncAction()
|
||||
@@ -33,11 +36,18 @@ const modelOptions = computed(() => {
|
||||
}
|
||||
return Array.from(options, ([value, label]) => ({ value, label }))
|
||||
})
|
||||
const invalidLimit = computed(() => draft.value.some(row => row.limit !== '' && !/^(?:[1-9]\d?|100)$/.test(row.limit)))
|
||||
const invalidModel = computed(() => draft.value.some(row => row.warmup && (!row.model.trim() || row.model.trim().length > 128 || /\p{Cc}/u.test(row.model))))
|
||||
const invalid = computed(() => invalidLimit.value || invalidModel.value)
|
||||
const limitRule = computed<FormRule>(() => ({
|
||||
validator: (_rule, value: string) => value === '' || /^(?:[1-9]\d?|100)$/.test(value),
|
||||
message: t('accounts.quotaSettings.invalid'),
|
||||
}))
|
||||
const modelRule = computed<FormRule>(() => ({
|
||||
required: true,
|
||||
validator: (_rule, value: string) => Boolean(value.trim()) && value.trim().length <= 128 && !/\p{Cc}/u.test(value),
|
||||
message: t('accounts.quotaSettings.invalidModel'),
|
||||
}))
|
||||
|
||||
async function edit() {
|
||||
formRef.value?.clearValidate()
|
||||
const windows = new Map(props.account.quota.windows.filter(window => window.accountWide).map(window => [window.key, window]))
|
||||
const keys = new Set([
|
||||
...windows.keys(),
|
||||
@@ -68,7 +78,7 @@ async function edit() {
|
||||
}
|
||||
|
||||
async function save() {
|
||||
if (invalid.value)
|
||||
if (loading.value || !draft.value.length || !await formRef.value?.validate().catch(() => false))
|
||||
return
|
||||
const accountId = props.account.id
|
||||
const settings: Record<string, AccountQuotaBucketSettings> = Object.fromEntries(draft.value
|
||||
@@ -105,37 +115,46 @@ async function save() {
|
||||
<SlidersHorizontal class="size-3.5" />
|
||||
</QuotaActionButton>
|
||||
<ZDialog v-model="open" :title="t('accounts.quotaSettings.title')" :description="t('accounts.quotaSettings.subtitle')" width="32rem" :close-on-click-modal="!loading" :close-on-press-escape="!loading" :show-close="!loading">
|
||||
<div class="grid gap-4">
|
||||
<ZForm :id="formId" ref="formElement" :model="draft" :validate-on-rule-change="false" :show-message="false" class="gap-4" scroll-to-error focus-on-error novalidate @submit="save">
|
||||
<p v-if="!draft.length" class="m-0 text-z-sm text-z-text-secondary">
|
||||
{{ t('accounts.quotaSettings.empty') }}
|
||||
</p>
|
||||
<section v-for="row in draft" :key="row.key" class="relative grid gap-3 rounded-z bg-z-fill-quaternary p-3" :aria-label="row.label">
|
||||
<h3 class="m-0 pr-32 text-z-sm font-heavy text-z-text">
|
||||
{{ row.label }}
|
||||
</h3>
|
||||
<ZSwitch v-model="row.warmup" class="absolute! top-2 right-3" :label="t('accounts.quotaSettings.warmup')" :aria-label="`${row.label} · ${t('accounts.quotaSettings.warmup')}`" :disabled="loading" />
|
||||
<section v-for="(row, index) in draft" :key="row.key" class="grid gap-3 rounded-z bg-z-fill-quaternary p-3" :aria-label="row.label">
|
||||
<div class="flex items-center justify-between gap-3">
|
||||
<h3 class="m-0 min-w-0 wrap-anywhere text-z-sm font-heavy text-z-text">
|
||||
{{ row.label }}
|
||||
</h3>
|
||||
<ZSwitch
|
||||
v-model="row.warmup"
|
||||
size="small"
|
||||
inline-prompt
|
||||
class="w-12 [&:lang(en)]:w-18"
|
||||
width="100%"
|
||||
:active-text="t('accounts.quotaSettings.warmup')"
|
||||
:inactive-text="t('accounts.quotaSettings.warmup')"
|
||||
:aria-label="`${row.label} · ${t('accounts.quotaSettings.warmup')}`"
|
||||
:disabled="loading"
|
||||
/>
|
||||
</div>
|
||||
<div class="grid gap-3 sm:grid-cols-2">
|
||||
<ZFormItem :label="t('accounts.quotaSettings.limit')">
|
||||
<ZInput v-model="row.limit" type="number" min="1" max="100" step="1" :aria-label="`${row.label} · ${t('accounts.quotaSettings.limit')}`" :placeholder="t('accounts.quotaSettings.unlimited')" :disabled="loading">
|
||||
<ZFormItem :label="t('accounts.quotaSettings.limit')" :prop="`${index}.limit`" :rules="limitRule">
|
||||
<ZInput v-model="row.limit" :validate-event="false" type="number" min="1" max="100" step="1" :aria-label="`${row.label} · ${t('accounts.quotaSettings.limit')}`" :placeholder="t('accounts.quotaSettings.unlimited')" :disabled="loading" @update:model-value="formRef?.clearValidate(`${index}.limit`)">
|
||||
<template #suffix>
|
||||
%
|
||||
</template>
|
||||
</ZInput>
|
||||
</ZFormItem>
|
||||
<ZFormItem v-if="row.warmup" :label="t('accounts.quotaSettings.model')" required>
|
||||
<ZSelect v-model="row.model" class="w-full" :options="modelOptions" :aria-label="`${row.label} · ${t('accounts.quotaSettings.model')}`" :placeholder="t('accounts.quotaSettings.modelPlaceholder')" :empty-text="t('accounts.connectionTest.noModels')" :disabled="loading || loadingModels" />
|
||||
<ZFormItem v-if="row.warmup" :label="t('accounts.quotaSettings.model')" :prop="`${index}.model`" :rules="modelRule">
|
||||
<ZSelect v-model="row.model" :validate-event="false" class="w-full" :options="modelOptions" :aria-label="`${row.label} · ${t('accounts.quotaSettings.model')}`" :placeholder="t('accounts.quotaSettings.modelPlaceholder')" :empty-text="t('accounts.connectionTest.noModels')" :disabled="loading || loadingModels" @update:model-value="formRef?.clearValidate(`${index}.model`)" />
|
||||
</ZFormItem>
|
||||
</div>
|
||||
</section>
|
||||
<p v-if="invalid" class="m-0 text-z-xs text-z-error" role="alert">
|
||||
{{ invalidLimit ? t('accounts.quotaSettings.invalid') : t('accounts.quotaSettings.invalidModel') }}
|
||||
</p>
|
||||
</div>
|
||||
</ZForm>
|
||||
<template #footer>
|
||||
<ZButton :disabled="loading" @click="open = false">
|
||||
{{ t('common.actions.cancel') }}
|
||||
</ZButton>
|
||||
<ZButton type="primary" :disabled="!draft.length || invalid" :loading="loading" @click="save">
|
||||
<ZButton type="primary" native-type="submit" :form="formId" :disabled="!draft.length" :loading="loading">
|
||||
{{ t('common.actions.save') }}
|
||||
</ZButton>
|
||||
</template>
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
<script setup lang="ts">
|
||||
import type { ApiKey } from '@/api'
|
||||
|
||||
import { ZIconButton, ZMenuItem, ZPopover } from '@codex-proxy/ui'
|
||||
import { ZIconButton, ZMenuItem } from '@codex-proxy/ui'
|
||||
|
||||
import { MoreHorizontal, Pencil, Power, RotateCcw, Terminal, Trash2, Upload } from '@lucide/vue'
|
||||
import { Pencil, Power, RotateCcw, Terminal, Trash2, Upload } from '@lucide/vue'
|
||||
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import RowActionMenu from '@/components/RowActionMenu.vue'
|
||||
|
||||
defineProps<{
|
||||
apiKey: ApiKey
|
||||
@@ -46,40 +47,31 @@ const { t } = useI18n({ useScope: 'global' })
|
||||
<Terminal class="size-3.5 text-z-primary-text" />
|
||||
</ZIconButton>
|
||||
|
||||
<ZPopover placement="bottom-end">
|
||||
<template #reference="{ open }">
|
||||
<ZIconButton size="small" :aria-label="t('keys.actions.moreActions')" :pressed="open">
|
||||
<MoreHorizontal class="size-4" />
|
||||
</ZIconButton>
|
||||
</template>
|
||||
<template #default="{ close }">
|
||||
<div class="w-36 p-1.5">
|
||||
<ZMenuItem @click.stop="(close(), emit('resetBudget', apiKey))">
|
||||
<template #icon>
|
||||
<RotateCcw class="size-3.5 text-z-text-quaternary" />
|
||||
</template>
|
||||
{{ t('keys.actions.resetUsedCredit') }}
|
||||
</ZMenuItem>
|
||||
<ZMenuItem :disabled="revealing" @click.stop="(close(), emit('importClient', apiKey))">
|
||||
<template #icon>
|
||||
<Upload class="size-3.5 text-z-text-quaternary" />
|
||||
</template>
|
||||
{{ t('keys.configuration.importTo') }}
|
||||
</ZMenuItem>
|
||||
<ZMenuItem :loading="updatingStatus" @click.stop="(close(), emit('toggle', apiKey))">
|
||||
<template #icon>
|
||||
<Power class="size-3.5" :class="apiKey.enabled ? 'text-z-warning' : 'text-z-success'" />
|
||||
</template>
|
||||
{{ apiKey.enabled ? t('keys.actions.disableKey') : t('keys.actions.enableKey') }}
|
||||
</ZMenuItem>
|
||||
<ZMenuItem type="danger" :disabled="deleting" @click.stop="(close(), emit('delete', apiKey))">
|
||||
<template #icon>
|
||||
<Trash2 class="size-3.5" />
|
||||
</template>
|
||||
{{ t('keys.actions.deleteKey') }}
|
||||
</ZMenuItem>
|
||||
</div>
|
||||
</template>
|
||||
</ZPopover>
|
||||
<RowActionMenu :label="t('keys.actions.moreActions')" menu-class="w-36 p-1.5">
|
||||
<ZMenuItem @click.stop="emit('resetBudget', apiKey)">
|
||||
<template #icon>
|
||||
<RotateCcw class="size-3.5 text-z-text-quaternary" />
|
||||
</template>
|
||||
{{ t('keys.actions.resetUsedCredit') }}
|
||||
</ZMenuItem>
|
||||
<ZMenuItem :disabled="revealing" @click.stop="emit('importClient', apiKey)">
|
||||
<template #icon>
|
||||
<Upload class="size-3.5 text-z-text-quaternary" />
|
||||
</template>
|
||||
{{ t('keys.configuration.importTo') }}
|
||||
</ZMenuItem>
|
||||
<ZMenuItem :loading="updatingStatus" @click.stop="emit('toggle', apiKey)">
|
||||
<template #icon>
|
||||
<Power class="size-3.5" :class="apiKey.enabled ? 'text-z-warning' : 'text-z-success'" />
|
||||
</template>
|
||||
{{ apiKey.enabled ? t('keys.actions.disableKey') : t('keys.actions.enableKey') }}
|
||||
</ZMenuItem>
|
||||
<ZMenuItem type="danger" :disabled="deleting" @click.stop="emit('delete', apiKey)">
|
||||
<template #icon>
|
||||
<Trash2 class="size-3.5" />
|
||||
</template>
|
||||
{{ t('keys.actions.deleteKey') }}
|
||||
</ZMenuItem>
|
||||
</RowActionMenu>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
<script setup lang="ts">
|
||||
import type { OutboundProxyRecord } from '@/api'
|
||||
|
||||
import { ZIconButton, ZMenuItem, ZPopover } from '@codex-proxy/ui'
|
||||
import { MoreHorizontal, Pencil, Power, Trash2, Wifi } from '@lucide/vue'
|
||||
import { ZIconButton, ZMenuItem } from '@codex-proxy/ui'
|
||||
import { Pencil, Power, Trash2, Wifi } from '@lucide/vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import RowActionMenu from '@/components/RowActionMenu.vue'
|
||||
|
||||
defineProps<{
|
||||
proxy: OutboundProxyRecord
|
||||
@@ -30,28 +31,19 @@ const { t } = useI18n({ useScope: 'global' })
|
||||
<ZIconButton size="small" :aria-label="t('proxies.actions.edit')" :disabled="testing || updating" @click="emit('edit', proxy)">
|
||||
<Pencil class="size-3.5 text-z-link" />
|
||||
</ZIconButton>
|
||||
<ZPopover placement="bottom-end">
|
||||
<template #reference="{ open }">
|
||||
<ZIconButton size="small" :aria-label="t('proxies.actions.moreActionsFor', { name: proxy.name })" :pressed="open" :disabled="testing || updating" :loading="updating">
|
||||
<MoreHorizontal class="size-4" />
|
||||
</ZIconButton>
|
||||
</template>
|
||||
<template #default="{ close }">
|
||||
<div class="w-36 p-1.5">
|
||||
<ZMenuItem :disabled="testing || updating" @click="(close(), emit('toggle', proxy))">
|
||||
<template #icon>
|
||||
<Power class="size-3.5" :class="proxy.enabled ? 'text-z-warning' : 'text-z-success'" />
|
||||
</template>
|
||||
{{ proxy.enabled ? t('proxies.actions.disableProxy') : t('proxies.actions.enableProxy') }}
|
||||
</ZMenuItem>
|
||||
<ZMenuItem type="danger" :disabled="testing || updating" @click="(close(), emit('delete', proxy))">
|
||||
<template #icon>
|
||||
<Trash2 class="size-3.5" />
|
||||
</template>
|
||||
{{ t('proxies.actions.deleteProxy') }}
|
||||
</ZMenuItem>
|
||||
</div>
|
||||
</template>
|
||||
</ZPopover>
|
||||
<RowActionMenu :label="t('proxies.actions.moreActionsFor', { name: proxy.name })" menu-class="w-36 p-1.5" :disabled="testing || updating" :loading="updating">
|
||||
<ZMenuItem :disabled="testing || updating" @click="emit('toggle', proxy)">
|
||||
<template #icon>
|
||||
<Power class="size-3.5" :class="proxy.enabled ? 'text-z-warning' : 'text-z-success'" />
|
||||
</template>
|
||||
{{ proxy.enabled ? t('proxies.actions.disableProxy') : t('proxies.actions.enableProxy') }}
|
||||
</ZMenuItem>
|
||||
<ZMenuItem type="danger" :disabled="testing || updating" @click="emit('delete', proxy)">
|
||||
<template #icon>
|
||||
<Trash2 class="size-3.5" />
|
||||
</template>
|
||||
{{ t('proxies.actions.deleteProxy') }}
|
||||
</ZMenuItem>
|
||||
</RowActionMenu>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
+1
-1
Submodule modules/ui updated: 68458e62e7...8ffe8a2386
Reference in New Issue
Block a user