From 8ea251b1443c2814562ad462ae3141e2651acce1 Mon Sep 17 00:00:00 2001 From: hrx <18603305412@163.com> Date: Mon, 22 Jun 2026 14:17:22 +0800 Subject: [PATCH] =?UTF-8?q?token=E7=94=A8=E9=87=8F=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E8=AE=A1=E8=B4=B9=E5=8D=95=E4=BD=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modelManagement/ModelFilter.vue | 6 ++ .../views/modelManagement/modelManagement.vue | 22 +++++- .../views/operation/operationReport/index.vue | 68 +++++++++++++++---- .../src/views/tokenManagement/index.vue | 4 +- f/web-kboss/src/views/tokenUsage/index.vue | 6 +- 5 files changed, 86 insertions(+), 20 deletions(-) diff --git a/f/web-kboss/src/components/modelManagement/ModelFilter.vue b/f/web-kboss/src/components/modelManagement/ModelFilter.vue index df6ade8..efe4cbc 100644 --- a/f/web-kboss/src/components/modelManagement/ModelFilter.vue +++ b/f/web-kboss/src/components/modelManagement/ModelFilter.vue @@ -12,6 +12,8 @@ size="small" prefix-icon="el-icon-search" placeholder="请输入模型名称" + @keyup.enter.native="$emit('search')" + @clear="$emit('search')" > @@ -21,6 +23,8 @@ filterable size="small" placeholder="请选择模型类型" + @change="$emit('search')" + @clear="$emit('search')" > Number(model.listing_status) === selectedStatus) + const modelName = this.normalizeSearchText(this.searchForm.name) + const modelType = this.normalizeSearchText(this.searchForm.type) + const provider = this.normalizeSearchText(this.searchForm.provider) + + return this.modelList.filter(model => { + if (Number(model.listing_status) !== selectedStatus) return false + + const displayName = this.normalizeSearchText(this.getModelDisplayName(model)) + const id = this.normalizeSearchText(this.getModelId(model)) + const type = this.normalizeSearchText(this.getModelType(model)) + const modelProvider = this.normalizeSearchText(this.getProvider(model)) + + const nameMatched = !modelName || displayName.includes(modelName) || id.includes(modelName) + const typeMatched = !modelType || type === modelType || type.includes(modelType) + const providerMatched = !provider || modelProvider === provider || modelProvider.includes(provider) + + return nameMatched && typeMatched && providerMatched + }) }, pagedModelList() { const start = (this.currentPage - 1) * this.pageSize @@ -282,6 +299,9 @@ if (this.searchForm.provider) params.provider = this.searchForm.provider return params }, + normalizeSearchText(value) { + return String(value || '').trim().toLowerCase() + }, extractModelData(res) { const data = res?.data ?? res if (data?.model_list) return data diff --git a/f/web-kboss/src/views/operation/operationReport/index.vue b/f/web-kboss/src/views/operation/operationReport/index.vue index 924e650..ad8f8d1 100644 --- a/f/web-kboss/src/views/operation/operationReport/index.vue +++ b/f/web-kboss/src/views/operation/operationReport/index.vue @@ -24,7 +24,10 @@
{{ item.label }}
-
{{ item.value }}
+
+ {{ item.value }} + {{ item.unit }} +
{{ item.desc }}
@@ -91,18 +94,35 @@ {{ scope.row.model || '-' }} - - - + + - - + + - - + + - - + + + + + @@ -158,9 +178,9 @@ export default { computed: { statCards() { return [ - { label: '请求次数', value: this.formatNumber(this.summary.request_count), desc: '当前筛选范围', type: 'purple', icon: 'el-icon-s-promotion' }, - { label: 'Token消耗', value: this.formatNumber(this.summary.total_tokens), desc: `输入 ${this.formatNumber(this.summary.prompt_tokens)} / 输出 ${this.formatNumber(this.summary.completion_tokens)}`, type: 'green', icon: 'el-icon-coin' }, - { label: 'Token总费用', value: `¥${this.formatAmount(this.summary.amount)}`, desc: '按调用记录汇总', type: 'orange', icon: 'el-icon-wallet' } + { label: '请求次数', value: this.formatNumber(this.summary.request_count), unit: '次', desc: '当前筛选范围', type: 'purple', icon: 'el-icon-s-promotion' }, + { label: 'Token消耗', value: this.formatNumber(this.summary.total_tokens), unit: 'Token', desc: `输入 ${this.formatNumber(this.summary.prompt_tokens)} Token / 输出 ${this.formatNumber(this.summary.completion_tokens)} Token`, type: 'green', icon: 'el-icon-coin' }, + { label: 'Token总费用', value: `¥${this.formatAmount(this.summary.amount)}`, unit: '元', desc: '按调用记录汇总', type: 'orange', icon: 'el-icon-wallet' } ] }, filterTimeText() { @@ -245,7 +265,7 @@ export default { return Number(value || 0).toLocaleString() }, formatAmount(value) { - return Number(value || 0).toFixed(6).replace(/0+$/, '').replace(/\.$/, '.00') + return Number(value || 0).toFixed(2) } } } @@ -400,6 +420,13 @@ export default { line-height: 1; } +.stat-unit { + margin-left: 6px; + color: #667085; + font-size: 14px; + font-weight: 500; +} + .stat-desc { margin-top: 10px; color: #98a2b3; @@ -505,6 +532,19 @@ export default { } } +.usage-number, +.usage-amount { + color: #344054; + font-weight: 600; +} + +.usage-unit { + margin-left: 4px; + color: #98a2b3; + font-size: 12px; + font-weight: 400; +} + @media (max-width: 900px) { .stat-grid { grid-template-columns: 1fr; diff --git a/f/web-kboss/src/views/tokenManagement/index.vue b/f/web-kboss/src/views/tokenManagement/index.vue index ba8b560..fae79b3 100644 --- a/f/web-kboss/src/views/tokenManagement/index.vue +++ b/f/web-kboss/src/views/tokenManagement/index.vue @@ -191,12 +191,12 @@ export default { try { const res = await reqApikeyList(params) if (res && res.status === false) { - throw new Error(res.msg || '获取 API Key 列表失败') + // throw new Error(res.msg || '获取 API Key 列表失败') } this.tokenList = this.normalizeApiKeyList(res) } catch (error) { this.tokenList = [] - this.$message.error(error && error.message ? error.message : '获取 API Key 列表失败') + // this.$message.error(error && error.message ? error.message : '获取 API Key 列表失败') } finally { this.tableLoading = false } diff --git a/f/web-kboss/src/views/tokenUsage/index.vue b/f/web-kboss/src/views/tokenUsage/index.vue index ba9bc44..6a30621 100644 --- a/f/web-kboss/src/views/tokenUsage/index.vue +++ b/f/web-kboss/src/views/tokenUsage/index.vue @@ -281,7 +281,7 @@ export default { return Number(value || 0).toLocaleString() }, formatAmount(value) { - return Number(value || 0).toFixed(6).replace(/0+$/, '').replace(/\.$/, '.00') + return Number(value || 0).toFixed(2) }, initCharts() { if (this.$refs.tokenRatioChart && !this.tokenRatioChart) { @@ -373,8 +373,8 @@ export default { return [ item.name, `${this.formatNumber(item.value)} Token`, - `调用次数:${this.formatNumber(rankItem.request_count)}`, - `预估费用:¥ ${this.formatAmount(rankItem.amount)}` + `调用次数:${this.formatNumber(rankItem.request_count)} 次`, + `预估费用:¥ ${this.formatAmount(rankItem.amount)} 元` ].join('
') } },