From 0ae6a2c1d4756ea92e66bb071afd96168b9f5ddb Mon Sep 17 00:00:00 2001 From: Tory Date: Tue, 17 Nov 2026 13:11:10 +0800 Subject: [PATCH] =?UTF-8?q?Issue#6=C2=B7B2:=20=E4=B8=89=E5=A5=91=E7=BA=A6?= =?UTF-8?q?=E9=A1=B5=201:1=20=E5=AE=9E=E8=A3=85(v3-2-tailwind.html=20?= =?UTF-8?q?=E9=80=90=E8=A1=8C=E7=9B=B4=E6=8A=84,=E7=9C=9F=E5=AE=9E?= =?UTF-8?q?=E6=95=B0=E6=8D=AE)=E2=80=94=E2=80=94=20=E2=91=A0#p-dash=20?= =?UTF-8?q?=E8=BF=90=E8=90=A5=E6=80=BB=E8=A7=88(895-1005):=E7=8A=B6?= =?UTF-8?q?=E6=80=81=E6=A8=AA=E5=B9=85(=E4=BA=94=E5=AD=90=E7=B3=BB?= =?UTF-8?q?=E7=BB=9F=20badge+summary=20=E6=8C=87=E6=A0=87=E4=B8=B2)+stat?= =?UTF-8?q?=20=E5=8F=8C=E8=A1=8C=206+4=20=E5=8D=A1+chart.js=20=E5=8F=91?= =?UTF-8?q?=E9=80=81=E8=B6=8B=E5=8A=BF(teal/sky=20=E5=8F=8C=E7=BA=BF?= =?UTF-8?q?=E6=B8=90=E5=8F=98=E5=A1=AB=E5=85=85,=E8=BF=917/30=20=E5=88=87?= =?UTF-8?q?=E6=8D=A2)+=E4=B8=9A=E5=8A=A1=E5=88=86=E5=B8=83=E5=8A=A8?= =?UTF-8?q?=E6=80=81=20donut(SVG=20dasharray)+=E9=80=9A=E9=81=93=E5=AE=9E?= =?UTF-8?q?=E6=97=B6=E7=9B=91=E6=8E=A7=E8=A1=A8(monitor=20=E5=BF=AB?= =?UTF-8?q?=E7=85=A7=205s=20=E8=BD=AE=E8=AF=A2,=E8=B4=9F=E8=BD=BD=E6=9D=A1?= =?UTF-8?q?/=E5=A4=B1=E8=B4=A5=E7=8E=87/P50)+=E7=B3=BB=E7=BB=9F=E5=81=A5?= =?UTF-8?q?=E5=BA=B7(overview=2010s=20=E8=BD=AE=E8=AF=A2,up/degraded/down?= =?UTF-8?q?=20=E4=B8=89=E6=80=81=20badge)+=E6=9C=80=E8=BF=91=E5=8A=A8?= =?UTF-8?q?=E6=80=81(=E8=AF=9A=E5=AE=9E=E7=A9=BA=E6=80=81)+=E5=BF=AB?= =?UTF-8?q?=E6=8D=B7=E6=93=8D=E4=BD=9C=204+=E9=80=9A=E9=81=93=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E5=BF=AB=E7=85=A7;=E7=BC=BA=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E9=A1=B9=E6=98=BE=E5=BC=8F=20=E2=80=94(=E4=BB=8A=E6=97=A5?= =?UTF-8?q?=E6=94=B6=E5=85=A5/TPM);=E2=91=A1#p-acct=20=E5=B8=90=E5=8F=B7?= =?UTF-8?q?=E7=AE=A1=E7=90=86(1006-1034):=E5=8D=95=E5=8D=A1=E4=B8=80?= =?UTF-8?q?=E4=BD=93=E7=AD=9B=E9=80=89=E5=8C=BA(input!w-56+=E5=8F=8C=20sel?= =?UTF-8?q?ect+=E6=90=9C=E7=B4=A2/=E9=87=8D=E7=BD=AE+=E5=B7=B2=E9=80=89N)+?= =?UTF-8?q?8=20=E5=88=97=E5=8E=9F=E7=94=9F=20table(=E5=BD=A9=E8=89=B2?= =?UTF-8?q?=E9=A6=96=E5=AD=97=E5=9C=86=E5=BE=BD=E8=BD=AE=E8=BD=AC/?= =?UTF-8?q?=E8=A7=92=E8=89=B2=20badge/=E4=BD=99=E9=A2=9D=E5=8F=B3=E5=AF=B9?= =?UTF-8?q?=E9=BD=90/=E5=81=9C=E7=94=A8=E7=81=B0)+=E5=88=86=E9=A1=B5?= =?UTF-8?q?=E6=9D=A1(=E5=85=B1N=E6=9D=A1+=E9=A1=B5=E7=A0=81=E7=AA=97?= =?UTF-8?q?=E5=8F=A3),/accounts=20=E7=9C=9F=E5=AE=9E=E5=88=86=E9=A1=B5;?= =?UTF-8?q?=E2=91=A2#p-chan=20=E9=80=9A=E9=81=93=E7=BC=96=E8=BE=91(1035-10?= =?UTF-8?q?59):=E5=8F=8C=E5=8D=A1=E8=A1=A8=E5=8D=95(=E5=9F=BA=E6=9C=AC?= =?UTF-8?q?=E5=8F=82=E6=95=B0=206=20=E5=AD=97=E6=AE=B5=E5=BF=85=E5=A1=AB?= =?UTF-8?q?=204*+=E5=90=9E=E5=90=90=E9=A3=8E=E6=8E=A7=205=20=E5=AD=97?= =?UTF-8?q?=E6=AE=B5+=E5=90=AF=E7=94=A8=20switch)+=E6=93=8D=E4=BD=9C?= =?UTF-8?q?=E6=9D=A1(=E6=8E=A2=E6=B5=8B=E6=9C=9F=E6=8F=90=E7=A4=BA/?= =?UTF-8?q?=E5=8F=96=E6=B6=88/=E4=BF=9D=E5=AD=98),=E5=8D=8F=E8=AE=AE?= =?UTF-8?q?=E9=94=AE=E2=86=94protocol+version=20=E6=98=A0=E5=B0=84,?= =?UTF-8?q?=E7=BC=96=E8=BE=91=E5=9B=9E=E5=A1=AB=20host:port=20=E5=90=88?= =?UTF-8?q?=E5=B9=B6;=E2=91=A3api=20=E5=B1=82=E8=A1=A5=20P2=20=E4=B8=89?= =?UTF-8?q?=E7=AB=AF=E7=82=B9=E5=B0=81=E8=A3=85(statsApi.biz/realtime+syst?= =?UTF-8?q?emApi.overview+channelApi.monitor+=E4=B8=89=E7=B1=BB=E5=9E=8B);?= =?UTF-8?q?=E2=91=A4=E5=90=8E=E7=AB=AF=E6=A0=B9=E4=BF=AE:stats=5Fhandler.g?= =?UTF-8?q?o=20=E4=B8=A4=E5=A4=84=20AS=20key=20=E6=92=9E=20MySQL=208.0=20?= =?UTF-8?q?=E4=BF=9D=E7=95=99=E5=AD=97=E8=87=B4=20/stats/biz=20500(?= =?UTF-8?q?=E5=8F=8D=E5=BC=95=E5=8F=B7=E8=BD=AC=E4=B9=89,P2=20=E9=81=97?= =?UTF-8?q?=E7=95=99=20bug=20B2=20=E9=A6=96=E6=AC=A1=E6=B6=88=E8=B4=B9?= =?UTF-8?q?=E6=9A=B4=E9=9C=B2);=E2=91=A5=E9=AA=8C=E6=94=B6:vue-tsc=200/bui?= =?UTF-8?q?ld=20=E2=9C=93(dash=20=E6=87=92=E5=8A=A0=E8=BD=BD=20chunk=20gzi?= =?UTF-8?q?p=2065KB)/Chrome=20=E5=86=92=E7=83=9F=2012/12(=E6=A8=AA?= =?UTF-8?q?=E5=B9=85=E7=9C=9F=E5=AE=9E=E5=88=A4=E5=AE=9A/=E5=81=A5?= =?UTF-8?q?=E5=BA=B7=205=20=E5=BE=BD=E7=AB=A0/acct=20=E7=9C=9F=E5=AE=9E?= =?UTF-8?q?=E8=B4=A6=E5=8F=B7=203=20=E8=A1=8C/chan=20=E5=8F=8C=E5=8D=A1)/s?= =?UTF-8?q?tat-card=20computed=20style=20=E5=8F=8C=E4=BC=9A=E8=AF=9D?= =?UTF-8?q?=E5=AF=B9=E6=8B=8D=E4=B8=80=E8=87=B4(radius16/pad20/flex/gap16/?= =?UTF-8?q?shadow=20=E5=90=8C=2017890);=E7=BD=91=E5=85=B3=E9=87=8D?= =?UTF-8?q?=E5=BB=BA=E9=87=8D=E5=90=AF(11-16=20=E6=97=A7=E4=BA=8C=E8=BF=9B?= =?UTF-8?q?=E5=88=B6=E2=86=92=E5=90=AB=20P2=20=E7=AB=AF=E7=82=B9)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/api/http/v1/stats_handler.go | 8 +- web-next/src/api/channel.ts | 19 + web-next/src/api/stats.ts | 19 + web-next/src/api/system.ts | 9 + web-next/src/router/routes.ts | 6 +- web-next/src/views/account/AccountList.vue | 187 ++++++++ web-next/src/views/channel/ChannelEdit.vue | 210 +++++++++ web-next/src/views/home/DashboardView.vue | 501 +++++++++++++++++++++ 8 files changed, 952 insertions(+), 7 deletions(-) create mode 100644 web-next/src/views/account/AccountList.vue create mode 100644 web-next/src/views/channel/ChannelEdit.vue create mode 100644 web-next/src/views/home/DashboardView.vue diff --git a/internal/api/http/v1/stats_handler.go b/internal/api/http/v1/stats_handler.go index d081b3f9..e3bb6c1a 100644 --- a/internal/api/http/v1/stats_handler.go +++ b/internal/api/http/v1/stats_handler.go @@ -344,8 +344,8 @@ func (h *statsHandler) biz(c *gin.Context) { var rows []row if err := h.db.Model(&entity.MessageTask{}). Where("created_at >= ?", start).Scopes(statsTaskScope(c)). - Select("COALESCE(NULLIF(business,''),'sms') AS key, COUNT(*) AS count"). - Group("key").Order("count DESC").Scan(&rows).Error; err != nil { + Select("COALESCE(NULLIF(business,''),'sms') AS `key`, COUNT(*) AS count"). + Group("`key`").Order("count DESC").Scan(&rows).Error; err != nil { bizResp(c, err) return } @@ -356,8 +356,8 @@ func (h *statsHandler) biz(c *gin.Context) { rows = nil if err := h.db.Model(&entity.MessageTask{}). Where("created_at >= ?", start).Scopes(statsTaskScope(c)). - Select("send_type AS key, COUNT(*) AS count"). - Group("key").Order("count DESC").Scan(&rows).Error; err != nil { + Select("send_type AS `key`, COUNT(*) AS count"). + Group("`key`").Order("count DESC").Scan(&rows).Error; err != nil { bizResp(c, err) return } diff --git a/web-next/src/api/channel.ts b/web-next/src/api/channel.ts index b20e1877..3ede7839 100644 --- a/web-next/src/api/channel.ts +++ b/web-next/src/api/channel.ts @@ -130,7 +130,26 @@ export interface ChannelPriceEntry { created_at?: string } +/** 通道实时快照(Day 40:/channels/monitor,与 WS 帧同构;60s 窗口均值)。 */ +export interface ChannelSnapshot { + channel_id: number + name: string + protocol: string + status: number + running: boolean + total: number + healthy: number + submit_ps: number + deliver_ps: number + fail_rate: number + latency_p50_ms: number + updated_at: string +} + export const channelApi = { + // ---- 实时监控(Day 40:HTTP 快照,与 /channels/monitor/ws 帧同构) ---- + monitor: () => get('/channels/monitor'), + // ---- 上家 ---- upstreamList: (q?: { page: number; page_size: number; name?: string }) => get>('/channels/upstreams', q as Record), diff --git a/web-next/src/api/stats.ts b/web-next/src/api/stats.ts index ec15ab4f..4903e423 100644 --- a/web-next/src/api/stats.ts +++ b/web-next/src/api/stats.ts @@ -29,4 +29,23 @@ export const statsApi = { // 叠加成 /api/v1/api/v1/... → msw 不匹配 → proxy 404(Home 指标一直空数据)。 summary: () => get('/stats/summary'), trend: (days = 7) => get('/stats/trend', { days }), + // ---- Issue#6·P2 Dashboard 三端点(openapi 1.5.0) ---- + biz: (days = 7) => get('/stats/biz', { days }), + realtime: () => get('/stats/realtime'), } + +/** 业务类型分布(P2:/stats/biz)。 */ +export interface BizDist { + days: number + by_business: { key: string; count: number }[] + by_send_type: { key: string; count: number }[] +} + +/** 实时提交速率(P2:/stats/realtime,60s 窗口均值)。 */ +export interface RealtimeStat { + ts: string + window_s: number + global_submit_ps: number + top_accounts: { account_id: number; name: string; submit_ps: number }[] +} + diff --git a/web-next/src/api/system.ts b/web-next/src/api/system.ts index 737b117b..c04b64ea 100644 --- a/web-next/src/api/system.ts +++ b/web-next/src/api/system.ts @@ -31,6 +31,15 @@ export const KNOWN_CFG_KEYS: { key: string; label: string; hint: string }[] = [ ] export const systemApi = { + // ---- Issue#6·P2:/ops/system/overview(admin/ops;gateway 视角五子系统三态) ---- + overview: () => get('/ops/system/overview'), list: () => get<{ list: SystemConfigRow[] }>('/system/config'), update: (body: SystemConfigSaveReq) => put('/system/config', body), } + +/** 系统健康总览(P2:/ops/system/overview)。 */ +export interface SystemOverview { + uptime_s: number + subsystems: { name: string; status: 'up' | 'degraded' | 'down' | 'unknown'; detail: string; latency_ms: number }[] +} + diff --git a/web-next/src/router/routes.ts b/web-next/src/router/routes.ts index 6a7a42c4..9dddcfb1 100644 --- a/web-next/src/router/routes.ts +++ b/web-next/src/router/routes.ts @@ -30,10 +30,10 @@ export const asyncRoutes: RouteRecordRaw[] = [ component: () => import('@/layouts/BasicLayout.vue'), redirect: '/home', children: [ - { path: 'home', name: 'home', component: () => import('@/views/coming/ComingSoon.vue'), meta: { title: '运营总览', icon: 'i-grid', menu: true, group: '工作台', subtitle: '今日平台运行概览 · 60s 自动刷新', roles: ['admin', 'ops', 'service', 'group', 'customer'] } }, + { path: 'home', name: 'home', component: () => import('@/views/home/DashboardView.vue'), meta: { title: '运营总览', icon: 'i-grid', menu: true, group: '工作台', subtitle: '今日平台运行概览 · 60s 自动刷新', roles: ['admin', 'ops', 'service', 'group', 'customer'] } }, { path: 'notice', name: 'notice', component: () => import('@/views/coming/ComingSoon.vue'), meta: { title: '预警公告', icon: 'i-bell', menu: true, group: '工作台', roles: ['admin', 'ops', 'service', 'group'] } }, - { path: 'account', name: 'account-list', component: () => import('@/views/coming/ComingSoon.vue'), meta: { title: '帐号管理', icon: 'i-users', menu: true, group: '运营管理', roles: ['admin', 'ops'] } }, + { path: 'account', name: 'account-list', component: () => import('@/views/account/AccountList.vue'), meta: { title: '帐号管理', icon: 'i-users', menu: true, group: '运营管理', roles: ['admin', 'ops'] } }, { path: 'account/create', name: 'account-create', component: () => import('@/views/coming/ComingSoon.vue'), meta: { title: '开户', group: '运营管理', roles: ['admin', 'ops'] } }, { path: 'account/:id', name: 'account-detail', component: () => import('@/views/coming/ComingSoon.vue'), meta: { title: '账号详情', group: '运营管理', roles: ['admin', 'ops'] } }, { path: 'account/:id/recharge', name: 'account-recharge', component: () => import('@/views/coming/ComingSoon.vue'), meta: { title: '充值', group: '运营管理', roles: ['admin', 'ops'] } }, @@ -63,7 +63,7 @@ export const asyncRoutes: RouteRecordRaw[] = [ { path: 'channel', name: 'channel', component: () => import('@/views/coming/ComingSoon.vue'), meta: { title: '通道配置', icon: 'i-layer', menu: true, group: '通道与策略', roles: ['admin', 'ops'] } }, { path: 'channel/upstream', name: 'channel-upstream', component: () => import('@/views/coming/ComingSoon.vue'), meta: { title: '上家管理', icon: 'i-srv', menu: true, group: '通道与策略', roles: ['admin', 'ops'] } }, - { path: 'channel/edit/:id?', name: 'channel-edit', component: () => import('@/views/coming/ComingSoon.vue'), meta: { title: '通道编辑', group: '通道与策略', roles: ['admin', 'ops'] } }, + { path: 'channel/edit/:id?', name: 'channel-edit', component: () => import('@/views/channel/ChannelEdit.vue'), meta: { title: '通道编辑', group: '通道与策略', roles: ['admin', 'ops'] } }, { path: 'channel/group', name: 'channel-group', component: () => import('@/views/coming/ComingSoon.vue'), meta: { title: '通道组路由', icon: 'i-route', menu: true, group: '通道与策略', roles: ['admin', 'ops'] } }, { path: 'policy', name: 'policy', component: () => import('@/views/coming/ComingSoon.vue'), meta: { title: '规则策略', icon: 'i-set', menu: true, group: '通道与策略', roles: ['admin', 'ops'] } }, { path: 'policy/route', name: 'policy-route', component: () => import('@/views/coming/ComingSoon.vue'), meta: { title: '导流策略', icon: 'i-route', menu: true, group: '通道与策略', roles: ['admin', 'ops'] } }, diff --git a/web-next/src/views/account/AccountList.vue b/web-next/src/views/account/AccountList.vue new file mode 100644 index 00000000..2113197c --- /dev/null +++ b/web-next/src/views/account/AccountList.vue @@ -0,0 +1,187 @@ + + + + diff --git a/web-next/src/views/channel/ChannelEdit.vue b/web-next/src/views/channel/ChannelEdit.vue new file mode 100644 index 00000000..812d0a74 --- /dev/null +++ b/web-next/src/views/channel/ChannelEdit.vue @@ -0,0 +1,210 @@ + + + + diff --git a/web-next/src/views/home/DashboardView.vue b/web-next/src/views/home/DashboardView.vue new file mode 100644 index 00000000..f4c46688 --- /dev/null +++ b/web-next/src/views/home/DashboardView.vue @@ -0,0 +1,501 @@ + + + + +