持久化常驻复用现有 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。
83 lines
3.6 KiB
Vue
83 lines
3.6 KiB
Vue
<script setup lang="ts">
|
||
import { computed, onMounted, ref } from 'vue'
|
||
import { RefreshCw, Search } from 'lucide-vue-next'
|
||
import { getReport, runCommand, type AiProReport } from '../api/client'
|
||
|
||
const report = ref<AiProReport | null>(null)
|
||
const error = ref('')
|
||
const keyword = ref('')
|
||
|
||
function row(value: unknown): Record<string, unknown> {
|
||
return (value ?? {}) as Record<string, unknown>
|
||
}
|
||
|
||
const filtered = computed(() => {
|
||
const rows = (report.value?.logs ?? []) as unknown[]
|
||
const kw = keyword.value.trim().toLowerCase()
|
||
if (!kw) return rows
|
||
return rows.filter((item) => JSON.stringify(item).toLowerCase().includes(kw))
|
||
})
|
||
|
||
async function load() {
|
||
error.value = ''
|
||
try {
|
||
report.value = await getReport()
|
||
} catch (err) {
|
||
error.value = err instanceof Error ? err.message : String(err)
|
||
}
|
||
}
|
||
|
||
async function queryBySn() {
|
||
if (!keyword.value.trim()) return
|
||
error.value = ''
|
||
try {
|
||
const result = await runCommand<unknown>(`logs ${keyword.value.trim()} --json --limit=200`)
|
||
const rows = Array.isArray(result) ? result : []
|
||
if (report.value) report.value = { ...report.value, logs: rows }
|
||
} catch (err) {
|
||
error.value = err instanceof Error ? err.message : String(err)
|
||
}
|
||
}
|
||
|
||
onMounted(load)
|
||
</script>
|
||
|
||
<template>
|
||
<div class="p-7 space-y-5 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">全链路操作留痕,含网关阻断与裁决记录</p>
|
||
</div>
|
||
<button class="btn-ghost" @click="load"><RefreshCw :size="15" />刷新</button>
|
||
</header>
|
||
|
||
<div v-if="error" class="card border-danger/30 bg-danger-soft text-danger text-sm whitespace-pre-wrap">{{ error }}</div>
|
||
|
||
<div class="card flex flex-wrap items-center gap-2">
|
||
<input v-model="keyword" class="input max-w-sm" placeholder="按单号检索摘要(本地过滤)" @keydown.enter="queryBySn" />
|
||
<button class="btn-ghost" :disabled="!keyword.trim()" @click="queryBySn"><Search :size="15" />按单号查询</button>
|
||
<span class="text-xs text-text-muted ml-auto">{{ filtered.length }} 条记录</span>
|
||
</div>
|
||
|
||
<section class="card overflow-x-auto">
|
||
<table class="w-full text-sm">
|
||
<thead><tr class="text-left text-xs text-text-muted border-b border-border">
|
||
<th class="py-2 pr-3">时间</th><th class="py-2 pr-3">动作</th><th class="py-2 pr-3">单号</th><th class="py-2 pr-3">状态</th><th class="py-2 pr-3">裁决</th><th class="py-2">摘要</th>
|
||
</tr></thead>
|
||
<tbody>
|
||
<tr v-for="(log, i) in filtered" :key="i" class="border-b border-border/60 last:border-0">
|
||
<td class="py-2 pr-3 text-xs text-text-muted whitespace-nowrap">{{ new Date(Number(row(log).createdAt) || 0).toLocaleString('zh-CN') }}</td>
|
||
<td class="py-2 pr-3"><span class="tag bg-accent-soft text-accent">{{ row(log).action }}</span></td>
|
||
<td class="py-2 pr-3 font-mono text-xs">{{ row(log).documentSn || '—' }}</td>
|
||
<td class="py-2 pr-3"><span class="tag" :class="row(log).status === 'SUCCESS' ? 'bg-success-soft text-success' : row(log).status === 'BLOCKED' ? 'bg-warning-soft text-warning' : 'bg-danger-soft text-danger'">{{ row(log).status }}</span></td>
|
||
<td class="py-2 pr-3 text-xs">{{ row(log).decision || '—' }}</td>
|
||
<td class="py-2 text-xs text-text-muted">{{ row(log).summary || '—' }}</td>
|
||
</tr>
|
||
<tr v-if="!filtered.length"><td colspan="6" class="py-6 text-center text-sm text-text-muted">暂无记录</td></tr>
|
||
</tbody>
|
||
</table>
|
||
</section>
|
||
</div>
|
||
</template>
|