4 Commits
Author SHA1 Message Date
wangdefa 7f529bd991 AI网关接入信息补齐新端点,CHANGELOG 0.4.0
CI / test (push) Successful in 26s
Release / release (push) Successful in 26s
2026-07-13 20:14:28 +08:00
wangdefa aea00c2382 关于页运行状态、代理关联租户与步进框修复
CI / test (push) Successful in 25s
Release / release (push) Successful in 25s
2026-07-13 12:21:28 +08:00
wangdefa 2ea5b73de2 移除告警规则界面、恢复 Chat 端点并优化列表
CI / test (push) Successful in 25s
Release / release (push) Successful in 26s
2026-07-13 10:08:08 +08:00
Wang Defa 94fbe62e4c 模型黑名单与密钥模型白名单界面、分组填入、删除弹窗排版
CI / test (push) Successful in 27s
Release / release (push) Successful in 26s
2026-07-12 17:44:46 +08:00
29 changed files with 667 additions and 455 deletions
+1 -1
View File
@@ -1 +1 @@
0.6.5 0.6.6
@@ -15,7 +15,7 @@ oci-portal-dash/
├── App.vue NConfigProvider 注入 Naive 主题 ├── App.vue NConfigProvider 注入 Naive 主题
├── assets/ main.css:Tailwind @theme 设计 token(浅色)+ html.dark 暗色变量覆盖与全局基础样式 ├── assets/ main.css:Tailwind @theme 设计 token(浅色)+ html.dark 暗色变量覆盖与全局基础样式
├── theme/ tokens.ts(JS 侧 token 唯一来源,含 darkTokens 暗色板)、naive.ts(亮暗两套 themeOverrides 同一工厂生成) ├── theme/ tokens.ts(JS 侧 token 唯一来源,含 darkTokens 暗色板)、naive.ts(亮暗两套 themeOverrides 同一工厂生成)
├── types/ api.ts:与 docs/API接口文档.md 一一对应的 DTO 类型 ├── types/ api.ts:与后端 swagger(oci-portal/docs/)一一对应的 DTO 类型
├── api/ request 封装(JWT 注入、401 跳登录、错误 hint 拼接)+ 按资源分模块;VITE_MOCK=1 时返回 mock.ts 数据 ├── api/ request 封装(JWT 注入、401 跳登录、错误 hint 拼接)+ 按资源分模块;VITE_MOCK=1 时返回 mock.ts 数据
├── stores/ Pinia:auth(令牌持久化)、app(侧栏收缩、暗色主题:默认跟随系统 + localStorage 记忆,驱动 html.dark 与 Naive darkTheme)、scope(全局作用域:租户/区域/区间,localStorage 按租户记忆) ├── stores/ Pinia:auth(令牌持久化)、app(侧栏收缩、暗色主题:默认跟随系统 + localStorage 记忆,驱动 html.dark 与 Naive darkTheme)、scope(全局作用域:租户/区域/区间,localStorage 按租户记忆)
├── router/ 路由与登录守卫 ├── router/ 路由与登录守卫
+1 -1
View File
@@ -27,7 +27,7 @@ Vue 3 + Vite + TypeScript + Naive UI + Tailwind CSS v4 + ECharts + Pinia。Naive
- [ ] 读过 [Directory Structure](./directory-structure.md),文件放对层(views / components / composables / api / stores / types) - [ ] 读过 [Directory Structure](./directory-structure.md),文件放对层(views / components / composables / api / stores / types)
- [ ] 涉及颜色、圆角、间距时先看 [Styling & Design Tokens](./styling-design-tokens.md),禁止硬编码 hex - [ ] 涉及颜色、圆角、间距时先看 [Styling & Design Tokens](./styling-design-tokens.md),禁止硬编码 hex
- [ ] 新增请求走 `api/` 统一封装,DTO 类型进 `types/`(与 `docs/API接口文档.md` 一一对应) - [ ] 新增请求走 `api/` 统一封装,DTO 类型进 `types/`(与后端 swagger `oci-portal/docs/` 一一对应)
- [ ] 出 UI 设计稿前读 `../guides/design-workflow.md` - [ ] 出 UI 设计稿前读 `../guides/design-workflow.md`
## Quality Check ## Quality Check
+1 -1
View File
@@ -4,7 +4,7 @@
- 开启 `strict`;禁止 `any`,未知类型用 `unknown` 后收窄。 - 开启 `strict`;禁止 `any`,未知类型用 `unknown` 后收窄。
- 对象形状优先 `interface`,联合/工具类型用 `type`;类型导入写 `import type` - 对象形状优先 `interface`,联合/工具类型用 `type`;类型导入写 `import type`
- 与后端交互的 DTO 类型集中在 `types/`,字段与 `docs/API接口文档.md` 一一对应,不在组件里手写内联响应类型。 - 与后端交互的 DTO 类型集中在 `types/`,字段与后端 swagger(`oci-portal/docs/`)一一对应,不在组件里手写内联响应类型。
-`const` 对象 + `as const` 代替 `enum` -`const` 对象 + `as const` 代替 `enum`
## Vue 组件 ## Vue 组件
+13 -13
View File
@@ -183,7 +183,7 @@ Complex task: ask the user if you can create a Trellis task and enter the planni
- 1.0 Create task `[required · once]` (only after task-creation consent) - 1.0 Create task `[required · once]` (only after task-creation consent)
- 1.1 Requirement exploration `[required · repeatable]` (`prd.md`; complex tasks also need `design.md` + `implement.md`) - 1.1 Requirement exploration `[required · repeatable]` (`prd.md`; complex tasks also need `design.md` + `implement.md`)
- 1.2 Research `[optional · repeatable]` - 1.2 Research `[optional · repeatable]`
- 1.3 Configure context `[required · once]` — Claude Code, Cursor, OpenCode, Codex, Kiro, Gemini, Qoder, CodeBuddy, Copilot, Droid, Pi, ZCode, Reasonix (sub-agent-dispatch platforms only; inline platforms skip) - 1.3 Configure context `[required · once]` — Claude Code, Cursor, OpenCode, Codex, Kiro, Gemini, Qoder, CodeBuddy, Copilot, Droid, Pi, Oh My Pi, ZCode, Reasonix (sub-agent-dispatch platforms only; inline platforms skip)
- 1.4 Activate task `[required · once]` (review gate, then `task.py start`; status → in_progress) - 1.4 Activate task `[required · once]` (review gate, then `task.py start`; status → in_progress)
- 1.5 Completion criteria - 1.5 Completion criteria
@@ -272,13 +272,13 @@ Code committed. Run `/trellis:finish-work`; if dirty, return to Phase 3.4 first.
When a user request matches one of these intents inside an active task, route first, then load the detailed phase step if needed. When a user request matches one of these intents inside an active task, route first, then load the detailed phase step if needed.
[Claude Code, Cursor, OpenCode, codex-sub-agent, Kiro, Gemini, Qoder, CodeBuddy, Copilot, Droid, Pi, ZCode, Reasonix, Trae] [Claude Code, Cursor, OpenCode, codex-sub-agent, Kiro, Gemini, Qoder, CodeBuddy, Copilot, Droid, Pi, Oh My Pi, ZCode, Reasonix, Trae]
- Planning or unclear requirements -> `trellis-brainstorm`. - Planning or unclear requirements -> `trellis-brainstorm`.
- `in_progress` implementation/check -> dispatch `trellis-implement` / `trellis-check`. - `in_progress` implementation/check -> dispatch `trellis-implement` / `trellis-check`.
- Repeated debugging -> `trellis-break-loop`; spec updates -> `trellis-update-spec`. - Repeated debugging -> `trellis-break-loop`; spec updates -> `trellis-update-spec`.
[/Claude Code, Cursor, OpenCode, codex-sub-agent, Kiro, Gemini, Qoder, CodeBuddy, Copilot, Droid, Pi, ZCode, Reasonix, Trae] [/Claude Code, Cursor, OpenCode, codex-sub-agent, Kiro, Gemini, Qoder, CodeBuddy, Copilot, Droid, Pi, Oh My Pi, ZCode, Reasonix, Trae]
[codex-inline, Kilo, Antigravity, Devin] [codex-inline, Kilo, Antigravity, Devin]
@@ -353,7 +353,7 @@ Return to this step whenever requirements change and revise the relevant artifac
Research can happen at any time during requirement exploration. It isn't limited to local code — you can use any available tool (MCP servers, skills, web search, etc.) to look up external information, including third-party library docs, industry practices, API references, etc. Research can happen at any time during requirement exploration. It isn't limited to local code — you can use any available tool (MCP servers, skills, web search, etc.) to look up external information, including third-party library docs, industry practices, API references, etc.
[Claude Code, Cursor, OpenCode, codex-sub-agent, Kiro, Gemini, Qoder, CodeBuddy, Copilot, Droid, Pi, ZCode, Reasonix, Trae] [Claude Code, Cursor, OpenCode, codex-sub-agent, Kiro, Gemini, Qoder, CodeBuddy, Copilot, Droid, Pi, Oh My Pi, ZCode, Reasonix, Trae]
Spawn the research sub-agent: Spawn the research sub-agent:
@@ -361,7 +361,7 @@ Spawn the research sub-agent:
- **Task description**: Research <specific question> - **Task description**: Research <specific question>
- **Key requirement**: Research output MUST be persisted to `{TASK_DIR}/research/` - **Key requirement**: Research output MUST be persisted to `{TASK_DIR}/research/`
[/Claude Code, Cursor, OpenCode, codex-sub-agent, Kiro, Gemini, Qoder, CodeBuddy, Copilot, Droid, Pi, ZCode, Reasonix, Trae] [/Claude Code, Cursor, OpenCode, codex-sub-agent, Kiro, Gemini, Qoder, CodeBuddy, Copilot, Droid, Pi, Oh My Pi, ZCode, Reasonix, Trae]
[codex-inline, Kilo, Antigravity, Devin] [codex-inline, Kilo, Antigravity, Devin]
@@ -380,7 +380,7 @@ Brainstorm and research can interleave freely — pause to research a technical
#### 1.3 Configure context `[required · once]` #### 1.3 Configure context `[required · once]`
[Claude Code, Cursor, OpenCode, codex-sub-agent, Kiro, Gemini, Qoder, CodeBuddy, Copilot, Droid, Pi, ZCode, Reasonix, Trae] [Claude Code, Cursor, OpenCode, codex-sub-agent, Kiro, Gemini, Qoder, CodeBuddy, Copilot, Droid, Pi, Oh My Pi, ZCode, Reasonix, Trae]
Curate `implement.jsonl` and `check.jsonl` so the Phase 2 sub-agents get the right spec/research context. These files were seeded on `task create` with a single self-describing `_example` line; your job here is to fill in real entries. Curate `implement.jsonl` and `check.jsonl` so the Phase 2 sub-agents get the right spec/research context. These files were seeded on `task create` with a single self-describing `_example` line; your job here is to fill in real entries.
@@ -425,7 +425,7 @@ Ready gate: both `implement.jsonl` and `check.jsonl` must contain at least one r
Skip this step only when both files already have real curated entries. Skip this step only when both files already have real curated entries.
[/Claude Code, Cursor, OpenCode, codex-sub-agent, Kiro, Gemini, Qoder, CodeBuddy, Copilot, Droid, Pi, ZCode, Reasonix, Trae] [/Claude Code, Cursor, OpenCode, codex-sub-agent, Kiro, Gemini, Qoder, CodeBuddy, Copilot, Droid, Pi, Oh My Pi, ZCode, Reasonix, Trae]
[codex-inline, Kilo, Antigravity, Devin] [codex-inline, Kilo, Antigravity, Devin]
@@ -458,11 +458,11 @@ If `task.py start` errors with a session-identity message (no context key from h
| `design.md` exists (complex tasks) | ✅ | | `design.md` exists (complex tasks) | ✅ |
| `implement.md` exists (complex tasks) | ✅ | | `implement.md` exists (complex tasks) | ✅ |
[Claude Code, Cursor, OpenCode, codex-sub-agent, Kiro, Gemini, Qoder, CodeBuddy, Copilot, Droid, Pi, ZCode, Reasonix, Trae] [Claude Code, Cursor, OpenCode, codex-sub-agent, Kiro, Gemini, Qoder, CodeBuddy, Copilot, Droid, Pi, Oh My Pi, ZCode, Reasonix, Trae]
| `implement.jsonl` and `check.jsonl` each contain at least one real curated entry (seed row does not count) | ✅ | | `implement.jsonl` and `check.jsonl` each contain at least one real curated entry (seed row does not count) | ✅ |
[/Claude Code, Cursor, OpenCode, codex-sub-agent, Kiro, Gemini, Qoder, CodeBuddy, Copilot, Droid, Pi, ZCode, Reasonix, Trae] [/Claude Code, Cursor, OpenCode, codex-sub-agent, Kiro, Gemini, Qoder, CodeBuddy, Copilot, Droid, Pi, Oh My Pi, ZCode, Reasonix, Trae]
--- ---
@@ -472,7 +472,7 @@ Goal: turn reviewed planning artifacts into code that passes quality checks.
#### 2.1 Implement `[required · repeatable]` #### 2.1 Implement `[required · repeatable]`
[Claude Code, Cursor, OpenCode, CodeBuddy, Droid, Pi] [Claude Code, Cursor, OpenCode, CodeBuddy, Droid, Pi, Oh My Pi]
Spawn the implement sub-agent: Spawn the implement sub-agent:
@@ -484,7 +484,7 @@ The platform hook/plugin auto-handles:
- Reads `implement.jsonl` and injects referenced spec/research files into the agent prompt - Reads `implement.jsonl` and injects referenced spec/research files into the agent prompt
- Injects `prd.md`, `design.md` if present, and `implement.md` if present - Injects `prd.md`, `design.md` if present, and `implement.md` if present
[/Claude Code, Cursor, OpenCode, CodeBuddy, Droid, Pi] [/Claude Code, Cursor, OpenCode, CodeBuddy, Droid, Pi, Oh My Pi]
[codex-sub-agent, Gemini, Qoder, Copilot, ZCode, Reasonix, Trae] [codex-sub-agent, Gemini, Qoder, Copilot, ZCode, Reasonix, Trae]
@@ -526,7 +526,7 @@ The platform prelude auto-handles the context load requirement:
#### 2.2 Quality check `[required · repeatable]` #### 2.2 Quality check `[required · repeatable]`
[Claude Code, Cursor, OpenCode, codex-sub-agent, Kiro, Gemini, Qoder, CodeBuddy, Copilot, Droid, Pi, ZCode, Reasonix, Trae] [Claude Code, Cursor, OpenCode, codex-sub-agent, Kiro, Gemini, Qoder, CodeBuddy, Copilot, Droid, Pi, Oh My Pi, ZCode, Reasonix, Trae]
Spawn the check sub-agent: Spawn the check sub-agent:
@@ -540,7 +540,7 @@ The check agent's job:
- Auto-fix issues it finds - Auto-fix issues it finds
- Run lint and typecheck to verify - Run lint and typecheck to verify
[/Claude Code, Cursor, OpenCode, codex-sub-agent, Kiro, Gemini, Qoder, CodeBuddy, Copilot, Droid, Pi, ZCode, Reasonix, Trae] [/Claude Code, Cursor, OpenCode, codex-sub-agent, Kiro, Gemini, Qoder, CodeBuddy, Copilot, Droid, Pi, Oh My Pi, ZCode, Reasonix, Trae]
[codex-inline, Kilo, Antigravity, Devin] [codex-inline, Kilo, Antigravity, Devin]
+46 -3
View File
@@ -1,8 +1,51 @@
# Changelog # Changelog
格式遵循 [Keep a Changelog](https://keepachangelog.com/zh-CN/1.1.0/),版本号遵循语义化版本。 格式参考 [Keep a Changelog](https://keepachangelog.com/zh-CN/1.1.0/)(版本段不记日期),版本号遵循语义化版本。
## [0.1.0] - 2026-07-10 ## [0.4.0]
### Added
- AI 网关「接入信息」补齐新端点展示:`POST /audio/speech`(文本转语音 · xAI Voice)、`POST /rerank`(文档重排 · Cohere Rerank)、`POST /moderations`(内容审核 · OCI Guardrails
## [0.3.0]
### Added
- AI 网关端点列表恢复展示 OpenAI Chat Completions 接口(`POST /ai/v1/chat/completions`),标明支持流式与非流式调用
- 租户列表分页支持 10 / 20 / 50 / 100 条每页切换
- 设置 · 关于新增「运行状态」面板:运行时长(随查看自增)与 CPU 均值 / 内存(堆)/ 存储占用 / Goroutines 四格指标,明暗主题与窄屏两列自适应;旧版后端缺运行时字段时面板自动隐藏
- 代理列表新增「关联租户」管理:弹窗回显当前关联名单(支持点 ✕ 移除),多选增删保存即设置全集,选中已关联其他代理的租户时提示保存后改挂
### Changed
- 回传日志告警统一改由「通知管理 → 云端事件」分类推送,租户删除提示同步移除已废弃的告警规则清理项
- 总览页租户测活列表改为限高滚动,「查看全部租户」入口固定展示
- 系统日志、OCI 审计日志与配额表格取消固定高度,分页内容随页面完整展开
- 代理列表「认证」列由用户名明文拼接改为「是 / 否」徽标,悬停「是」显示用户名(无用户名提示仅密码认证)
### Removed
- 移除日志页自定义审计告警规则的管理入口、条件表单及相关前端 API
### Fixed
- 修复租户列表分页状态在页面重绘时丢失,以及筛选后停留在越界页码的问题
- 修复「引导卷(GB)」等可清空数字输入框的步进箭头挤出输入框右缘的错位;清空图标改为悬浮在步进竖栏左侧,输入文本自动避让
## [0.2.0]
### Added
- AI 网关页「模型黑名单」管理:模型列表按厂商手风琴分组展示,可一键拉黑(全渠道剔除)、移除后重新同步渠道恢复
- AI 密钥模型白名单编辑:创建 / 编辑密钥时可限定放行的模型列表(空 = 不限)
- 渠道 / 密钥表单「现有分组」chips:点击即填入分组输入框
### Changed
- 租户删除确认弹窗分段排版(标题 / 面板清理范围 / 云端提示),列表与详情页文案一致
## [0.1.0]
### Added ### Added
@@ -24,7 +67,7 @@
- 租户详情「用户」「策略」等 Tab 切换域后内容不刷新 - 租户详情「用户」「策略」等 Tab 切换域后内容不刷新
- 实例详情区块加载中时禁用头部操作按钮,防误点 - 实例详情区块加载中时禁用头部操作按钮,防误点
## [0.0.1] - 2026-07-09 ## [0.0.1]
首个版本:OCI Portal 前端。 首个版本:OCI Portal 前端。
+1 -1
View File
@@ -1,7 +1,7 @@
{ {
"name": "oci-portal-dash", "name": "oci-portal-dash",
"private": true, "private": true,
"version": "0.1.0", "version": "0.2.0",
"type": "module", "type": "module",
"scripts": { "scripts": {
"dev": "vite", "dev": "vite",
+28 -2
View File
@@ -1,5 +1,13 @@
import { request } from './request' import { request } from './request'
import type { AiCallLog, AiChannel, AiContentLog, AiKey, AiModel, AiModelCacheItem } from '@/types/api' import type {
AiCallLog,
AiChannel,
AiContentLog,
AiKey,
AiModel,
AiModelBlacklistItem,
AiModelCacheItem,
} from '@/types/api'
// ---- 网关密钥 ---- // ---- 网关密钥 ----
@@ -11,6 +19,8 @@ export interface CreateAiKeyRequest {
name: string name: string
value?: string value?: string
group?: string group?: string
/** 模型白名单;缺省/空 = 不限 */
models?: string[]
} }
/** 创建密钥;key 为明文,仅本次响应返回 */ /** 创建密钥;key 为明文,仅本次响应返回 */
@@ -20,7 +30,7 @@ export function createAiKey(body: CreateAiKeyRequest): Promise<{ key: string; it
export function updateAiKey( export function updateAiKey(
id: number, id: number,
body: { name?: string; enabled?: boolean; group?: string }, body: { name?: string; enabled?: boolean; group?: string; models?: string[] },
): Promise<void> { ): Promise<void> {
return request(`/ai-keys/${id}`, { method: 'PUT', body }) return request(`/ai-keys/${id}`, { method: 'PUT', body })
} }
@@ -78,6 +88,22 @@ export function listAiModels(): Promise<AiModel[]> {
return request<{ items: AiModel[] }>('/ai-models').then((r) => r.items) return request<{ items: AiModel[] }>('/ai-models').then((r) => r.items)
} }
// ---- 模型黑名单 ----
export function listAiBlacklist(): Promise<AiModelBlacklistItem[]> {
return request<{ items: AiModelBlacklistItem[] }>('/ai-blacklist').then((r) => r.items)
}
/** 拉黑模型:删除全部渠道缓存中的同名条目,后续同步 / 探测均过滤 */
export function addAiBlacklist(name: string): Promise<void> {
return request('/ai-blacklist', { method: 'POST', body: { name } })
}
/** 移出黑名单:缓存不回填,重新同步 / 探测后恢复入池 */
export function removeAiBlacklist(id: number): Promise<void> {
return request(`/ai-blacklist/${id}`, { method: 'DELETE' })
}
export function listAiCallLogs(params: { export function listAiCallLogs(params: {
page: number page: number
size: number size: number
-23
View File
@@ -1,8 +1,6 @@
import { mockLogEvents, mockLogRelays, mockLogWebhooks } from './mock' import { mockLogEvents, mockLogRelays, mockLogWebhooks } from './mock'
import { mockOn, mocked, request } from './request' import { mockOn, mocked, request } from './request'
import type { import type {
AlertRule,
AlertRuleBody,
LogEventPage, LogEventPage,
LogRelayView, LogRelayView,
LogWebhookInfo, LogWebhookInfo,
@@ -30,27 +28,6 @@ export function listLogEvents(params: LogEventParams): Promise<LogEventPage> {
return request('/log-events', { query: { ...params } }) return request('/log-events', { query: { ...params } })
} }
// ---- 告警规则 ----
export function listAlertRules(): Promise<AlertRule[]> {
if (mockOn) return mocked([])
return request<{ items: AlertRule[] }>('/log-events/alert-rules').then((r) => r.items)
}
export function createAlertRule(body: AlertRuleBody): Promise<AlertRule> {
if (mockOn) return mocked({ ...body, id: 1, createdAt: '', updatedAt: '' }, 300)
return request('/log-events/alert-rules', { method: 'POST', body })
}
export function updateAlertRule(id: number, body: AlertRuleBody): Promise<AlertRule> {
if (mockOn) return mocked({ ...body, id, createdAt: '', updatedAt: '' }, 300)
return request(`/log-events/alert-rules/${id}`, { method: 'PUT', body })
}
export function deleteAlertRule(id: number): Promise<void> {
if (mockOn) return mocked(undefined, 300)
return request(`/log-events/alert-rules/${id}`, { method: 'DELETE' })
}
export function getLogWebhook(cfgId: number): Promise<LogWebhookState> { export function getLogWebhook(cfgId: number): Promise<LogWebhookState> {
if (mockOn) { if (mockOn) {
const info = mockLogWebhooks.get(cfgId) const info = mockLogWebhooks.get(cfgId)
+3 -2
View File
@@ -113,8 +113,9 @@ export const mockConfigs: OciConfig[] = [
promotionStatus: 'EXPIRED', promotionStatus: 'EXPIRED',
multiRegion: true, multiRegion: true,
multiCompartment: true, multiCompartment: true,
proxyId: null, // 与 mockProxies[0].usedBy = 1 呼应:主号经东京 socks5 出站
proxyName: '', proxyId: 1,
proxyName: '东京 socks5',
}), }),
cfg({ cfg({
id: 2, id: 2,
+17 -1
View File
@@ -1,4 +1,4 @@
import { mockProxies } from './mock' import { mockConfigs, mockProxies } from './mock'
import { mockOn, mocked, request } from './request' import { mockOn, mocked, request } from './request'
import type { ProxyImportResult, ProxyInfo, ProxyInput } from '@/types/api' import type { ProxyImportResult, ProxyInfo, ProxyInput } from '@/types/api'
@@ -78,6 +78,22 @@ export function importProxies(text: string): Promise<ProxyImportResult> {
return request('/proxies/import', { method: 'POST', body: { text } }) return request('/proxies/import', { method: 'POST', body: { text } })
} }
/** 代理侧设置关联租户全集:选中即关联(含从其他代理改挂),未选中即解除 */
export function setProxyTenants(id: number, ociConfigIds: number[]): Promise<{ usedBy: number }> {
if (mockOn) {
const found = mockProxies.find((p) => p.id === id)
if (!found) return Promise.reject(new Error('代理不存在'))
for (const c of mockConfigs) {
if (ociConfigIds.includes(c.id)) Object.assign(c, { proxyId: id, proxyName: found.name })
else if (c.proxyId === id) Object.assign(c, { proxyId: null, proxyName: '' })
}
// 改挂会影响其他代理的引用数,全量重算保持一致
for (const p of mockProxies) p.usedBy = mockConfigs.filter((c) => c.proxyId === p.id).length
return mocked({ usedBy: found.usedBy })
}
return request(`/proxies/${id}/tenants`, { method: 'PUT', body: { ociConfigIds } })
}
/** 手动重测出口地区,同步返回最新视图 */ /** 手动重测出口地区,同步返回最新视图 */
export function probeProxy(id: number): Promise<ProxyInfo> { export function probeProxy(id: number): Promise<ProxyInfo> {
if (mockOn) { if (mockOn) {
+11
View File
@@ -181,6 +181,17 @@ export function getAbout(): Promise<AboutInfo> {
buildTime: '2026-07-09T12:00Z', buildTime: '2026-07-09T12:00Z',
goVersion: 'go1.26.4', goVersion: 'go1.26.4',
platform: 'linux/amd64', platform: 'linux/amd64',
startedAt: '2026-07-01T08:23:00+08:00',
uptimeSeconds: 1053360, // 12 天 4 小时 36 分
resources: {
cpuAvgPercent: 1.4,
numCpu: 4,
goroutines: 36,
memHeapBytes: 50537000,
memSysBytes: 101187000,
dbEngine: 'sqlite',
dbBytes: 13212000,
},
}) })
return request('/about') return request('/about')
} }
+13
View File
@@ -168,6 +168,19 @@ body {
background: var(--color-wash); background: var(--color-wash);
color: var(--color-ink); color: var(--color-ink);
} }
/* clearable 时 naive-ui 在 suffix 首位多渲染 .n-base-clear,会被上面的
2 行网格自动排进隐式第 2 列、把 26px 竖栏撑爆(箭头溢出框外)——
绝对定位使其脱离网格流,悬浮在竖栏左侧;文本区同步加宽避让清空图标 */
.app-input-number .n-input__suffix .n-base-clear {
position: absolute;
right: 100%;
top: 50%;
transform: translateY(-50%);
margin-right: 5px;
}
.app-input-number .n-input:has(.n-base-clear) .n-input-wrapper {
padding-right: 52px;
}
/* useToast 可展开详情:toast 内嵌代码块(标签 + 复制 + 内滚 pre)。 /* useToast 可展开详情:toast 内嵌代码块(标签 + 复制 + 内滚 pre)。
message 经 teleport 渲染于 body,组件 scoped 样式不可达,故置于全局。 */ message 经 teleport 渲染于 body,组件 scoped 样式不可达,故置于全局。 */
+5 -1
View File
@@ -4,6 +4,7 @@ import { computed, h, reactive, ref } from 'vue'
import { createAiChannel, deleteAiChannel, probeAiChannel, syncAiChannelModels, updateAiChannel } from '@/api/aigateway' import { createAiChannel, deleteAiChannel, probeAiChannel, syncAiChannelModels, updateAiChannel } from '@/api/aigateway'
import { listCachedRegions } from '@/api/configs' import { listCachedRegions } from '@/api/configs'
import GroupChips from '@/components/ai/GroupChips.vue'
import AppInputNumber from '@/components/AppInputNumber.vue' import AppInputNumber from '@/components/AppInputNumber.vue'
import FormField from '@/components/FormField.vue' import FormField from '@/components/FormField.vue'
import FormModal from '@/components/FormModal.vue' import FormModal from '@/components/FormModal.vue'
@@ -15,9 +16,11 @@ import { useToast } from '@/composables/useToast'
import { useScopeStore } from '@/stores/scope' import { useScopeStore } from '@/stores/scope'
import type { AiChannel, AiProbeStatus } from '@/types/api' import type { AiChannel, AiProbeStatus } from '@/types/api'
defineProps<{ channels: AiChannel[]; loading: boolean }>() const props = defineProps<{ channels: AiChannel[]; loading: boolean }>()
const emit = defineEmits<{ changed: [] }>() const emit = defineEmits<{ changed: [] }>()
const groupHints = computed(() => [...new Set(props.channels.map((c) => c.group).filter(Boolean))])
const toast = useToast() const toast = useToast()
const dialog = useDialog() const dialog = useDialog()
const scope = useScopeStore() const scope = useScopeStore()
@@ -233,6 +236,7 @@ const columns = computed<DataTableColumns<AiChannel>>(() => [
<div class="grid grid-cols-3 gap-3"> <div class="grid grid-cols-3 gap-3">
<FormField label="分组" hint="分组供密钥定向路由;留空归入默认分组"> <FormField label="分组" hint="分组供密钥定向路由;留空归入默认分组">
<NInput v-model:value="form.group" placeholder="默认" /> <NInput v-model:value="form.group" placeholder="默认" />
<GroupChips :groups="groupHints" @pick="form.group = $event" />
</FormField> </FormField>
<FormField label="优先级" hint="数字小优先"> <FormField label="优先级" hint="数字小优先">
<AppInputNumber v-model:value="form.priority" :min="1" /> <AppInputNumber v-model:value="form.priority" :min="1" />
+45 -19
View File
@@ -1,17 +1,18 @@
<script setup lang="ts"> <script setup lang="ts">
import { NButton, NDataTable, NInput, useDialog, type DataTableColumns } from 'naive-ui' import { NButton, NDataTable, NInput, NSelect, NTooltip, useDialog, type DataTableColumns } from 'naive-ui'
import { computed, h, reactive, ref } from 'vue' import { computed, h, reactive, ref } from 'vue'
import { createAiKey, deleteAiKey, updateAiKey, updateAiKeyContentLog } from '@/api/aigateway' import { createAiKey, deleteAiKey, updateAiKey, updateAiKeyContentLog } from '@/api/aigateway'
import GroupChips from '@/components/ai/GroupChips.vue'
import AppInputNumber from '@/components/AppInputNumber.vue' import AppInputNumber from '@/components/AppInputNumber.vue'
import FormField from '@/components/FormField.vue' import FormField from '@/components/FormField.vue'
import FormModal from '@/components/FormModal.vue' import FormModal from '@/components/FormModal.vue'
import StatusBadge from '@/components/StatusBadge.vue' import StatusBadge from '@/components/StatusBadge.vue'
import { fmtTime } from '@/composables/useFormat' import { fmtTime } from '@/composables/useFormat'
import type { AiKey } from '@/types/api' import type { AiKey, AiModel } from '@/types/api'
import { useToast } from '@/composables/useToast' import { useToast } from '@/composables/useToast'
const props = defineProps<{ keys: AiKey[]; loading: boolean; groups: string[] }>() const props = defineProps<{ keys: AiKey[]; loading: boolean; groups: string[]; models: AiModel[] }>()
const emit = defineEmits<{ changed: [] }>() const emit = defineEmits<{ changed: [] }>()
const message = useToast() const message = useToast()
@@ -21,20 +22,23 @@ const dialog = useDialog()
const showForm = ref(false) const showForm = ref(false)
const editing = ref<AiKey | null>(null) const editing = ref<AiKey | null>(null)
const submitting = ref(false) const submitting = ref(false)
const form = reactive({ name: '', value: '', group: '' }) const form = reactive({ name: '', value: '', group: '', models: [] as string[] })
function openCreate() { function openCreate() {
editing.value = null editing.value = null
Object.assign(form, { name: '', value: '', group: '' }) Object.assign(form, { name: '', value: '', group: '', models: [] })
showForm.value = true showForm.value = true
} }
function openEdit(key: AiKey) { function openEdit(key: AiKey) {
editing.value = key editing.value = key
Object.assign(form, { name: key.name, value: '', group: key.group }) Object.assign(form, { name: key.name, value: '', group: key.group, models: key.models ?? [] })
showForm.value = true showForm.value = true
} }
/** 限制模型下拉选项:聚合模型列表;tag 模式允许手输未同步模型 */
const modelOptions = computed(() => props.models.map((m) => ({ label: m.id, value: m.id })))
// 创建成功后明文只在此弹窗展示一次 // 创建成功后明文只在此弹窗展示一次
const createdKey = ref('') const createdKey = ref('')
const showCreated = ref(false) const showCreated = ref(false)
@@ -43,10 +47,13 @@ async function submit() {
submitting.value = true submitting.value = true
try { try {
if (editing.value) { if (editing.value) {
await updateAiKey(editing.value.id, { name: form.name, group: form.group }) await updateAiKey(editing.value.id, { name: form.name, group: form.group, models: form.models })
message.success('已更新密钥') message.success('已更新密钥')
} else { } else {
const { key } = await createAiKey({ name: form.name, value: form.value || undefined, group: form.group || undefined }) const { key } = await createAiKey({
name: form.name, value: form.value || undefined, group: form.group || undefined,
models: form.models.length ? form.models : undefined,
})
createdKey.value = key createdKey.value = key
showCreated.value = true showCreated.value = true
} }
@@ -118,6 +125,21 @@ function confirmRemove(key: AiKey) {
const groupHints = computed(() => props.groups.filter(Boolean)) const groupHints = computed(() => props.groups.filter(Boolean))
// modelsCell 渲染模型白名单列:空 = 不限;非空显示数量,悬浮列明细
function modelsCell(r: AiKey) {
const list = r.models ?? []
if (!list.length) return h('span', { class: 'text-xs text-ink-3' }, '不限')
return h(
NTooltip,
{ style: { maxWidth: '320px' } },
{
trigger: () =>
h('span', { class: 'cursor-help rounded-[5px] bg-info/15 px-2 py-0.5 text-xs font-medium text-info' }, `${list.length}`),
default: () => h('span', { class: 'text-xs leading-relaxed whitespace-pre-wrap break-all' }, list.join('\n')),
},
)
}
const columns = computed<DataTableColumns<AiKey>>(() => [ const columns = computed<DataTableColumns<AiKey>>(() => [
{ title: '名称', key: 'name', width: 220, ellipsis: { tooltip: true }, render: (r) => h('span', { class: 'text-[13px] font-medium' }, r.name) }, { title: '名称', key: 'name', width: 220, ellipsis: { tooltip: true }, render: (r) => h('span', { class: 'text-[13px] font-medium' }, r.name) },
{ title: '密钥', key: 'tail', width: 120, render: (r) => h('span', { class: 'mono text-[13px] text-ink-2' }, `……${r.tail}`) }, { title: '密钥', key: 'tail', width: 120, render: (r) => h('span', { class: 'mono text-[13px] text-ink-2' }, `……${r.tail}`) },
@@ -127,6 +149,7 @@ const columns = computed<DataTableColumns<AiKey>>(() => [
? h('span', { class: 'rounded-[5px] bg-info/15 px-2 py-0.5 text-xs font-medium text-info' }, r.group) ? h('span', { class: 'rounded-[5px] bg-info/15 px-2 py-0.5 text-xs font-medium text-info' }, r.group)
: h('span', { class: 'text-xs text-ink-3' }, '不限'), : h('span', { class: 'text-xs text-ink-3' }, '不限'),
}, },
{ title: '模型', key: 'models', width: 90, render: modelsCell },
{ {
title: '状态', key: 'enabled', width: 100, title: '状态', key: 'enabled', width: 100,
render: (r) => h(StatusBadge, r.enabled ? { kind: 'run', label: '启用' } : { kind: 'stop', label: '已禁用' }), render: (r) => h(StatusBadge, r.enabled ? { kind: 'run', label: '启用' } : { kind: 'stop', label: '已禁用' }),
@@ -170,18 +193,21 @@ const columns = computed<DataTableColumns<AiKey>>(() => [
</FormField> </FormField>
<FormField label="渠道分组" hint="选择分组后,该密钥的调用只在该分组的渠道内负载均衡;留空不限分组"> <FormField label="渠道分组" hint="选择分组后,该密钥的调用只在该分组的渠道内负载均衡;留空不限分组">
<NInput v-model:value="form.group" placeholder="留空 = 不限(全部渠道)" /> <NInput v-model:value="form.group" placeholder="留空 = 不限(全部渠道)" />
<div v-if="groupHints.length" class="mt-1.5 flex flex-wrap items-center gap-1.5"> <GroupChips :groups="groupHints" @pick="form.group = $event" />
<span class="text-xs text-ink-3">现有分组:</span> </FormField>
<button <FormField
v-for="g in groupHints" label="限制模型"
:key="g" hint="非空时该密钥仅能调用所选模型,/v1/models 同步只返回交集;可手输未同步的模型名;留空不限"
type="button"
class="cursor-pointer rounded-[5px] border border-line bg-card px-2 py-0.5 text-xs text-ink-2 hover:border-accent hover:text-accent"
@click="form.group = g"
> >
{{ g }} <NSelect
</button> v-model:value="form.models"
</div> :options="modelOptions"
multiple
filterable
clearable
tag
placeholder="留空 = 不限(全部模型)"
/>
</FormField> </FormField>
<FormField v-if="!editing" label="自定义密钥值" hint="至少 8 位;仅测试场景建议自定义"> <FormField v-if="!editing" label="自定义密钥值" hint="至少 8 位;仅测试场景建议自定义">
<NInput v-model:value="form.value" placeholder="留空自动生成 sk- 开头随机密钥(推荐)" /> <NInput v-model:value="form.value" placeholder="留空自动生成 sk- 开头随机密钥(推荐)" />
+20
View File
@@ -0,0 +1,20 @@
<script setup lang="ts">
// 现有分组提示行:点击 chip 将分组名填入外部输入框;无分组时整行不渲染
defineProps<{ groups: string[] }>()
defineEmits<{ pick: [group: string] }>()
</script>
<template>
<div v-if="groups.length" class="mt-1.5 flex flex-wrap items-center gap-1.5">
<span class="text-xs text-ink-3">现有分组:</span>
<button
v-for="g in groups"
:key="g"
type="button"
class="cursor-pointer rounded-[5px] border border-line bg-card px-2 py-0.5 text-xs text-ink-2 hover:border-accent hover:text-accent"
@click="$emit('pick', g)"
>
{{ g }}
</button>
</div>
</template>
-313
View File
@@ -1,313 +0,0 @@
<script setup lang="ts">
import {
NButton,
NInput,
NModal,
NPopconfirm,
NSelect,
NSwitch,
type SelectOption,
} from 'naive-ui'
import { computed, reactive, ref, watch } from 'vue'
import {
createAlertRule,
deleteAlertRule,
listAlertRules,
updateAlertRule,
} from '@/api/logevents'
import { listNotifyTemplates } from '@/api/settings'
import AppInputNumber from '@/components/AppInputNumber.vue'
import FormField from '@/components/FormField.vue'
import NotifyTemplateModal from '@/components/settings/NotifyTemplateModal.vue'
import TenantPicker from '@/components/TenantPicker.vue'
import { eventLabel } from '@/composables/useEventLabel'
import { useAsync } from '@/composables/useAsync'
import { useScopeStore } from '@/stores/scope'
import type { AlertRule, AlertRuleBody, NotifyTemplateItem } from '@/types/api'
import { useToast } from '@/composables/useToast'
const show = defineModel<boolean>('show', { required: true })
const message = useToast()
const scope = useScopeStore()
/** 可选事件短名 = 回传链路的关键事件清单(Connector 侧 filter 一致) */
const RELAY_EVENTS = [
'LaunchInstance', 'TerminateInstance', 'InstanceAction',
'CreateUser', 'DeleteUser', 'UpdateUser',
'CreateApiKey', 'DeleteApiKey', 'UpdateUserCapabilities',
'CreateRegionSubscription', 'CreatePolicy', 'UpdatePolicy', 'DeletePolicy',
'InteractiveLogin',
]
const eventOptions: SelectOption[] = RELAY_EVENTS.map((e) => ({
value: e,
label: eventLabel(e) ? `${eventLabel(e)}(${e})` : e,
}))
const rules = useAsync(listAlertRules, false)
watch(show, (v) => {
if (v) void rules.run()
})
// ---- 编辑表单:editing 非 null 时进入表单视图,id=0 表示新建 ----
const editing = ref<AlertRule | null>(null)
const saving = ref(false)
const form = reactive({
name: '',
enabled: true,
cfgId: null as number | null,
eventTypes: [] as string[],
sourceIps: '',
sourceIpMode: 'in' as 'in' | 'notin',
resourceMatch: '',
threshold: 1 as number | null,
windowMinutes: 5 as number | null,
})
function openCreate() {
editing.value = {
id: 0, name: '', enabled: true, ociConfigId: 0, eventTypes: '', sourceIps: '',
sourceIpMode: 'in', resourceMatch: '', threshold: 1, windowMinutes: 5,
createdAt: '', updatedAt: '',
}
}
function openEdit(rule: AlertRule) {
editing.value = rule
}
// 进入表单时由所编辑规则回填
watch(editing, (r) => {
if (!r) return
form.name = r.name
form.enabled = r.enabled
form.cfgId = r.ociConfigId || null
form.eventTypes = r.eventTypes ? r.eventTypes.split(',') : []
form.sourceIps = r.sourceIps
form.sourceIpMode = r.sourceIpMode || 'in'
form.resourceMatch = r.resourceMatch
form.threshold = r.threshold || 1
form.windowMinutes = r.windowMinutes || 5
})
function buildBody(): AlertRuleBody {
return {
name: form.name.trim(),
enabled: form.enabled,
ociConfigId: form.cfgId ?? 0,
eventTypes: form.eventTypes.join(','),
sourceIps: form.sourceIps.trim(),
sourceIpMode: form.sourceIpMode,
resourceMatch: form.resourceMatch.trim(),
threshold: form.threshold ?? 1,
windowMinutes: form.windowMinutes ?? 5,
}
}
async function save() {
if (!editing.value) return
saving.value = true
try {
const body = buildBody()
if (editing.value.id) await updateAlertRule(editing.value.id, body)
else await createAlertRule(body)
message.success(editing.value.id ? '规则已更新' : '规则已创建')
editing.value = null
void rules.run()
} catch (e) {
message.error(e instanceof Error ? e.message : '保存失败')
} finally {
saving.value = false
}
}
/** 列表行的启停开关:就地整体覆盖保存 */
async function toggleRule(rule: AlertRule, enabled: boolean) {
try {
await updateAlertRule(rule.id, { ...rule, enabled })
rule.enabled = enabled
} catch (e) {
message.error(e instanceof Error ? e.message : '操作失败')
}
}
async function removeRule(rule: AlertRule) {
try {
await deleteAlertRule(rule.id)
message.success(`已删除「${rule.name}`)
void rules.run()
} catch (e) {
message.error(e instanceof Error ? e.message : '删除失败')
}
}
/** 条件摘要:留空条件不出现 */
function ruleSummary(r: AlertRule): string {
const parts: string[] = []
const alias = scope.cfgOptions.find((o) => Number(o.value) === r.ociConfigId)?.label
parts.push(r.ociConfigId ? `租户 ${alias ?? `#${r.ociConfigId}`}` : '全部租户')
parts.push(r.eventTypes ? `${r.eventTypes.split(',').length} 种事件` : '全部事件')
if (r.sourceIps) parts.push(`IP ${r.sourceIpMode === 'notin' ? '不在' : '命中'} ${r.sourceIps}`)
if (r.resourceMatch) parts.push(`资源含「${r.resourceMatch}`)
parts.push(r.threshold > 1 ? `${r.windowMinutes} 分钟内 ${r.threshold}` : '即时触发')
return parts.join(' · ')
}
// ---- 通知模板入口:复用设置页模板编辑弹窗(kind=audit_alert) ----
const templates = useAsync(listNotifyTemplates, false)
const tplShow = ref(false)
const tplItem = ref<NotifyTemplateItem | null>(null)
async function openTemplate() {
if (!templates.data.value) await templates.run()
const item = (templates.data.value ?? []).find((t) => t.kind === 'audit_alert')
if (!item) {
message.error('模板加载失败,请稍后再试')
return
}
tplItem.value = item
tplShow.value = true
}
const canSave = computed(() => !!form.name.trim())
</script>
<template>
<NModal
v-model:show="show"
preset="card"
closable
title="审计告警规则"
:style="{ width: '680px', maxWidth: 'calc(100vw - 24px)' }"
>
<!-- 表单视图 -->
<div v-if="editing" class="flex flex-col">
<FormField label="规则名称" required>
<NInput v-model:value="form.name" placeholder="如:非白名单终止实例" />
</FormField>
<div class="grid grid-cols-2 gap-3 max-md:grid-cols-1">
<FormField label="租户范围" hint="留空对全部租户生效">
<TenantPicker
v-model:value="form.cfgId"
clearable
placeholder="全部租户"
:configs="scope.configs.data ?? []"
:loading="scope.configs.loading"
/>
</FormField>
<FormField label="事件类型" hint="留空匹配全部回传事件">
<NSelect
v-model:value="form.eventTypes"
multiple
clearable
:options="eventOptions"
placeholder="全部事件"
:max-tag-count="2"
/>
</FormField>
</div>
<FormField
label="来源 IP 条件"
hint="逗号分隔 IP 或 CIDR;「不在列表才告警」适合白名单场景(非我发起的操作)"
>
<div class="mb-1.5 flex gap-1.5">
<button
v-for="m in [
{ v: 'in', t: '命中列表告警' },
{ v: 'notin', t: '不在列表才告警' },
]"
:key="m.v"
type="button"
class="cursor-pointer rounded-md border px-3 py-1 text-xs"
:class="
form.sourceIpMode === m.v
? 'border-accent bg-accent/10 font-semibold text-accent'
: 'border-line bg-white text-ink-2 hover:border-ink-3'
"
@click="form.sourceIpMode = m.v as 'in' | 'notin'"
>
{{ m.t }}
</button>
</div>
<NInput v-model:value="form.sourceIps" class="mono" placeholder="203.0.113.8, 10.0.0.0/8(留空=任意)" />
</FormField>
<div class="grid grid-cols-3 gap-3 max-md:grid-cols-1">
<FormField label="资源名包含" hint="子串匹配,留空=任意">
<NInput v-model:value="form.resourceMatch" placeholder="web-" />
</FormField>
<FormField label="触发阈值(次)" hint="1=每次命中即告警">
<AppInputNumber v-model:value="form.threshold" :min="1" :max="100" class="!w-full" />
</FormField>
<FormField label="聚合窗口(分钟)" hint="阈值>1 时生效,告警后同窗冷却">
<AppInputNumber
v-model:value="form.windowMinutes"
:min="1"
:max="1440"
:disabled="(form.threshold ?? 1) <= 1"
class="!w-full"
/>
</FormField>
</div>
<div class="flex items-center justify-between rounded-lg bg-wash px-3 py-2">
<span class="text-[12.5px]">启用该规则</span>
<NSwitch v-model:value="form.enabled" size="small" />
</div>
<div class="mt-3 flex items-center gap-2">
<NButton size="small" type="primary" :loading="saving" :disabled="!canSave" @click="save">
保存
</NButton>
<NButton size="small" @click="editing = null">返回列表</NButton>
</div>
</div>
<!-- 列表视图 -->
<div v-else class="flex flex-col">
<div class="mb-2 flex items-center justify-between gap-2">
<div class="text-xs text-ink-3">
命中规则的回传事件经「通知方式」的启用渠道推送;仅已建回传链路的租户产生事件
</div>
<div class="flex flex-none items-center gap-2">
<NButton size="tiny" quaternary type="primary" @click="openTemplate">通知模板</NButton>
<NButton size="small" type="primary" @click="openCreate">新建规则</NButton>
</div>
</div>
<div
v-for="rule in rules.data.value ?? []"
:key="rule.id"
class="flex items-center gap-3 border-b border-line-soft py-2.5 last:border-b-0"
>
<div class="min-w-0 flex-1">
<div class="text-[13px] font-medium">{{ rule.name }}</div>
<div class="mt-0.5 truncate text-xs text-ink-3" :title="ruleSummary(rule)">
{{ ruleSummary(rule) }}
</div>
</div>
<NSwitch
size="small"
:value="rule.enabled"
@update:value="(v: boolean) => toggleRule(rule, v)"
/>
<NButton size="tiny" quaternary type="primary" @click="openEdit(rule)">编辑</NButton>
<NPopconfirm @positive-click="removeRule(rule)">
<template #trigger>
<NButton size="tiny" quaternary type="error">删除</NButton>
</template>
删除规则「{{ rule.name }}」?
</NPopconfirm>
</div>
<div
v-if="!rules.loading.value && !(rules.data.value ?? []).length"
class="py-8 text-center text-[13px] text-ink-3"
>
暂无规则,点击「新建规则」创建第一条
</div>
</div>
<NotifyTemplateModal
v-model:show="tplShow"
:item="tplItem"
hint="命中告警规则时推送;变量:rule / tenant / event / resource / ip / count"
/>
</NModal>
</template>
+2 -8
View File
@@ -1,11 +1,10 @@
<script setup lang="ts"> <script setup lang="ts">
import { NButton, NDataTable, NModal, NPopover, type DataTableColumns } from 'naive-ui' import { NDataTable, NModal, NPopover, type DataTableColumns } from 'naive-ui'
import { computed, h, reactive, ref } from 'vue' import { computed, h, reactive, ref } from 'vue'
import { useRouter } from 'vue-router' import { useRouter } from 'vue-router'
import { listConfigs } from '@/api/configs' import { listConfigs } from '@/api/configs'
import { listLogEvents } from '@/api/logevents' import { listLogEvents } from '@/api/logevents'
import AlertRuleModal from '@/components/logs/AlertRuleModal.vue'
import DetailFieldList, { type DetailRow } from '@/components/DetailFieldList.vue' import DetailFieldList, { type DetailRow } from '@/components/DetailFieldList.vue'
import DetailHero, { type HeroChip } from '@/components/DetailHero.vue' import DetailHero, { type HeroChip } from '@/components/DetailHero.vue'
import FootNote from '@/components/FootNote.vue' import FootNote from '@/components/FootNote.vue'
@@ -41,7 +40,6 @@ const cfgById = computed(() => {
const detail = ref<LogEvent | null>(null) const detail = ref<LogEvent | null>(null)
const showDetail = ref(false) const showDetail = ref(false)
const showRules = ref(false)
/** 受控远程分页:字面量对象会在重渲染时被重建导致状态丢失 */ /** 受控远程分页:字面量对象会在重渲染时被重建导致状态丢失 */
const pagination = reactive({ const pagination = reactive({
@@ -223,7 +221,6 @@ useAutoRefresh(() => load(true))
</div> </div>
</div> </div>
<div class="flex flex-wrap items-center gap-2"> <div class="flex flex-wrap items-center gap-2">
<NButton size="small" @click="showRules = true">告警规则</NButton>
<TenantPicker <TenantPicker
v-model:value="cfgFilter" v-model:value="cfgFilter"
size="small" size="small"
@@ -251,12 +248,9 @@ useAutoRefresh(() => load(true))
在租户详情「其他」tab 一键创建链路后,实例生命周期(Launch/Terminate/InstanceAction)、 在租户详情「其他」tab 一键创建链路后,实例生命周期(Launch/Terminate/InstanceAction)、
用户与凭据(Create/Delete/UpdateUser、Create/DeleteApiKey、UpdateUserCapabilities)、 用户与凭据(Create/Delete/UpdateUser、Create/DeleteApiKey、UpdateUserCapabilities)、
区域订阅与策略变更等关键审计事件将自动回传;消息按 MessageId 幂等去重,保留 90 区域订阅与策略变更等关键审计事件将自动回传;消息按 MessageId 幂等去重,保留 90
天、总量超 2 万条时删除最旧,关键事件另经「通知管理 → 云端事件」推送告警; 天、总量超 2 万条时删除最旧,关键事件另经「通知管理 → 云端事件」推送告警
更细粒度的条件告警(事件/来源 IP/资源/频率)在「告警规则」中配置
</FootNote> </FootNote>
<AlertRuleModal v-model:show="showRules" />
<NModal v-model:show="showDetail" preset="card" closable :style="{ width: '720px', maxWidth: 'calc(100vw - 24px)' }"> <NModal v-model:show="showDetail" preset="card" closable :style="{ width: '720px', maxWidth: 'calc(100vw - 24px)' }">
<template #header> <template #header>
<DetailHero <DetailHero
-1
View File
@@ -185,7 +185,6 @@ useAutoRefresh(() => load(true))
:loading="loading" :loading="loading"
:pagination="pagination" :pagination="pagination"
:scroll-x="880" :scroll-x="880"
:max-height="480"
:row-key="(r: SystemLog) => r.id" :row-key="(r: SystemLog) => r.id"
:row-props="rowProps" :row-props="rowProps"
/> />
+28 -8
View File
@@ -22,6 +22,8 @@ import {
import AppInputNumber from '@/components/AppInputNumber.vue' import AppInputNumber from '@/components/AppInputNumber.vue'
import FootNote from '@/components/FootNote.vue' import FootNote from '@/components/FootNote.vue'
import FormField from '@/components/FormField.vue' import FormField from '@/components/FormField.vue'
import ProxyTenantsModal from '@/components/proxy/ProxyTenantsModal.vue'
import StatusBadge from '@/components/StatusBadge.vue'
import { useAsync } from '@/composables/useAsync' import { useAsync } from '@/composables/useAsync'
import type { ProxyImportResult, ProxyInfo } from '@/types/api' import type { ProxyImportResult, ProxyInfo } from '@/types/api'
import { useToast } from '@/composables/useToast' import { useToast } from '@/composables/useToast'
@@ -120,6 +122,15 @@ async function remove(row: ProxyInfo) {
} }
} }
// ---- 关联租户管理 ----
const showTenants = ref(false)
const tenantsFor = ref<ProxyInfo | null>(null)
function openTenants(row: ProxyInfo) {
tenantsFor.value = row
showTenants.value = true
}
// ---- 手动重测出口地区 ---- // ---- 手动重测出口地区 ----
const probingIds = ref(new Set<number>()) const probingIds = ref(new Set<number>())
@@ -207,13 +218,15 @@ const columns: DataTableColumns<ProxyInfo> = [
{ {
title: '认证', title: '认证',
key: 'username', key: 'username',
width: 110, width: 76,
render: (row) => render: (row) => {
h( const has = !!row.username || row.passwordSet
'span', // 悬停「是」可见用户名(无用户名则提示仅密码)
{ class: 'text-[12.5px] text-ink-2' }, const title = has ? (row.username ? `用户名 ${row.username}` : '仅密码认证') : undefined
row.username ? `${row.username}${row.passwordSet ? ' / ●●●' : ''}` : row.passwordSet ? '●●●' : '无', return h('span', { title }, [
), h(StatusBadge, { kind: has ? 'run' : 'check', label: has ? '是' : '否', dot: false }),
])
},
}, },
{ {
title: '关联租户', title: '关联租户',
@@ -225,7 +238,7 @@ const columns: DataTableColumns<ProxyInfo> = [
{ {
title: '操作', title: '操作',
key: 'actions', key: 'actions',
width: 168, width: 236,
render: (row) => render: (row) =>
h('div', { class: 'flex items-center gap-1' }, [ h('div', { class: 'flex items-center gap-1' }, [
h( h(
@@ -233,6 +246,7 @@ const columns: DataTableColumns<ProxyInfo> = [
{ size: 'tiny', quaternary: true, loading: probingIds.value.has(row.id), onClick: () => probe(row) }, { size: 'tiny', quaternary: true, loading: probingIds.value.has(row.id), onClick: () => probe(row) },
() => '重测', () => '重测',
), ),
h(NButton, { size: 'tiny', quaternary: true, onClick: () => openTenants(row) }, () => '关联租户'),
h(NButton, { size: 'tiny', quaternary: true, onClick: () => openEdit(row) }, () => '编辑'), h(NButton, { size: 'tiny', quaternary: true, onClick: () => openEdit(row) }, () => '编辑'),
h( h(
NPopconfirm, NPopconfirm,
@@ -261,6 +275,12 @@ const columns: DataTableColumns<ProxyInfo> = [
支持 SOCKS5 / HTTP / HTTPS;密码 AES 加密存储、不回显明文;地区为经代理实测的出口位置(ip-api.com),创建后自动检测;被租户关联的代理不可删除,请先解除关联 支持 SOCKS5 / HTTP / HTTPS;密码 AES 加密存储、不回显明文;地区为经代理实测的出口位置(ip-api.com),创建后自动检测;被租户关联的代理不可删除,请先解除关联
</FootNote> </FootNote>
<ProxyTenantsModal
v-model:show="showTenants"
:proxy="tenantsFor"
@saved="void proxies.run({ silent: true })"
/>
<NModal <NModal
v-model:show="showForm" v-model:show="showForm"
preset="card" preset="card"
+130
View File
@@ -0,0 +1,130 @@
<script setup lang="ts">
import { NButton, NModal } from 'naive-ui'
import { computed, ref, watch } from 'vue'
import { listConfigs } from '@/api/configs'
import { setProxyTenants } from '@/api/proxies'
import FormField from '@/components/FormField.vue'
import TenantPicker from '@/components/TenantPicker.vue'
import { useAsync } from '@/composables/useAsync'
import type { ProxyInfo } from '@/types/api'
import { useToast } from '@/composables/useToast'
/** 代理侧关联租户管理:打开时回显当前关联名单,多选增删,保存即设置全集
* (选中即关联,含从其他代理改挂;取消选中即解除)。 */
const props = defineProps<{ show: boolean; proxy: ProxyInfo | null }>()
const emit = defineEmits<{ 'update:show': [boolean]; saved: [] }>()
const message = useToast()
const configs = useAsync(listConfigs, false)
const selected = ref<number[]>([])
const saving = ref(false)
watch(
() => props.show,
async (v) => {
if (!v || !props.proxy) return
selected.value = []
await configs.run()
const pid = props.proxy.id
selected.value = (configs.data.value ?? []).filter((c) => c.proxyId === pid).map((c) => c.id)
},
)
const all = computed(() => configs.data.value ?? [])
/** 当前选中名单(打开时即已关联名单),chips 展示并支持点 × 移除 */
const picked = computed(() => all.value.filter((c) => selected.value.includes(c.id)))
/** 选中但已挂其他代理的租户:保存即改挂,给出警示 */
const rebinding = computed(() =>
picked.value.filter((c) => c.proxyId !== null && c.proxyId !== props.proxy?.id),
)
function removeOne(id: number) {
selected.value = selected.value.filter((v) => v !== id)
}
async function save() {
if (!props.proxy) return
saving.value = true
try {
const res = await setProxyTenants(props.proxy.id, selected.value)
message.success(`已更新关联,当前 ${res.usedBy} 个租户经此代理出站`)
emit('update:show', false)
emit('saved')
} catch (e) {
message.error(e instanceof Error ? e.message : '保存失败')
} finally {
saving.value = false
}
}
</script>
<template>
<NModal
:show="show"
preset="card"
:title="`关联租户 · ${proxy?.name ?? ''}`"
:style="{ width: '480px', maxWidth: 'calc(100vw - 24px)' }"
@update:show="emit('update:show', $event)"
>
<FormField label="关联租户" hint="选中即关联,取消选中即解除;关联后租户全部 SDK 请求经此代理出站">
<TenantPicker
v-model:values="selected"
multiple
:configs="all"
:loading="configs.loading.value"
placeholder="选择要关联的租户"
/>
</FormField>
<div v-if="picked.length" class="mb-3 flex flex-wrap gap-1.5">
<span
v-for="c in picked"
:key="c.id"
class="inline-flex items-center gap-1 rounded-full border border-line bg-wash px-2.5 py-0.5 text-[11.5px] font-medium text-ink-2"
>
{{ c.alias }}
<button
type="button"
class="cursor-pointer text-ink-3 hover:text-err"
:aria-label="`移除 ${c.alias}`"
@click="removeOne(c.id)"
>
</button>
</span>
</div>
<div v-else class="mb-3 text-xs text-ink-3">暂无租户关联此代理</div>
<div
v-if="rebinding.length"
class="mb-3 flex items-start gap-2 rounded-lg border border-warn/30 bg-warn/10 px-3 py-2.5 text-xs leading-relaxed"
>
<svg
class="mt-0.5 h-[14px] w-[14px] flex-none text-warn"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
>
<path d="M10.3 3.9 1.8 18a2 2 0 0 0 1.7 3h17a2 2 0 0 0 1.7-3L13.7 3.9a2 2 0 0 0-3.4 0z" />
<path d="M12 9v4M12 17h.01" />
</svg>
<span>
<template v-for="(c, i) in rebinding" :key="c.id">
<template v-if="i > 0"></template>
<b>{{ c.alias }}</b>
<span v-if="c.proxyName" class="text-ink-3">现挂 {{ c.proxyName }}</span>
</template>
已关联其他代理,保存后将改挂到本代理
</span>
</div>
<div class="mt-1 flex items-center gap-2">
<NButton size="small" type="primary" :loading="saving" @click="save">保存</NButton>
<NButton size="small" quaternary @click="emit('update:show', false)">取消</NButton>
</div>
</NModal>
</template>
+106 -1
View File
@@ -1,9 +1,10 @@
<script setup lang="ts"> <script setup lang="ts">
import { NButton, NSpin } from 'naive-ui' import { NButton, NSpin } from 'naive-ui'
import { onMounted, ref } from 'vue' import { computed, onMounted, onUnmounted, ref } from 'vue'
import { getAbout } from '@/api/settings' import { getAbout } from '@/api/settings'
import AppLogo from '@/components/AppLogo.vue' import AppLogo from '@/components/AppLogo.vue'
import { fmtBytes, fmtTime } from '@/composables/useFormat'
import { useParticles } from '@/composables/useParticles' import { useParticles } from '@/composables/useParticles'
import { useAppStore } from '@/stores/app' import { useAppStore } from '@/stores/app'
import type { AboutInfo } from '@/types/api' import type { AboutInfo } from '@/types/api'
@@ -20,15 +21,56 @@ const loading = ref(true)
const pcanvas = ref<HTMLCanvasElement | null>(null) const pcanvas = ref<HTMLCanvasElement | null>(null)
useParticles(pcanvas, { count: 26 }) useParticles(pcanvas, { count: 26 })
// 运行时长随查看自增:记录拉取时刻,30s 粒度刷新本地流逝时间
const loadedAt = ref(0)
const nowTick = ref(0)
let upTimer: ReturnType<typeof setInterval> | null = null
onMounted(async () => { onMounted(async () => {
try { try {
info.value = await getAbout() info.value = await getAbout()
loadedAt.value = nowTick.value = Date.now()
upTimer = setInterval(() => (nowTick.value = Date.now()), 30_000)
} catch { } catch {
/* 构建信息加载失败不阻塞页面,chips 显示占位 */ /* 构建信息加载失败不阻塞页面,chips 显示占位 */
} finally { } finally {
loading.value = false loading.value = false
} }
}) })
onUnmounted(() => {
if (upTimer) clearInterval(upTimer)
})
/** 运行时长分段:天(为 0 时省略)/ 小时 / 分 */
const uptimeParts = computed(() => {
const base = info.value?.uptimeSeconds
if (base === undefined) return []
const sec = base + Math.max(0, (nowTick.value - loadedAt.value) / 1000)
const d = Math.floor(sec / 86400)
const h = Math.floor((sec % 86400) / 3600)
const parts: { v: number; u: string }[] = []
if (d > 0) parts.push({ v: d, u: '天' })
if (d > 0 || h > 0) parts.push({ v: h, u: '小时' })
parts.push({ v: Math.floor((sec % 3600) / 60), u: '分' })
return parts
})
const DB_LABEL: Record<string, string> = { sqlite: 'SQLite', mysql: 'MySQL', postgres: 'PostgreSQL' }
/** 四格资源指标:值与单位拆开渲染,sub 为口径说明 */
const statCells = computed(() => {
const r = info.value?.resources
if (!r) return []
const heap = fmtBytes(r.memHeapBytes).split(' ')
const store = r.dbBytes >= 0 ? fmtBytes(r.dbBytes).split(' ') : ['—', '']
const db = DB_LABEL[r.dbEngine] ?? r.dbEngine
return [
{ label: 'CPU 均值', value: String(r.cpuAvgPercent), unit: '%', sub: `${r.numCpu} 核 · 占单核百分比` },
{ label: '内存(堆)', value: heap[0], unit: heap[1], sub: `向系统申请 ${fmtBytes(r.memSysBytes)}` },
{ label: '存储占用', value: store[0], unit: store[1], sub: r.dbBytes >= 0 ? `${db} 含 WAL 日志` : `${db} 外部数据库,不可度量` },
{ label: 'Goroutines', value: String(r.goroutines), unit: '', sub: '运行时并发任务数' },
]
})
function fmtBuild(t: string) { function fmtBuild(t: string) {
return t ? t.replace('T', ' ').replace('Z', ' UTC') : '—' return t ? t.replace('T', ' ').replace('Z', ' UTC') : '—'
@@ -69,6 +111,40 @@ function openRepo() {
</div> </div>
</div> </div>
<!-- 运行状态:运行时长随查看自增,资源指标为进程自启动累计口径 -->
<div v-if="info?.resources" class="panel">
<div
class="flex items-center justify-between gap-3 border-b border-line-soft px-5 py-3.5 max-md:flex-col max-md:items-start max-md:gap-1"
>
<div class="flex items-center gap-2">
<span class="live-dot"></span>
<span class="text-[13px] font-semibold">运行状态</span>
</div>
<span class="text-xs text-ink-3">
{{ fmtTime(info.startedAt) }} 启动 · 指标为进程自启动累计口径
</span>
</div>
<div class="px-5 pt-[22px] pb-5">
<div class="text-xs font-medium text-ink-2">运行时间</div>
<div class="mt-1.5 text-[38px] leading-[1.1] font-semibold tracking-[-0.6px]">
<template v-for="p in uptimeParts" :key="p.u"
>{{ p.v }}<span class="uptime-unit">{{ p.u }}</span></template
>
</div>
</div>
<div class="mx-5 h-px bg-line-soft"></div>
<div class="grid grid-cols-4 max-md:grid-cols-2">
<div v-for="c in statCells" :key="c.label" class="statcell flex flex-col gap-[5px] px-5 pt-4 pb-[18px]">
<div class="text-xs font-medium text-ink-2">{{ c.label }}</div>
<div class="text-[26px] leading-[1.15] font-semibold tracking-[-0.3px]">
<span>{{ c.value }}</span
><span v-if="c.unit" class="ml-0.5 text-sm font-medium text-ink-2">{{ c.unit }}</span>
</div>
<div class="text-[11.5px] text-ink-3">{{ c.sub }}</div>
</div>
</div>
</div>
<!-- GitHub 仓库 --> <!-- GitHub 仓库 -->
<div class="panel flex items-center gap-3.5 px-5 py-4"> <div class="panel flex items-center gap-3.5 px-5 py-4">
<span class="flex h-10 w-10 flex-none items-center justify-center rounded-[9px] bg-wash"> <span class="flex h-10 w-10 flex-none items-center justify-center rounded-[9px] bg-wash">
@@ -88,6 +164,35 @@ function openRepo() {
</template> </template>
<style scoped> <style scoped>
.live-dot {
width: 7px;
height: 7px;
border-radius: 50%;
background: var(--color-ok);
box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-ok) 18%, transparent);
}
.uptime-unit {
margin: 0 8px 0 3px;
font-size: 16px;
font-weight: 500;
letter-spacing: 0;
color: var(--color-ink-2);
}
.uptime-unit:last-of-type {
margin-right: 0;
}
/* 四格分栏:桌面竖线分隔;窄屏 2 列换行时第二行改上边框接续 */
.statcell + .statcell {
border-left: 1px solid var(--color-line-soft);
}
@media (width < 768px) {
.statcell:nth-child(3) {
border-left: none;
}
.statcell:nth-child(n + 3) {
border-top: 1px solid var(--color-line-soft);
}
}
.chip { .chip {
display: inline-flex; display: inline-flex;
align-items: center; align-items: center;
-1
View File
@@ -222,7 +222,6 @@ const columns: DataTableColumns<AuditEvent> = [
:loading="loading" :loading="loading"
:pagination="pagination" :pagination="pagination"
:scroll-x="820" :scroll-x="820"
:max-height="480"
:row-props="rowProps" :row-props="rowProps"
/> />
<FootNote> <FootNote>
-1
View File
@@ -222,7 +222,6 @@ const columns = computed(() => (withAvail.value ? [...baseColumns, ...availColum
:loading="limits.loading.value" :loading="limits.loading.value"
:pagination="pagination" :pagination="pagination"
:scroll-x="withAvail ? 660 : 380" :scroll-x="withAvail ? 660 : 380"
:max-height="440"
:row-key="(r: LimitItem) => r.name + (r.availabilityDomain ?? '')" :row-key="(r: LimitItem) => r.name + (r.availabilityDomain ?? '')"
/> />
<FootNote> <FootNote>
+28 -27
View File
@@ -878,32 +878,6 @@ export interface LogEventPage {
total: number total: number
} }
/** 回传事件告警规则;条件间 AND,空条件视为任意 */
export interface AlertRule {
id: number
name: string
enabled: boolean
/** 0=全部租户 */
ociConfigId: number
/** 逗号分隔事件短名(如 TerminateInstance),空=全部 */
eventTypes: string
/** 逗号分隔 IP/CIDR,空=任意 */
sourceIps: string
/** in:命中列表告警;notin:不在列表才告警(白名单) */
sourceIpMode: 'in' | 'notin'
/** 资源名子串,空=任意 */
resourceMatch: string
/** 触发阈值,默认 1(即时) */
threshold: number
/** 聚合窗口分钟,threshold>1 时必填 */
windowMinutes: number
createdAt: string
updatedAt: string
}
/** 创建/更新告警规则请求体 */
export type AlertRuleBody = Omit<AlertRule, 'id' | 'createdAt' | 'updatedAt'>
/** 每租户回传回调地址;path 需以面板公网域名拼接完整 URL */ /** 每租户回传回调地址;path 需以面板公网域名拼接完整 URL */
export interface LogWebhookInfo { export interface LogWebhookInfo {
path: string path: string
@@ -946,6 +920,8 @@ export interface AiKey {
name: string name: string
tail: string tail: string
group: string group: string
/** 模型白名单;null/空 = 不限,非空时网关仅放行列表内模型 */
models: string[] | null
enabled: boolean enabled: boolean
lastUsedAt: string | null lastUsedAt: string | null
/** 内容日志开启截止时间;null = 永关(默认,红线),开启必须限时到期自动停写 */ /** 内容日志开启截止时间;null = 永关(默认,红线),开启必须限时到期自动停写 */
@@ -991,6 +967,13 @@ export interface AiModelCacheItem {
syncedAt: string syncedAt: string
} }
/** 模型黑名单条目:拉黑即全渠道剔除,同步 / 探测不再入库 */
export interface AiModelBlacklistItem {
id: number
name: string
createdAt: string
}
/** 调用日志:仅元数据与 token 用量 */ /** 调用日志:仅元数据与 token 用量 */
export interface AiCallLog { export interface AiCallLog {
id: number id: number
@@ -1032,10 +1015,28 @@ export interface AiContentLog {
} }
// ---- 关于 ---- // ---- 关于 ----
/** GET /about:构建与运行环境信息 */ /** 进程资源占用快照,指标为自启动累计口径 */
export interface AboutResources {
/** CPU 自启动均值,占单核百分比(多核并行可超 100) */
cpuAvgPercent: number
numCpu: number
goroutines: number
/** Go 堆在用字节数 */
memHeapBytes: number
/** 向系统申请的总字节数 */
memSysBytes: number
dbEngine: string
/** 数据库磁盘占用;-1 表示外部数据库不可度量 */
dbBytes: number
}
/** GET /about:构建与运行环境信息;运行时字段旧版后端可能缺失 */
export interface AboutInfo { export interface AboutInfo {
version: string version: string
buildTime: string buildTime: string
goVersion: string goVersion: string
platform: string platform: string
startedAt?: string
uptimeSeconds?: number
resources?: AboutResources
} }
+109 -7
View File
@@ -1,18 +1,28 @@
<script setup lang="ts"> <script setup lang="ts">
import { NButton } from 'naive-ui' import { NButton, useDialog } from 'naive-ui'
import { computed, ref } from 'vue' import { computed, ref } from 'vue'
import { listAiChannels, listAiKeys, listAiModels } from '@/api/aigateway' import {
addAiBlacklist,
listAiBlacklist,
listAiChannels,
listAiKeys,
listAiModels,
removeAiBlacklist,
} from '@/api/aigateway'
import AiChannelPanel from '@/components/ai/AiChannelPanel.vue' import AiChannelPanel from '@/components/ai/AiChannelPanel.vue'
import AiKeyPanel from '@/components/ai/AiKeyPanel.vue' import AiKeyPanel from '@/components/ai/AiKeyPanel.vue'
import { useAsync } from '@/composables/useAsync' import { useAsync } from '@/composables/useAsync'
import { useToast } from '@/composables/useToast' import { useToast } from '@/composables/useToast'
import type { AiModelBlacklistItem } from '@/types/api'
const message = useToast() const message = useToast()
const dialog = useDialog()
const keys = useAsync(listAiKeys) const keys = useAsync(listAiKeys)
const channels = useAsync(listAiChannels) const channels = useAsync(listAiChannels)
const models = useAsync(listAiModels) const models = useAsync(listAiModels)
const blacklist = useAsync(listAiBlacklist)
const baseUrl = `${window.location.origin}/ai/v1` const baseUrl = `${window.location.origin}/ai/v1`
@@ -21,6 +31,9 @@ const endpoints = [
{ method: 'POST', path: '/responses', note: 'OpenAI Responses · 无状态子集' }, { method: 'POST', path: '/responses', note: 'OpenAI Responses · 无状态子集' },
{ method: 'POST', path: '/messages', note: 'Claude · 流式/非流式' }, { method: 'POST', path: '/messages', note: 'Claude · 流式/非流式' },
{ method: 'POST', path: '/embeddings', note: 'OpenAI Embeddings · 向量化' }, { method: 'POST', path: '/embeddings', note: 'OpenAI Embeddings · 向量化' },
{ method: 'POST', path: '/audio/speech', note: '文本转语音 · xAI Voice' },
{ method: 'POST', path: '/rerank', note: '文档重排 · Cohere Rerank' },
{ method: 'POST', path: '/moderations', note: '内容审核 · OCI Guardrails' },
{ method: 'GET', path: '/models', note: '模型列表(按密钥分组过滤)' }, { method: 'GET', path: '/models', note: '模型列表(按密钥分组过滤)' },
] ]
@@ -43,9 +56,12 @@ const modelGroups = computed(() => {
.map(([vendor, ids]) => ({ vendor, label: VENDOR_LABEL[vendor] ?? vendor, ids: ids.sort() })) .map(([vendor, ids]) => ({ vendor, label: VENDOR_LABEL[vendor] ?? vendor, ids: ids.sort() }))
}) })
/** 手风琴:同时只展开一个厂商,配合展开区限高控制卡片总高度 */ /** 手风琴:同时只展开一个分组(厂商或黑名单),配合展开区限高控制卡片总高度 */
const expandedVendor = ref<string | null>(null) const expandedVendor = ref<string | null>(null)
/** 黑名单在手风琴中的分组 key(厂商 key 取自模型名前缀,不会与此冲突) */
const BLACKLIST_KEY = '__blacklist__'
function toggleVendor(vendor: string) { function toggleVendor(vendor: string) {
expandedVendor.value = expandedVendor.value === vendor ? null : vendor expandedVendor.value = expandedVendor.value === vendor ? null : vendor
} }
@@ -71,9 +87,43 @@ async function copyModel(id: string) {
} }
} }
function refreshModels() {
void models.run({ silent: true })
void blacklist.run({ silent: true })
}
function refreshChannels() { function refreshChannels() {
void channels.run({ silent: true }) void channels.run({ silent: true })
void models.run({ silent: true }) refreshModels()
}
/** 拉黑:删除全部渠道缓存中的该模型,后续同步 / 探测均过滤 */
function banModel(id: string) {
dialog.warning({
title: '加入模型黑名单',
content: `拉黑「${id}」?全部渠道立即剔除该模型,后续同步与探测不再收录。`,
positiveText: '拉黑',
negativeText: '取消',
onPositiveClick: async () => {
try {
await addAiBlacklist(id)
message.success(`已拉黑:${id}`)
} catch (e) {
message.error(e instanceof Error ? e.message : '操作失败')
}
refreshModels()
},
})
}
async function unbanModel(b: AiModelBlacklistItem) {
try {
await removeAiBlacklist(b.id)
message.success(`已移出黑名单:${b.name},重新同步渠道后恢复`)
} catch (e) {
message.error(e instanceof Error ? e.message : '操作失败')
}
refreshModels()
} }
</script> </script>
@@ -114,7 +164,7 @@ function refreshChannels() {
<div class="flex items-center justify-between border-b border-line-soft px-4.5 py-3"> <div class="flex items-center justify-between border-b border-line-soft px-4.5 py-3">
<div> <div>
<div class="text-sm font-semibold">可用模型</div> <div class="text-sm font-semibold">可用模型</div>
<div class="mt-0.5 text-xs text-ink-3">按厂商分组;点击厂商展开,点击模型名复制</div> <div class="mt-0.5 text-xs text-ink-3">按厂商分组;点击厂商展开,点击模型名复制, 加入黑名单</div>
</div> </div>
<span class="text-xs text-ink-3">{{ models.data.value?.length ?? '…' }} </span> <span class="text-xs text-ink-3">{{ models.data.value?.length ?? '…' }} </span>
</div> </div>
@@ -144,16 +194,67 @@ function refreshChannels() {
v-if="expandedVendor === g.vendor" v-if="expandedVendor === g.vendor"
class="flex max-h-36 flex-wrap content-start gap-1.5 overflow-y-auto pb-2 pl-5" class="flex max-h-36 flex-wrap content-start gap-1.5 overflow-y-auto pb-2 pl-5"
> >
<button <span
v-for="id in g.ids" v-for="id in g.ids"
:key="id" :key="id"
class="mono inline-flex items-center overflow-hidden rounded-[5px] border border-line bg-card text-[11.5px]"
>
<button
type="button" type="button"
class="mono cursor-pointer rounded-[5px] border border-line bg-card px-2 py-0.5 text-[11.5px] hover:border-accent hover:text-accent" class="cursor-pointer py-0.5 pr-1 pl-2 hover:text-accent"
:title="`复制 ${id}`" :title="`复制 ${id}`"
@click="copyModel(id)" @click="copyModel(id)"
> >
{{ id }} {{ id }}
</button> </button>
<button
type="button"
class="cursor-pointer self-stretch pr-1.5 pl-0.5 text-ink-3 hover:text-err"
:title="`加入黑名单:${id}`"
@click="banModel(id)"
>
<svg
class="h-2.5 w-2.5"
viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.4"
stroke-linecap="round" stroke-linejoin="round"
>
<path d="M18 6 6 18M6 6l12 12" />
</svg>
</button>
</span>
</div>
</div>
<div v-if="blacklist.data.value?.length" class="border-b border-line-soft py-1 last:border-b-0">
<button
type="button"
class="flex w-full cursor-pointer items-center gap-2 py-1.5 text-left"
@click="toggleVendor(BLACKLIST_KEY)"
>
<svg
class="h-3 w-3 flex-none text-ink-3 transition-transform"
:class="expandedVendor === BLACKLIST_KEY ? 'rotate-90' : ''"
viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.2"
stroke-linecap="round" stroke-linejoin="round"
>
<path d="m9 18 6-6-6-6" />
</svg>
<span class="text-[13px] font-medium">模型黑名单</span>
<span class="text-xs text-ink-3">{{ blacklist.data.value.length }} </span>
</button>
<div v-if="expandedVendor === BLACKLIST_KEY" class="pb-2 pl-5">
<div class="mb-1.5 text-xs text-ink-3">同步与探测均过滤;点击移出,重新同步渠道后恢复入池</div>
<div class="flex max-h-36 flex-wrap content-start gap-1.5 overflow-y-auto">
<button
v-for="b in blacklist.data.value"
:key="b.id"
type="button"
class="mono cursor-pointer rounded-[5px] border border-err/30 bg-err/5 px-2 py-0.5 text-[11.5px] text-ink-3 line-through hover:border-err hover:text-err"
:title="`移出黑名单:${b.name}`"
@click="unbanModel(b)"
>
{{ b.name }}
</button>
</div>
</div> </div>
</div> </div>
<div v-if="models.data.value && !models.data.value.length" class="py-2 text-xs text-ink-3"> <div v-if="models.data.value && !models.data.value.length" class="py-2 text-xs text-ink-3">
@@ -170,6 +271,7 @@ function refreshChannels() {
:keys="keys.data.value ?? []" :keys="keys.data.value ?? []"
:loading="keys.loading.value" :loading="keys.loading.value"
:groups="groups" :groups="groups"
:models="models.data.value ?? []"
@changed="keys.run({ silent: true })" @changed="keys.run({ silent: true })"
/> />
+4 -3
View File
@@ -163,7 +163,8 @@ const currencySymbol = computed(() => {
{{ ov?.tenants.alive ?? 0 }}/{{ ov?.tenants.total ?? 0 }} 存活 {{ ov?.tenants.alive ?? 0 }}/{{ ov?.tenants.total ?? 0 }} 存活
</div> </div>
</div> </div>
<div class="px-4.5 py-1.5"> <!-- 限高内部滚动:租户多时不撑高整行,底部露半行暗示可滚 -->
<div class="max-h-90 overflow-y-auto px-4.5 py-1.5">
<div <div
v-for="c in configs.data.value ?? []" v-for="c in configs.data.value ?? []"
:key="c.id" :key="c.id"
@@ -188,7 +189,8 @@ const currencySymbol = computed(() => {
</div> </div>
<div class="w-18 flex-none text-right text-xs text-ink-3">{{ fmtRelative(c.lastVerifiedAt) }}</div> <div class="w-18 flex-none text-right text-xs text-ink-3">{{ fmtRelative(c.lastVerifiedAt) }}</div>
</div> </div>
<div class="py-2.5 text-center"> </div>
<div class="border-t border-line-soft py-2.5 text-center">
<RouterLink <RouterLink
class="text-[13px] font-medium text-accent hover:text-accent-hover" class="text-[13px] font-medium text-accent hover:text-accent-hover"
:to="{ name: 'tenants' }" :to="{ name: 'tenants' }"
@@ -197,7 +199,6 @@ const currencySymbol = computed(() => {
</div> </div>
</div> </div>
</div> </div>
</div>
<!-- 最近任务执行 --> <!-- 最近任务执行 -->
<div class="panel"> <div class="panel">
+9 -2
View File
@@ -140,8 +140,15 @@ async function remove() {
<template #trigger> <template #trigger>
<NButton size="small" type="error" ghost>删除租户</NButton> <NButton size="small" type="error" ghost>删除租户</NButton>
</template> </template>
删除{{ config.data.value.alias }}将清理本面板中的关联任务快照回传事件与 Webhook <div class="max-w-80 text-[13px] leading-relaxed">
密钥告警及 AI 渠道数据OCI 云端资源不会被删除云端日志回传链路请先在其他页销毁 <div class="font-medium">删除{{ config.data.value.alias }}</div>
<div class="mt-1 text-xs text-ink-3">
将清理面板内关联数据后台任务测活 / 成本快照回传事件Webhook 密钥与 AI 渠道
</div>
<div class="mt-0.5 text-xs text-ink-3">
OCI 云端资源不受影响云端日志回传链路请先在其他页销毁
</div>
</div>
</NPopconfirm> </NPopconfirm>
</div> </div>
+34 -3
View File
@@ -1,6 +1,6 @@
<script setup lang="ts"> <script setup lang="ts">
import { NButton, NDataTable, NInput, NInputGroup, NInputGroupLabel, NPopconfirm, NPopover, NSelect, NTooltip, type DataTableColumns } from 'naive-ui' import { NButton, NDataTable, NInput, NInputGroup, NInputGroupLabel, NPopconfirm, NPopover, NSelect, NTooltip, type DataTableColumns } from 'naive-ui'
import { computed, h, ref, type VNodeChild } from 'vue' import { computed, h, reactive, ref, watch, type VNodeChild } from 'vue'
import { RouterLink, useRouter } from 'vue-router' import { RouterLink, useRouter } from 'vue-router'
import { listAiChannels } from '@/api/aigateway' import { listAiChannels } from '@/api/aigateway'
@@ -63,6 +63,25 @@ const filtered = computed(() => {
) )
}) })
/** 客户端分页:字面量对象会在重渲染时被重建导致状态丢失,须用 reactive 受控 */
const pagination = reactive({
page: 1,
pageSize: 10,
showSizePicker: true,
pageSizes: [10, 20, 50, 100],
onUpdatePage: (p: number) => {
pagination.page = p
},
onUpdatePageSize: (ps: number) => {
pagination.pageSize = ps
pagination.page = 1
},
})
/** 搜索或分组过滤变化后回第 1 页,避免停留在越界页码 */
watch([keyword, groupFilter], () => {
pagination.page = 1
})
/** 任务是否作用于该租户:抢机看目标租户;AI 探测看号池渠道(仅入池租户); /** 任务是否作用于该租户:抢机看目标租户;AI 探测看号池渠道(仅入池租户);
* 测活 / 成本看范围(空 = 全部租户) */ * 测活 / 成本看范围(空 = 全部租户) */
function taskTouchesCfg(task: Task, cfgId: number): boolean { function taskTouchesCfg(task: Task, cfgId: number): boolean {
@@ -222,7 +241,19 @@ function renderActions(row: OciConfigSummary): VNodeChild {
trigger: () => trigger: () =>
h(NButton, { size: 'tiny', quaternary: true, type: 'error' }, { default: () => '删除' }), h(NButton, { size: 'tiny', quaternary: true, type: 'error' }, { default: () => '删除' }),
default: () => default: () =>
`删除「${row.alias}」?将清理本面板中的关联任务、快照、回传事件与 Webhook 密钥、告警及 AI 渠道数据;OCI 云端资源不会被删除(云端日志回传链路请先在“其他”页销毁)。`, h('div', { class: 'max-w-80 text-[13px] leading-relaxed' }, [
h('div', { class: 'font-medium' }, `删除「${row.alias}」?`),
h(
'div',
{ class: 'mt-1 text-xs text-ink-3' },
'将清理面板内关联数据:后台任务、测活 / 成本快照、回传事件、Webhook 密钥与 AI 渠道。',
),
h(
'div',
{ class: 'mt-0.5 text-xs text-ink-3' },
'OCI 云端资源不受影响;云端日志回传链路请先在「其他」页销毁。',
),
]),
}, },
), ),
]) ])
@@ -320,7 +351,7 @@ const columns = computed<DataTableColumns<OciConfigSummary>>(() => [
:columns="columns" :columns="columns"
:data="filtered" :data="filtered"
:loading="configs.loading.value" :loading="configs.loading.value"
:pagination="{ pageSize: 10 }" :pagination="pagination"
:scroll-x="1200" :scroll-x="1200"
:row-key="(r: OciConfigSummary) => r.id" :row-key="(r: OciConfigSummary) => r.id"
/> />