## 主要变更 ### UI 重构(基于 Gemini) - 引入 Tailwind CSS 设计系统,替换原有样式 - 重构所有主要页面组件(Dashboard、AgentChat、Sources 等) - 新增 CommandPalette 和 ToolCallDisplay 组件 - 优化布局和交互体验 ### 关键问题修复 1. 修复 AI 对话页面 TypeError 错误 - 问题:后端 conversations API 返回格式不标准,导致前端访问 res.data 为 undefined - 修复:agent.ts 中使用 `res.data ?? res as any ?? []` 兼容两种响应格式 2. 修复 Tailwind CSS 样式未加载 - 问题:main.ts 中缺少 style.css 导入 - 修复:添加 `import './style.css'` 3. 安装缺失依赖 - 新增 @vueuse/core(MessageItem.vue 使用 useClipboard) - 新增 Tailwind CSS 相关依赖 ### 新增配置 - postcss.config.js - PostCSS 配置 - tailwind.config.js - Tailwind 主题配置 - user.ts store - 用户状态管理 Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
69 lines
2.2 KiB
Vue
69 lines
2.2 KiB
Vue
<template>
|
|
<div class="mt-2 space-y-2">
|
|
<div
|
|
v-for="(call, index) in toolCalls"
|
|
:key="index"
|
|
class="rounded-lg border bg-muted/30 p-3 text-xs shadow-sm transition-all hover:bg-muted/50"
|
|
>
|
|
<div class="flex items-center justify-between mb-2">
|
|
<div class="flex items-center gap-2 font-semibold text-foreground/80">
|
|
<Terminal class="h-3.5 w-3.5 text-blue-500" />
|
|
<span>{{ getToolName(call.name) }}</span>
|
|
</div>
|
|
<div v-if="call.result" class="flex items-center gap-1 text-green-600 dark:text-green-400">
|
|
<CheckCircle2 class="h-3 w-3" />
|
|
<span>已完成</span>
|
|
</div>
|
|
<div v-else class="flex items-center gap-1 text-amber-500 animate-pulse">
|
|
<Loader2 class="h-3 w-3 animate-spin" />
|
|
<span>执行中...</span>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="space-y-2">
|
|
<div class="space-y-1">
|
|
<p class="text-[10px] uppercase tracking-wider text-muted-foreground font-bold">参数 (Arguments)</p>
|
|
<pre class="overflow-x-auto rounded bg-background/50 p-2 font-mono leading-relaxed">{{ formatJson(call.arguments) }}</pre>
|
|
</div>
|
|
|
|
<div v-if="call.result" class="space-y-1">
|
|
<p class="text-[10px] uppercase tracking-wider text-muted-foreground font-bold">结果 (Result)</p>
|
|
<pre class="overflow-x-auto rounded bg-background/50 p-2 font-mono leading-relaxed max-h-32">{{ formatJson(call.result) }}</pre>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import { Terminal, CheckCircle2, Loader2 } from 'lucide-vue-next'
|
|
|
|
interface Props {
|
|
toolCalls: Array<{
|
|
name: string;
|
|
arguments: any;
|
|
result?: any;
|
|
}>;
|
|
}
|
|
|
|
defineProps<Props>()
|
|
|
|
const toolNameMap: Record<string, string> = {
|
|
searchArticles: '搜索资讯库',
|
|
analyzeReport: '深度分析报告',
|
|
webSearch: '互联网实时搜索',
|
|
}
|
|
|
|
function getToolName(name: string): string {
|
|
return toolNameMap[name] || name
|
|
}
|
|
|
|
function formatJson(obj: any): string {
|
|
try {
|
|
return typeof obj === 'string' ? JSON.stringify(JSON.parse(obj), null, 2) : JSON.stringify(obj, null, 2)
|
|
} catch {
|
|
return String(obj)
|
|
}
|
|
}
|
|
</script>
|