merge upstream main
This commit is contained in:
@@ -14,6 +14,7 @@ export interface SystemSettings {
|
||||
email_verify_enabled: boolean
|
||||
promo_code_enabled: boolean
|
||||
password_reset_enabled: boolean
|
||||
invitation_code_enabled: boolean
|
||||
totp_enabled: boolean // TOTP 双因素认证
|
||||
totp_encryption_key_configured: boolean // TOTP 加密密钥是否已配置
|
||||
// Default settings
|
||||
@@ -72,6 +73,7 @@ export interface UpdateSettingsRequest {
|
||||
email_verify_enabled?: boolean
|
||||
promo_code_enabled?: boolean
|
||||
password_reset_enabled?: boolean
|
||||
invitation_code_enabled?: boolean
|
||||
totp_enabled?: boolean // TOTP 双因素认证
|
||||
default_balance?: number
|
||||
default_concurrency?: number
|
||||
|
||||
@@ -164,6 +164,24 @@ export async function validatePromoCode(code: string): Promise<ValidatePromoCode
|
||||
return data
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate invitation code response
|
||||
*/
|
||||
export interface ValidateInvitationCodeResponse {
|
||||
valid: boolean
|
||||
error_code?: string
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate invitation code (public endpoint, no auth required)
|
||||
* @param code - Invitation code to validate
|
||||
* @returns Validation result
|
||||
*/
|
||||
export async function validateInvitationCode(code: string): Promise<ValidateInvitationCodeResponse> {
|
||||
const { data } = await apiClient.post<ValidateInvitationCodeResponse>('/auth/validate-invitation-code', { code })
|
||||
return data
|
||||
}
|
||||
|
||||
/**
|
||||
* Forgot password request
|
||||
*/
|
||||
@@ -229,6 +247,7 @@ export const authAPI = {
|
||||
getPublicSettings,
|
||||
sendVerifyCode,
|
||||
validatePromoCode,
|
||||
validateInvitationCode,
|
||||
forgotPassword,
|
||||
resetPassword
|
||||
}
|
||||
|
||||
@@ -21,6 +21,12 @@
|
||||
<span class="font-medium text-gray-900 dark:text-white">{{ value }}</span>
|
||||
</template>
|
||||
|
||||
<template #cell-reasoning_effort="{ row }">
|
||||
<span class="text-sm text-gray-900 dark:text-white">
|
||||
{{ formatReasoningEffort(row.reasoning_effort) }}
|
||||
</span>
|
||||
</template>
|
||||
|
||||
<template #cell-group="{ row }">
|
||||
<span v-if="row.group" class="inline-flex items-center rounded px-2 py-0.5 text-xs font-medium bg-indigo-100 text-indigo-800 dark:bg-indigo-900 dark:text-indigo-200">
|
||||
{{ row.group.name }}
|
||||
@@ -235,7 +241,7 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, computed } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { formatDateTime } from '@/utils/format'
|
||||
import { formatDateTime, formatReasoningEffort } from '@/utils/format'
|
||||
import DataTable from '@/components/common/DataTable.vue'
|
||||
import EmptyState from '@/components/common/EmptyState.vue'
|
||||
import Icon from '@/components/icons/Icon.vue'
|
||||
@@ -259,6 +265,7 @@ const cols = computed(() => [
|
||||
{ key: 'api_key', label: t('usage.apiKeyFilter'), sortable: false },
|
||||
{ key: 'account', label: t('admin.usage.account'), sortable: false },
|
||||
{ key: 'model', label: t('usage.model'), sortable: true },
|
||||
{ key: 'reasoning_effort', label: t('usage.reasoningEffort'), sortable: false },
|
||||
{ key: 'group', label: t('admin.usage.group'), sortable: false },
|
||||
{ key: 'stream', label: t('usage.type'), sortable: false },
|
||||
{ key: 'tokens', label: t('usage.tokens'), sortable: false },
|
||||
|
||||
@@ -265,6 +265,13 @@ export default {
|
||||
promoCodeAlreadyUsed: 'You have already used this promo code',
|
||||
promoCodeValidating: 'Promo code is being validated, please wait',
|
||||
promoCodeInvalidCannotRegister: 'Invalid promo code. Please check and try again or clear the promo code field',
|
||||
invitationCodeLabel: 'Invitation Code',
|
||||
invitationCodePlaceholder: 'Enter invitation code',
|
||||
invitationCodeRequired: 'Invitation code is required',
|
||||
invitationCodeValid: 'Invitation code is valid',
|
||||
invitationCodeInvalid: 'Invalid or used invitation code',
|
||||
invitationCodeValidating: 'Validating invitation code...',
|
||||
invitationCodeInvalidCannotRegister: 'Invalid invitation code. Please check and try again',
|
||||
linuxdo: {
|
||||
signIn: 'Continue with Linux.do',
|
||||
orContinue: 'or continue with email',
|
||||
@@ -495,6 +502,7 @@ export default {
|
||||
exporting: 'Exporting...',
|
||||
preparingExport: 'Preparing export...',
|
||||
model: 'Model',
|
||||
reasoningEffort: 'Reasoning Effort',
|
||||
type: 'Type',
|
||||
tokens: 'Tokens',
|
||||
cost: 'Cost',
|
||||
@@ -1009,6 +1017,14 @@ export default {
|
||||
hint: 'Triggered only when upstream explicitly returns prompt too long. Leave empty to disable fallback.',
|
||||
noFallback: 'No Fallback'
|
||||
},
|
||||
copyAccounts: {
|
||||
title: 'Copy Accounts from Groups',
|
||||
tooltip: 'Select one or more groups of the same platform. After creation, all accounts from these groups will be automatically bound to the new group (deduplicated).',
|
||||
tooltipEdit: 'Select one or more groups of the same platform. After saving, current group accounts will be replaced with accounts from these groups (deduplicated).',
|
||||
selectPlaceholder: 'Select groups to copy accounts from...',
|
||||
hint: 'Multiple groups can be selected, accounts will be deduplicated',
|
||||
hintEdit: '⚠️ Warning: This will replace all existing account bindings'
|
||||
},
|
||||
modelRouting: {
|
||||
title: 'Model Routing',
|
||||
tooltip: 'Configure specific model requests to be routed to designated accounts. Supports wildcard matching, e.g., claude-opus-* matches all opus models.',
|
||||
@@ -1922,6 +1938,8 @@ export default {
|
||||
balance: 'Balance',
|
||||
concurrency: 'Concurrency',
|
||||
subscription: 'Subscription',
|
||||
invitation: 'Invitation',
|
||||
invitationHint: 'Invitation codes are used to restrict user registration. They are automatically marked as used after use.',
|
||||
unused: 'Unused',
|
||||
used: 'Used',
|
||||
columns: {
|
||||
@@ -1968,6 +1986,7 @@ export default {
|
||||
balance: 'Balance',
|
||||
concurrency: 'Concurrency',
|
||||
subscription: 'Subscription',
|
||||
invitation: 'Invitation',
|
||||
// Admin adjustment types (created when admin modifies user balance/concurrency)
|
||||
admin_balance: 'Balance (Admin)',
|
||||
admin_concurrency: 'Concurrency (Admin)'
|
||||
@@ -2925,6 +2944,8 @@ export default {
|
||||
emailVerificationHint: 'Require email verification for new registrations',
|
||||
promoCode: 'Promo Code',
|
||||
promoCodeHint: 'Allow users to use promo codes during registration',
|
||||
invitationCode: 'Invitation Code Registration',
|
||||
invitationCodeHint: 'When enabled, users must enter a valid invitation code to register',
|
||||
passwordReset: 'Password Reset',
|
||||
passwordResetHint: 'Allow users to reset their password via email',
|
||||
totp: 'Two-Factor Authentication (2FA)',
|
||||
|
||||
@@ -262,6 +262,13 @@ export default {
|
||||
promoCodeAlreadyUsed: '您已使用过此优惠码',
|
||||
promoCodeValidating: '优惠码正在验证中,请稍候',
|
||||
promoCodeInvalidCannotRegister: '优惠码无效,请检查后重试或清空优惠码',
|
||||
invitationCodeLabel: '邀请码',
|
||||
invitationCodePlaceholder: '请输入邀请码',
|
||||
invitationCodeRequired: '请输入邀请码',
|
||||
invitationCodeValid: '邀请码有效',
|
||||
invitationCodeInvalid: '邀请码无效或已被使用',
|
||||
invitationCodeValidating: '正在验证邀请码...',
|
||||
invitationCodeInvalidCannotRegister: '邀请码无效,请检查后重试',
|
||||
linuxdo: {
|
||||
signIn: '使用 Linux.do 登录',
|
||||
orContinue: '或使用邮箱密码继续',
|
||||
@@ -491,6 +498,7 @@ export default {
|
||||
exporting: '导出中...',
|
||||
preparingExport: '正在准备导出...',
|
||||
model: '模型',
|
||||
reasoningEffort: '推理强度',
|
||||
type: '类型',
|
||||
tokens: 'Token',
|
||||
cost: '费用',
|
||||
@@ -1084,6 +1092,14 @@ export default {
|
||||
hint: '仅当上游明确返回 prompt too long 时才会触发,留空表示不兜底',
|
||||
noFallback: '不兜底'
|
||||
},
|
||||
copyAccounts: {
|
||||
title: '从分组复制账号',
|
||||
tooltip: '选择一个或多个相同平台的分组,创建后会自动将这些分组的所有账号绑定到新分组(去重)。',
|
||||
tooltipEdit: '选择一个或多个相同平台的分组,保存后当前分组的账号会被替换为这些分组的账号(去重)。',
|
||||
selectPlaceholder: '选择分组以复制其账号...',
|
||||
hint: '可选多个分组,账号会自动去重',
|
||||
hintEdit: '⚠️ 注意:这会替换当前分组的所有账号绑定'
|
||||
},
|
||||
modelRouting: {
|
||||
title: '模型路由配置',
|
||||
tooltip: '配置特定模型请求优先路由到指定账号。支持通配符匹配,如 claude-opus-* 匹配所有 opus 模型。',
|
||||
@@ -2045,6 +2061,7 @@ export default {
|
||||
balance: '余额',
|
||||
concurrency: '并发数',
|
||||
subscription: '订阅',
|
||||
invitation: '邀请码',
|
||||
// 管理员在用户管理页面调整余额/并发时产生的记录
|
||||
admin_balance: '余额(管理员)',
|
||||
admin_concurrency: '并发数(管理员)'
|
||||
@@ -2053,6 +2070,8 @@ export default {
|
||||
balance: '余额',
|
||||
concurrency: '并发数',
|
||||
subscription: '订阅',
|
||||
invitation: '邀请码',
|
||||
invitationHint: '邀请码用于限制用户注册,使用后自动标记为已使用。',
|
||||
allTypes: '全部类型',
|
||||
allStatus: '全部状态',
|
||||
unused: '未使用',
|
||||
@@ -3078,6 +3097,8 @@ export default {
|
||||
emailVerificationHint: '新用户注册时需要验证邮箱',
|
||||
promoCode: '优惠码',
|
||||
promoCodeHint: '允许用户在注册时使用优惠码',
|
||||
invitationCode: '邀请码注册',
|
||||
invitationCodeHint: '开启后,用户注册时需要填写有效的邀请码',
|
||||
passwordReset: '忘记密码',
|
||||
passwordResetHint: '允许用户通过邮箱重置密码',
|
||||
totp: '双因素认证 (2FA)',
|
||||
|
||||
@@ -314,6 +314,7 @@ export const useAppStore = defineStore('app', () => {
|
||||
email_verify_enabled: false,
|
||||
promo_code_enabled: true,
|
||||
password_reset_enabled: false,
|
||||
invitation_code_enabled: false,
|
||||
turnstile_enabled: false,
|
||||
turnstile_site_key: '',
|
||||
site_name: siteName.value,
|
||||
|
||||
@@ -55,6 +55,7 @@ export interface RegisterRequest {
|
||||
verify_code?: string
|
||||
turnstile_token?: string
|
||||
promo_code?: string
|
||||
invitation_code?: string
|
||||
}
|
||||
|
||||
export interface SendVerifyCodeRequest {
|
||||
@@ -72,6 +73,7 @@ export interface PublicSettings {
|
||||
email_verify_enabled: boolean
|
||||
promo_code_enabled: boolean
|
||||
password_reset_enabled: boolean
|
||||
invitation_code_enabled: boolean
|
||||
turnstile_enabled: boolean
|
||||
turnstile_site_key: string
|
||||
site_name: string
|
||||
@@ -419,7 +421,10 @@ export interface CreateGroupRequest {
|
||||
claude_code_only?: boolean
|
||||
fallback_group_id?: number | null
|
||||
fallback_group_id_on_invalid_request?: number | null
|
||||
mcp_xml_inject?: boolean
|
||||
supported_model_scopes?: string[]
|
||||
// 从指定分组复制账号
|
||||
copy_accounts_from_group_ids?: number[]
|
||||
}
|
||||
|
||||
export interface UpdateGroupRequest {
|
||||
@@ -439,7 +444,9 @@ export interface UpdateGroupRequest {
|
||||
claude_code_only?: boolean
|
||||
fallback_group_id?: number | null
|
||||
fallback_group_id_on_invalid_request?: number | null
|
||||
mcp_xml_inject?: boolean
|
||||
supported_model_scopes?: string[]
|
||||
copy_accounts_from_group_ids?: number[]
|
||||
}
|
||||
|
||||
// ==================== Account & Proxy Types ====================
|
||||
@@ -712,7 +719,7 @@ export interface UpdateProxyRequest {
|
||||
|
||||
// ==================== Usage & Redeem Types ====================
|
||||
|
||||
export type RedeemCodeType = 'balance' | 'concurrency' | 'subscription'
|
||||
export type RedeemCodeType = 'balance' | 'concurrency' | 'subscription' | 'invitation'
|
||||
|
||||
export interface UsageLog {
|
||||
id: number
|
||||
@@ -721,6 +728,7 @@ export interface UsageLog {
|
||||
account_id: number | null
|
||||
request_id: string
|
||||
model: string
|
||||
reasoning_effort?: string | null
|
||||
|
||||
group_id: number | null
|
||||
subscription_id: number | null
|
||||
|
||||
@@ -174,6 +174,35 @@ export function parseDateTimeLocalInput(value: string): number | null {
|
||||
return Math.floor(date.getTime() / 1000)
|
||||
}
|
||||
|
||||
/**
|
||||
* 格式化 OpenAI reasoning effort(用于使用记录展示)
|
||||
* @param effort 原始 effort(如 "low" / "medium" / "high" / "xhigh")
|
||||
* @returns 格式化后的字符串(Low / Medium / High / Xhigh),无值返回 "-"
|
||||
*/
|
||||
export function formatReasoningEffort(effort: string | null | undefined): string {
|
||||
const raw = (effort ?? '').toString().trim()
|
||||
if (!raw) return '-'
|
||||
|
||||
const normalized = raw.toLowerCase().replace(/[-_\s]/g, '')
|
||||
switch (normalized) {
|
||||
case 'low':
|
||||
return 'Low'
|
||||
case 'medium':
|
||||
return 'Medium'
|
||||
case 'high':
|
||||
return 'High'
|
||||
case 'xhigh':
|
||||
case 'extrahigh':
|
||||
return 'Xhigh'
|
||||
case 'none':
|
||||
case 'minimal':
|
||||
return '-'
|
||||
default:
|
||||
// best-effort: Title-case first letter
|
||||
return raw.length > 1 ? raw[0].toUpperCase() + raw.slice(1) : raw.toUpperCase()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 格式化时间(只显示时分)
|
||||
* @param date 日期字符串或 Date 对象
|
||||
|
||||
@@ -240,9 +240,73 @@
|
||||
v-model="createForm.platform"
|
||||
:options="platformOptions"
|
||||
data-tour="group-form-platform"
|
||||
@change="createForm.copy_accounts_from_group_ids = []"
|
||||
/>
|
||||
<p class="input-hint">{{ t('admin.groups.platformHint') }}</p>
|
||||
</div>
|
||||
<!-- 从分组复制账号 -->
|
||||
<div v-if="copyAccountsGroupOptions.length > 0">
|
||||
<div class="mb-1.5 flex items-center gap-1">
|
||||
<label class="text-sm font-medium text-gray-700 dark:text-gray-300">
|
||||
{{ t('admin.groups.copyAccounts.title') }}
|
||||
</label>
|
||||
<div class="group relative inline-flex">
|
||||
<Icon
|
||||
name="questionCircle"
|
||||
size="sm"
|
||||
:stroke-width="2"
|
||||
class="cursor-help text-gray-400 transition-colors hover:text-primary-500 dark:text-gray-500 dark:hover:text-primary-400"
|
||||
/>
|
||||
<div class="pointer-events-none absolute bottom-full left-0 z-50 mb-2 w-72 opacity-0 transition-all duration-200 group-hover:pointer-events-auto group-hover:opacity-100">
|
||||
<div class="rounded-lg bg-gray-900 p-3 text-white shadow-lg dark:bg-gray-800">
|
||||
<p class="text-xs leading-relaxed text-gray-300">
|
||||
{{ t('admin.groups.copyAccounts.tooltip') }}
|
||||
</p>
|
||||
<div class="absolute -bottom-1.5 left-3 h-3 w-3 rotate-45 bg-gray-900 dark:bg-gray-800"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 已选分组标签 -->
|
||||
<div v-if="createForm.copy_accounts_from_group_ids.length > 0" class="flex flex-wrap gap-1.5 mb-2">
|
||||
<span
|
||||
v-for="groupId in createForm.copy_accounts_from_group_ids"
|
||||
:key="groupId"
|
||||
class="inline-flex items-center gap-1 rounded-full bg-primary-100 px-2.5 py-1 text-xs font-medium text-primary-700 dark:bg-primary-900/30 dark:text-primary-300"
|
||||
>
|
||||
{{ copyAccountsGroupOptions.find(o => o.value === groupId)?.label || `#${groupId}` }}
|
||||
<button
|
||||
type="button"
|
||||
@click="createForm.copy_accounts_from_group_ids = createForm.copy_accounts_from_group_ids.filter(id => id !== groupId)"
|
||||
class="ml-0.5 text-primary-500 hover:text-primary-700 dark:hover:text-primary-200"
|
||||
>
|
||||
<Icon name="x" size="xs" />
|
||||
</button>
|
||||
</span>
|
||||
</div>
|
||||
<!-- 分组选择下拉 -->
|
||||
<select
|
||||
class="input"
|
||||
@change="(e) => {
|
||||
const val = Number((e.target as HTMLSelectElement).value)
|
||||
if (val && !createForm.copy_accounts_from_group_ids.includes(val)) {
|
||||
createForm.copy_accounts_from_group_ids.push(val)
|
||||
}
|
||||
(e.target as HTMLSelectElement).value = ''
|
||||
}"
|
||||
>
|
||||
<option value="">{{ t('admin.groups.copyAccounts.selectPlaceholder') }}</option>
|
||||
<option
|
||||
v-for="opt in copyAccountsGroupOptions"
|
||||
:key="opt.value"
|
||||
:value="opt.value"
|
||||
:disabled="createForm.copy_accounts_from_group_ids.includes(opt.value)"
|
||||
>
|
||||
{{ opt.label }}
|
||||
</option>
|
||||
</select>
|
||||
<p class="input-hint">{{ t('admin.groups.copyAccounts.hint') }}</p>
|
||||
</div>
|
||||
<div>
|
||||
<label class="input-label">{{ t('admin.groups.form.rateMultiplier') }}</label>
|
||||
<input
|
||||
@@ -795,6 +859,69 @@
|
||||
/>
|
||||
<p class="input-hint">{{ t('admin.groups.platformNotEditable') }}</p>
|
||||
</div>
|
||||
<!-- 从分组复制账号(编辑时) -->
|
||||
<div v-if="copyAccountsGroupOptionsForEdit.length > 0">
|
||||
<div class="mb-1.5 flex items-center gap-1">
|
||||
<label class="text-sm font-medium text-gray-700 dark:text-gray-300">
|
||||
{{ t('admin.groups.copyAccounts.title') }}
|
||||
</label>
|
||||
<div class="group relative inline-flex">
|
||||
<Icon
|
||||
name="questionCircle"
|
||||
size="sm"
|
||||
:stroke-width="2"
|
||||
class="cursor-help text-gray-400 transition-colors hover:text-primary-500 dark:text-gray-500 dark:hover:text-primary-400"
|
||||
/>
|
||||
<div class="pointer-events-none absolute bottom-full left-0 z-50 mb-2 w-72 opacity-0 transition-all duration-200 group-hover:pointer-events-auto group-hover:opacity-100">
|
||||
<div class="rounded-lg bg-gray-900 p-3 text-white shadow-lg dark:bg-gray-800">
|
||||
<p class="text-xs leading-relaxed text-gray-300">
|
||||
{{ t('admin.groups.copyAccounts.tooltipEdit') }}
|
||||
</p>
|
||||
<div class="absolute -bottom-1.5 left-3 h-3 w-3 rotate-45 bg-gray-900 dark:bg-gray-800"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 已选分组标签 -->
|
||||
<div v-if="editForm.copy_accounts_from_group_ids.length > 0" class="flex flex-wrap gap-1.5 mb-2">
|
||||
<span
|
||||
v-for="groupId in editForm.copy_accounts_from_group_ids"
|
||||
:key="groupId"
|
||||
class="inline-flex items-center gap-1 rounded-full bg-primary-100 px-2.5 py-1 text-xs font-medium text-primary-700 dark:bg-primary-900/30 dark:text-primary-300"
|
||||
>
|
||||
{{ copyAccountsGroupOptionsForEdit.find(o => o.value === groupId)?.label || `#${groupId}` }}
|
||||
<button
|
||||
type="button"
|
||||
@click="editForm.copy_accounts_from_group_ids = editForm.copy_accounts_from_group_ids.filter(id => id !== groupId)"
|
||||
class="ml-0.5 text-primary-500 hover:text-primary-700 dark:hover:text-primary-200"
|
||||
>
|
||||
<Icon name="x" size="xs" />
|
||||
</button>
|
||||
</span>
|
||||
</div>
|
||||
<!-- 分组选择下拉 -->
|
||||
<select
|
||||
class="input"
|
||||
@change="(e) => {
|
||||
const val = Number((e.target as HTMLSelectElement).value)
|
||||
if (val && !editForm.copy_accounts_from_group_ids.includes(val)) {
|
||||
editForm.copy_accounts_from_group_ids.push(val)
|
||||
}
|
||||
(e.target as HTMLSelectElement).value = ''
|
||||
}"
|
||||
>
|
||||
<option value="">{{ t('admin.groups.copyAccounts.selectPlaceholder') }}</option>
|
||||
<option
|
||||
v-for="opt in copyAccountsGroupOptionsForEdit"
|
||||
:key="opt.value"
|
||||
:value="opt.value"
|
||||
:disabled="editForm.copy_accounts_from_group_ids.includes(opt.value)"
|
||||
>
|
||||
{{ opt.label }}
|
||||
</option>
|
||||
</select>
|
||||
<p class="input-hint">{{ t('admin.groups.copyAccounts.hintEdit') }}</p>
|
||||
</div>
|
||||
<div>
|
||||
<label class="input-label">{{ t('admin.groups.form.rateMultiplier') }}</label>
|
||||
<input
|
||||
@@ -1470,6 +1597,29 @@ const invalidRequestFallbackOptionsForEdit = computed(() => {
|
||||
return options
|
||||
})
|
||||
|
||||
// 复制账号的源分组选项(创建时)- 仅包含相同平台且有账号的分组
|
||||
const copyAccountsGroupOptions = computed(() => {
|
||||
const eligibleGroups = groups.value.filter(
|
||||
(g) => g.platform === createForm.platform && (g.account_count || 0) > 0
|
||||
)
|
||||
return eligibleGroups.map((g) => ({
|
||||
value: g.id,
|
||||
label: `${g.name} (${g.account_count || 0} 个账号)`
|
||||
}))
|
||||
})
|
||||
|
||||
// 复制账号的源分组选项(编辑时)- 仅包含相同平台且有账号的分组,排除自身
|
||||
const copyAccountsGroupOptionsForEdit = computed(() => {
|
||||
const currentId = editingGroup.value?.id
|
||||
const eligibleGroups = groups.value.filter(
|
||||
(g) => g.platform === editForm.platform && (g.account_count || 0) > 0 && g.id !== currentId
|
||||
)
|
||||
return eligibleGroups.map((g) => ({
|
||||
value: g.id,
|
||||
label: `${g.name} (${g.account_count || 0} 个账号)`
|
||||
}))
|
||||
})
|
||||
|
||||
const groups = ref<AdminGroup[]>([])
|
||||
const loading = ref(false)
|
||||
const searchQuery = ref('')
|
||||
@@ -1517,7 +1667,9 @@ const createForm = reactive({
|
||||
// 支持的模型系列(仅 antigravity 平台)
|
||||
supported_model_scopes: ['claude', 'gemini_text', 'gemini_image'] as string[],
|
||||
// MCP XML 协议注入开关(仅 antigravity 平台)
|
||||
mcp_xml_inject: true
|
||||
mcp_xml_inject: true,
|
||||
// 从分组复制账号
|
||||
copy_accounts_from_group_ids: [] as number[]
|
||||
})
|
||||
|
||||
// 简单账号类型(用于模型路由选择)
|
||||
@@ -1713,7 +1865,9 @@ const editForm = reactive({
|
||||
// 支持的模型系列(仅 antigravity 平台)
|
||||
supported_model_scopes: ['claude', 'gemini_text', 'gemini_image'] as string[],
|
||||
// MCP XML 协议注入开关(仅 antigravity 平台)
|
||||
mcp_xml_inject: true
|
||||
mcp_xml_inject: true,
|
||||
// 从分组复制账号
|
||||
copy_accounts_from_group_ids: [] as number[]
|
||||
})
|
||||
|
||||
// 根据分组类型返回不同的删除确认消息
|
||||
@@ -1798,6 +1952,7 @@ const closeCreateModal = () => {
|
||||
createForm.fallback_group_id_on_invalid_request = null
|
||||
createForm.supported_model_scopes = ['claude', 'gemini_text', 'gemini_image']
|
||||
createForm.mcp_xml_inject = true
|
||||
createForm.copy_accounts_from_group_ids = []
|
||||
createModelRoutingRules.value = []
|
||||
}
|
||||
|
||||
@@ -1851,6 +2006,7 @@ const handleEdit = async (group: AdminGroup) => {
|
||||
editForm.model_routing_enabled = group.model_routing_enabled || false
|
||||
editForm.supported_model_scopes = group.supported_model_scopes || ['claude', 'gemini_text', 'gemini_image']
|
||||
editForm.mcp_xml_inject = group.mcp_xml_inject ?? true
|
||||
editForm.copy_accounts_from_group_ids = [] // 复制账号字段每次编辑时重置为空
|
||||
// 加载模型路由规则(异步加载账号名称)
|
||||
editModelRoutingRules.value = await convertApiFormatToRoutingRules(group.model_routing)
|
||||
showEditModal.value = true
|
||||
@@ -1860,6 +2016,7 @@ const closeEditModal = () => {
|
||||
showEditModal.value = false
|
||||
editingGroup.value = null
|
||||
editModelRoutingRules.value = []
|
||||
editForm.copy_accounts_from_group_ids = []
|
||||
}
|
||||
|
||||
const handleUpdateGroup = async () => {
|
||||
|
||||
@@ -213,7 +213,7 @@
|
||||
<Select v-model="generateForm.type" :options="typeOptions" />
|
||||
</div>
|
||||
<!-- 余额/并发类型:显示数值输入 -->
|
||||
<div v-if="generateForm.type !== 'subscription'">
|
||||
<div v-if="generateForm.type !== 'subscription' && generateForm.type !== 'invitation'">
|
||||
<label class="input-label">
|
||||
{{
|
||||
generateForm.type === 'balance'
|
||||
@@ -230,6 +230,12 @@
|
||||
class="input"
|
||||
/>
|
||||
</div>
|
||||
<!-- 邀请码类型:显示提示信息 -->
|
||||
<div v-if="generateForm.type === 'invitation'" class="rounded-lg bg-blue-50 p-3 dark:bg-blue-900/20">
|
||||
<p class="text-sm text-blue-700 dark:text-blue-300">
|
||||
{{ t('admin.redeem.invitationHint') }}
|
||||
</p>
|
||||
</div>
|
||||
<!-- 订阅类型:显示分组选择和有效天数 -->
|
||||
<template v-if="generateForm.type === 'subscription'">
|
||||
<div>
|
||||
@@ -387,7 +393,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, computed, onMounted, onUnmounted } from 'vue'
|
||||
import { ref, reactive, computed, onMounted, onUnmounted, watch } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { useAppStore } from '@/stores/app'
|
||||
import { useClipboard } from '@/composables/useClipboard'
|
||||
@@ -499,14 +505,16 @@ const columns = computed<Column[]>(() => [
|
||||
const typeOptions = computed(() => [
|
||||
{ value: 'balance', label: t('admin.redeem.balance') },
|
||||
{ value: 'concurrency', label: t('admin.redeem.concurrency') },
|
||||
{ value: 'subscription', label: t('admin.redeem.subscription') }
|
||||
{ value: 'subscription', label: t('admin.redeem.subscription') },
|
||||
{ value: 'invitation', label: t('admin.redeem.invitation') }
|
||||
])
|
||||
|
||||
const filterTypeOptions = computed(() => [
|
||||
{ value: '', label: t('admin.redeem.allTypes') },
|
||||
{ value: 'balance', label: t('admin.redeem.balance') },
|
||||
{ value: 'concurrency', label: t('admin.redeem.concurrency') },
|
||||
{ value: 'subscription', label: t('admin.redeem.subscription') }
|
||||
{ value: 'subscription', label: t('admin.redeem.subscription') },
|
||||
{ value: 'invitation', label: t('admin.redeem.invitation') }
|
||||
])
|
||||
|
||||
const filterStatusOptions = computed(() => [
|
||||
@@ -546,6 +554,18 @@ const generateForm = reactive({
|
||||
validity_days: 30
|
||||
})
|
||||
|
||||
// 监听类型变化,邀请码类型时自动设置 value 为 0
|
||||
watch(
|
||||
() => generateForm.type,
|
||||
(newType) => {
|
||||
if (newType === 'invitation') {
|
||||
generateForm.value = 0
|
||||
} else if (generateForm.value === 0) {
|
||||
generateForm.value = 10
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
const loadCodes = async () => {
|
||||
if (abortController) {
|
||||
abortController.abort()
|
||||
|
||||
@@ -339,6 +339,20 @@
|
||||
<Toggle v-model="form.promo_code_enabled" />
|
||||
</div>
|
||||
|
||||
<!-- Invitation Code -->
|
||||
<div
|
||||
class="flex items-center justify-between border-t border-gray-100 pt-4 dark:border-dark-700"
|
||||
>
|
||||
<div>
|
||||
<label class="font-medium text-gray-900 dark:text-white">{{
|
||||
t('admin.settings.registration.invitationCode')
|
||||
}}</label>
|
||||
<p class="text-sm text-gray-500 dark:text-gray-400">
|
||||
{{ t('admin.settings.registration.invitationCodeHint') }}
|
||||
</p>
|
||||
</div>
|
||||
<Toggle v-model="form.invitation_code_enabled" />
|
||||
</div>
|
||||
<!-- Password Reset - Only show when email verification is enabled -->
|
||||
<div
|
||||
v-if="form.email_verify_enabled"
|
||||
@@ -1115,6 +1129,7 @@ const form = reactive<SettingsForm>({
|
||||
registration_enabled: true,
|
||||
email_verify_enabled: false,
|
||||
promo_code_enabled: true,
|
||||
invitation_code_enabled: false,
|
||||
password_reset_enabled: false,
|
||||
totp_enabled: false,
|
||||
totp_encryption_key_configured: false,
|
||||
@@ -1243,6 +1258,7 @@ async function saveSettings() {
|
||||
registration_enabled: form.registration_enabled,
|
||||
email_verify_enabled: form.email_verify_enabled,
|
||||
promo_code_enabled: form.promo_code_enabled,
|
||||
invitation_code_enabled: form.invitation_code_enabled,
|
||||
password_reset_enabled: form.password_reset_enabled,
|
||||
totp_enabled: form.totp_enabled,
|
||||
default_balance: form.default_balance,
|
||||
|
||||
@@ -37,6 +37,7 @@ import { ref, reactive, computed, onMounted, onUnmounted } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { saveAs } from 'file-saver'
|
||||
import { useAppStore } from '@/stores/app'; import { adminAPI } from '@/api/admin'; import { adminUsageAPI } from '@/api/admin/usage'
|
||||
import { formatReasoningEffort } from '@/utils/format'
|
||||
import AppLayout from '@/components/layout/AppLayout.vue'; import Pagination from '@/components/common/Pagination.vue'; import Select from '@/components/common/Select.vue'
|
||||
import UsageStatsCards from '@/components/admin/usage/UsageStatsCards.vue'; import UsageFilters from '@/components/admin/usage/UsageFilters.vue'
|
||||
import UsageTable from '@/components/admin/usage/UsageTable.vue'; import UsageExportProgress from '@/components/admin/usage/UsageExportProgress.vue'
|
||||
@@ -104,7 +105,7 @@ const exportToExcel = async () => {
|
||||
const XLSX = await import('xlsx')
|
||||
const headers = [
|
||||
t('usage.time'), t('admin.usage.user'), t('usage.apiKeyFilter'),
|
||||
t('admin.usage.account'), t('usage.model'), t('admin.usage.group'),
|
||||
t('admin.usage.account'), t('usage.model'), t('usage.reasoningEffort'), t('admin.usage.group'),
|
||||
t('usage.type'),
|
||||
t('admin.usage.inputTokens'), t('admin.usage.outputTokens'),
|
||||
t('admin.usage.cacheReadTokens'), t('admin.usage.cacheCreationTokens'),
|
||||
@@ -120,6 +121,7 @@ const exportToExcel = async () => {
|
||||
log.api_key?.name || '',
|
||||
log.account?.name || '',
|
||||
log.model,
|
||||
formatReasoningEffort(log.reasoning_effort),
|
||||
log.group?.name || '',
|
||||
log.stream ? t('usage.stream') : t('usage.sync'),
|
||||
log.input_tokens,
|
||||
|
||||
@@ -201,6 +201,7 @@ const email = ref<string>('')
|
||||
const password = ref<string>('')
|
||||
const initialTurnstileToken = ref<string>('')
|
||||
const promoCode = ref<string>('')
|
||||
const invitationCode = ref<string>('')
|
||||
const hasRegisterData = ref<boolean>(false)
|
||||
|
||||
// Public settings
|
||||
@@ -230,6 +231,7 @@ onMounted(async () => {
|
||||
password.value = registerData.password || ''
|
||||
initialTurnstileToken.value = registerData.turnstile_token || ''
|
||||
promoCode.value = registerData.promo_code || ''
|
||||
invitationCode.value = registerData.invitation_code || ''
|
||||
hasRegisterData.value = !!(email.value && password.value)
|
||||
} catch {
|
||||
hasRegisterData.value = false
|
||||
@@ -384,7 +386,8 @@ async function handleVerify(): Promise<void> {
|
||||
password: password.value,
|
||||
verify_code: verifyCode.value.trim(),
|
||||
turnstile_token: initialTurnstileToken.value || undefined,
|
||||
promo_code: promoCode.value || undefined
|
||||
promo_code: promoCode.value || undefined,
|
||||
invitation_code: invitationCode.value || undefined
|
||||
})
|
||||
|
||||
// Clear session data
|
||||
|
||||
@@ -95,6 +95,59 @@
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<!-- Invitation Code Input (Required when enabled) -->
|
||||
<div v-if="invitationCodeEnabled">
|
||||
<label for="invitation_code" class="input-label">
|
||||
{{ t('auth.invitationCodeLabel') }}
|
||||
</label>
|
||||
<div class="relative">
|
||||
<div class="pointer-events-none absolute inset-y-0 left-0 flex items-center pl-3.5">
|
||||
<Icon name="key" size="md" :class="invitationValidation.valid ? 'text-green-500' : 'text-gray-400 dark:text-dark-500'" />
|
||||
</div>
|
||||
<input
|
||||
id="invitation_code"
|
||||
v-model="formData.invitation_code"
|
||||
type="text"
|
||||
:disabled="isLoading"
|
||||
class="input pl-11 pr-10"
|
||||
:class="{
|
||||
'border-green-500 focus:border-green-500 focus:ring-green-500': invitationValidation.valid,
|
||||
'border-red-500 focus:border-red-500 focus:ring-red-500': invitationValidation.invalid || errors.invitation_code
|
||||
}"
|
||||
:placeholder="t('auth.invitationCodePlaceholder')"
|
||||
@input="handleInvitationCodeInput"
|
||||
/>
|
||||
<!-- Validation indicator -->
|
||||
<div v-if="invitationValidating" class="absolute inset-y-0 right-0 flex items-center pr-3.5">
|
||||
<svg class="h-4 w-4 animate-spin text-gray-400" fill="none" viewBox="0 0 24 24">
|
||||
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
|
||||
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
|
||||
</svg>
|
||||
</div>
|
||||
<div v-else-if="invitationValidation.valid" class="absolute inset-y-0 right-0 flex items-center pr-3.5">
|
||||
<Icon name="checkCircle" size="md" class="text-green-500" />
|
||||
</div>
|
||||
<div v-else-if="invitationValidation.invalid || errors.invitation_code" class="absolute inset-y-0 right-0 flex items-center pr-3.5">
|
||||
<Icon name="exclamationCircle" size="md" class="text-red-500" />
|
||||
</div>
|
||||
</div>
|
||||
<!-- Invitation code validation result -->
|
||||
<transition name="fade">
|
||||
<div v-if="invitationValidation.valid" class="mt-2 flex items-center gap-2 rounded-lg bg-green-50 px-3 py-2 dark:bg-green-900/20">
|
||||
<Icon name="checkCircle" size="sm" class="text-green-600 dark:text-green-400" />
|
||||
<span class="text-sm text-green-700 dark:text-green-400">
|
||||
{{ t('auth.invitationCodeValid') }}
|
||||
</span>
|
||||
</div>
|
||||
<p v-else-if="invitationValidation.invalid" class="input-error-text">
|
||||
{{ invitationValidation.message }}
|
||||
</p>
|
||||
<p v-else-if="errors.invitation_code" class="input-error-text">
|
||||
{{ errors.invitation_code }}
|
||||
</p>
|
||||
</transition>
|
||||
</div>
|
||||
|
||||
<!-- Promo Code Input (Optional) -->
|
||||
<div v-if="promoCodeEnabled">
|
||||
<label for="promo_code" class="input-label">
|
||||
@@ -239,7 +292,7 @@ import LinuxDoOAuthSection from '@/components/auth/LinuxDoOAuthSection.vue'
|
||||
import Icon from '@/components/icons/Icon.vue'
|
||||
import TurnstileWidget from '@/components/TurnstileWidget.vue'
|
||||
import { useAuthStore, useAppStore } from '@/stores'
|
||||
import { getPublicSettings, validatePromoCode } from '@/api/auth'
|
||||
import { getPublicSettings, validatePromoCode, validateInvitationCode } from '@/api/auth'
|
||||
|
||||
const { t } = useI18n()
|
||||
|
||||
@@ -261,6 +314,7 @@ const showPassword = ref<boolean>(false)
|
||||
const registrationEnabled = ref<boolean>(true)
|
||||
const emailVerifyEnabled = ref<boolean>(false)
|
||||
const promoCodeEnabled = ref<boolean>(true)
|
||||
const invitationCodeEnabled = ref<boolean>(false)
|
||||
const turnstileEnabled = ref<boolean>(false)
|
||||
const turnstileSiteKey = ref<string>('')
|
||||
const siteName = ref<string>('Sub2API')
|
||||
@@ -280,16 +334,27 @@ const promoValidation = reactive({
|
||||
})
|
||||
let promoValidateTimeout: ReturnType<typeof setTimeout> | null = null
|
||||
|
||||
// Invitation code validation
|
||||
const invitationValidating = ref<boolean>(false)
|
||||
const invitationValidation = reactive({
|
||||
valid: false,
|
||||
invalid: false,
|
||||
message: ''
|
||||
})
|
||||
let invitationValidateTimeout: ReturnType<typeof setTimeout> | null = null
|
||||
|
||||
const formData = reactive({
|
||||
email: '',
|
||||
password: '',
|
||||
promo_code: ''
|
||||
promo_code: '',
|
||||
invitation_code: ''
|
||||
})
|
||||
|
||||
const errors = reactive({
|
||||
email: '',
|
||||
password: '',
|
||||
turnstile: ''
|
||||
turnstile: '',
|
||||
invitation_code: ''
|
||||
})
|
||||
|
||||
// ==================== Lifecycle ====================
|
||||
@@ -300,6 +365,7 @@ onMounted(async () => {
|
||||
registrationEnabled.value = settings.registration_enabled
|
||||
emailVerifyEnabled.value = settings.email_verify_enabled
|
||||
promoCodeEnabled.value = settings.promo_code_enabled
|
||||
invitationCodeEnabled.value = settings.invitation_code_enabled
|
||||
turnstileEnabled.value = settings.turnstile_enabled
|
||||
turnstileSiteKey.value = settings.turnstile_site_key || ''
|
||||
siteName.value = settings.site_name || 'Sub2API'
|
||||
@@ -325,6 +391,9 @@ onUnmounted(() => {
|
||||
if (promoValidateTimeout) {
|
||||
clearTimeout(promoValidateTimeout)
|
||||
}
|
||||
if (invitationValidateTimeout) {
|
||||
clearTimeout(invitationValidateTimeout)
|
||||
}
|
||||
})
|
||||
|
||||
// ==================== Promo Code Validation ====================
|
||||
@@ -400,6 +469,70 @@ function getPromoErrorMessage(errorCode?: string): string {
|
||||
}
|
||||
}
|
||||
|
||||
// ==================== Invitation Code Validation ====================
|
||||
|
||||
function handleInvitationCodeInput(): void {
|
||||
const code = formData.invitation_code.trim()
|
||||
|
||||
// Clear previous validation
|
||||
invitationValidation.valid = false
|
||||
invitationValidation.invalid = false
|
||||
invitationValidation.message = ''
|
||||
errors.invitation_code = ''
|
||||
|
||||
if (!code) {
|
||||
return
|
||||
}
|
||||
|
||||
// Debounce validation
|
||||
if (invitationValidateTimeout) {
|
||||
clearTimeout(invitationValidateTimeout)
|
||||
}
|
||||
|
||||
invitationValidateTimeout = setTimeout(() => {
|
||||
validateInvitationCodeDebounced(code)
|
||||
}, 500)
|
||||
}
|
||||
|
||||
async function validateInvitationCodeDebounced(code: string): Promise<void> {
|
||||
invitationValidating.value = true
|
||||
|
||||
try {
|
||||
const result = await validateInvitationCode(code)
|
||||
|
||||
if (result.valid) {
|
||||
invitationValidation.valid = true
|
||||
invitationValidation.invalid = false
|
||||
invitationValidation.message = ''
|
||||
} else {
|
||||
invitationValidation.valid = false
|
||||
invitationValidation.invalid = true
|
||||
invitationValidation.message = getInvitationErrorMessage(result.error_code)
|
||||
}
|
||||
} catch {
|
||||
invitationValidation.valid = false
|
||||
invitationValidation.invalid = true
|
||||
invitationValidation.message = t('auth.invitationCodeInvalid')
|
||||
} finally {
|
||||
invitationValidating.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function getInvitationErrorMessage(errorCode?: string): string {
|
||||
switch (errorCode) {
|
||||
case 'INVITATION_CODE_NOT_FOUND':
|
||||
return t('auth.invitationCodeInvalid')
|
||||
case 'INVITATION_CODE_INVALID':
|
||||
return t('auth.invitationCodeInvalid')
|
||||
case 'INVITATION_CODE_USED':
|
||||
return t('auth.invitationCodeInvalid')
|
||||
case 'INVITATION_CODE_DISABLED':
|
||||
return t('auth.invitationCodeInvalid')
|
||||
default:
|
||||
return t('auth.invitationCodeInvalid')
|
||||
}
|
||||
}
|
||||
|
||||
// ==================== Turnstile Handlers ====================
|
||||
|
||||
function onTurnstileVerify(token: string): void {
|
||||
@@ -429,6 +562,7 @@ function validateForm(): boolean {
|
||||
errors.email = ''
|
||||
errors.password = ''
|
||||
errors.turnstile = ''
|
||||
errors.invitation_code = ''
|
||||
|
||||
let isValid = true
|
||||
|
||||
@@ -450,6 +584,14 @@ function validateForm(): boolean {
|
||||
isValid = false
|
||||
}
|
||||
|
||||
// Invitation code validation (required when enabled)
|
||||
if (invitationCodeEnabled.value) {
|
||||
if (!formData.invitation_code.trim()) {
|
||||
errors.invitation_code = t('auth.invitationCodeRequired')
|
||||
isValid = false
|
||||
}
|
||||
}
|
||||
|
||||
// Turnstile validation
|
||||
if (turnstileEnabled.value && !turnstileToken.value) {
|
||||
errors.turnstile = t('auth.completeVerification')
|
||||
@@ -484,6 +626,30 @@ async function handleRegister(): Promise<void> {
|
||||
}
|
||||
}
|
||||
|
||||
// Check invitation code validation status (if enabled and code provided)
|
||||
if (invitationCodeEnabled.value) {
|
||||
// If still validating, wait
|
||||
if (invitationValidating.value) {
|
||||
errorMessage.value = t('auth.invitationCodeValidating')
|
||||
return
|
||||
}
|
||||
// If invitation code is invalid, block submission
|
||||
if (invitationValidation.invalid) {
|
||||
errorMessage.value = t('auth.invitationCodeInvalidCannotRegister')
|
||||
return
|
||||
}
|
||||
// If invitation code is required but not validated yet
|
||||
if (formData.invitation_code.trim() && !invitationValidation.valid) {
|
||||
errorMessage.value = t('auth.invitationCodeValidating')
|
||||
// Trigger validation
|
||||
await validateInvitationCodeDebounced(formData.invitation_code.trim())
|
||||
if (!invitationValidation.valid) {
|
||||
errorMessage.value = t('auth.invitationCodeInvalidCannotRegister')
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
isLoading.value = true
|
||||
|
||||
try {
|
||||
@@ -496,7 +662,8 @@ async function handleRegister(): Promise<void> {
|
||||
email: formData.email,
|
||||
password: formData.password,
|
||||
turnstile_token: turnstileToken.value,
|
||||
promo_code: formData.promo_code || undefined
|
||||
promo_code: formData.promo_code || undefined,
|
||||
invitation_code: formData.invitation_code || undefined
|
||||
})
|
||||
)
|
||||
|
||||
@@ -510,7 +677,8 @@ async function handleRegister(): Promise<void> {
|
||||
email: formData.email,
|
||||
password: formData.password,
|
||||
turnstile_token: turnstileEnabled.value ? turnstileToken.value : undefined,
|
||||
promo_code: formData.promo_code || undefined
|
||||
promo_code: formData.promo_code || undefined,
|
||||
invitation_code: formData.invitation_code || undefined
|
||||
})
|
||||
|
||||
// Show success toast
|
||||
|
||||
@@ -237,6 +237,18 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex items-center justify-between rounded-xl border border-gray-200 p-3 dark:border-dark-700">
|
||||
<div>
|
||||
<p class="text-sm font-medium text-gray-900 dark:text-white">
|
||||
{{ t("setup.redis.enableTls") }}
|
||||
</p>
|
||||
<p class="text-xs text-gray-500 dark:text-dark-400">
|
||||
{{ t("setup.redis.enableTlsHint") }}
|
||||
</p>
|
||||
</div>
|
||||
<Toggle v-model="formData.redis.enable_tls" />
|
||||
</div>
|
||||
|
||||
<button
|
||||
@click="testRedisConnection"
|
||||
:disabled="testingRedis"
|
||||
@@ -482,6 +494,7 @@ import { ref, reactive, computed } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { testDatabase, testRedis, install, type InstallRequest } from '@/api/setup'
|
||||
import Select from '@/components/common/Select.vue'
|
||||
import Toggle from '@/components/common/Toggle.vue'
|
||||
import Icon from '@/components/icons/Icon.vue'
|
||||
|
||||
const { t } = useI18n()
|
||||
|
||||
@@ -157,6 +157,12 @@
|
||||
<span class="font-medium text-gray-900 dark:text-white">{{ value }}</span>
|
||||
</template>
|
||||
|
||||
<template #cell-reasoning_effort="{ row }">
|
||||
<span class="text-sm text-gray-900 dark:text-white">
|
||||
{{ formatReasoningEffort(row.reasoning_effort) }}
|
||||
</span>
|
||||
</template>
|
||||
|
||||
<template #cell-stream="{ row }">
|
||||
<span
|
||||
class="inline-flex items-center rounded px-2 py-0.5 text-xs font-medium"
|
||||
@@ -438,12 +444,12 @@ import TablePageLayout from '@/components/layout/TablePageLayout.vue'
|
||||
import DataTable from '@/components/common/DataTable.vue'
|
||||
import Pagination from '@/components/common/Pagination.vue'
|
||||
import EmptyState from '@/components/common/EmptyState.vue'
|
||||
import Select from '@/components/common/Select.vue'
|
||||
import DateRangePicker from '@/components/common/DateRangePicker.vue'
|
||||
import Icon from '@/components/icons/Icon.vue'
|
||||
import type { UsageLog, ApiKey, UsageQueryParams, UsageStatsResponse } from '@/types'
|
||||
import type { Column } from '@/components/common/types'
|
||||
import { formatDateTime } from '@/utils/format'
|
||||
import Select from '@/components/common/Select.vue'
|
||||
import DateRangePicker from '@/components/common/DateRangePicker.vue'
|
||||
import Icon from '@/components/icons/Icon.vue'
|
||||
import type { UsageLog, ApiKey, UsageQueryParams, UsageStatsResponse } from '@/types'
|
||||
import type { Column } from '@/components/common/types'
|
||||
import { formatDateTime, formatReasoningEffort } from '@/utils/format'
|
||||
|
||||
const { t } = useI18n()
|
||||
const appStore = useAppStore()
|
||||
@@ -466,6 +472,7 @@ const usageStats = ref<UsageStatsResponse | null>(null)
|
||||
const columns = computed<Column[]>(() => [
|
||||
{ key: 'api_key', label: t('usage.apiKeyFilter'), sortable: false },
|
||||
{ key: 'model', label: t('usage.model'), sortable: true },
|
||||
{ key: 'reasoning_effort', label: t('usage.reasoningEffort'), sortable: false },
|
||||
{ key: 'stream', label: t('usage.type'), sortable: false },
|
||||
{ key: 'tokens', label: t('usage.tokens'), sortable: false },
|
||||
{ key: 'cost', label: t('usage.cost'), sortable: false },
|
||||
@@ -723,6 +730,7 @@ const exportToCSV = async () => {
|
||||
'Time',
|
||||
'API Key Name',
|
||||
'Model',
|
||||
'Reasoning Effort',
|
||||
'Type',
|
||||
'Input Tokens',
|
||||
'Output Tokens',
|
||||
@@ -739,6 +747,7 @@ const exportToCSV = async () => {
|
||||
log.created_at,
|
||||
log.api_key?.name || '',
|
||||
log.model,
|
||||
formatReasoningEffort(log.reasoning_effort),
|
||||
log.stream ? 'Stream' : 'Sync',
|
||||
log.input_tokens,
|
||||
log.output_tokens,
|
||||
|
||||
Reference in New Issue
Block a user