Compare commits
7
Commits
v0.1.0
..
78cc2aab56
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
78cc2aab56 | ||
|
|
08fa529348 | ||
|
|
e2cdb99194 | ||
|
|
7f529bd991 | ||
|
|
aea00c2382 | ||
|
|
2ea5b73de2 | ||
|
|
94fbe62e4c |
+1
-1
@@ -1 +1 @@
|
||||
0.6.5
|
||||
0.6.6
|
||||
@@ -15,7 +15,7 @@ oci-portal-dash/
|
||||
├── App.vue NConfigProvider 注入 Naive 主题
|
||||
├── assets/ main.css:Tailwind @theme 设计 token(浅色)+ html.dark 暗色变量覆盖与全局基础样式
|
||||
├── 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 数据
|
||||
├── stores/ Pinia:auth(令牌持久化)、app(侧栏收缩、暗色主题:默认跟随系统 + localStorage 记忆,驱动 html.dark 与 Naive darkTheme)、scope(全局作用域:租户/区域/区间,localStorage 按租户记忆)
|
||||
├── router/ 路由与登录守卫
|
||||
|
||||
@@ -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)
|
||||
- [ ] 涉及颜色、圆角、间距时先看 [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`
|
||||
|
||||
## Quality Check
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
- 开启 `strict`;禁止 `any`,未知类型用 `unknown` 后收窄。
|
||||
- 对象形状优先 `interface`,联合/工具类型用 `type`;类型导入写 `import type`。
|
||||
- 与后端交互的 DTO 类型集中在 `types/`,字段与 `docs/API接口文档.md` 一一对应,不在组件里手写内联响应类型。
|
||||
- 与后端交互的 DTO 类型集中在 `types/`,字段与后端 swagger(`oci-portal/docs/`)一一对应,不在组件里手写内联响应类型。
|
||||
- 用 `const` 对象 + `as const` 代替 `enum`。
|
||||
|
||||
## Vue 组件
|
||||
|
||||
+13
-13
@@ -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.1 Requirement exploration `[required · repeatable]` (`prd.md`; complex tasks also need `design.md` + `implement.md`)
|
||||
- 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.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.
|
||||
|
||||
[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`.
|
||||
- `in_progress` implementation/check -> dispatch `trellis-implement` / `trellis-check`.
|
||||
- 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]
|
||||
|
||||
@@ -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.
|
||||
|
||||
[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:
|
||||
|
||||
@@ -361,7 +361,7 @@ Spawn the research sub-agent:
|
||||
- **Task description**: Research <specific question>
|
||||
- **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]
|
||||
|
||||
@@ -380,7 +380,7 @@ Brainstorm and research can interleave freely — pause to research a technical
|
||||
|
||||
#### 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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
[/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]
|
||||
|
||||
@@ -458,11 +458,11 @@ If `task.py start` errors with a session-identity message (no context key from h
|
||||
| `design.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) | ✅ |
|
||||
|
||||
[/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]`
|
||||
|
||||
[Claude Code, Cursor, OpenCode, CodeBuddy, Droid, Pi]
|
||||
[Claude Code, Cursor, OpenCode, CodeBuddy, Droid, Pi, Oh My Pi]
|
||||
|
||||
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
|
||||
- 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]
|
||||
|
||||
@@ -526,7 +526,7 @@ The platform prelude auto-handles the context load requirement:
|
||||
|
||||
#### 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:
|
||||
|
||||
@@ -540,7 +540,7 @@ The check agent's job:
|
||||
- Auto-fix issues it finds
|
||||
- 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]
|
||||
|
||||
|
||||
+71
-3
@@ -1,8 +1,76 @@
|
||||
# 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.6.0]
|
||||
|
||||
### Added
|
||||
|
||||
- AI 网关渠道表格新增「模型数量」列(与模型列表同口径:排除黑名单、随「过滤弃用」开关)
|
||||
- 渠道「模型列表」弹窗(替代原「同步模型」按钮,同步入口迁入弹窗):模型按能力分组展示(对话 / 向量 / 重排 / 语音),支持关键字过滤;每行可「测试」(通过即标记「验证模型」徽章并置渠道可用,后续探测优先使用)与「拉黑」(全局黑名单);弃用模型降灰标注,非对话模型不提供测试;操作按钮悬停行时着色,保持列表安静
|
||||
|
||||
## [0.5.1]
|
||||
|
||||
### Changed
|
||||
|
||||
- 设置 · 账号安全绑定入口:已绑定的登录方式按钮置禁用态并显示「已绑定」,解绑后自动恢复可点
|
||||
|
||||
### Fixed
|
||||
|
||||
- 修复禁用密码登录后登录页闪烁:登录方式加载完成前显示加载态,不再先渲染密码表单再切换,同时消除了闪烁窗口内误提交密码触发 403「密码登录已禁用」日志的问题
|
||||
- 系统日志「动作」列补齐 26 条缺失描述(退出登录、外部身份登录 / 绑定、修改登录凭据、AI 密钥 / 渠道 / 黑名单 / 网关设置、通知渠道 / 模板、代理导入 / 探测 / 关联租户等)
|
||||
|
||||
## [0.5.0]
|
||||
|
||||
### Added
|
||||
|
||||
- AI 网关「接入信息」新增 `POST /tts` 端点展示(文本转语音 · xAI 官方格式)
|
||||
- AI 网关「可用模型」新增「过滤弃用」开关:开启后已宣布弃用(即使未退役)的模型从模型列表与路由中排除,状态持久化,切换即时刷新列表
|
||||
|
||||
## [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
|
||||
|
||||
@@ -24,7 +92,7 @@
|
||||
- 租户详情「用户」「策略」等 Tab 切换域后内容不刷新
|
||||
- 实例详情区块加载中时禁用头部操作按钮,防误点
|
||||
|
||||
## [0.0.1] - 2026-07-09
|
||||
## [0.0.1]
|
||||
|
||||
首个版本:OCI Portal 前端。
|
||||
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "oci-portal-dash",
|
||||
"private": true,
|
||||
"version": "0.1.0",
|
||||
"version": "0.2.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
|
||||
+48
-2
@@ -1,5 +1,14 @@
|
||||
import { request } from './request'
|
||||
import type { AiCallLog, AiChannel, AiContentLog, AiKey, AiModel, AiModelCacheItem } from '@/types/api'
|
||||
import type {
|
||||
AiCallLog,
|
||||
AiChannel,
|
||||
AiContentLog,
|
||||
AiKey,
|
||||
AiModel,
|
||||
AiModelBlacklistItem,
|
||||
AiModelCacheItem,
|
||||
AiSettings,
|
||||
} from '@/types/api'
|
||||
|
||||
// ---- 网关密钥 ----
|
||||
|
||||
@@ -11,6 +20,8 @@ export interface CreateAiKeyRequest {
|
||||
name: string
|
||||
value?: string
|
||||
group?: string
|
||||
/** 模型白名单;缺省/空 = 不限 */
|
||||
models?: string[]
|
||||
}
|
||||
|
||||
/** 创建密钥;key 为明文,仅本次响应返回 */
|
||||
@@ -20,7 +31,7 @@ export function createAiKey(body: CreateAiKeyRequest): Promise<{ key: string; it
|
||||
|
||||
export function updateAiKey(
|
||||
id: number,
|
||||
body: { name?: string; enabled?: boolean; group?: string },
|
||||
body: { name?: string; enabled?: boolean; group?: string; models?: string[] },
|
||||
): Promise<void> {
|
||||
return request(`/ai-keys/${id}`, { method: 'PUT', body })
|
||||
}
|
||||
@@ -72,12 +83,47 @@ export function syncAiChannelModels(id: number): Promise<AiModelCacheItem[]> {
|
||||
}).then((r) => r.items)
|
||||
}
|
||||
|
||||
export function listAiChannelModels(id: number): Promise<AiModelCacheItem[]> {
|
||||
return request<{ items: AiModelCacheItem[] }>(`/ai-channels/${id}/models`).then((r) => r.items)
|
||||
}
|
||||
|
||||
/** 单模型 max_tokens=16 试调;通过即设为该渠道探测验证模型并按需置渠道可用 */
|
||||
export function testAiChannelModel(id: number, model: string): Promise<AiChannel> {
|
||||
return request(`/ai-channels/${id}/test-model`, { method: 'POST', body: { model } })
|
||||
}
|
||||
|
||||
// ---- 聚合模型与调用日志 ----
|
||||
|
||||
export function listAiModels(): Promise<AiModel[]> {
|
||||
return request<{ items: AiModel[] }>('/ai-models').then((r) => r.items)
|
||||
}
|
||||
|
||||
// ---- 网关全局设置 ----
|
||||
|
||||
export function getAiSettings(): Promise<AiSettings> {
|
||||
return request<AiSettings>('/ai-settings')
|
||||
}
|
||||
|
||||
export function updateAiSettings(body: AiSettings): Promise<AiSettings> {
|
||||
return request<AiSettings>('/ai-settings', { method: 'PUT', body })
|
||||
}
|
||||
|
||||
// ---- 模型黑名单 ----
|
||||
|
||||
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: {
|
||||
page: number
|
||||
size: number
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import { mockLogEvents, mockLogRelays, mockLogWebhooks } from './mock'
|
||||
import { mockOn, mocked, request } from './request'
|
||||
import type {
|
||||
AlertRule,
|
||||
AlertRuleBody,
|
||||
LogEventPage,
|
||||
LogRelayView,
|
||||
LogWebhookInfo,
|
||||
@@ -30,27 +28,6 @@ export function listLogEvents(params: LogEventParams): Promise<LogEventPage> {
|
||||
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> {
|
||||
if (mockOn) {
|
||||
const info = mockLogWebhooks.get(cfgId)
|
||||
|
||||
+3
-2
@@ -113,8 +113,9 @@ export const mockConfigs: OciConfig[] = [
|
||||
promotionStatus: 'EXPIRED',
|
||||
multiRegion: true,
|
||||
multiCompartment: true,
|
||||
proxyId: null,
|
||||
proxyName: '',
|
||||
// 与 mockProxies[0].usedBy = 1 呼应:主号经东京 socks5 出站
|
||||
proxyId: 1,
|
||||
proxyName: '东京 socks5',
|
||||
}),
|
||||
cfg({
|
||||
id: 2,
|
||||
|
||||
+17
-1
@@ -1,4 +1,4 @@
|
||||
import { mockProxies } from './mock'
|
||||
import { mockConfigs, mockProxies } from './mock'
|
||||
import { mockOn, mocked, request } from './request'
|
||||
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 } })
|
||||
}
|
||||
|
||||
/** 代理侧设置关联租户全集:选中即关联(含从其他代理改挂),未选中即解除 */
|
||||
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> {
|
||||
if (mockOn) {
|
||||
|
||||
@@ -181,6 +181,17 @@ export function getAbout(): Promise<AboutInfo> {
|
||||
buildTime: '2026-07-09T12:00Z',
|
||||
goVersion: 'go1.26.4',
|
||||
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')
|
||||
}
|
||||
|
||||
@@ -168,6 +168,19 @@ body {
|
||||
background: var(--color-wash);
|
||||
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)。
|
||||
message 经 teleport 渲染于 body,组件 scoped 样式不可达,故置于全局。 */
|
||||
|
||||
@@ -0,0 +1,201 @@
|
||||
<script setup lang="ts">
|
||||
import { NButton, NInput, NModal, useDialog } from 'naive-ui'
|
||||
import { computed, ref, watch } from 'vue'
|
||||
|
||||
import {
|
||||
addAiBlacklist,
|
||||
listAiChannelModels,
|
||||
syncAiChannelModels,
|
||||
testAiChannelModel,
|
||||
} from '@/api/aigateway'
|
||||
import { useToast } from '@/composables/useToast'
|
||||
import type { AiChannel, AiModelCacheItem } from '@/types/api'
|
||||
|
||||
const props = defineProps<{ show: boolean; channel: AiChannel | null }>()
|
||||
const emit = defineEmits<{ 'update:show': [boolean]; changed: [] }>()
|
||||
|
||||
const toast = useToast()
|
||||
const dialog = useDialog()
|
||||
|
||||
const rows = ref<AiModelCacheItem[]>([])
|
||||
const loading = ref(false)
|
||||
const syncing = ref(false)
|
||||
const testing = ref('')
|
||||
const filter = ref('')
|
||||
/** 本地镜像验证模型:测试通过即时高亮,不等父级刷新 */
|
||||
const probeModel = ref('')
|
||||
|
||||
const CAP_ORDER = ['CHAT', 'EMBEDDING', 'RERANK', 'TTS']
|
||||
const CAP_LABEL: Record<string, string> = { CHAT: '对话', EMBEDDING: '向量', RERANK: '重排', TTS: '语音' }
|
||||
|
||||
/** 按能力分组 + 关键字过滤;仅对话组提供「测试」入口 */
|
||||
const groups = computed(() => {
|
||||
const kw = filter.value.trim().toLowerCase()
|
||||
const buckets = new Map<string, AiModelCacheItem[]>()
|
||||
for (const r of rows.value) {
|
||||
if (kw && !r.name.toLowerCase().includes(kw)) continue
|
||||
const cap = r.capability || 'CHAT'
|
||||
buckets.set(cap, [...(buckets.get(cap) ?? []), r])
|
||||
}
|
||||
const order = [...CAP_ORDER, ...[...buckets.keys()].filter((c) => !CAP_ORDER.includes(c))]
|
||||
return order
|
||||
.filter((cap) => buckets.has(cap))
|
||||
.map((cap) => ({ cap, label: CAP_LABEL[cap] ?? cap, items: buckets.get(cap)! }))
|
||||
})
|
||||
|
||||
const shownCount = computed(() => groups.value.reduce((n, g) => n + g.items.length, 0))
|
||||
|
||||
watch(
|
||||
() => props.show,
|
||||
(show) => {
|
||||
if (show && props.channel) {
|
||||
probeModel.value = props.channel.probeModel
|
||||
filter.value = ''
|
||||
void reload()
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
async function reload() {
|
||||
if (!props.channel) return
|
||||
loading.value = true
|
||||
try {
|
||||
rows.value = await listAiChannelModels(props.channel.id)
|
||||
} catch (e) {
|
||||
toast.error(e instanceof Error ? e.message : '加载失败')
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function doSync() {
|
||||
if (!props.channel) return
|
||||
syncing.value = true
|
||||
try {
|
||||
rows.value = await syncAiChannelModels(props.channel.id)
|
||||
toast.success(`已同步 ${rows.value.length} 个模型`)
|
||||
emit('changed')
|
||||
} catch (e) {
|
||||
toast.error(e instanceof Error ? e.message : '同步失败')
|
||||
} finally {
|
||||
syncing.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function doTest(name: string) {
|
||||
if (!props.channel || testing.value) return
|
||||
testing.value = name
|
||||
try {
|
||||
const ch = await testAiChannelModel(props.channel.id, name)
|
||||
probeModel.value = ch.probeModel
|
||||
toast.success('测试通过', '已设为该渠道探测验证模型,后续探测优先使用')
|
||||
emit('changed')
|
||||
} catch (e) {
|
||||
toast.error(e instanceof Error ? e.message : '测试失败')
|
||||
} finally {
|
||||
testing.value = ''
|
||||
}
|
||||
}
|
||||
|
||||
function confirmBlacklist(name: string) {
|
||||
dialog.warning({
|
||||
title: '拉黑模型',
|
||||
content: `「${name}」将从全部渠道剔除,同步与探测不再入库;可在模型黑名单中移出后重新同步恢复。`,
|
||||
positiveText: '拉黑',
|
||||
negativeText: '取消',
|
||||
onPositiveClick: async () => {
|
||||
try {
|
||||
await addAiBlacklist(name)
|
||||
toast.success('已拉黑')
|
||||
void reload()
|
||||
emit('changed')
|
||||
} catch (e) {
|
||||
toast.error(e instanceof Error ? e.message : '拉黑失败')
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<NModal
|
||||
:show="show"
|
||||
preset="card"
|
||||
:style="{ width: '640px', maxWidth: 'calc(100vw - 24px)' }"
|
||||
@update:show="emit('update:show', $event)"
|
||||
>
|
||||
<template #header>
|
||||
<div>
|
||||
<div class="text-[15px] leading-tight font-semibold">模型列表</div>
|
||||
<div class="mono mt-1 text-xs font-normal text-ink-3">{{ channel?.name ?? '' }}</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<div class="flex items-center gap-2 pb-2">
|
||||
<NInput v-model:value="filter" size="small" placeholder="过滤模型名…" clearable class="min-w-0 flex-1" />
|
||||
<span class="flex-none text-xs whitespace-nowrap text-ink-3">
|
||||
{{ filter ? `${shownCount} / ${rows.length}` : `${rows.length} 个模型` }}
|
||||
</span>
|
||||
<NButton size="small" :loading="syncing" @click="doSync">同步模型</NButton>
|
||||
</div>
|
||||
|
||||
<div class="-mx-2 max-h-[58vh] overflow-y-auto">
|
||||
<div v-if="loading" class="py-10 text-center text-xs text-ink-3">加载中…</div>
|
||||
<template v-else>
|
||||
<template v-for="g in groups" :key="g.cap">
|
||||
<div class="px-3 pt-3 pb-1 text-[11.5px] font-semibold tracking-wide text-ink-3">
|
||||
{{ g.label }} <span class="font-normal">· {{ g.items.length }}</span>
|
||||
</div>
|
||||
<div
|
||||
v-for="r in g.items"
|
||||
:key="r.name"
|
||||
class="group flex items-center gap-2 rounded-lg px-3 py-[5px] hover:bg-row-hover"
|
||||
>
|
||||
<span
|
||||
class="mono min-w-0 truncate text-[13px]"
|
||||
:class="r.deprecatedAt ? 'text-ink-3' : ''"
|
||||
:title="r.modelOcid"
|
||||
>
|
||||
{{ r.name }}
|
||||
</span>
|
||||
<span
|
||||
v-if="r.name === probeModel"
|
||||
class="flex flex-none items-center gap-1 rounded-[5px] bg-info/15 px-1.5 py-px text-[10.5px] font-medium text-info"
|
||||
>
|
||||
<span class="h-[5px] w-[5px] rounded-full bg-info" />验证模型
|
||||
</span>
|
||||
<span v-if="r.deprecatedAt" class="flex-none text-[11px] text-warn">弃用</span>
|
||||
<span class="min-w-0 flex-1" />
|
||||
<button
|
||||
v-if="g.cap === 'CHAT'"
|
||||
type="button"
|
||||
class="flex-none cursor-pointer rounded-[5px] px-1.5 py-0.5 text-xs hover:bg-accent/10"
|
||||
:class="testing === r.name ? 'text-accent' : 'text-ink-3/70 group-hover:text-accent'"
|
||||
:disabled="!!testing"
|
||||
@click="doTest(r.name)"
|
||||
>
|
||||
{{ testing === r.name ? '测试中…' : '测试' }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="flex-none cursor-pointer rounded-[5px] px-1.5 py-0.5 text-xs text-ink-3/70 group-hover:text-err hover:bg-err/10"
|
||||
@click="confirmBlacklist(r.name)"
|
||||
>
|
||||
拉黑
|
||||
</button>
|
||||
</div>
|
||||
</template>
|
||||
<div v-if="!shownCount" class="py-10 text-center text-xs text-ink-3">
|
||||
{{ rows.length ? '无匹配模型' : '暂无模型缓存,点击右上「同步模型」拉取' }}
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
|
||||
<div class="mt-1 border-t border-line-soft pt-2.5 text-[11.5px] leading-relaxed text-ink-3">
|
||||
<span class="font-medium text-ink-2">测试</span>:发 max_tokens=16
|
||||
试调,通过即设为该渠道探测验证模型(后续探测优先使用)并置渠道可用 ·
|
||||
<span class="font-medium text-ink-2">拉黑</span>:全局生效,从全部渠道剔除 ·
|
||||
非对话模型不提供测试
|
||||
</div>
|
||||
</NModal>
|
||||
</template>
|
||||
@@ -2,8 +2,10 @@
|
||||
import { NButton, NDataTable, NInput, NSelect, NTooltip, useDialog, type DataTableColumns } from 'naive-ui'
|
||||
import { computed, h, reactive, ref } from 'vue'
|
||||
|
||||
import { createAiChannel, deleteAiChannel, probeAiChannel, syncAiChannelModels, updateAiChannel } from '@/api/aigateway'
|
||||
import { createAiChannel, deleteAiChannel, probeAiChannel, updateAiChannel } from '@/api/aigateway'
|
||||
import { listCachedRegions } from '@/api/configs'
|
||||
import AiChannelModelsModal from '@/components/ai/AiChannelModelsModal.vue'
|
||||
import GroupChips from '@/components/ai/GroupChips.vue'
|
||||
import AppInputNumber from '@/components/AppInputNumber.vue'
|
||||
import FormField from '@/components/FormField.vue'
|
||||
import FormModal from '@/components/FormModal.vue'
|
||||
@@ -15,9 +17,11 @@ import { useToast } from '@/composables/useToast'
|
||||
import { useScopeStore } from '@/stores/scope'
|
||||
import type { AiChannel, AiProbeStatus } from '@/types/api'
|
||||
|
||||
defineProps<{ channels: AiChannel[]; loading: boolean }>()
|
||||
const props = defineProps<{ channels: AiChannel[]; loading: boolean }>()
|
||||
const emit = defineEmits<{ changed: [] }>()
|
||||
|
||||
const groupHints = computed(() => [...new Set(props.channels.map((c) => c.group).filter(Boolean))])
|
||||
|
||||
const toast = useToast()
|
||||
const dialog = useDialog()
|
||||
const scope = useScopeStore()
|
||||
@@ -106,14 +110,13 @@ async function doProbe(id: number) {
|
||||
}
|
||||
}
|
||||
|
||||
async function doSync(id: number) {
|
||||
try {
|
||||
const models = await syncAiChannelModels(id)
|
||||
toast.success(`已同步 ${models.length} 个模型`)
|
||||
emit('changed')
|
||||
} catch (e) {
|
||||
toast.error(e instanceof Error ? e.message : '同步失败')
|
||||
}
|
||||
// ---- 模型列表弹窗 ----
|
||||
const showModels = ref(false)
|
||||
const modelsChannel = ref<AiChannel | null>(null)
|
||||
|
||||
function openModels(ch: AiChannel) {
|
||||
modelsChannel.value = ch
|
||||
showModels.value = true
|
||||
}
|
||||
|
||||
async function toggle(ch: AiChannel) {
|
||||
@@ -175,12 +178,16 @@ const columns = computed<DataTableColumns<AiChannel>>(() => [
|
||||
},
|
||||
{ title: '优先级', key: 'priority', width: 76, render: (r) => h('span', { class: 'mono text-[13px]' }, String(r.priority)) },
|
||||
{ title: '权重', key: 'weight', width: 66, render: (r) => h('span', { class: 'mono text-[13px]' }, String(r.weight)) },
|
||||
{
|
||||
title: '模型数量', key: 'modelCount', width: 86,
|
||||
render: (r) => h('span', { class: r.modelCount ? 'mono text-[13px]' : 'text-xs text-ink-3' }, String(r.modelCount ?? 0)),
|
||||
},
|
||||
{ title: '探测状态', key: 'probeStatus', width: 120, render: probeCell },
|
||||
{
|
||||
title: '操作', key: 'actions', width: 250,
|
||||
render: (r) => h('div', { class: 'flex items-center gap-0.5' }, [
|
||||
h(NButton, { size: 'tiny', quaternary: true, type: 'primary', loading: probing.value.has(r.id), onClick: () => doProbe(r.id) }, { default: () => '探测' }),
|
||||
h(NButton, { size: 'tiny', quaternary: true, type: 'primary', onClick: () => doSync(r.id) }, { default: () => '同步模型' }),
|
||||
h(NButton, { size: 'tiny', quaternary: true, type: 'primary', onClick: () => openModels(r) }, { default: () => '模型列表' }),
|
||||
h(NButton, { size: 'tiny', quaternary: true, onClick: () => toggle(r) }, { default: () => (r.enabled ? '停用' : '启用') }),
|
||||
h(NButton, { size: 'tiny', quaternary: true, type: 'primary', onClick: () => openEdit(r) }, { default: () => '编辑' }),
|
||||
h(NButton, { size: 'tiny', quaternary: true, type: 'error', onClick: () => confirmRemove(r) }, { default: () => '删除' }),
|
||||
@@ -202,10 +209,16 @@ const columns = computed<DataTableColumns<AiChannel>>(() => [
|
||||
</div>
|
||||
<NDataTable :columns="columns" :data="channels" :loading="loading" :bordered="false" size="small" />
|
||||
<div class="border-t border-line-soft bg-wash px-4.5 py-2.5 text-xs leading-relaxed text-ink-3">
|
||||
探测三步:列模型(服务可见性)→ 同步模型缓存 → max_tokens=1 试调(配额)· 探测成功自动复位熔断 ·
|
||||
探测三步:列模型(服务可见性)→ 同步模型缓存 → max_tokens=16 试调(配额)· 探测成功自动复位熔断 ·
|
||||
有渠道时系统自动维护「AI渠道探测」后台任务(每天 00:00 逐渠道探测,渠道清空自动暂停)
|
||||
</div>
|
||||
|
||||
<AiChannelModelsModal
|
||||
v-model:show="showModels"
|
||||
:channel="modelsChannel"
|
||||
@changed="emit('changed')"
|
||||
/>
|
||||
|
||||
<FormModal
|
||||
v-model:show="showForm"
|
||||
:title="editing ? '编辑渠道' : '添加渠道'"
|
||||
@@ -233,6 +246,7 @@ const columns = computed<DataTableColumns<AiChannel>>(() => [
|
||||
<div class="grid grid-cols-3 gap-3">
|
||||
<FormField label="分组" hint="分组供密钥定向路由;留空归入默认分组">
|
||||
<NInput v-model:value="form.group" placeholder="默认" />
|
||||
<GroupChips :groups="groupHints" @pick="form.group = $event" />
|
||||
</FormField>
|
||||
<FormField label="优先级" hint="数字小优先">
|
||||
<AppInputNumber v-model:value="form.priority" :min="1" />
|
||||
|
||||
@@ -1,17 +1,18 @@
|
||||
<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 { createAiKey, deleteAiKey, updateAiKey, updateAiKeyContentLog } from '@/api/aigateway'
|
||||
import GroupChips from '@/components/ai/GroupChips.vue'
|
||||
import AppInputNumber from '@/components/AppInputNumber.vue'
|
||||
import FormField from '@/components/FormField.vue'
|
||||
import FormModal from '@/components/FormModal.vue'
|
||||
import StatusBadge from '@/components/StatusBadge.vue'
|
||||
import { fmtTime } from '@/composables/useFormat'
|
||||
import type { AiKey } from '@/types/api'
|
||||
import type { AiKey, AiModel } from '@/types/api'
|
||||
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 message = useToast()
|
||||
@@ -21,20 +22,23 @@ const dialog = useDialog()
|
||||
const showForm = ref(false)
|
||||
const editing = ref<AiKey | null>(null)
|
||||
const submitting = ref(false)
|
||||
const form = reactive({ name: '', value: '', group: '' })
|
||||
const form = reactive({ name: '', value: '', group: '', models: [] as string[] })
|
||||
|
||||
function openCreate() {
|
||||
editing.value = null
|
||||
Object.assign(form, { name: '', value: '', group: '' })
|
||||
Object.assign(form, { name: '', value: '', group: '', models: [] })
|
||||
showForm.value = true
|
||||
}
|
||||
|
||||
function openEdit(key: AiKey) {
|
||||
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
|
||||
}
|
||||
|
||||
/** 限制模型下拉选项:聚合模型列表;tag 模式允许手输未同步模型 */
|
||||
const modelOptions = computed(() => props.models.map((m) => ({ label: m.id, value: m.id })))
|
||||
|
||||
// 创建成功后明文只在此弹窗展示一次
|
||||
const createdKey = ref('')
|
||||
const showCreated = ref(false)
|
||||
@@ -43,10 +47,13 @@ async function submit() {
|
||||
submitting.value = true
|
||||
try {
|
||||
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('已更新密钥')
|
||||
} 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
|
||||
showCreated.value = true
|
||||
}
|
||||
@@ -118,6 +125,21 @@ function confirmRemove(key: AiKey) {
|
||||
|
||||
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>>(() => [
|
||||
{ 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}`) },
|
||||
@@ -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: 'text-xs text-ink-3' }, '不限'),
|
||||
},
|
||||
{ title: '模型', key: 'models', width: 90, render: modelsCell },
|
||||
{
|
||||
title: '状态', key: 'enabled', width: 100,
|
||||
render: (r) => h(StatusBadge, r.enabled ? { kind: 'run', label: '启用' } : { kind: 'stop', label: '已禁用' }),
|
||||
@@ -170,18 +193,21 @@ const columns = computed<DataTableColumns<AiKey>>(() => [
|
||||
</FormField>
|
||||
<FormField label="渠道分组" hint="选择分组后,该密钥的调用只在该分组的渠道内负载均衡;留空不限分组">
|
||||
<NInput v-model:value="form.group" placeholder="留空 = 不限(全部渠道)" />
|
||||
<div v-if="groupHints.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 groupHints"
|
||||
: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="form.group = g"
|
||||
<GroupChips :groups="groupHints" @pick="form.group = $event" />
|
||||
</FormField>
|
||||
<FormField
|
||||
label="限制模型"
|
||||
hint="非空时该密钥仅能调用所选模型,/v1/models 同步只返回交集;可手输未同步的模型名;留空不限"
|
||||
>
|
||||
{{ g }}
|
||||
</button>
|
||||
</div>
|
||||
<NSelect
|
||||
v-model:value="form.models"
|
||||
:options="modelOptions"
|
||||
multiple
|
||||
filterable
|
||||
clearable
|
||||
tag
|
||||
placeholder="留空 = 不限(全部模型)"
|
||||
/>
|
||||
</FormField>
|
||||
<FormField v-if="!editing" label="自定义密钥值" hint="至少 8 位;仅测试场景建议自定义">
|
||||
<NInput v-model:value="form.value" placeholder="留空自动生成 sk- 开头随机密钥(推荐)" />
|
||||
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
@@ -1,11 +1,10 @@
|
||||
<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 { useRouter } from 'vue-router'
|
||||
|
||||
import { listConfigs } from '@/api/configs'
|
||||
import { listLogEvents } from '@/api/logevents'
|
||||
import AlertRuleModal from '@/components/logs/AlertRuleModal.vue'
|
||||
import DetailFieldList, { type DetailRow } from '@/components/DetailFieldList.vue'
|
||||
import DetailHero, { type HeroChip } from '@/components/DetailHero.vue'
|
||||
import FootNote from '@/components/FootNote.vue'
|
||||
@@ -41,7 +40,6 @@ const cfgById = computed(() => {
|
||||
|
||||
const detail = ref<LogEvent | null>(null)
|
||||
const showDetail = ref(false)
|
||||
const showRules = ref(false)
|
||||
|
||||
/** 受控远程分页:字面量对象会在重渲染时被重建导致状态丢失 */
|
||||
const pagination = reactive({
|
||||
@@ -223,7 +221,6 @@ useAutoRefresh(() => load(true))
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<NButton size="small" @click="showRules = true">告警规则</NButton>
|
||||
<TenantPicker
|
||||
v-model:value="cfgFilter"
|
||||
size="small"
|
||||
@@ -251,12 +248,9 @@ useAutoRefresh(() => load(true))
|
||||
在租户详情「其他」tab 一键创建链路后,实例生命周期(Launch/Terminate/InstanceAction)、
|
||||
用户与凭据(Create/Delete/UpdateUser、Create/DeleteApiKey、UpdateUserCapabilities)、
|
||||
区域订阅与策略变更等关键审计事件将自动回传;消息按 MessageId 幂等去重,保留 90
|
||||
天、总量超 2 万条时删除最旧,关键事件另经「通知管理 → 云端事件」推送告警;
|
||||
更细粒度的条件告警(事件/来源 IP/资源/频率)在「告警规则」中配置
|
||||
天、总量超 2 万条时删除最旧,关键事件另经「通知管理 → 云端事件」推送告警
|
||||
</FootNote>
|
||||
|
||||
<AlertRuleModal v-model:show="showRules" />
|
||||
|
||||
<NModal v-model:show="showDetail" preset="card" closable :style="{ width: '720px', maxWidth: 'calc(100vw - 24px)' }">
|
||||
<template #header>
|
||||
<DetailHero
|
||||
|
||||
@@ -185,7 +185,6 @@ useAutoRefresh(() => load(true))
|
||||
:loading="loading"
|
||||
:pagination="pagination"
|
||||
:scroll-x="880"
|
||||
:max-height="480"
|
||||
:row-key="(r: SystemLog) => r.id"
|
||||
:row-props="rowProps"
|
||||
/>
|
||||
|
||||
@@ -22,6 +22,8 @@ import {
|
||||
import AppInputNumber from '@/components/AppInputNumber.vue'
|
||||
import FootNote from '@/components/FootNote.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 type { ProxyImportResult, ProxyInfo } from '@/types/api'
|
||||
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>())
|
||||
|
||||
@@ -207,13 +218,15 @@ const columns: DataTableColumns<ProxyInfo> = [
|
||||
{
|
||||
title: '认证',
|
||||
key: 'username',
|
||||
width: 110,
|
||||
render: (row) =>
|
||||
h(
|
||||
'span',
|
||||
{ class: 'text-[12.5px] text-ink-2' },
|
||||
row.username ? `${row.username}${row.passwordSet ? ' / ●●●' : ''}` : row.passwordSet ? '●●●' : '无',
|
||||
),
|
||||
width: 76,
|
||||
render: (row) => {
|
||||
const has = !!row.username || row.passwordSet
|
||||
// 悬停「是」可见用户名(无用户名则提示仅密码)
|
||||
const title = has ? (row.username ? `用户名 ${row.username}` : '仅密码认证') : undefined
|
||||
return h('span', { title }, [
|
||||
h(StatusBadge, { kind: has ? 'run' : 'check', label: has ? '是' : '否', dot: false }),
|
||||
])
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '关联租户',
|
||||
@@ -225,7 +238,7 @@ const columns: DataTableColumns<ProxyInfo> = [
|
||||
{
|
||||
title: '操作',
|
||||
key: 'actions',
|
||||
width: 168,
|
||||
width: 236,
|
||||
render: (row) =>
|
||||
h('div', { class: 'flex items-center gap-1' }, [
|
||||
h(
|
||||
@@ -233,6 +246,7 @@ const columns: DataTableColumns<ProxyInfo> = [
|
||||
{ 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(
|
||||
NPopconfirm,
|
||||
@@ -261,6 +275,12 @@ const columns: DataTableColumns<ProxyInfo> = [
|
||||
支持 SOCKS5 / HTTP / HTTPS;密码 AES 加密存储、不回显明文;地区为经代理实测的出口位置(ip-api.com),创建后自动检测;被租户关联的代理不可删除,请先解除关联
|
||||
</FootNote>
|
||||
|
||||
<ProxyTenantsModal
|
||||
v-model:show="showTenants"
|
||||
:proxy="tenantsFor"
|
||||
@saved="void proxies.run({ silent: true })"
|
||||
/>
|
||||
|
||||
<NModal
|
||||
v-model:show="showForm"
|
||||
preset="card"
|
||||
|
||||
@@ -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>
|
||||
@@ -1,9 +1,10 @@
|
||||
<script setup lang="ts">
|
||||
import { NButton, NSpin } from 'naive-ui'
|
||||
import { onMounted, ref } from 'vue'
|
||||
import { computed, onMounted, onUnmounted, ref } from 'vue'
|
||||
|
||||
import { getAbout } from '@/api/settings'
|
||||
import AppLogo from '@/components/AppLogo.vue'
|
||||
import { fmtBytes, fmtTime } from '@/composables/useFormat'
|
||||
import { useParticles } from '@/composables/useParticles'
|
||||
import { useAppStore } from '@/stores/app'
|
||||
import type { AboutInfo } from '@/types/api'
|
||||
@@ -20,15 +21,56 @@ const loading = ref(true)
|
||||
const pcanvas = ref<HTMLCanvasElement | null>(null)
|
||||
useParticles(pcanvas, { count: 26 })
|
||||
|
||||
// 运行时长随查看自增:记录拉取时刻,30s 粒度刷新本地流逝时间
|
||||
const loadedAt = ref(0)
|
||||
const nowTick = ref(0)
|
||||
let upTimer: ReturnType<typeof setInterval> | null = null
|
||||
|
||||
onMounted(async () => {
|
||||
try {
|
||||
info.value = await getAbout()
|
||||
loadedAt.value = nowTick.value = Date.now()
|
||||
upTimer = setInterval(() => (nowTick.value = Date.now()), 30_000)
|
||||
} catch {
|
||||
/* 构建信息加载失败不阻塞页面,chips 显示占位 */
|
||||
} finally {
|
||||
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) {
|
||||
return t ? t.replace('T', ' ').replace('Z', ' UTC') : '—'
|
||||
@@ -69,6 +111,40 @@ function openRepo() {
|
||||
</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 仓库 -->
|
||||
<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">
|
||||
@@ -88,6 +164,35 @@ function openRepo() {
|
||||
</template>
|
||||
|
||||
<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 {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
|
||||
@@ -204,6 +204,11 @@ const bindableProviders = computed(() => {
|
||||
return out
|
||||
})
|
||||
|
||||
/** 已绑定的 provider 集合;绑定入口按钮据此禁用,解绑后自动恢复 */
|
||||
const boundProviders = computed(
|
||||
() => new Set((identities.data.value?.items ?? []).map((it) => it.provider)),
|
||||
)
|
||||
|
||||
async function bindProvider(provider: string) {
|
||||
binding.value = provider
|
||||
try {
|
||||
@@ -507,9 +512,10 @@ async function deleteProvider(p: ProviderType) {
|
||||
:key="p"
|
||||
size="small"
|
||||
:loading="binding === p"
|
||||
:disabled="boundProviders.has(p)"
|
||||
@click="bindProvider(p)"
|
||||
>
|
||||
绑定 {{ displayNameOf(p) }}
|
||||
{{ boundProviders.has(p) ? '已绑定' : '绑定' }} {{ displayNameOf(p) }}
|
||||
</NButton>
|
||||
<span class="text-xs text-ink-3">将跳转到对应平台授权</span>
|
||||
</div>
|
||||
|
||||
@@ -222,7 +222,6 @@ const columns: DataTableColumns<AuditEvent> = [
|
||||
:loading="loading"
|
||||
:pagination="pagination"
|
||||
:scroll-x="820"
|
||||
:max-height="480"
|
||||
:row-props="rowProps"
|
||||
/>
|
||||
<FootNote>
|
||||
|
||||
@@ -222,7 +222,6 @@ const columns = computed(() => (withAvail.value ? [...baseColumns, ...availColum
|
||||
:loading="limits.loading.value"
|
||||
:pagination="pagination"
|
||||
:scroll-x="withAvail ? 660 : 380"
|
||||
:max-height="440"
|
||||
:row-key="(r: LimitItem) => r.name + (r.availabilityDomain ?? '')"
|
||||
/>
|
||||
<FootNote>
|
||||
|
||||
@@ -4,6 +4,11 @@
|
||||
*/
|
||||
const exact: Record<string, string> = {
|
||||
'POST /api/v1/auth/login': '登录面板',
|
||||
'POST /api/v1/auth/logout': '退出登录',
|
||||
'GET /api/v1/auth/oauth/:provider/callback': '外部身份登录 / 绑定',
|
||||
'PUT /api/v1/auth/credentials': '修改登录凭据',
|
||||
'PUT /api/v1/auth/password-login': '切换密码登录开关',
|
||||
'POST /api/v1/auth/revoke-sessions': '撤销全部会话',
|
||||
'POST /api/v1/auth/totp/setup': '发起两步验证绑定',
|
||||
'POST /api/v1/auth/totp/activate': '启用两步验证',
|
||||
'POST /api/v1/auth/totp/disable': '停用两步验证',
|
||||
@@ -42,6 +47,26 @@ const exact: Record<string, string> = {
|
||||
'DELETE /api/v1/tasks/:id': '删除后台任务',
|
||||
'POST /api/v1/tasks/:id/run': '手动执行任务',
|
||||
'POST /api/v1/webhooks/oci-logs/:secret': '回传消息投递',
|
||||
'POST /api/v1/ai-keys': '创建网关密钥',
|
||||
'PUT /api/v1/ai-keys/:id': '修改网关密钥',
|
||||
'DELETE /api/v1/ai-keys/:id': '删除网关密钥',
|
||||
'PUT /api/v1/ai-keys/:id/content-log': '设置密钥内容留痕',
|
||||
'POST /api/v1/ai-channels': '创建网关渠道',
|
||||
'PUT /api/v1/ai-channels/:id': '修改网关渠道',
|
||||
'DELETE /api/v1/ai-channels/:id': '删除网关渠道',
|
||||
'POST /api/v1/ai-channels/:id/probe': '探测网关渠道',
|
||||
'POST /api/v1/ai-channels/:id/sync-models': '同步渠道模型',
|
||||
'POST /api/v1/ai-channels/:id/test-model': '测试渠道模型',
|
||||
'POST /api/v1/ai-blacklist': '拉黑模型',
|
||||
'DELETE /api/v1/ai-blacklist/:id': '移出模型黑名单',
|
||||
'PUT /api/v1/ai-settings': '保存网关设置',
|
||||
'PUT /api/v1/settings/notify-channels/:type': '保存通知渠道配置',
|
||||
'POST /api/v1/settings/notify-channels/:type/test': '发送通知测试消息',
|
||||
'PUT /api/v1/settings/notify-templates/:kind': '保存通知模板',
|
||||
'POST /api/v1/settings/notify-templates/:kind/test': '发送模板测试消息',
|
||||
'POST /api/v1/proxies/import': '批量导入代理',
|
||||
'POST /api/v1/proxies/:id/probe': '探测代理',
|
||||
'PUT /api/v1/proxies/:id/tenants': '设置代理关联租户',
|
||||
}
|
||||
|
||||
/** 资源段兜底词典:精确表未命中时以「动词 + 资源」组合 */
|
||||
|
||||
+40
-27
@@ -878,32 +878,6 @@ export interface LogEventPage {
|
||||
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 */
|
||||
export interface LogWebhookInfo {
|
||||
path: string
|
||||
@@ -946,6 +920,8 @@ export interface AiKey {
|
||||
name: string
|
||||
tail: string
|
||||
group: string
|
||||
/** 模型白名单;null/空 = 不限,非空时网关仅放行列表内模型 */
|
||||
models: string[] | null
|
||||
enabled: boolean
|
||||
lastUsedAt: string | null
|
||||
/** 内容日志开启截止时间;null = 永关(默认,红线),开启必须限时到期自动停写 */
|
||||
@@ -970,8 +946,12 @@ export interface AiChannel {
|
||||
lastProbeAt: string | null
|
||||
probeStatus: AiProbeStatus
|
||||
probeError: string
|
||||
/** 用户测试通过后固定的探测验证模型;探测时置于候选首位 */
|
||||
probeModel: string
|
||||
createdAt: string
|
||||
updatedAt: string
|
||||
/** 渠道模型缓存计数(列表查询回填) */
|
||||
modelCount: number
|
||||
}
|
||||
|
||||
/** 聚合可用模型(OpenAI /models 形态) */
|
||||
@@ -988,7 +968,22 @@ export interface AiModelCacheItem {
|
||||
modelOcid: string
|
||||
name: string
|
||||
vendor: string
|
||||
capability: string
|
||||
syncedAt: string
|
||||
deprecatedAt: string | null
|
||||
retiredAt: string | null
|
||||
}
|
||||
|
||||
/** 模型黑名单条目:拉黑即全渠道剔除,同步 / 探测不再入库 */
|
||||
/** AI 网关全局设置 */
|
||||
export interface AiSettings {
|
||||
filterDeprecated: boolean
|
||||
}
|
||||
|
||||
export interface AiModelBlacklistItem {
|
||||
id: number
|
||||
name: string
|
||||
createdAt: string
|
||||
}
|
||||
|
||||
/** 调用日志:仅元数据与 token 用量 */
|
||||
@@ -1032,10 +1027,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 {
|
||||
version: string
|
||||
buildTime: string
|
||||
goVersion: string
|
||||
platform: string
|
||||
startedAt?: string
|
||||
uptimeSeconds?: number
|
||||
resources?: AboutResources
|
||||
}
|
||||
|
||||
+140
-7
@@ -1,18 +1,30 @@
|
||||
<script setup lang="ts">
|
||||
import { NButton } from 'naive-ui'
|
||||
import { NButton, NSwitch, useDialog } from 'naive-ui'
|
||||
import { computed, ref } from 'vue'
|
||||
|
||||
import { listAiChannels, listAiKeys, listAiModels } from '@/api/aigateway'
|
||||
import {
|
||||
addAiBlacklist,
|
||||
getAiSettings,
|
||||
listAiBlacklist,
|
||||
listAiChannels,
|
||||
listAiKeys,
|
||||
listAiModels,
|
||||
removeAiBlacklist,
|
||||
updateAiSettings,
|
||||
} from '@/api/aigateway'
|
||||
import AiChannelPanel from '@/components/ai/AiChannelPanel.vue'
|
||||
import AiKeyPanel from '@/components/ai/AiKeyPanel.vue'
|
||||
import { useAsync } from '@/composables/useAsync'
|
||||
import { useToast } from '@/composables/useToast'
|
||||
import type { AiModelBlacklistItem } from '@/types/api'
|
||||
|
||||
const message = useToast()
|
||||
const dialog = useDialog()
|
||||
|
||||
const keys = useAsync(listAiKeys)
|
||||
const channels = useAsync(listAiChannels)
|
||||
const models = useAsync(listAiModels)
|
||||
const blacklist = useAsync(listAiBlacklist)
|
||||
|
||||
const baseUrl = `${window.location.origin}/ai/v1`
|
||||
|
||||
@@ -21,6 +33,10 @@ const endpoints = [
|
||||
{ method: 'POST', path: '/responses', note: 'OpenAI Responses · 无状态子集' },
|
||||
{ method: 'POST', path: '/messages', note: 'Claude · 流式/非流式' },
|
||||
{ method: 'POST', path: '/embeddings', note: 'OpenAI Embeddings · 向量化' },
|
||||
{ method: 'POST', path: '/audio/speech', note: '文本转语音 · xAI Voice' },
|
||||
{ method: 'POST', path: '/tts', note: '文本转语音 · xAI 官方格式' },
|
||||
{ method: 'POST', path: '/rerank', note: '文档重排 · Cohere Rerank' },
|
||||
{ method: 'POST', path: '/moderations', note: '内容审核 · OCI Guardrails' },
|
||||
{ method: 'GET', path: '/models', note: '模型列表(按密钥分组过滤)' },
|
||||
]
|
||||
|
||||
@@ -43,9 +59,12 @@ const modelGroups = computed(() => {
|
||||
.map(([vendor, ids]) => ({ vendor, label: VENDOR_LABEL[vendor] ?? vendor, ids: ids.sort() }))
|
||||
})
|
||||
|
||||
/** 手风琴:同时只展开一个厂商,配合展开区限高控制卡片总高度 */
|
||||
/** 手风琴:同时只展开一个分组(厂商或黑名单),配合展开区限高控制卡片总高度 */
|
||||
const expandedVendor = ref<string | null>(null)
|
||||
|
||||
/** 黑名单在手风琴中的分组 key(厂商 key 取自模型名前缀,不会与此冲突) */
|
||||
const BLACKLIST_KEY = '__blacklist__'
|
||||
|
||||
function toggleVendor(vendor: string) {
|
||||
expandedVendor.value = expandedVendor.value === vendor ? null : vendor
|
||||
}
|
||||
@@ -71,9 +90,62 @@ async function copyModel(id: string) {
|
||||
}
|
||||
}
|
||||
|
||||
/** 「过滤弃用模型」开关:开启后已宣布弃用(即使未退役)的模型从列表与路由中排除 */
|
||||
const filterDeprecated = ref(false)
|
||||
void getAiSettings()
|
||||
.then((s) => { filterDeprecated.value = s.filterDeprecated })
|
||||
.catch(() => {})
|
||||
|
||||
async function toggleFilterDeprecated(v: boolean) {
|
||||
filterDeprecated.value = v
|
||||
try {
|
||||
const s = await updateAiSettings({ filterDeprecated: v })
|
||||
filterDeprecated.value = s.filterDeprecated
|
||||
message.success(v ? '已过滤弃用模型(列表与路由同时排除)' : '已恢复展示弃用模型')
|
||||
} catch (e) {
|
||||
message.error(e instanceof Error ? e.message : '操作失败')
|
||||
filterDeprecated.value = !v
|
||||
}
|
||||
refreshModels()
|
||||
}
|
||||
|
||||
function refreshModels() {
|
||||
void models.run({ silent: true })
|
||||
void blacklist.run({ silent: true })
|
||||
}
|
||||
|
||||
function refreshChannels() {
|
||||
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>
|
||||
|
||||
@@ -114,10 +186,19 @@ function refreshChannels() {
|
||||
<div class="flex items-center justify-between border-b border-line-soft px-4.5 py-3">
|
||||
<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 class="flex flex-none items-center gap-3">
|
||||
<label
|
||||
class="flex cursor-pointer items-center gap-1.5 text-xs text-ink-3"
|
||||
title="开启后,已宣布弃用(即使未退役)的模型从模型列表与路由中排除;关闭恢复"
|
||||
>
|
||||
过滤弃用
|
||||
<NSwitch size="small" :value="filterDeprecated" @update:value="toggleFilterDeprecated" />
|
||||
</label>
|
||||
<span class="text-xs text-ink-3">{{ models.data.value?.length ?? '…' }} 个</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="px-4.5 py-1.5">
|
||||
<div
|
||||
v-for="g in modelGroups"
|
||||
@@ -144,16 +225,67 @@ function refreshChannels() {
|
||||
v-if="expandedVendor === g.vendor"
|
||||
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"
|
||||
:key="id"
|
||||
class="mono inline-flex items-center overflow-hidden rounded-[5px] border border-line bg-card text-[11.5px]"
|
||||
>
|
||||
<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}`"
|
||||
@click="copyModel(id)"
|
||||
>
|
||||
{{ id }}
|
||||
</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 v-if="models.data.value && !models.data.value.length" class="py-2 text-xs text-ink-3">
|
||||
@@ -170,6 +302,7 @@ function refreshChannels() {
|
||||
:keys="keys.data.value ?? []"
|
||||
:loading="keys.loading.value"
|
||||
:groups="groups"
|
||||
:models="models.data.value ?? []"
|
||||
@changed="keys.run({ silent: true })"
|
||||
/>
|
||||
|
||||
|
||||
+11
-1
@@ -1,5 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { NButton, NInput } from 'naive-ui'
|
||||
import { NButton, NInput, NSpin } from 'naive-ui'
|
||||
import { onMounted, ref } from 'vue'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
|
||||
@@ -30,6 +30,8 @@ const errorMsg = ref('')
|
||||
const providers = ref<OauthProviderInfo[]>([])
|
||||
// 密码登录已禁用(设置里开启且存在可用外部身份):隐藏用户名密码表单
|
||||
const passwordLoginDisabled = ref(false)
|
||||
// 登录方式加载中:providers 返回前不渲染表单,避免「先见密码表单再消失」的闪烁与误提交
|
||||
const bootLoading = ref(true)
|
||||
|
||||
// 左侧品牌区功能徽章:各自不同周期/幅度/相位上下浮动(不规律观感)
|
||||
const featureChips = [
|
||||
@@ -47,6 +49,8 @@ onMounted(async () => {
|
||||
passwordLoginDisabled.value = r.passwordLoginDisabled && r.providers.length > 0
|
||||
} catch {
|
||||
/* 登录页容忍 provider 列表加载失败 */
|
||||
} finally {
|
||||
bootLoading.value = false
|
||||
}
|
||||
})
|
||||
|
||||
@@ -155,6 +159,11 @@ async function oauthLogin(provider: string) {
|
||||
<div class="rounded-[14px] border border-line bg-card px-[30px] pt-[30px] pb-7 shadow-[0_18px_50px_rgba(20,20,19,.10),0_2px_8px_rgba(20,20,19,.05)]">
|
||||
<div class="font-serif text-[19px] font-semibold">欢迎回来</div>
|
||||
|
||||
<div v-if="bootLoading" class="flex items-center justify-center py-14">
|
||||
<NSpin size="small" />
|
||||
</div>
|
||||
|
||||
<template v-else>
|
||||
<div
|
||||
v-if="errorMsg"
|
||||
class="mt-4 flex items-start gap-2 rounded-md border border-err/30 bg-err/10 px-3 py-2 text-[12.5px] text-err"
|
||||
@@ -227,6 +236,7 @@ async function oauthLogin(provider: string) {
|
||||
由管理员在 设置 · 账号安全 中管理
|
||||
</div>
|
||||
</template>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -163,7 +163,8 @@ const currencySymbol = computed(() => {
|
||||
{{ ov?.tenants.alive ?? 0 }}/{{ ov?.tenants.total ?? 0 }} 存活
|
||||
</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
|
||||
v-for="c in configs.data.value ?? []"
|
||||
:key="c.id"
|
||||
@@ -188,7 +189,8 @@ const currencySymbol = computed(() => {
|
||||
</div>
|
||||
<div class="w-18 flex-none text-right text-xs text-ink-3">{{ fmtRelative(c.lastVerifiedAt) }}</div>
|
||||
</div>
|
||||
<div class="py-2.5 text-center">
|
||||
</div>
|
||||
<div class="border-t border-line-soft py-2.5 text-center">
|
||||
<RouterLink
|
||||
class="text-[13px] font-medium text-accent hover:text-accent-hover"
|
||||
:to="{ name: 'tenants' }"
|
||||
@@ -197,7 +199,6 @@ const currencySymbol = computed(() => {
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 最近任务执行 -->
|
||||
<div class="panel">
|
||||
|
||||
@@ -140,8 +140,15 @@ async function remove() {
|
||||
<template #trigger>
|
||||
<NButton size="small" type="error" ghost>删除租户</NButton>
|
||||
</template>
|
||||
删除「{{ config.data.value.alias }}」?将清理本面板中的关联任务、快照、回传事件与 Webhook
|
||||
密钥、告警及 AI 渠道数据;OCI 云端资源不会被删除(云端日志回传链路请先在“其他”页销毁)。
|
||||
<div class="max-w-80 text-[13px] leading-relaxed">
|
||||
<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>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
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 { 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 探测看号池渠道(仅入池租户);
|
||||
* 测活 / 成本看范围(空 = 全部租户) */
|
||||
function taskTouchesCfg(task: Task, cfgId: number): boolean {
|
||||
@@ -222,7 +241,19 @@ function renderActions(row: OciConfigSummary): VNodeChild {
|
||||
trigger: () =>
|
||||
h(NButton, { size: 'tiny', quaternary: true, type: 'error' }, { 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"
|
||||
:data="filtered"
|
||||
:loading="configs.loading.value"
|
||||
:pagination="{ pageSize: 10 }"
|
||||
:pagination="pagination"
|
||||
:scroll-x="1200"
|
||||
:row-key="(r: OciConfigSummary) => r.id"
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user