优化: AI Chat全栈多批审查修复与架构清理(risk_level清理/路由解耦/工具渲染/测试补测/死代码)
This commit is contained in:
@@ -1,31 +1,31 @@
|
||||
<template>
|
||||
<div class="audit-log">
|
||||
<header class="page-header">
|
||||
<h1>审批历史</h1>
|
||||
<h1>{{ t('auditLog.title') }}</h1>
|
||||
<div class="header-actions">
|
||||
<button class="btn btn-ghost" @click="reload">刷新</button>
|
||||
<button class="btn btn-ghost" @click="reload">{{ t('auditLog.refresh') }}</button>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<p class="page-desc">AI 工具调用审计记录(按请求时间倒序)。参数与结果仅展示摘要,完整数据留存本地数据库。</p>
|
||||
<p class="page-desc">{{ t('auditLog.desc') }}</p>
|
||||
|
||||
<!-- 状态条 -->
|
||||
<div v-if="loading" class="empty-state">加载中…</div>
|
||||
<div v-if="loading" class="empty-state">{{ t('auditLog.loading') }}</div>
|
||||
<div v-else-if="errorMsg" class="empty-state">{{ errorMsg }}</div>
|
||||
<div v-else-if="records.length === 0" class="empty-state">暂无审计记录</div>
|
||||
<div v-else-if="records.length === 0" class="empty-state">{{ t('auditLog.empty') }}</div>
|
||||
|
||||
<!-- 表格 -->
|
||||
<div v-else class="audit-table-wrap">
|
||||
<table class="audit-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="col-time">请求时间</th>
|
||||
<th class="col-tool">工具</th>
|
||||
<th class="col-risk">风险</th>
|
||||
<th class="col-status">状态</th>
|
||||
<th class="col-decided">决策者</th>
|
||||
<th class="col-args">参数摘要</th>
|
||||
<th class="col-result">结果摘要</th>
|
||||
<th class="col-time">{{ t('auditLog.col.time') }}</th>
|
||||
<th class="col-tool">{{ t('auditLog.col.tool') }}</th>
|
||||
<th class="col-risk">{{ t('auditLog.col.risk') }}</th>
|
||||
<th class="col-status">{{ t('auditLog.col.status') }}</th>
|
||||
<th class="col-decided">{{ t('auditLog.col.decided') }}</th>
|
||||
<th class="col-args">{{ t('auditLog.col.args') }}</th>
|
||||
<th class="col-result">{{ t('auditLog.col.result') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -54,18 +54,21 @@
|
||||
|
||||
<!-- 分页 -->
|
||||
<div v-if="!loading && !errorMsg" class="pager">
|
||||
<button class="btn btn-ghost" :disabled="offset === 0" @click="prevPage">上一页</button>
|
||||
<span class="pager-info">第 {{ page }} 页{{ hasMore ? '' : '(末页)' }}</span>
|
||||
<button class="btn btn-ghost" :disabled="!hasMore" @click="nextPage">下一页</button>
|
||||
<button class="btn btn-ghost" :disabled="offset === 0" @click="prevPage">{{ t('auditLog.pager.prev') }}</button>
|
||||
<span class="pager-info">{{ t('auditLog.pager.page', { n: page }) }}{{ hasMore ? '' : t('auditLog.pager.last') }}</span>
|
||||
<button class="btn btn-ghost" :disabled="!hasMore" @click="nextPage">{{ t('auditLog.pager.next') }}</button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, computed, onMounted } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { invoke } from '@tauri-apps/api/core'
|
||||
import { formatRelativeZh, formatDate } from '@/utils/time'
|
||||
|
||||
const { t } = useI18n()
|
||||
|
||||
// 本地 interface(不进 api/types.ts,避撞 B-42 agent)
|
||||
// 字段与后端 ToolExecutionDto(audit.rs) 一一对应
|
||||
interface ToolExecutionRecord {
|
||||
@@ -128,21 +131,15 @@ function nextPage() {
|
||||
}
|
||||
|
||||
// ── 标签 / 样式映射 ──
|
||||
// 文本走 i18n(auditLog.risk/status/decided);class 映射不国际化
|
||||
function riskLabel(r: string): string {
|
||||
return ({ low: '低', medium: '中', high: '高' } as Record<string, string>)[r] ?? r
|
||||
return t(`auditLog.risk.${r}`)
|
||||
}
|
||||
function riskClass(r: string): string {
|
||||
return ({ low: 'risk-low', medium: 'risk-medium', high: 'risk-high' } as Record<string, string>)[r] ?? 'risk-low'
|
||||
}
|
||||
function statusLabel(s: string): string {
|
||||
return ({
|
||||
pending: '待审批',
|
||||
approved: '已批准',
|
||||
rejected: '已拒绝',
|
||||
executing: '执行中',
|
||||
completed: '已完成',
|
||||
failed: '失败',
|
||||
} as Record<string, string>)[s] ?? s
|
||||
return t(`auditLog.status.${s}`)
|
||||
}
|
||||
function statusClass(s: string): string {
|
||||
return ({
|
||||
@@ -155,7 +152,7 @@ function statusClass(s: string): string {
|
||||
} as Record<string, string>)[s] ?? 'status-pending'
|
||||
}
|
||||
function decidedLabel(d: string): string {
|
||||
return d === 'human' ? '人工' : d === 'auto' ? '自动' : d
|
||||
return t(`auditLog.decided.${d}`)
|
||||
}
|
||||
function decidedClass(d: string): string {
|
||||
return d === 'human' ? 'decided-human' : 'decided-auto'
|
||||
|
||||
Reference in New Issue
Block a user