Files
hose-use/web/src/views/OverviewView.vue
T
gitea 36e21e5dc2 feat: AI PRO 本地 Web 控制台与聚合报表
持久化常驻复用现有 hose-aipro service start(detached + pid 文件、
127.0.0.1:8889),本次只补前端与数据出口,不做端口/K8s 化改造。
是否映射公网由使用者自行决定,工具仍只监听回环地址。

- web/:Vue 3.5 + Vite 6 + TS + vue-router + Tailwind 3 子工程,配置对齐
  本机 twc-approval-go-bridge/web(base /static/、outDir 到后端内嵌目录、
  dev proxy → 8889、hash 路由)。5 个视图:总览、审批会话、规则与要点、
  审计流水、命令终端;统一经 POST /api/cli 调用现有 CLI 能力。
- scripts/build/build-webui.mjs:把 Vite 产物 JS/CSS 内联成单文件 HTML,
  生成 src/packaging/generated/webui.txt。生成物随 git 提交,编译二进制
  与 CI 不需要安装前端依赖;.webui-dist/ 为忽略的中间产物。
- src/packaging/embedded-webui.ts:with { type: text } 内嵌。用 .txt 后缀
  而非 .html,避开 Bun 对 .html 的 HTMLBundle 类型推断导致 tsc 报错。
- src/http/routes.ts:AI Pro daemon 暴露 GET /report(含 /report/* 兜底);
  server.ts 启动日志补控制台地址;hose-use daemon 不暴露该路由。
- src/cli/commands/aipro/report.ts:新增 report --json 聚合命令,一次返回
  场景/规则/会话/要点/流水/授权状态;单据快照等大字段不下发,避免撑爆
  浏览器。命令在统一门禁之后,未激活仍会被拦截。
- 新增 embedded-webui / webui 路由 / report 聚合三组测试;同步
  SKILL.md、README.md、packaging README、.gitignore 与 package.json 脚本。

校验:bun test 1108 pass / 0 fail,bun run check、check:readme 全通过;
编译二进制实测 GET /report 返回 200 且资源全内联(140KB、零外链),
POST /api/cli report --json 返回真实聚合数据(2 场景/3 规则/45 条流水)。

本次不打 tag、不发版,留待 0.9.4。
2026-11-05 19:25:52 +08:00

92 lines
5.1 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<script setup lang="ts">
import { onMounted, ref } from 'vue'
import { RefreshCw, ShieldCheck, ShieldAlert, Building2, Layers, ScrollText, ClipboardList, Activity } from 'lucide-vue-next'
import { getReport, type AiProReport } from '../api/client'
const report = ref<AiProReport | null>(null)
const error = ref('')
const loading = ref(false)
async function load() {
loading.value = true
error.value = ''
try {
report.value = await getReport()
} catch (err) {
error.value = err instanceof Error ? err.message : String(err)
} finally {
loading.value = false
}
}
onMounted(load)
</script>
<template>
<div class="p-7 space-y-6 max-w-6xl">
<header class="flex items-start justify-between gap-4">
<div>
<h1 class="text-xl font-semibold">运行总览</h1>
<p class="text-sm text-text-muted mt-1">AI PRO 确定性审批网关的本地运行态与审计概览</p>
</div>
<button class="btn-ghost" :disabled="loading" @click="load">
<RefreshCw :size="15" :class="loading ? 'animate-spin' : ''" /> 刷新
</button>
</header>
<div v-if="error" class="card border-danger/30 bg-danger-soft text-danger text-sm whitespace-pre-wrap">{{ error }}</div>
<template v-if="report">
<div class="grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-3">
<div class="card"><div class="flex items-center gap-2 text-text-muted text-xs"><Layers :size="14" />规约场景</div><div class="text-2xl font-semibold mt-2">{{ report.summary.scopes }}</div></div>
<div class="card"><div class="flex items-center gap-2 text-text-muted text-xs"><Activity :size="14" />仲裁规则</div><div class="text-2xl font-semibold mt-2">{{ report.summary.rules }}</div></div>
<div class="card"><div class="flex items-center gap-2 text-text-muted text-xs"><ClipboardList :size="14" />审批会话</div><div class="text-2xl font-semibold mt-2">{{ report.summary.runs }}</div></div>
<div class="card"><div class="flex items-center gap-2 text-text-muted text-xs"><ClipboardList :size="14" />待决断</div><div class="text-2xl font-semibold mt-2">{{ report.summary.pending }}</div></div>
<div class="card"><div class="flex items-center gap-2 text-text-muted text-xs"><ShieldCheck :size="14" />审核要点</div><div class="text-2xl font-semibold mt-2">{{ report.summary.findings }}</div></div>
<div class="card"><div class="flex items-center gap-2 text-text-muted text-xs"><ScrollText :size="14" />审计流水</div><div class="text-2xl font-semibold mt-2">{{ report.summary.logs }}</div></div>
</div>
<div class="grid md:grid-cols-2 gap-4">
<section class="card space-y-3">
<h2 class="text-sm font-semibold">授权与环境</h2>
<div class="flex items-center gap-2 text-sm">
<ShieldCheck v-if="report.license.activated" :size="16" class="text-success" />
<ShieldAlert v-else :size="16" class="text-danger" />
<span :class="report.license.activated ? 'text-success' : 'text-danger'">
{{ report.license.activated ? '已激活' : '未激活' }}
</span>
<span class="text-text-muted">· v{{ report.version }}</span>
</div>
<div v-if="report.license.activated" class="text-xs text-text-muted space-y-1">
<div>授权对象:{{ report.license.subject }}</div>
<div>到期时间:{{ String(report.license.expiresAt).slice(0, 10) }}</div>
<div>版本上限:v{{ report.license.maxVersion }}</div>
</div>
<div v-else class="text-xs text-danger">{{ report.license.message }}</div>
<div class="border-t border-border pt-3 flex items-center gap-2 text-sm">
<Building2 :size="15" class="text-text-muted" />
{{ report.corp?.name || '未指定企业' }}
<span class="text-xs text-text-muted">{{ report.corp?.id || '' }}</span>
</div>
<div class="text-xs text-text-muted">操作员:{{ report.operator }}</div>
</section>
<section class="card">
<h2 class="text-sm font-semibold mb-3">最近审计流水</h2>
<div v-if="!report.logs.length" class="text-sm text-text-muted">暂无记录</div>
<div v-else class="space-y-2 max-h-64 overflow-auto">
<div v-for="(log, i) in report.logs.slice(0, 8)" :key="i" class="flex items-start gap-2 text-xs border-b border-border pb-2 last:border-0">
<span class="tag bg-accent-soft text-accent shrink-0">{{ (log as Record<string, unknown>).action ?? 'log' }}</span>
<span class="text-text-muted truncate flex-1">{{ (log as Record<string, unknown>).summary ?? (log as Record<string, unknown>).documentSn ?? '—' }}</span>
<span class="text-text-muted shrink-0">{{ String((log as Record<string, unknown>).status ?? '') }}</span>
</div>
</div>
</section>
</div>
<p class="text-xs text-text-muted">数据生成于 {{ report.generatedAt }} · 全部来自本机 SQLite,不上传任何数据</p>
</template>
<div v-else-if="!loading" class="card text-sm text-text-muted">尚未加载数据</div>
</div>
</template>