feat:完成多token分发

This commit is contained in:
chenchun
2025-12-04 16:32:30 +08:00
parent 525545329b
commit c03ef82643
3 changed files with 17 additions and 24 deletions

View File

@@ -162,7 +162,7 @@ async function handleFormSubmit(data: TokenFormData) {
id: data.id,
name: data.name,
expireTime: data.expireTime || null,
premiumQuotaLimit: data.premiumQuotaLimit || 0,
premiumQuotaLimit: data.premiumQuotaLimit || null,
};
if (formMode.value === 'create') {
@@ -418,7 +418,7 @@ onMounted(async () => {
<el-table-column
label="API 密钥"
min-width="300"
min-width="200"
align="left"
header-align="left"
resizable
@@ -426,11 +426,8 @@ onMounted(async () => {
<template #default="{ row }">
<div class="key-cell">
<div class="key-content">
<el-icon class="key-icon">
<i-ep-key />
</el-icon>
<span class="key-text">
{{ row.showKey ? row.apiKey : '••••••••••••••••••••••••••••••••' }}
{{ row.showKey ? row.apiKey : '•••••••••••••••••••••' }}
</span>
</div>
<div class="key-actions">
@@ -534,7 +531,7 @@ onMounted(async () => {
<el-table-column
label="创建时间"
min-width="180"
min-width="160"
prop="creationTime"
sortable
align="center"
@@ -543,9 +540,6 @@ onMounted(async () => {
>
<template #default="{ row }">
<div class="time-cell">
<el-icon class="time-icon">
<i-ep-clock />
</el-icon>
<span>{{ formatDateTime(row.creationTime) }}</span>
</div>
</template>
@@ -553,7 +547,7 @@ onMounted(async () => {
<el-table-column
label="操作"
width="300"
width="80"
fixed="right"
align="center"
header-align="center"
@@ -568,6 +562,7 @@ onMounted(async () => {
编辑
</el-button>
<el-button
style="margin-left: 0px"
size="small"
:type="row.isDisabled ? 'success' : 'warning'"
:icon="row.isDisabled ? Check : Close"
@@ -577,6 +572,7 @@ onMounted(async () => {
{{ row.isDisabled ? '启用' : '禁用' }}
</el-button>
<el-button
style="margin-left: 0px"
size="small"
type="danger"
:icon="Delete"
@@ -668,7 +664,8 @@ onMounted(async () => {
border: 1px solid #e8e8e8;
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.04);
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
margin-bottom: 24px;
margin-bottom: 10px;
overflow: hidden;
&:hover {
@@ -682,7 +679,7 @@ onMounted(async () => {
}
:deep(.el-card__body) {
padding: 28px;
padding: 15px;
}
}
@@ -829,10 +826,9 @@ onMounted(async () => {
.key-cell {
display: flex;
align-items: center;
justify-content: space-between;
flex-direction: column;
gap: 16px;
padding: 0 8px;
padding: 0;
}
.key-content {
@@ -864,8 +860,8 @@ onMounted(async () => {
.key-actions {
display: flex;
gap: 4px;
flex-shrink: 0;
justify-content: center;
}
.quota-cell {

View File

@@ -6,7 +6,7 @@ interface TokenFormData {
id?: string;
name: string;
expireTime: string;
premiumQuotaLimit: number;
premiumQuotaLimit: number | null;
quotaUnit: string;
}
@@ -154,12 +154,11 @@ async function handleConfirm() {
try {
// 将展示值转换为实际值
let actualQuota = 0;
let actualQuota = null;
if (!unlimitedQuota.value) {
const unit = quotaUnitOptions.find(u => u.value === localFormData.value.quotaUnit);
actualQuota = localFormData.value.premiumQuotaLimit * (unit?.multiplier || 1);
}
const submitData: TokenFormData = {
...localFormData.value,
expireTime: neverExpire.value ? '' : localFormData.value.expireTime,

View File

@@ -1,11 +1,9 @@
import { useUserStore } from '@/stores/index.js';
import {useUserStore} from '@/stores/index.js';
// 判断是否是 VIP 用户
export function isUserVip(): boolean {
const userStore = useUserStore();
const userRoles = userStore.userInfo?.roles ?? [];
const isVip = userRoles.some((role: any) => role.roleCode === 'YiXinAi-Vip');
return isVip;
return userStore.userInfo.isVip;
}
// 用户头像