F1 告警静默规则 [done]: - 后端 alert_silence.go: CRUD + Toggle (onetime/daily/weekly 三模式) - 告警引擎 isSilenced 集成 (alert_engine.go) - 前端 SilenceRuleTab + SilenceDialog - 路由 /alerts/silences 已注册 F2 审计日志导出 [done]: - 重写 ExportAuditLogs: 真正的 CSV 导出 (encoding/csv + UTF-8 BOM) - 支持 module/action/username/startTime/endTime 筛选 - 导出限制 10000 条防溢出,自动记录审计日志 - JSON 格式向后兼容 (format=json) - 前端 exportLogs 传递查询参数 同时包含累积的前期工作: - 目录重构 internal/ -> controller/model/router (v0.55-v0.57) - 后端分层架构 dto/repository/service/utils - 审计模块全功能 (终端审计/操作审计/登录日志) - asciicast v2 录制格式 - SFTP 文件浏览器 - StatStrip 紧凑统计条 - 在线会话自动刷新 - LiveMonitor WebSocket 诊断修复 验证: go build ✅ | npm run build ✅ | Docker 部署 ✅ | 10 回归端点 ✅ | CSV 导出 ✅ | 静默 CRUD ✅
2 lines
36 KiB
JavaScript
2 lines
36 KiB
JavaScript
import{g as Z,j as e,r as a,D as ee,b as se,c as le,d as oe,e as te,I as j,f as ce,B as m,L as R,a as ye,T as De,J as M}from"./index-DfyorCky.js";import{L as r}from"./label-BK0h2apY.js";import{C as A,a as V}from"./card-C55cvSHg.js";import{B as Re}from"./badge-xNW8x0G1.js";import{S as ne}from"./switch-CGiGgOnh.js";import{S as w,a as S,b as k,c as _,d as h}from"./select-D5qUzdAs.js";import{t as p}from"./index-a3ybMjbR.js";import{b as g}from"./cloud-Dzoer-2i.js";import{T as ae}from"./trending-up-CdusV6gc.js";import{T as we}from"./trending-down-BGTWG_dA.js";import{R as J}from"./refresh-cw-DUB_tAG-.js";import{P as U}from"./plus-CUG-9kpu.js";import{P as G}from"./pencil-BqUotcjf.js";import{T as K}from"./trash-2-Dx32pOzT.js";import"./index-CWVNW_qu.js";const Se=[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M8 14h.01",key:"6423bh"}],["path",{d:"M12 14h.01",key:"1etili"}],["path",{d:"M16 14h.01",key:"1gbofw"}],["path",{d:"M8 18h.01",key:"lrp35t"}],["path",{d:"M12 18h.01",key:"mhygvu"}],["path",{d:"M16 18h.01",key:"kzsmim"}]],ke=Z("calendar-days",Se);const _e=[["path",{d:"M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1",key:"18etb6"}],["path",{d:"M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4",key:"xoc0q4"}]],Q=Z("wallet",_e),v={aliyun:"阿里云",tencent:"腾讯云",aws:"AWS",huawei:"华为云",azure:"Azure"},O={aliyun:"bg-orange-500",tencent:"bg-blue-500",aws:"bg-amber-500",huawei:"bg-red-500",azure:"bg-sky-500"};function u(d){return`¥${d.toLocaleString("zh-CN",{minimumFractionDigits:2,maximumFractionDigits:2})}`}function E({icon:d,label:i,value:t,trend:c,trendLabel:o,alert:n}){return e.jsxs("div",{"code-path":"src/components/cloud/CloudBillingHelpers.tsx:35:5",className:`rounded-lg border p-4 ${n?"border-amber-500/30 bg-amber-500/5":"border-slate-800 bg-slate-900/50"}`,children:[e.jsxs("div",{"code-path":"src/components/cloud/CloudBillingHelpers.tsx:36:7",className:"flex items-center justify-between mb-2",children:[e.jsx("span",{"code-path":"src/components/cloud/CloudBillingHelpers.tsx:37:9",className:"text-slate-400 text-sm",children:i}),e.jsx("span",{"code-path":"src/components/cloud/CloudBillingHelpers.tsx:38:9",className:n?"text-amber-400":"text-slate-500",children:d})]}),e.jsx("div",{"code-path":"src/components/cloud/CloudBillingHelpers.tsx:40:7",className:`text-2xl font-bold ${n?"text-amber-300":"text-slate-100"}`,children:t}),o&&e.jsxs("div",{"code-path":"src/components/cloud/CloudBillingHelpers.tsx:42:9",className:"flex items-center gap-1 mt-1 text-xs",children:[c!==void 0&&c>0&&e.jsx(ae,{"code-path":"src/components/cloud/CloudBillingHelpers.tsx:43:48",className:"h-3 w-3 text-red-400"}),c!==void 0&&c<0&&e.jsx(we,{"code-path":"src/components/cloud/CloudBillingHelpers.tsx:44:48",className:"h-3 w-3 text-green-400"}),e.jsx("span",{"code-path":"src/components/cloud/CloudBillingHelpers.tsx:45:11",className:"text-slate-500",children:o})]})]})}function He({data:d}){if(d.length===0)return e.jsx("p",{"code-path":"src/components/cloud/CloudBillingHelpers.tsx:54:12",className:"text-sm text-slate-500 py-8 text-center",children:"暂无数据"});const i=Math.max(...d.map(c=>c.cost),1),t=d.slice(-30);return e.jsxs("div",{"code-path":"src/components/cloud/CloudBillingHelpers.tsx:60:5",children:[e.jsx("div",{"code-path":"src/components/cloud/CloudBillingHelpers.tsx:61:7",className:"flex items-end gap-0.5 h-40",children:t.map((c,o)=>{const n=Math.max(c.cost/i*100,2);return e.jsxs("div",{"code-path":"src/components/cloud/CloudBillingHelpers.tsx:65:13",className:"flex-1 group relative",style:{height:"100%"},children:[e.jsx("div",{"code-path":"src/components/cloud/CloudBillingHelpers.tsx:70:15",className:"absolute bottom-0 w-full rounded-t-sm bg-gradient-to-t from-blue-600/60 to-blue-400/80 group-hover:from-blue-500 group-hover:to-blue-300 transition-colors",style:{height:`${n}%`}}),e.jsxs("div",{"code-path":"src/components/cloud/CloudBillingHelpers.tsx:74:15",className:"absolute bottom-full left-1/2 -translate-x-1/2 mb-2 hidden group-hover:block whitespace-nowrap text-xs bg-slate-800 text-slate-200 px-2 py-1 rounded border border-slate-700 z-10",children:[c.date,": ",u(c.cost)]})]},o)})}),e.jsxs("div",{"code-path":"src/components/cloud/CloudBillingHelpers.tsx:81:7",className:"flex justify-between mt-2 text-xs text-slate-500",children:[e.jsx("span",{"code-path":"src/components/cloud/CloudBillingHelpers.tsx:82:9",children:t[0]?.date}),e.jsx("span",{"code-path":"src/components/cloud/CloudBillingHelpers.tsx:83:9",children:t[t.length-1]?.date})]})]})}const X={provider:"aliyun",billing_date:"",cost:"",service:"",region:"",account_name:"",description:""};function ze({open:d,onOpenChange:i,editingRecord:t,onSuccess:c}){const[o,n]=a.useState(X),[B,C]=a.useState(!1);a.useEffect(()=>{d&&n(t?{provider:t.provider,billing_date:t.billing_date,cost:t.cost,service:t.service||"",region:t.region||"",account_name:t.account_name||"",description:t.description||""}:{...X,billing_date:new Date().toISOString().slice(0,10)})},[d,t]);const D=async()=>{if(!o.provider||!o.billing_date||!o.cost){p.error("请填写必填字段");return}C(!0);try{const l={...o,cost:parseFloat(o.cost)};t?(await g.remove(t.id),await g.create(l)):await g.create(l),i(!1),c(),p("保存成功")}catch(l){p.error("保存失败",{description:l.message})}finally{C(!1)}};return e.jsx(ee,{"code-path":"src/components/cloud/BillingRecordDialog.tsx:90:5",open:d,onOpenChange:i,children:e.jsxs(se,{"code-path":"src/components/cloud/BillingRecordDialog.tsx:91:7",className:"max-w-md",children:[e.jsxs(le,{"code-path":"src/components/cloud/BillingRecordDialog.tsx:92:9",children:[e.jsx(oe,{"code-path":"src/components/cloud/BillingRecordDialog.tsx:93:11",children:t?"编辑成本记录":"记录成本"}),e.jsx(te,{"code-path":"src/components/cloud/BillingRecordDialog.tsx:94:11",children:"记录一条每日云资源成本"})]}),e.jsxs("div",{"code-path":"src/components/cloud/BillingRecordDialog.tsx:96:9",className:"space-y-3",children:[e.jsxs("div",{"code-path":"src/components/cloud/BillingRecordDialog.tsx:97:11",className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{"code-path":"src/components/cloud/BillingRecordDialog.tsx:98:13",children:[e.jsx(r,{"code-path":"src/components/cloud/BillingRecordDialog.tsx:99:15",className:"text-sm text-slate-300",children:"厂商 *"}),e.jsxs(w,{"code-path":"src/components/cloud/BillingRecordDialog.tsx:100:15",value:o.provider,onValueChange:l=>n({...o,provider:l}),children:[e.jsx(S,{"code-path":"src/components/cloud/BillingRecordDialog.tsx:101:17",className:"mt-1",children:e.jsx(k,{"code-path":"src/components/cloud/BillingRecordDialog.tsx:101:49"})}),e.jsx(_,{"code-path":"src/components/cloud/BillingRecordDialog.tsx:102:17",children:Object.entries(v).map(([l,f])=>e.jsx(h,{"code-path":"src/components/cloud/BillingRecordDialog.tsx:104:21",value:l,children:f},l))})]})]}),e.jsxs("div",{"code-path":"src/components/cloud/BillingRecordDialog.tsx:109:13",children:[e.jsx(r,{"code-path":"src/components/cloud/BillingRecordDialog.tsx:110:15",className:"text-sm text-slate-300",children:"日期 *"}),e.jsx(j,{"code-path":"src/components/cloud/BillingRecordDialog.tsx:111:15",type:"date",className:"mt-1",value:o.billing_date,onChange:l=>n({...o,billing_date:l.target.value})})]})]}),e.jsxs("div",{"code-path":"src/components/cloud/BillingRecordDialog.tsx:114:11",className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{"code-path":"src/components/cloud/BillingRecordDialog.tsx:115:13",children:[e.jsx(r,{"code-path":"src/components/cloud/BillingRecordDialog.tsx:116:15",className:"text-sm text-slate-300",children:"费用(元) *"}),e.jsx(j,{"code-path":"src/components/cloud/BillingRecordDialog.tsx:117:15",type:"number",step:"0.01",className:"mt-1",placeholder:"0.00",value:o.cost,onChange:l=>n({...o,cost:l.target.value})})]}),e.jsxs("div",{"code-path":"src/components/cloud/BillingRecordDialog.tsx:119:13",children:[e.jsx(r,{"code-path":"src/components/cloud/BillingRecordDialog.tsx:120:15",className:"text-sm text-slate-300",children:"服务"}),e.jsx(j,{"code-path":"src/components/cloud/BillingRecordDialog.tsx:121:15",className:"mt-1",placeholder:"ECS, RDS...",value:o.service,onChange:l=>n({...o,service:l.target.value})})]})]}),e.jsxs("div",{"code-path":"src/components/cloud/BillingRecordDialog.tsx:124:11",className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{"code-path":"src/components/cloud/BillingRecordDialog.tsx:125:13",children:[e.jsx(r,{"code-path":"src/components/cloud/BillingRecordDialog.tsx:126:15",className:"text-sm text-slate-300",children:"区域"}),e.jsx(j,{"code-path":"src/components/cloud/BillingRecordDialog.tsx:127:15",className:"mt-1",placeholder:"cn-hangzhou",value:o.region,onChange:l=>n({...o,region:l.target.value})})]}),e.jsxs("div",{"code-path":"src/components/cloud/BillingRecordDialog.tsx:129:13",children:[e.jsx(r,{"code-path":"src/components/cloud/BillingRecordDialog.tsx:130:15",className:"text-sm text-slate-300",children:"账号名称"}),e.jsx(j,{"code-path":"src/components/cloud/BillingRecordDialog.tsx:131:15",className:"mt-1",placeholder:"主账号",value:o.account_name,onChange:l=>n({...o,account_name:l.target.value})})]})]}),e.jsxs("div",{"code-path":"src/components/cloud/BillingRecordDialog.tsx:134:11",children:[e.jsx(r,{"code-path":"src/components/cloud/BillingRecordDialog.tsx:135:13",className:"text-sm text-slate-300",children:"备注"}),e.jsx(j,{"code-path":"src/components/cloud/BillingRecordDialog.tsx:136:13",className:"mt-1",placeholder:"可选",value:o.description,onChange:l=>n({...o,description:l.target.value})})]})]}),e.jsxs(ce,{"code-path":"src/components/cloud/BillingRecordDialog.tsx:139:9",children:[e.jsx(m,{"code-path":"src/components/cloud/BillingRecordDialog.tsx:140:11",variant:"outline",onClick:()=>i(!1),children:"取消"}),e.jsxs(m,{"code-path":"src/components/cloud/BillingRecordDialog.tsx:141:11",onClick:D,disabled:B,children:[B&&e.jsx(R,{"code-path":"src/components/cloud/BillingRecordDialog.tsx:142:28",className:"h-4 w-4 mr-1 animate-spin"}),"保存"]})]})]})})}const Y={name:"",provider:"",metric:"daily",threshold:"",operator:">",enabled:!0};function $e({open:d,onOpenChange:i,editingRule:t,onSuccess:c}){const[o,n]=a.useState(Y),[B,C]=a.useState(!1);a.useEffect(()=>{d&&n(t?{name:t.name,provider:t.provider||"",metric:t.metric||"daily",threshold:t.threshold,operator:t.operator||">",enabled:t.enabled}:{...Y})},[d,t]);const D=async()=>{if(!o.name||!o.threshold){p.error("请填写规则名称和阈值");return}C(!0);try{const l={...o,threshold:parseFloat(o.threshold)};t?await g.updateAlertRule(t.id,l):await g.createAlertRule(l),i(!1),c(),p("保存成功")}catch(l){p.error("保存失败",{description:l.message})}finally{C(!1)}};return e.jsx(ee,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:81:5",open:d,onOpenChange:i,children:e.jsxs(se,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:82:7",className:"max-w-md",children:[e.jsxs(le,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:83:9",children:[e.jsx(oe,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:84:11",children:t?"编辑预警规则":"添加预警规则"}),e.jsx(te,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:85:11",children:"设置成本阈值,超标时自动预警"})]}),e.jsxs("div",{"code-path":"src/components/cloud/BillingRuleDialog.tsx:87:9",className:"space-y-3",children:[e.jsxs("div",{"code-path":"src/components/cloud/BillingRuleDialog.tsx:88:11",children:[e.jsx(r,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:89:13",className:"text-sm text-slate-300",children:"规则名称 *"}),e.jsx(j,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:90:13",className:"mt-1",placeholder:"如:日成本超 500 元预警",value:o.name,onChange:l=>n({...o,name:l.target.value})})]}),e.jsxs("div",{"code-path":"src/components/cloud/BillingRuleDialog.tsx:92:11",className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{"code-path":"src/components/cloud/BillingRuleDialog.tsx:93:13",children:[e.jsx(r,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:94:15",className:"text-sm text-slate-300",children:"厂商"}),e.jsxs(w,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:95:15",value:o.provider||"all",onValueChange:l=>n({...o,provider:l==="all"?"":l}),children:[e.jsx(S,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:96:17",className:"mt-1",children:e.jsx(k,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:96:49"})}),e.jsxs(_,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:97:17",children:[e.jsx(h,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:98:19",value:"all",children:"全部厂商"}),Object.entries(v).map(([l,f])=>e.jsx(h,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:100:21",value:l,children:f},l))]})]})]}),e.jsxs("div",{"code-path":"src/components/cloud/BillingRuleDialog.tsx:105:13",children:[e.jsx(r,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:106:15",className:"text-sm text-slate-300",children:"指标"}),e.jsxs(w,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:107:15",value:o.metric,onValueChange:l=>n({...o,metric:l}),children:[e.jsx(S,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:108:17",className:"mt-1",children:e.jsx(k,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:108:49"})}),e.jsxs(_,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:109:17",children:[e.jsx(h,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:110:19",value:"daily",children:"日成本"}),e.jsx(h,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:111:19",value:"monthly",children:"月累计"})]})]})]})]}),e.jsxs("div",{"code-path":"src/components/cloud/BillingRuleDialog.tsx:116:11",className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{"code-path":"src/components/cloud/BillingRuleDialog.tsx:117:13",children:[e.jsx(r,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:118:15",className:"text-sm text-slate-300",children:"比较"}),e.jsxs(w,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:119:15",value:o.operator,onValueChange:l=>n({...o,operator:l}),children:[e.jsx(S,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:120:17",className:"mt-1",children:e.jsx(k,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:120:49"})}),e.jsxs(_,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:121:17",children:[e.jsx(h,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:122:19",value:">",children:"大于 >"}),e.jsx(h,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:123:19",value:">=",children:"大于等于 ≥"}),e.jsx(h,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:124:19",value:"<",children:"小于 <"}),e.jsx(h,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:125:19",value:"<=",children:"小于等于 ≤"})]})]})]}),e.jsxs("div",{"code-path":"src/components/cloud/BillingRuleDialog.tsx:129:13",children:[e.jsx(r,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:130:15",className:"text-sm text-slate-300",children:"阈值(元) *"}),e.jsx(j,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:131:15",type:"number",step:"0.01",className:"mt-1",placeholder:"500.00",value:o.threshold,onChange:l=>n({...o,threshold:l.target.value})})]})]}),e.jsxs("div",{"code-path":"src/components/cloud/BillingRuleDialog.tsx:134:11",className:"flex items-center gap-2",children:[e.jsx(ne,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:135:13",checked:o.enabled,onCheckedChange:l=>n({...o,enabled:l})}),e.jsx(r,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:136:13",className:"text-sm text-slate-300",children:"启用"})]})]}),e.jsxs(ce,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:139:9",children:[e.jsx(m,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:140:11",variant:"outline",onClick:()=>i(!1),children:"取消"}),e.jsxs(m,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:141:11",onClick:D,disabled:B,children:[B&&e.jsx(R,{"code-path":"src/components/cloud/BillingRuleDialog.tsx:142:28",className:"h-4 w-4 mr-1 animate-spin"}),"保存"]})]})]})})}function Ke(){const d=ye(),[i,t]=a.useState("overview"),[c,o]=a.useState(null),[n,B]=a.useState(!0),[C,D]=a.useState([]),[l,f]=a.useState(!0),[H,ie]=a.useState(""),[z,de]=a.useState(""),[$,re]=a.useState(""),[P,pe]=a.useState([]),[xe,I]=a.useState(!0),[me,L]=a.useState(!1),[ue,W]=a.useState(null),[he,T]=a.useState(!1),[ge,q]=a.useState(null),N=a.useCallback(async()=>{B(!0);try{const s=await g.getStats();o(s)}catch(s){p.error("加载统计失败",{description:s.message})}finally{B(!1)}},[]),b=a.useCallback(async()=>{f(!0);try{const s={};H&&(s.provider=H),z&&(s.start_date=z),$&&(s.end_date=$);const x=await g.list(s);D(x.list||[])}catch(s){p.error("加载账单失败",{description:s.message})}finally{f(!1)}},[H,z,$]),y=a.useCallback(async()=>{I(!0);try{const s=await g.listAlertRules();pe(s.list||[])}catch(s){p.error("加载预警规则失败",{description:s.message})}finally{I(!1)}},[]);a.useEffect(()=>{N()},[N]),a.useEffect(()=>{i==="records"&&b()},[i,b]),a.useEffect(()=>{i==="alerts"&&y()},[i,y]);const je=()=>{W(null),L(!0)},Be=s=>{W(s),L(!0)},Ce=()=>{q(null),T(!0)},ve=s=>{q(s),T(!0)},Ne=async s=>{if(await d({title:"删除账单记录",description:"确定删除这条成本记录?",variant:"destructive"}))try{await g.remove(s),b(),N(),p("删除成功")}catch(F){p.error("删除失败",{description:F.message})}},fe=async s=>{if(await d({title:"删除预警规则",description:"确定删除此预警规则?",variant:"destructive"}))try{await g.deleteAlertRule(s),y(),p("删除成功")}catch(F){p.error("删除失败",{description:F.message})}},be=async s=>{try{await g.toggleAlertRule(s),y(),N()}catch(x){p.error("操作失败",{description:x.message})}};return e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:165:5",className:"space-y-4",children:[e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:166:7",className:"flex items-center justify-between",children:[e.jsx("h2",{"code-path":"src/components/cloud/CloudBilling.tsx:167:9",className:"text-lg font-semibold text-slate-100",children:"云账单管理"}),e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:168:9",className:"flex items-center gap-2",children:[e.jsxs(m,{"code-path":"src/components/cloud/CloudBilling.tsx:169:11",variant:"outline",size:"sm",onClick:()=>{N(),i==="records"&&b(),i==="alerts"&&y()},children:[e.jsx(J,{"code-path":"src/components/cloud/CloudBilling.tsx:170:13",className:"h-4 w-4 mr-1"}),"刷新"]}),i==="records"&&e.jsxs(m,{"code-path":"src/components/cloud/CloudBilling.tsx:173:13",size:"sm",onClick:je,children:[e.jsx(U,{"code-path":"src/components/cloud/CloudBilling.tsx:174:15",className:"h-4 w-4 mr-1"}),"记录成本"]}),i==="alerts"&&e.jsxs(m,{"code-path":"src/components/cloud/CloudBilling.tsx:178:13",size:"sm",onClick:Ce,children:[e.jsx(U,{"code-path":"src/components/cloud/CloudBilling.tsx:179:15",className:"h-4 w-4 mr-1"}),"添加规则"]})]})]}),e.jsx("div",{"code-path":"src/components/cloud/CloudBilling.tsx:185:7",className:"flex gap-1 border-b border-slate-800",children:[{key:"overview",label:"概览统计"},{key:"records",label:"成本记录"},{key:"alerts",label:"预警规则"}].map(s=>e.jsx("button",{"code-path":"src/components/cloud/CloudBilling.tsx:191:11",onClick:()=>t(s.key),className:`px-4 py-2 text-sm font-medium transition-colors border-b-2 -mb-px ${i===s.key?"text-blue-400 border-blue-400":"text-slate-400 border-transparent hover:text-slate-200"}`,children:s.label},s.key))}),i==="overview"&&e.jsx("div",{"code-path":"src/components/cloud/CloudBilling.tsx:206:9",className:"space-y-4",children:n?e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:208:13",className:"flex items-center justify-center py-20 text-slate-500",children:[e.jsx(R,{"code-path":"src/components/cloud/CloudBilling.tsx:208:84",className:"h-6 w-6 animate-spin mr-2"}),"加载中..."]}):c?e.jsxs(e.Fragment,{children:[e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:211:15",className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-3",children:[e.jsx(E,{"code-path":"src/components/cloud/CloudBilling.tsx:212:17",icon:e.jsx(Q,{"code-path":"src/components/cloud/CloudBilling.tsx:213:25",className:"h-5 w-5"}),label:"今日成本",value:u(c.today_cost||0),trend:c.today_cost-(c.yesterday_cost||0),trendLabel:`昨日 ${u(c.yesterday_cost||0)}`}),e.jsx(E,{"code-path":"src/components/cloud/CloudBilling.tsx:219:17",icon:e.jsx(ke,{"code-path":"src/components/cloud/CloudBilling.tsx:220:25",className:"h-5 w-5"}),label:"本月成本",value:u(c.month_cost||0)}),e.jsx(E,{"code-path":"src/components/cloud/CloudBilling.tsx:224:17",icon:e.jsx(ae,{"code-path":"src/components/cloud/CloudBilling.tsx:225:25",className:"h-5 w-5"}),label:"年度成本",value:u(c.year_cost||0)}),e.jsx(E,{"code-path":"src/components/cloud/CloudBilling.tsx:229:17",icon:e.jsx(De,{"code-path":"src/components/cloud/CloudBilling.tsx:230:25",className:"h-5 w-5"}),label:"活跃预警",value:`${c.alerts?.length||0} 条`,alert:c.alerts?.length>0})]}),c.alerts?.length>0&&e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:238:17",className:"rounded-lg border border-amber-500/30 bg-amber-500/5 p-4",children:[e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:239:19",className:"flex items-center gap-2 mb-3",children:[e.jsx(M,{"code-path":"src/components/cloud/CloudBilling.tsx:240:21",className:"h-4 w-4 text-amber-400"}),e.jsx("span",{"code-path":"src/components/cloud/CloudBilling.tsx:241:21",className:"text-sm font-medium text-amber-300",children:"成本预警"})]}),e.jsx("div",{"code-path":"src/components/cloud/CloudBilling.tsx:243:19",className:"space-y-2",children:c.alerts.map((s,x)=>e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:245:23",className:"flex items-center justify-between text-sm",children:[e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:246:25",className:"flex items-center gap-2",children:[e.jsx(Re,{"code-path":"src/components/cloud/CloudBilling.tsx:247:27",variant:"outline",className:"border-amber-500/50 text-amber-300",children:s.rule_name}),e.jsxs("span",{"code-path":"src/components/cloud/CloudBilling.tsx:248:27",className:"text-slate-400",children:[s.provider," · ",s.metric==="daily"?"日":"月","成本"]})]}),e.jsxs("span",{"code-path":"src/components/cloud/CloudBilling.tsx:252:25",className:"text-slate-300",children:["当前 ",e.jsx("span",{"code-path":"src/components/cloud/CloudBilling.tsx:253:30",className:"text-amber-300 font-medium",children:u(s.current)})," ",s.operator," ","阈值 ",e.jsx("span",{"code-path":"src/components/cloud/CloudBilling.tsx:255:30",className:"text-red-400 font-medium",children:u(s.threshold)})]})]},x))})]}),e.jsx(A,{"code-path":"src/components/cloud/CloudBilling.tsx:263:15",className:"bg-slate-900/50 border-slate-800",children:e.jsxs(V,{"code-path":"src/components/cloud/CloudBilling.tsx:264:17",className:"pt-4",children:[e.jsx("h3",{"code-path":"src/components/cloud/CloudBilling.tsx:265:19",className:"text-sm font-medium text-slate-200 mb-4",children:"近 30 天成本趋势"}),e.jsx(He,{"code-path":"src/components/cloud/CloudBilling.tsx:266:19",data:c.month_trend||[]})]})}),e.jsx(A,{"code-path":"src/components/cloud/CloudBilling.tsx:270:15",className:"bg-slate-900/50 border-slate-800",children:e.jsxs(V,{"code-path":"src/components/cloud/CloudBilling.tsx:271:17",className:"pt-4",children:[e.jsx("h3",{"code-path":"src/components/cloud/CloudBilling.tsx:272:19",className:"text-sm font-medium text-slate-200 mb-4",children:"本月厂商成本分布"}),(c.provider_dist||[]).length===0?e.jsx("p",{"code-path":"src/components/cloud/CloudBilling.tsx:274:21",className:"text-sm text-slate-500 py-8 text-center",children:"暂无数据"}):e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:276:21",className:"space-y-3",children:[e.jsx("div",{"code-path":"src/components/cloud/CloudBilling.tsx:277:23",className:"flex h-8 rounded-lg overflow-hidden",children:c.provider_dist.map((s,x)=>e.jsx("div",{"code-path":"src/components/cloud/CloudBilling.tsx:279:27",className:`${O[s.provider]||"bg-slate-600"} flex items-center justify-center text-xs text-white font-medium`,style:{width:`${s.percent}%`},title:`${v[s.provider]||s.provider}: ${u(s.cost)} (${s.percent.toFixed(1)}%)`,children:s.percent>8?v[s.provider]||s.provider:""},x))}),e.jsx("div",{"code-path":"src/components/cloud/CloudBilling.tsx:289:23",className:"grid grid-cols-2 md:grid-cols-3 gap-2",children:c.provider_dist.map((s,x)=>e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:291:27",className:"flex items-center justify-between text-sm",children:[e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:292:29",className:"flex items-center gap-2",children:[e.jsx("div",{"code-path":"src/components/cloud/CloudBilling.tsx:293:31",className:`w-3 h-3 rounded ${O[s.provider]||"bg-slate-600"}`}),e.jsx("span",{"code-path":"src/components/cloud/CloudBilling.tsx:294:31",className:"text-slate-300",children:v[s.provider]||s.provider})]}),e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:296:29",className:"text-right",children:[e.jsx("span",{"code-path":"src/components/cloud/CloudBilling.tsx:297:31",className:"text-slate-200 font-medium",children:u(s.cost)}),e.jsxs("span",{"code-path":"src/components/cloud/CloudBilling.tsx:298:31",className:"text-slate-500 ml-2",children:[s.percent.toFixed(1),"%"]})]})]},x))})]})]})})]}):null}),i==="records"&&e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:313:9",className:"space-y-3",children:[e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:314:11",className:"flex flex-wrap items-end gap-3",children:[e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:315:13",children:[e.jsx(r,{"code-path":"src/components/cloud/CloudBilling.tsx:316:15",className:"text-xs text-slate-400 mb-1",children:"厂商"}),e.jsxs(w,{"code-path":"src/components/cloud/CloudBilling.tsx:317:15",value:H||"all",onValueChange:s=>ie(s==="all"?"":s),children:[e.jsx(S,{"code-path":"src/components/cloud/CloudBilling.tsx:318:17",className:"w-32 h-9",children:e.jsx(k,{"code-path":"src/components/cloud/CloudBilling.tsx:318:53"})}),e.jsxs(_,{"code-path":"src/components/cloud/CloudBilling.tsx:319:17",children:[e.jsx(h,{"code-path":"src/components/cloud/CloudBilling.tsx:320:19",value:"all",children:"全部"}),Object.entries(v).map(([s,x])=>e.jsx(h,{"code-path":"src/components/cloud/CloudBilling.tsx:322:21",value:s,children:x},s))]})]})]}),e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:327:13",children:[e.jsx(r,{"code-path":"src/components/cloud/CloudBilling.tsx:328:15",className:"text-xs text-slate-400 mb-1",children:"开始日期"}),e.jsx(j,{"code-path":"src/components/cloud/CloudBilling.tsx:329:15",type:"date",className:"w-40 h-9",value:z,onChange:s=>de(s.target.value)})]}),e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:331:13",children:[e.jsx(r,{"code-path":"src/components/cloud/CloudBilling.tsx:332:15",className:"text-xs text-slate-400 mb-1",children:"结束日期"}),e.jsx(j,{"code-path":"src/components/cloud/CloudBilling.tsx:333:15",type:"date",className:"w-40 h-9",value:$,onChange:s=>re(s.target.value)})]}),e.jsxs(m,{"code-path":"src/components/cloud/CloudBilling.tsx:335:13",variant:"outline",size:"sm",onClick:b,children:[e.jsx(J,{"code-path":"src/components/cloud/CloudBilling.tsx:336:15",className:"h-4 w-4 mr-1"}),"查询"]})]}),l?e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:341:13",className:"flex items-center justify-center py-20 text-slate-500",children:[e.jsx(R,{"code-path":"src/components/cloud/CloudBilling.tsx:341:84",className:"h-6 w-6 animate-spin mr-2"}),"加载中..."]}):C.length===0?e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:343:13",className:"py-20 text-center text-slate-500",children:[e.jsx(Q,{"code-path":"src/components/cloud/CloudBilling.tsx:344:15",className:"h-12 w-12 mx-auto mb-3 opacity-30"}),e.jsx("p",{"code-path":"src/components/cloud/CloudBilling.tsx:345:15",className:"text-sm",children:"暂无成本记录"})]}):e.jsx("div",{"code-path":"src/components/cloud/CloudBilling.tsx:348:13",className:"overflow-x-auto rounded-lg border border-slate-800",children:e.jsxs("table",{"code-path":"src/components/cloud/CloudBilling.tsx:349:15",className:"w-full text-sm",children:[e.jsx("thead",{"code-path":"src/components/cloud/CloudBilling.tsx:350:17",className:"bg-slate-900/80 text-slate-400",children:e.jsxs("tr",{"code-path":"src/components/cloud/CloudBilling.tsx:351:19",children:[e.jsx("th",{"code-path":"src/components/cloud/CloudBilling.tsx:352:21",className:"px-4 py-2.5 text-left font-medium",children:"日期"}),e.jsx("th",{"code-path":"src/components/cloud/CloudBilling.tsx:353:21",className:"px-4 py-2.5 text-left font-medium",children:"厂商"}),e.jsx("th",{"code-path":"src/components/cloud/CloudBilling.tsx:354:21",className:"px-4 py-2.5 text-left font-medium",children:"服务"}),e.jsx("th",{"code-path":"src/components/cloud/CloudBilling.tsx:355:21",className:"px-4 py-2.5 text-left font-medium",children:"区域"}),e.jsx("th",{"code-path":"src/components/cloud/CloudBilling.tsx:356:21",className:"px-4 py-2.5 text-left font-medium",children:"账号"}),e.jsx("th",{"code-path":"src/components/cloud/CloudBilling.tsx:357:21",className:"px-4 py-2.5 text-right font-medium",children:"费用"}),e.jsx("th",{"code-path":"src/components/cloud/CloudBilling.tsx:358:21",className:"px-4 py-2.5 text-left font-medium",children:"说明"}),e.jsx("th",{"code-path":"src/components/cloud/CloudBilling.tsx:359:21",className:"px-4 py-2.5 text-center font-medium",children:"操作"})]})}),e.jsx("tbody",{"code-path":"src/components/cloud/CloudBilling.tsx:362:17",children:C.map(s=>e.jsxs("tr",{"code-path":"src/components/cloud/CloudBilling.tsx:364:21",className:"border-t border-slate-800 hover:bg-slate-800/30",children:[e.jsx("td",{"code-path":"src/components/cloud/CloudBilling.tsx:365:23",className:"px-4 py-2.5 text-slate-300",children:s.billing_date}),e.jsx("td",{"code-path":"src/components/cloud/CloudBilling.tsx:366:23",className:"px-4 py-2.5",children:e.jsxs("span",{"code-path":"src/components/cloud/CloudBilling.tsx:367:25",className:"inline-flex items-center gap-1.5",children:[e.jsx("span",{"code-path":"src/components/cloud/CloudBilling.tsx:368:27",className:`w-2 h-2 rounded-full ${O[s.provider]||"bg-slate-500"}`}),v[s.provider]||s.provider]})}),e.jsx("td",{"code-path":"src/components/cloud/CloudBilling.tsx:372:23",className:"px-4 py-2.5 text-slate-400",children:s.service||"-"}),e.jsx("td",{"code-path":"src/components/cloud/CloudBilling.tsx:373:23",className:"px-4 py-2.5 text-slate-400",children:s.region||"-"}),e.jsx("td",{"code-path":"src/components/cloud/CloudBilling.tsx:374:23",className:"px-4 py-2.5 text-slate-400",children:s.account_name||"-"}),e.jsx("td",{"code-path":"src/components/cloud/CloudBilling.tsx:375:23",className:"px-4 py-2.5 text-right text-slate-200 font-medium",children:u(s.cost)}),e.jsx("td",{"code-path":"src/components/cloud/CloudBilling.tsx:376:23",className:"px-4 py-2.5 text-slate-500 max-w-xs truncate",children:s.description||"-"}),e.jsx("td",{"code-path":"src/components/cloud/CloudBilling.tsx:377:23",className:"px-4 py-2.5",children:e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:378:25",className:"flex items-center justify-center gap-1",children:[e.jsx(m,{"code-path":"src/components/cloud/CloudBilling.tsx:379:27",variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>Be(s),children:e.jsx(G,{"code-path":"src/components/cloud/CloudBilling.tsx:380:29",className:"h-3.5 w-3.5"})}),e.jsx(m,{"code-path":"src/components/cloud/CloudBilling.tsx:382:27",variant:"ghost",size:"icon",className:"h-7 w-7 text-red-400 hover:text-red-300",onClick:()=>Ne(s.id),children:e.jsx(K,{"code-path":"src/components/cloud/CloudBilling.tsx:383:29",className:"h-3.5 w-3.5"})})]})})]},s.id))})]})})]}),i==="alerts"&&e.jsx("div",{"code-path":"src/components/cloud/CloudBilling.tsx:397:9",className:"space-y-3",children:xe?e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:399:13",className:"flex items-center justify-center py-20 text-slate-500",children:[e.jsx(R,{"code-path":"src/components/cloud/CloudBilling.tsx:399:84",className:"h-6 w-6 animate-spin mr-2"}),"加载中..."]}):P.length===0?e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:401:13",className:"py-20 text-center text-slate-500",children:[e.jsx(M,{"code-path":"src/components/cloud/CloudBilling.tsx:402:15",className:"h-12 w-12 mx-auto mb-3 opacity-30"}),e.jsx("p",{"code-path":"src/components/cloud/CloudBilling.tsx:403:15",className:"text-sm",children:"暂无预警规则"})]}):e.jsx("div",{"code-path":"src/components/cloud/CloudBilling.tsx:406:13",className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:P.map(s=>e.jsx(A,{"code-path":"src/components/cloud/CloudBilling.tsx:408:17",className:"bg-slate-900/50 border-slate-800",children:e.jsxs(V,{"code-path":"src/components/cloud/CloudBilling.tsx:409:19",className:"pt-4",children:[e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:410:21",className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:411:23",className:"flex items-center gap-2",children:[e.jsx(M,{"code-path":"src/components/cloud/CloudBilling.tsx:412:25",className:`h-4 w-4 ${s.enabled?"text-amber-400":"text-slate-600"}`}),e.jsx("span",{"code-path":"src/components/cloud/CloudBilling.tsx:413:25",className:"text-sm font-medium text-slate-200",children:s.name})]}),e.jsx(ne,{"code-path":"src/components/cloud/CloudBilling.tsx:415:23",checked:s.enabled,onCheckedChange:()=>be(s.id)})]}),e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:417:21",className:"grid grid-cols-2 gap-2 text-sm",children:[e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:418:23",children:[e.jsx("span",{"code-path":"src/components/cloud/CloudBilling.tsx:419:25",className:"text-slate-500",children:"厂商"}),e.jsx("span",{"code-path":"src/components/cloud/CloudBilling.tsx:420:25",className:"ml-2 text-slate-300",children:s.provider?v[s.provider]||s.provider:"全部"})]}),e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:422:23",children:[e.jsx("span",{"code-path":"src/components/cloud/CloudBilling.tsx:423:25",className:"text-slate-500",children:"指标"}),e.jsx("span",{"code-path":"src/components/cloud/CloudBilling.tsx:424:25",className:"ml-2 text-slate-300",children:s.metric==="daily"?"日成本":"月累计"})]}),e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:426:23",children:[e.jsx("span",{"code-path":"src/components/cloud/CloudBilling.tsx:427:25",className:"text-slate-500",children:"阈值"}),e.jsxs("span",{"code-path":"src/components/cloud/CloudBilling.tsx:428:25",className:"ml-2 text-amber-300 font-medium",children:[s.operator," ",u(s.threshold)]})]}),s.last_triggered&&e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:431:25",children:[e.jsx("span",{"code-path":"src/components/cloud/CloudBilling.tsx:432:27",className:"text-slate-500",children:"最后触发"}),e.jsx("span",{"code-path":"src/components/cloud/CloudBilling.tsx:433:27",className:"ml-2 text-slate-400",children:new Date(s.last_triggered).toLocaleString("zh-CN")})]})]}),e.jsxs("div",{"code-path":"src/components/cloud/CloudBilling.tsx:437:21",className:"flex justify-end gap-1 mt-3",children:[e.jsx(m,{"code-path":"src/components/cloud/CloudBilling.tsx:438:23",variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>ve(s),children:e.jsx(G,{"code-path":"src/components/cloud/CloudBilling.tsx:439:25",className:"h-3.5 w-3.5"})}),e.jsx(m,{"code-path":"src/components/cloud/CloudBilling.tsx:441:23",variant:"ghost",size:"icon",className:"h-7 w-7 text-red-400 hover:text-red-300",onClick:()=>fe(s.id),children:e.jsx(K,{"code-path":"src/components/cloud/CloudBilling.tsx:442:25",className:"h-3.5 w-3.5"})})]})]})},s.id))})}),e.jsx(ze,{"code-path":"src/components/cloud/CloudBilling.tsx:453:7",open:me,onOpenChange:L,editingRecord:ue,onSuccess:()=>{b(),N()}}),e.jsx($e,{"code-path":"src/components/cloud/CloudBilling.tsx:459:7",open:he,onOpenChange:T,editingRule:ge,onSuccess:()=>{y(),N()}})]})}export{Ke as CloudBilling};
|