mirror of
https://gitee.com/270580156/weiyu.git
synced 2026-05-14 19:27:53 +00:00
1 line
12 KiB
JavaScript
1 line
12 KiB
JavaScript
"use strict";(self.webpackChunkadmin=self.webpackChunkadmin||[]).push([[1902],{49910:function(e,t,r){r.d(t,{bU:function(){return b},eT:function(){return l},oH:function(){return h},x:function(){return m}});var n=r(90819),s=r.n(n),a=r(73193),i=r.n(a),o=r(89933),c=r.n(o),d=r(25191),u=r(75699);function l(e){return f.apply(this,arguments)}function f(){return(f=c()(s()().mark((function e(t){return s()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",(0,u.request)("/api/v1/browse/query/org",{method:"GET",params:i()(i()({},t),{},{channel:d.XtJ})}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function m(e){return p.apply(this,arguments)}function p(){return(p=c()(s()().mark((function e(t){return s()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",(0,u.request)("/api/v1/browse/create",{method:"POST",data:i()(i()({},t),{},{channel:d.XtJ})}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function b(e){return g.apply(this,arguments)}function g(){return(g=c()(s()().mark((function e(t){return s()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",(0,u.request)("/api/v1/browse/update",{method:"POST",data:i()(i()({},t),{},{channel:d.XtJ})}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function h(e){return x.apply(this,arguments)}function x(){return(x=c()(s()().mark((function e(t){return s()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",(0,u.request)("/api/v1/browse/delete",{method:"POST",data:i()(i()({},t),{},{channel:d.XtJ})}));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}},84104:function(e,t,r){r.r(t);var n=r(73193),s=r.n(n),a=r(90819),i=r.n(a),o=r(89933),c=r.n(o),d=r(45332),u=r.n(d),l=r(44194),f=r(41123),m=r(43443),p=r(63065),b=r(43413),g=r(10337),h=r(77407),x=r(5858),v=r(9248),y=r(14318),w=r(3867),j=r(79640),M=r(68525),k=r(35911),Z=r(58896),D=r(57039),Y=r(7083),S=r(31881),O=r(49910),I=r(28977),R=r.n(I),T=r(75699),B=r(31549),C=f.default.RangePicker;t.default=function(){var e=(0,T.useIntl)(),t=(0,S.u)((function(e){return e.currentOrg})),r=(0,l.useState)(!1),n=u()(r,2),a=n[0],o=n[1],d=(0,l.useState)(null),f=u()(d,2),I=f[0],q=f[1],A=(0,l.useState)([]),V=u()(A,2),z=V[0],E=V[1],P=(0,l.useState)({current:1,pageSize:10,total:0}),F=u()(P,2),J=F[0],W=F[1],X=(0,l.useState)(0),H=u()(X,2),L=H[0],G=H[1],U=(0,l.useState)(R()().startOf("day")),K=u()(U,2),N=K[0],Q=K[1],$=(0,l.useState)(R()().endOf("day")),_=u()($,2),ee=_[0],te=_[1],re=(0,l.useState)("today"),ne=u()(re,2),se=ne[0],ae=ne[1],ie=(0,l.useState)([R()().startOf("day"),R()().endOf("day")]),oe=u()(ie,2),ce=oe[0],de=oe[1],ue=[{label:(0,B.jsx)(T.FormattedMessage,{id:"ticket.statistic.timeRange.today"}),value:"today"},{label:(0,B.jsx)(T.FormattedMessage,{id:"ticket.statistic.timeRange.yesterday"}),value:"yesterday"},{label:(0,B.jsx)(T.FormattedMessage,{id:"ticket.statistic.timeRange.week"}),value:"week"},{label:(0,B.jsx)(T.FormattedMessage,{id:"ticket.statistic.timeRange.lastWeek"}),value:"lastWeek"},{label:(0,B.jsx)(T.FormattedMessage,{id:"ticket.statistic.timeRange.month"}),value:"month"},{label:(0,B.jsx)(T.FormattedMessage,{id:"ticket.statistic.timeRange.custom"}),value:"custom"}];(0,l.useEffect)((function(){if("custom"===se)Q(N),te(ee);else{var e=R()();"today"===se?(Q(e.startOf("day")),te(e.endOf("day"))):"yesterday"===se?(Q(e.subtract(1,"day").startOf("day")),te(e.subtract(1,"day").endOf("day"))):"week"===se?(Q(e.startOf("week")),te(e.endOf("week"))):"lastWeek"===se?(Q(e.subtract(1,"week").startOf("week")),te(e.subtract(1,"week").endOf("week"))):"month"===se&&(Q(e.startOf("month")),te(e.endOf("month")))}}),[se]),(0,l.useEffect)((function(){de([N,ee])}),[N,ee]);var le=function(){var e=c()(i()().mark((function e(){var r,n,s,a,c,d,l,f=arguments;return i()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=f.length>0&&void 0!==f[0]?f[0]:1,n=f.length>1&&void 0!==f[1]?f[1]:10,null!=t&&t.uid){e.next=4;break}return e.abrupt("return");case 4:return o(!0),e.prev=5,s={orgUid:t.uid,pageNumber:r-1,pageSize:n,sortBy:"createdAt",sortDirection:"descend"},ce&&2===ce.length&&(a=u()(ce,2),c=a[0],d=a[1],c&&d&&(s.startDate=c.format("YYYY-MM-DD"),s.endDate=d.format("YYYY-MM-DD"))),e.next=10,(0,O.eT)(s);case 10:l=e.sent,console.log("queryBrowsesByOrg response:",l.data,s),200===l.code&&l.data&&(E(l.data.content||[]),G(l.data.totalElements||0),W({current:r,pageSize:n,total:l.data.totalElements||0})),e.next=19;break;case 15:e.prev=15,e.t0=e.catch(5),console.error("获取浏览数据失败:",e.t0),q("获取数据失败,请稍后重试");case 19:return e.prev=19,o(!1),e.finish(19);case 22:case"end":return e.stop()}}),e,null,[[5,15,19,22]])})));return function(){return e.apply(this,arguments)}}();(0,l.useEffect)((function(){le()}),[null==t?void 0:t.uid,ce]);var fe=[{title:e.formatMessage({id:"bi.browse.table.visitTime"}),dataIndex:"createdAt",key:"createdAt",render:function(e){return e?R()(e).format("YYYY-MM-DD HH:mm:ss"):"-"}},{title:e.formatMessage({id:"bi.browse.table.visitor"}),dataIndex:["visitor","nickname"],key:"visitor",render:function(t,r){var n;return(0,B.jsx)("span",{children:t||(null===(n=r.visitor)||void 0===n?void 0:n.uid)||e.formatMessage({id:"bi.browse.anonymousVisitor"})})}},{title:e.formatMessage({id:"bi.browse.table.visitPage"}),dataIndex:"title",key:"title",render:function(e,t){return(0,B.jsxs)("div",{children:[(0,B.jsx)("div",{children:e||t.url||"-"}),t.url&&(0,B.jsx)("div",{style:{fontSize:"12px",color:"#666"},children:t.url.length>50?t.url.substring(0,50)+"...":t.url})]})}},{title:e.formatMessage({id:"bi.browse.table.duration"}),dataIndex:"duration",key:"duration",render:function(t){if(!t)return"-";var r=Math.floor(t/60),n=t%60;return"".concat(r).concat(e.formatMessage({id:"bi.time.minute"})).concat(n).concat(e.formatMessage({id:"bi.time.second"}))}},{title:e.formatMessage({id:"bi.browse.table.deviceType"}),dataIndex:"deviceType",key:"deviceType",render:function(t){var r={desktop:e.formatMessage({id:"bi.browse.device.desktop"}),mobile:e.formatMessage({id:"bi.browse.device.mobile"}),tablet:e.formatMessage({id:"bi.browse.device.tablet"})};return(0,B.jsx)(m.Z,{color:"mobile"===t?"purple":"desktop"===t?"cyan":"orange",children:r[t]||t||e.formatMessage({id:"bi.browse.device.unknown"})})}},{title:e.formatMessage({id:"bi.browse.table.browser"}),dataIndex:"browser",key:"browser",render:function(e){return e||"-"}},{title:e.formatMessage({id:"bi.browse.table.ipAddress"}),dataIndex:"ipAddress",key:"ipAddress",render:function(e){return e||"-"}},{title:e.formatMessage({id:"bi.browse.table.source"}),dataIndex:"utmSource",key:"utmSource",render:function(t,r){var n=t||(r.referrer?e.formatMessage({id:"bi.browse.source.external"}):e.formatMessage({id:"bi.browse.source.direct"}));return(0,B.jsx)(m.Z,{color:"blue",children:n})}}],me=function(){if(!z.length)return{totalVisits:0,uniqueVisitors:0,avgDuration:0,bounceRate:0};var e=L,t=new Set(z.map((function(e){var t;return null===(t=e.visitor)||void 0===t?void 0:t.uid})).filter(Boolean)).size,r=z.reduce((function(e,t){return e+(t.duration||0)}),0),n=e>0?Math.round(r/e):0,s=z.filter((function(e){return(e.duration||0)<10})).length;return{totalVisits:e,uniqueVisitors:t,avgDuration:n,bounceRate:e>0?Math.round(s/e*100):0}}(),pe=function(){var t=new Map;z.forEach((function(r){var n=r.utmSource||r.referrer?e.formatMessage({id:"bi.browse.source.external"}):e.formatMessage({id:"bi.browse.source.direct"});t.set(n,(t.get(n)||0)+1)}));var r=z.length;return Array.from(t.entries()).map((function(e){var t=u()(e,2),n=t[0],s=t[1];return{source:n,visits:s,percentage:r>0?Math.round(s/r*100):0}}))}(),be=function(){var t=new Map;z.forEach((function(r){var n=r.deviceType||e.formatMessage({id:"bi.browse.device.unknown"});t.set(n,(t.get(n)||0)+1)}));var r=z.length;return Array.from(t.entries()).map((function(t){var n=u()(t,2),s=n[0],a=n[1];return{device:"desktop"===s?e.formatMessage({id:"bi.browse.device.desktop"}):"mobile"===s?e.formatMessage({id:"bi.browse.device.mobile"}):"tablet"===s?e.formatMessage({id:"bi.browse.device.tablet"}):s,visits:a,percentage:r>0?Math.round(a/r*100):0}}))}();return(0,B.jsxs)("div",{style:{padding:"24px"},children:[(0,B.jsxs)("div",{style:{marginBottom:"24px"},children:[(0,B.jsx)("h2",{children:e.formatMessage({id:"bi.browse.title"})}),(0,B.jsxs)("p",{children:[e.formatMessage({id:"bi.browse.description"}),"today"===se&&(0,B.jsxs)("span",{style:{color:"#666",marginLeft:8},children:["(",N.format("YYYY-MM-DD"),")"]}),"yesterday"===se&&(0,B.jsxs)("span",{style:{color:"#666",marginLeft:8},children:["(",N.format("YYYY-MM-DD"),")"]}),("week"===se||"lastWeek"===se||"month"===se||"custom"===se)&&(0,B.jsxs)("span",{style:{color:"#666",marginLeft:8},children:["(",N.format("YYYY-MM-DD")," ~ ",ee.format("YYYY-MM-DD"),")"]})]})]}),(0,B.jsx)(p.Z,{style:{marginBottom:"24px"},children:(0,B.jsx)(b.Z,{direction:"vertical",style:{width:"100%"},children:(0,B.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[(0,B.jsxs)(b.Z,{wrap:!0,children:[(0,B.jsx)(g.ZP.Group,{value:se,onChange:function(e){return ae(e.target.value)},children:ue.map((function(e){return(0,B.jsx)(g.ZP.Button,{value:e.value,children:e.label},e.value)}))}),"custom"===se&&(0,B.jsx)(C,{value:ce,onChange:function(e){e&&2===e.length&&de([e[0],e[1]])}})]}),(0,B.jsx)(h.ZP,{type:"primary",icon:(0,B.jsx)(k.Z,{}),onClick:function(){return le()},loading:a,children:e.formatMessage({id:"bi.common.refresh"})})]})})}),(0,B.jsxs)(x.Z,{gutter:16,style:{marginBottom:"24px"},children:[(0,B.jsx)(v.Z,{span:6,children:(0,B.jsx)(p.Z,{children:(0,B.jsx)(y.Z,{title:e.formatMessage({id:"bi.browse.card.totalVisits"}),value:me.totalVisits,prefix:(0,B.jsx)(Z.Z,{}),valueStyle:{color:"#3f8600"}})})}),(0,B.jsx)(v.Z,{span:6,children:(0,B.jsx)(p.Z,{children:(0,B.jsx)(y.Z,{title:e.formatMessage({id:"bi.browse.card.uniqueVisitors"}),value:me.uniqueVisitors,prefix:(0,B.jsx)(D.Z,{}),valueStyle:{color:"#1890ff"}})})}),!1,(0,B.jsx)(v.Z,{span:6,children:(0,B.jsx)(p.Z,{children:(0,B.jsx)(y.Z,{title:e.formatMessage({id:"bi.browse.card.bounceRate"}),value:me.bounceRate,prefix:(0,B.jsx)(Y.Z,{}),valueStyle:{color:me.bounceRate<30?"#3f8600":me.bounceRate<50?"#faad14":"#ff4d4f"},suffix:"%"})})})]}),(0,B.jsxs)(x.Z,{gutter:16,style:{marginBottom:"24px"},children:[(0,B.jsx)(v.Z,{span:12,children:(0,B.jsx)(p.Z,{title:e.formatMessage({id:"bi.browse.sourceDistribution"}),children:(0,B.jsx)("div",{style:{height:300},children:pe.length>0?pe.map((function(e,t){return(0,B.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:12},children:[(0,B.jsx)("span",{children:e.source}),(0,B.jsxs)("div",{style:{display:"flex",alignItems:"center"},children:[(0,B.jsx)("span",{style:{marginRight:8},children:e.visits}),(0,B.jsxs)("span",{style:{color:"#666"},children:["(",e.percentage,"%)"]})]})]},t)})):(0,B.jsx)("div",{style:{textAlign:"center",color:"#999",marginTop:100},children:e.formatMessage({id:"bi.common.noData"})})})})}),(0,B.jsx)(v.Z,{span:12,children:(0,B.jsx)(p.Z,{title:e.formatMessage({id:"bi.browse.deviceDistribution"}),children:(0,B.jsx)("div",{style:{height:300},children:be.length>0?be.map((function(e,t){return(0,B.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:12},children:[(0,B.jsx)("span",{children:e.device}),(0,B.jsxs)("div",{style:{display:"flex",alignItems:"center"},children:[(0,B.jsx)("span",{style:{marginRight:8},children:e.visits}),(0,B.jsxs)("span",{style:{color:"#666"},children:["(",e.percentage,"%)"]})]})]},t)})):(0,B.jsx)("div",{style:{textAlign:"center",color:"#999",marginTop:100},children:e.formatMessage({id:"bi.common.noData"})})})})})]}),(0,B.jsx)(p.Z,{title:e.formatMessage({id:"bi.browse.detailData"}),children:(0,B.jsxs)(w.Z,{spinning:a,children:[I&&(0,B.jsx)(j.Z,{message:e.formatMessage({id:"bi.common.error"}),description:I,type:"error",showIcon:!0,style:{marginBottom:16},closable:!0,onClose:function(){return q(null)}}),!(null!=t&&t.uid)&&(0,B.jsx)(j.Z,{message:e.formatMessage({id:"bi.common.selectOrg"}),description:e.formatMessage({id:"bi.browse.selectOrgDescription"}),type:"warning",showIcon:!0,style:{marginBottom:16}}),0===z.length&&!a&&!I&&(0,B.jsx)(j.Z,{message:e.formatMessage({id:"bi.common.noData"}),description:e.formatMessage({id:"bi.browse.noDataDescription"}),type:"info",showIcon:!0,style:{marginBottom:16}}),(0,B.jsx)(M.Z,{columns:fe,dataSource:z,pagination:s()(s()({},J),{},{showSizeChanger:!0,showQuickJumper:!0,showTotal:function(e,t){return"".concat(t[0],"-").concat(t[1]," of ").concat(e," items")}}),onChange:function(e){le(e.current,e.pageSize)},size:"middle",rowKey:"uid",locale:{emptyText:e.formatMessage({id:"bi.common.noData"})}})]})})]})}}}]); |