refactor(frontend): UI/UX改进和组件优化
- DataTable组件操作列自适应 - 优化各种Modal弹窗 - 统一API调用方式(AbortSignal) - 添加全局订阅状态管理 - 优化各管理视图的交互和布局 - 修复国际化翻译问题
This commit is contained in:
@@ -1,6 +1,11 @@
|
||||
<template>
|
||||
<Modal :show="show" :title="t('admin.accounts.bulkEdit.title')" size="lg" @close="handleClose">
|
||||
<form class="space-y-5" @submit.prevent="handleSubmit">
|
||||
<BaseDialog
|
||||
:show="show"
|
||||
:title="t('admin.accounts.bulkEdit.title')"
|
||||
width="wide"
|
||||
@close="handleClose"
|
||||
>
|
||||
<form id="bulk-edit-account-form" class="space-y-5" @submit.prevent="handleSubmit">
|
||||
<!-- Info -->
|
||||
<div class="rounded-lg bg-blue-50 p-4 dark:bg-blue-900/20">
|
||||
<p class="text-sm text-blue-700 dark:text-blue-400">
|
||||
@@ -19,20 +24,30 @@
|
||||
<!-- Base URL (API Key only) -->
|
||||
<div class="border-t border-gray-200 pt-4 dark:border-dark-600">
|
||||
<div class="mb-3 flex items-center justify-between">
|
||||
<label class="input-label mb-0">{{ t('admin.accounts.baseUrl') }}</label>
|
||||
<label
|
||||
id="bulk-edit-base-url-label"
|
||||
class="input-label mb-0"
|
||||
for="bulk-edit-base-url-enabled"
|
||||
>
|
||||
{{ t('admin.accounts.baseUrl') }}
|
||||
</label>
|
||||
<input
|
||||
v-model="enableBaseUrl"
|
||||
id="bulk-edit-base-url-enabled"
|
||||
type="checkbox"
|
||||
aria-controls="bulk-edit-base-url"
|
||||
class="rounded border-gray-300 text-primary-600 focus:ring-primary-500"
|
||||
/>
|
||||
</div>
|
||||
<input
|
||||
v-model="baseUrl"
|
||||
id="bulk-edit-base-url"
|
||||
type="text"
|
||||
:disabled="!enableBaseUrl"
|
||||
class="input"
|
||||
:class="!enableBaseUrl && 'cursor-not-allowed opacity-50'"
|
||||
:placeholder="t('admin.accounts.bulkEdit.baseUrlPlaceholder')"
|
||||
aria-labelledby="bulk-edit-base-url-label"
|
||||
/>
|
||||
<p class="input-hint">
|
||||
{{ t('admin.accounts.bulkEdit.baseUrlNotice') }}
|
||||
@@ -42,15 +57,28 @@
|
||||
<!-- Model restriction -->
|
||||
<div class="border-t border-gray-200 pt-4 dark:border-dark-600">
|
||||
<div class="mb-3 flex items-center justify-between">
|
||||
<label class="input-label mb-0">{{ t('admin.accounts.modelRestriction') }}</label>
|
||||
<label
|
||||
id="bulk-edit-model-restriction-label"
|
||||
class="input-label mb-0"
|
||||
for="bulk-edit-model-restriction-enabled"
|
||||
>
|
||||
{{ t('admin.accounts.modelRestriction') }}
|
||||
</label>
|
||||
<input
|
||||
v-model="enableModelRestriction"
|
||||
id="bulk-edit-model-restriction-enabled"
|
||||
type="checkbox"
|
||||
aria-controls="bulk-edit-model-restriction-body"
|
||||
class="rounded border-gray-300 text-primary-600 focus:ring-primary-500"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div :class="!enableModelRestriction && 'pointer-events-none opacity-50'">
|
||||
<div
|
||||
id="bulk-edit-model-restriction-body"
|
||||
:class="!enableModelRestriction && 'pointer-events-none opacity-50'"
|
||||
role="group"
|
||||
aria-labelledby="bulk-edit-model-restriction-label"
|
||||
>
|
||||
<!-- Mode Toggle -->
|
||||
<div class="mb-4 flex gap-2">
|
||||
<button
|
||||
@@ -267,19 +295,27 @@
|
||||
<div class="border-t border-gray-200 pt-4 dark:border-dark-600">
|
||||
<div class="mb-3 flex items-center justify-between">
|
||||
<div>
|
||||
<label class="input-label mb-0">{{ t('admin.accounts.customErrorCodes') }}</label>
|
||||
<label
|
||||
id="bulk-edit-custom-error-codes-label"
|
||||
class="input-label mb-0"
|
||||
for="bulk-edit-custom-error-codes-enabled"
|
||||
>
|
||||
{{ t('admin.accounts.customErrorCodes') }}
|
||||
</label>
|
||||
<p class="mt-1 text-xs text-gray-500 dark:text-gray-400">
|
||||
{{ t('admin.accounts.customErrorCodesHint') }}
|
||||
</p>
|
||||
</div>
|
||||
<input
|
||||
v-model="enableCustomErrorCodes"
|
||||
id="bulk-edit-custom-error-codes-enabled"
|
||||
type="checkbox"
|
||||
aria-controls="bulk-edit-custom-error-codes-body"
|
||||
class="rounded border-gray-300 text-primary-600 focus:ring-primary-500"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div v-if="enableCustomErrorCodes" class="space-y-3">
|
||||
<div v-if="enableCustomErrorCodes" id="bulk-edit-custom-error-codes-body" class="space-y-3">
|
||||
<div class="rounded-lg bg-amber-50 p-3 dark:bg-amber-900/20">
|
||||
<p class="text-xs text-amber-700 dark:text-amber-400">
|
||||
<svg
|
||||
@@ -321,11 +357,13 @@
|
||||
<div class="flex items-center gap-2">
|
||||
<input
|
||||
v-model="customErrorCodeInput"
|
||||
id="bulk-edit-custom-error-code-input"
|
||||
type="number"
|
||||
min="100"
|
||||
max="599"
|
||||
class="input flex-1"
|
||||
:placeholder="t('admin.accounts.enterErrorCode')"
|
||||
aria-labelledby="bulk-edit-custom-error-codes-label"
|
||||
@keyup.enter="addCustomErrorCode"
|
||||
/>
|
||||
<button type="button" class="btn btn-secondary px-3" @click="addCustomErrorCode">
|
||||
@@ -374,20 +412,26 @@
|
||||
<div class="border-t border-gray-200 pt-4 dark:border-dark-600">
|
||||
<div class="flex items-center justify-between">
|
||||
<div class="flex-1 pr-4">
|
||||
<label class="input-label mb-0">{{
|
||||
t('admin.accounts.interceptWarmupRequests')
|
||||
}}</label>
|
||||
<label
|
||||
id="bulk-edit-intercept-warmup-label"
|
||||
class="input-label mb-0"
|
||||
for="bulk-edit-intercept-warmup-enabled"
|
||||
>
|
||||
{{ t('admin.accounts.interceptWarmupRequests') }}
|
||||
</label>
|
||||
<p class="mt-1 text-xs text-gray-500 dark:text-gray-400">
|
||||
{{ t('admin.accounts.interceptWarmupRequestsDesc') }}
|
||||
</p>
|
||||
</div>
|
||||
<input
|
||||
v-model="enableInterceptWarmup"
|
||||
id="bulk-edit-intercept-warmup-enabled"
|
||||
type="checkbox"
|
||||
aria-controls="bulk-edit-intercept-warmup-body"
|
||||
class="rounded border-gray-300 text-primary-600 focus:ring-primary-500"
|
||||
/>
|
||||
</div>
|
||||
<div v-if="enableInterceptWarmup" class="mt-3">
|
||||
<div v-if="enableInterceptWarmup" id="bulk-edit-intercept-warmup-body" class="mt-3">
|
||||
<button
|
||||
type="button"
|
||||
:class="[
|
||||
@@ -409,15 +453,27 @@
|
||||
<!-- Proxy -->
|
||||
<div class="border-t border-gray-200 pt-4 dark:border-dark-600">
|
||||
<div class="mb-3 flex items-center justify-between">
|
||||
<label class="input-label mb-0">{{ t('admin.accounts.proxy') }}</label>
|
||||
<label
|
||||
id="bulk-edit-proxy-label"
|
||||
class="input-label mb-0"
|
||||
for="bulk-edit-proxy-enabled"
|
||||
>
|
||||
{{ t('admin.accounts.proxy') }}
|
||||
</label>
|
||||
<input
|
||||
v-model="enableProxy"
|
||||
id="bulk-edit-proxy-enabled"
|
||||
type="checkbox"
|
||||
aria-controls="bulk-edit-proxy-body"
|
||||
class="rounded border-gray-300 text-primary-600 focus:ring-primary-500"
|
||||
/>
|
||||
</div>
|
||||
<div :class="!enableProxy && 'pointer-events-none opacity-50'">
|
||||
<ProxySelector v-model="proxyId" :proxies="proxies" />
|
||||
<div id="bulk-edit-proxy-body" :class="!enableProxy && 'pointer-events-none opacity-50'">
|
||||
<ProxySelector
|
||||
v-model="proxyId"
|
||||
:proxies="proxies"
|
||||
aria-labelledby="bulk-edit-proxy-label"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -425,38 +481,58 @@
|
||||
<div class="grid grid-cols-2 gap-4 border-t border-gray-200 pt-4 dark:border-dark-600">
|
||||
<div>
|
||||
<div class="mb-3 flex items-center justify-between">
|
||||
<label class="input-label mb-0">{{ t('admin.accounts.concurrency') }}</label>
|
||||
<label
|
||||
id="bulk-edit-concurrency-label"
|
||||
class="input-label mb-0"
|
||||
for="bulk-edit-concurrency-enabled"
|
||||
>
|
||||
{{ t('admin.accounts.concurrency') }}
|
||||
</label>
|
||||
<input
|
||||
v-model="enableConcurrency"
|
||||
id="bulk-edit-concurrency-enabled"
|
||||
type="checkbox"
|
||||
aria-controls="bulk-edit-concurrency"
|
||||
class="rounded border-gray-300 text-primary-600 focus:ring-primary-500"
|
||||
/>
|
||||
</div>
|
||||
<input
|
||||
v-model.number="concurrency"
|
||||
id="bulk-edit-concurrency"
|
||||
type="number"
|
||||
min="1"
|
||||
:disabled="!enableConcurrency"
|
||||
class="input"
|
||||
:class="!enableConcurrency && 'cursor-not-allowed opacity-50'"
|
||||
aria-labelledby="bulk-edit-concurrency-label"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<div class="mb-3 flex items-center justify-between">
|
||||
<label class="input-label mb-0">{{ t('admin.accounts.priority') }}</label>
|
||||
<label
|
||||
id="bulk-edit-priority-label"
|
||||
class="input-label mb-0"
|
||||
for="bulk-edit-priority-enabled"
|
||||
>
|
||||
{{ t('admin.accounts.priority') }}
|
||||
</label>
|
||||
<input
|
||||
v-model="enablePriority"
|
||||
id="bulk-edit-priority-enabled"
|
||||
type="checkbox"
|
||||
aria-controls="bulk-edit-priority"
|
||||
class="rounded border-gray-300 text-primary-600 focus:ring-primary-500"
|
||||
/>
|
||||
</div>
|
||||
<input
|
||||
v-model.number="priority"
|
||||
id="bulk-edit-priority"
|
||||
type="number"
|
||||
min="1"
|
||||
:disabled="!enablePriority"
|
||||
class="input"
|
||||
:class="!enablePriority && 'cursor-not-allowed opacity-50'"
|
||||
aria-labelledby="bulk-edit-priority-label"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
@@ -464,39 +540,69 @@
|
||||
<!-- Status -->
|
||||
<div class="border-t border-gray-200 pt-4 dark:border-dark-600">
|
||||
<div class="mb-3 flex items-center justify-between">
|
||||
<label class="input-label mb-0">{{ t('common.status') }}</label>
|
||||
<label
|
||||
id="bulk-edit-status-label"
|
||||
class="input-label mb-0"
|
||||
for="bulk-edit-status-enabled"
|
||||
>
|
||||
{{ t('common.status') }}
|
||||
</label>
|
||||
<input
|
||||
v-model="enableStatus"
|
||||
id="bulk-edit-status-enabled"
|
||||
type="checkbox"
|
||||
aria-controls="bulk-edit-status"
|
||||
class="rounded border-gray-300 text-primary-600 focus:ring-primary-500"
|
||||
/>
|
||||
</div>
|
||||
<div :class="!enableStatus && 'pointer-events-none opacity-50'">
|
||||
<Select v-model="status" :options="statusOptions" />
|
||||
<div id="bulk-edit-status" :class="!enableStatus && 'pointer-events-none opacity-50'">
|
||||
<Select
|
||||
v-model="status"
|
||||
:options="statusOptions"
|
||||
aria-labelledby="bulk-edit-status-label"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Groups -->
|
||||
<div class="border-t border-gray-200 pt-4 dark:border-dark-600">
|
||||
<div class="mb-3 flex items-center justify-between">
|
||||
<label class="input-label mb-0">{{ t('nav.groups') }}</label>
|
||||
<label
|
||||
id="bulk-edit-groups-label"
|
||||
class="input-label mb-0"
|
||||
for="bulk-edit-groups-enabled"
|
||||
>
|
||||
{{ t('nav.groups') }}
|
||||
</label>
|
||||
<input
|
||||
v-model="enableGroups"
|
||||
id="bulk-edit-groups-enabled"
|
||||
type="checkbox"
|
||||
aria-controls="bulk-edit-groups"
|
||||
class="rounded border-gray-300 text-primary-600 focus:ring-primary-500"
|
||||
/>
|
||||
</div>
|
||||
<div :class="!enableGroups && 'pointer-events-none opacity-50'">
|
||||
<GroupSelector v-model="groupIds" :groups="groups" />
|
||||
<div id="bulk-edit-groups" :class="!enableGroups && 'pointer-events-none opacity-50'">
|
||||
<GroupSelector
|
||||
v-model="groupIds"
|
||||
:groups="groups"
|
||||
aria-labelledby="bulk-edit-groups-label"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<!-- Action buttons -->
|
||||
<div class="flex justify-end gap-3 pt-4">
|
||||
<template #footer>
|
||||
<div class="flex justify-end gap-3">
|
||||
<button type="button" class="btn btn-secondary" @click="handleClose">
|
||||
{{ t('common.cancel') }}
|
||||
</button>
|
||||
<button type="submit" :disabled="submitting" class="btn btn-primary">
|
||||
<button
|
||||
type="submit"
|
||||
form="bulk-edit-account-form"
|
||||
:disabled="submitting"
|
||||
class="btn btn-primary"
|
||||
>
|
||||
<svg
|
||||
v-if="submitting"
|
||||
class="-ml-1 mr-2 h-4 w-4 animate-spin"
|
||||
@@ -522,8 +628,8 @@
|
||||
}}
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</Modal>
|
||||
</template>
|
||||
</BaseDialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
@@ -532,7 +638,7 @@ import { useI18n } from 'vue-i18n'
|
||||
import { useAppStore } from '@/stores/app'
|
||||
import { adminAPI } from '@/api/admin'
|
||||
import type { Proxy, Group } from '@/types'
|
||||
import Modal from '@/components/common/Modal.vue'
|
||||
import BaseDialog from '@/components/common/BaseDialog.vue'
|
||||
import Select from '@/components/common/Select.vue'
|
||||
import ProxySelector from '@/components/common/ProxySelector.vue'
|
||||
import GroupSelector from '@/components/common/GroupSelector.vue'
|
||||
|
||||
Reference in New Issue
Block a user