@topthink/common 1.0.17 → 1.0.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{jsx as e,jsxs as c,Fragment as n}from"react/jsx-runtime";import t,{SubMenu as i,MenuItem as r}from"rc-menu";import o from"styled-components";import{useRoutes as a,useLocation as l,Link as s,BrowserRouter as d,Routes as h,Route as u,Navigate as m}from"react-router-dom";import g,{useMemo as v,useEffect as p,useState as f,useContext as b,Children as x,useCallback as y,createElement as w,forwardRef as _,useRef as k,useImperativeHandle as z,Fragment as C}from"react";import"rc-menu/assets/index.css";import N from"sweetalert2/dist/sweetalert2.js";import S from"sweetalert2-react-content";import{Dropdown as j,Spinner as I,Card as A,Alert as D,Button as E,Pagination as P,Table as B,Modal as F}from"react-bootstrap";import O from"query-string";import M from"axios";import*as T from"retry-axios";import L from"classnames";import{intersection as U,mapValues as q}from"lodash";import H from"@topthink/json-form";import K from"rc-table";import{useAsyncCallback as R}from"react-async-hook";function V(e,c){return c||(c=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(c)}}))}var G;const Y=o.footer(G||(G=V(["\n\n"])));function $(){return e(Y,{children:e("div",{className:"container"},void 0)},void 0)}const J=function(e){let c=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"/";const n=[];for(const o of e){var t,i,r;if(null!==(t=o.meta)&&void 0!==t&&t.hideInMenu)continue;const e=null===(i=o.meta)||void 0===i?void 0:i.title;if(!e)continue;let a=o.path||"";a="".concat(c,"/").concat(a),a=a.replace(/\/+/,"/").replace(/\/$/,"");const l={title:e,path:a,children:[]};null!==(r=o.meta)&&void 0!==r&&r.hideChildrenInMenu||o.children&&o.children.length>0&&(l.children=J(o.children,a)),n.push(l)}return n};var Q,W,X,Z,ee,ce;const ne=c=>c.map((c=>c.children.length>0?e(i,{title:c.title,children:ne(c.children)},c.path):e(r,{children:e(s,{to:c.path,children:c.title},void 0)},c.path))),te=()=>({height:0}),ie=e=>({height:e.scrollHeight}),re={motionName:"rc-menu-collapse",motionAppear:!0,onAppearStart:te,onAppearActive:ie,onEnterStart:te,onEnterActive:ie,onLeaveStart:ie,onLeaveActive:te};function oe(n){let{routes:t,basename:i,title:r}=n;const o=a(t),s=v((()=>function(e){return J(e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:"/")}(t,i)),[t,i]),{pathname:d}=l(),h=v((()=>{const e=[];return d.split("/").reduce(((c,n)=>(c.length>1&&e.push(c.join("/")),[...c,n])),[]),e}),[d]),u=v((()=>[...h,d]),[d,h]);return c(ae,{children:[c(le,{children:[e(se,{children:r},void 0),e(ue,{mode:"inline",motion:re,defaultOpenKeys:h,selectedKeys:u,children:ne(s)},void 0)]},void 0),c(de,{children:[e(he,{children:o},void 0),e($,{},void 0)]},void 0)]},void 0)}const ae=o.div(Q||(Q=V(["\n display: flex;\n flex-wrap: nowrap;\n width: 100%;\n"]))),le=o.nav(W||(W=V(["\n position: fixed;\n top: 0;\n bottom: 0;\n left: 0;\n z-index: 100;\n padding: 54px 0 0;\n border-right: 1px solid #e3e3e3;\n width: 230px;\n background-color: #f5f5f5;\n"]))),se=o.div(X||(X=V(["\n padding: 10px 0;\n height: 64px;\n line-height: 44px;\n text-indent: 24px;\n text-overflow: ellipsis;\n white-space: nowrap;\n overflow: hidden;\n font-size: 16px;\n"]))),de=o.div(Z||(Z=V(["\n margin-left: 230px;\n flex: 1;\n"]))),he=o.main(ee||(ee=V(["\n min-height: calc(100vh - 54px);\n position: relative;\n"]))),ue=o(t)(ce||(ce=V(["\n border: none;\n box-shadow: none;\n padding: 0;\n\n .rc-menu-item {\n display: flex;\n\n &:hover {\n background-color: #f0f0f0;\n }\n\n a {\n flex: 1;\n text-decoration: none;\n color: inherit;\n }\n }\n\n .rc-menu-sub {\n background-color: #eee;\n border-top: 1px solid #eee;\n border-bottom: 1px solid #eee;\n\n & > li {\n &:first-child {\n margin-top: 4px;\n }\n\n &:last-child {\n margin-bottom: 4px;\n }\n }\n\n .rc-menu-item-selected {\n background-color: #eee;\n color: var(--bs-primary);\n }\n\n .rc-menu-item-active {\n background-color: #eee;\n }\n\n .rc-menu-item {\n &:hover {\n background-color: #e7e7e7;\n }\n }\n }\n\n .rc-menu-submenu {\n & > .rc-menu-submenu-title {\n &:hover {\n background-color: #e7e7e7;\n }\n }\n }\n\n .rc-menu-submenu-active > .rc-menu-submenu-title {\n background-color: #eee;\n }\n\n .rc-menu-item,\n .rc-menu-submenu > .rc-menu-submenu-title {\n padding: 0 8px 0 24px;\n font-size: 14px;\n line-height: 36px;\n cursor: pointer;\n }\n\n .rc-menu-sub > .rc-menu-item,\n .rc-menu-sub > .rc-menu-submenu > .rc-menu-submenu-title {\n padding-top: 0;\n padding-bottom: 0;\n padding-right: 0;\n }\n\n .rc-menu-submenu-arrow {\n line-height: 38px;\n }\n\n .rc-menu-item-selected {\n background-color: #f5f5f5;\n color: var(--bs-primary);\n }\n\n .rc-menu-submenu-selected {\n background-color: #eee;\n\n .rc-menu-submenu-title {\n color: var(--bs-primary);\n font-weight: 500;\n }\n }\n\n & > .rc-menu-item {\n line-height: 38px;\n }\n\n & > .rc-menu-submenu {\n &.rc-menu-submenu-selected {\n background-color: #f5f5f5;\n }\n\n & > .rc-menu-submenu-title {\n line-height: 38px;\n\n &:hover {\n background-color: #f0f0f0;\n }\n }\n\n &.rc-menu-submenu-active > .rc-menu-submenu-title {\n background-color: #f5f5f5;\n }\n\n & > .rc-menu-sub {\n border-top: 1px solid #e6e6e6;\n border-bottom: 1px solid #e6e6e6;\n\n & > li {\n &:first-child {\n margin-top: 9px;\n }\n\n &:last-child {\n margin-bottom: 9px;\n }\n }\n }\n }\n\n"]))),me=S(N),ge={confirmButtonText:"确定",cancelButtonText:"取消"},ve={confirm:async e=>{const{isConfirmed:c}=await me.fire({...ge,icon:"warning",showCancelButton:!0,...e});return c},error:e=>{me.fire({...ge,toast:!0,position:"top",icon:"error",timer:3e3,showConfirmButton:!1,...e})}};var pe,fe,be,xe;const ye=o.div(pe||(pe=V(["\n padding: 48px 32px;\n"]))),we=o.div(fe||(fe=V(["\n margin-bottom: 24px;\n text-align: center;\n font-size: 72px;\n"]))),_e=o.div(be||(be=V(["\n color: rgba(0, 0, 0, .85);\n font-size: 24px;\n line-height: 1.8;\n text-align: center;\n"]))),ke=o.div(xe||(xe=V(["\n margin-top: 32px;\n text-align: center;\n"]))),ze={success:e("i",{className:"bi bi-check-circle-fill text-success"},void 0),error:e("i",{className:"bi bi-exclamation-circle-fill text-danger"},void 0),info:e("i",{className:"bi bi-info-circle-fill text-info"},void 0),warning:e("i",{className:"bi bi-exclamation-triangle-fill text-warning"},void 0)};function Ce(n){let{status:t,title:i,icon:r,extra:o}=n;return!r&&t&&(r=ze[t]),c(ye,{children:[r&&e(we,{children:r},void 0),i&&e(_e,{children:i},void 0),o&&e(ke,{children:o},void 0)]},void 0)}var Ne,Se;const je=o.a(Ne||(Ne=V(["\n cursor: pointer;\n"])));function Ie(n){let{children:t,menus:i}=n;return e(Ae,{className:"navbar navbar-light bg-white border-bottom sticky-top",children:c("div",{className:"container-fluid",children:[e("a",{className:"navbar-brand",href:"https://www.topthink.com",children:e("img",{src:"data:image/svg+xml,%3csvg width='485' height='132' xmlns='http://www.w3.org/2000/svg' xml:space='preserve' style='enable-background:new 0 0 531.69 198.43%3b' version='1.1'%3e %3cstyle type='text/css'%3e.st0%7bfill:%233C60FF%3b%7d%3c/style%3e %3cg%3e %3ctitle%3ebackground%3c/title%3e %3crect fill='none' id='canvas_background' height='134' width='487' y='-1' x='-1'/%3e %3c/g%3e %3cg%3e %3ctitle%3eLayer 1%3c/title%3e %3cpath id='svg_1' d='m132.29%2c62.34c-1.19%2c-18.77 -10.34%2c-35.36 -24.11%2c-46.46c-11.15%2c-8.99 -25.34%2c-14.38 -40.79%2c-14.38c-0.55%2c0 -1.09%2c0.01 -1.63%2c0.02c-3.32%2c0.08 -6.57%2c0.41 -9.75%2c0.98c-30.49%2c5.38 -53.65%2c32 -53.65%2c64.04c0%2c1.87 0.08%2c3.73 0.24%2c5.57c2.5%2c29.51 24.7%2c53.4 53.41%2c58.47c2.38%2c0.42 4.8%2c0.72 7.26%2c0.86c0.83%2c0.05 1.66%2c0.09 2.5%2c0.11c0.54%2c0.01 1.08%2c0.02 1.63%2c0.02c34.04%2c0 61.97%2c-26.16 64.79%2c-59.46c0.16%2c-1.83 0.24%2c-3.69 0.24%2c-5.57c0%2c-1.42 -0.05%2c-2.82 -0.14%2c-4.2zm-76.27%2c32.5c-0.26%2c0.01 -0.53%2c0.01 -0.79%2c0.01c-14.56%2c0 -26.88%2c-9.57 -31.03%2c-22.76c-0.97%2c-3.08 -1.49%2c-6.35 -1.49%2c-9.75c0%2c-17.95 14.56%2c-32.52 32.51%2c-32.52c0.26%2c0 0.53%2c0 0.79%2c0.01c3.41%2c0.08 6.69%2c0.68 9.75%2c1.74c6.5%2c2.22 12.06%2c6.45 15.97%2c11.94c1.98%2c2.78 3.54%2c5.9 4.57%2c9.25c0.94%2c3.03 1.44%2c6.24 1.44%2c9.58l-9.75%2c0c0%2c-2.18 -0.31%2c-4.29 -0.88%2c-6.28c-0.92%2c-3.23 -2.55%2c-6.17 -4.69%2c-8.64c-1.86%2c-2.14 -4.12%2c-3.93 -6.65%2c-5.25c-2.93%2c-1.54 -6.24%2c-2.46 -9.75%2c-2.58c-0.26%2c-0.01 -0.52%2c-0.01 -0.79%2c-0.01c-12.57%2c0 -22.76%2c10.19 -22.76%2c22.76c0%2c3.49 0.79%2c6.8 2.19%2c9.75c3.65%2c7.69 11.49%2c13.01 20.57%2c13.01c0.27%2c0 0.53%2c-0.01 0.79%2c-0.01l0%2c9.75zm55.7%2c-17.92c-3.35%2c10.5 -13.18%2c18.09 -24.78%2c18.09c-3.13%2c0 -6.13%2c-0.55 -8.91%2c-1.57c-2.18%2c-0.8 -4.24%2c-1.88 -6.11%2c-3.21c-2.38%2c-1.68 -4.47%2c-3.76 -6.16%2c-6.13c-0.28%2c-0.39 -0.55%2c-0.79 -0.81%2c-1.2c-2.03%2c-3.2 -3.38%2c-6.87 -3.85%2c-10.82l9.87%2c0c0.33%2c1.71 0.92%2c3.32 1.74%2c4.8c1.61%2c2.91 4.09%2c5.26 7.09%2c6.72c0.57%2c0.28 1.15%2c0.53 1.76%2c0.73c1.68%2c0.6 3.49%2c0.92 5.37%2c0.92c7.92%2c0 14.52%2c-5.67 15.96%2c-13.17c0.2%2c-1 0.3%2c-2.04 0.3%2c-3.09c0%2c-2.37 -0.51%2c-4.63 -1.43%2c-6.67c-1.66%2c-3.71 -4.68%2c-6.68 -8.43%2c-8.28l3.54%2c-9.1c7.43%2c3.08 13.13%2c9.49 15.21%2c17.38c0.44%2c1.64 0.72%2c3.34 0.81%2c5.09c0.04%2c0.52 0.05%2c1.05 0.05%2c1.58c0%2c1.05 -0.07%2c2.07 -0.18%2c3.09c-0.18%2c1.68 -0.54%2c3.3 -1.04%2c4.84z' class='st0'/%3e %3cg id='svg_2'%3e %3cg id='svg_3'%3e %3crect id='svg_4' height='6.34' width='94.12' class='st0' y='20.46' x='163.29'/%3e %3c/g%3e %3cg id='svg_5'%3e %3cpath id='svg_6' d='m169.31%2c113.72l0%2c-6.34c6.49%2c0 11.77%2c-5.28 11.77%2c-11.77l0%2c-71.98l6.34%2c0l0%2c71.98c0%2c9.98 -8.12%2c18.11 -18.11%2c18.11z' class='st0'/%3e %3c/g%3e %3cg id='svg_7'%3e %3cpath id='svg_8' d='m255.49%2c91.27l-6.34%2c0l0%2c-38.2c0%2c-5.06 -4.12%2c-9.18 -9.18%2c-9.18l-19.37%2c0c-5.06%2c0 -9.18%2c4.12 -9.18%2c9.18l0%2c38.2l-6.34%2c0l0%2c-38.2c0%2c-8.55 6.96%2c-15.51 15.51%2c-15.51l19.38%2c0c8.55%2c0 15.51%2c6.96 15.51%2c15.51l0%2c38.2l0.01%2c0z' class='st0'/%3e %3c/g%3e %3cg id='svg_9'%3e %3crect id='svg_10' height='17.09' width='6.34' class='st0' y='23.63' x='227.12'/%3e %3c/g%3e %3cg id='svg_11'%3e %3cpath id='svg_12' d='m206.43%2c113.84l-3.34%2c0l0%2c-6.34l3.34%2c0c6.3%2c0 12.9%2c-3.56 15.35%2c-8.29c3.49%2c-6.71 5.33%2c-14.25 5.33%2c-21.81l0%2c-26.13l6.34%2c0l0%2c26.13c0%2c8.58 -2.09%2c17.13 -6.05%2c24.74c-3.98%2c7.68 -13.57%2c11.7 -20.97%2c11.7z' class='st0'/%3e %3c/g%3e %3cg id='svg_13'%3e %3cpath id='svg_14' d='m257.48%2c113.84l-3.34%2c0c-7.4%2c0 -16.98%2c-4.02 -20.98%2c-11.7c-3.96%2c-7.61 -6.05%2c-16.16 -6.05%2c-24.74l6.34%2c0c0%2c7.56 1.84%2c15.1 5.33%2c21.81c2.46%2c4.73 9.06%2c8.29 15.35%2c8.29l3.34%2c0l0%2c6.34l0.01%2c0z' class='st0'/%3e %3c/g%3e %3cg id='svg_15'%3e %3crect id='svg_16' height='6.34' width='42.87' class='st0' y='27.89' x='274.07'/%3e %3c/g%3e %3cg id='svg_17'%3e %3crect id='svg_18' height='61.38' width='6.34' class='st0' y='14.89' x='293.05'/%3e %3c/g%3e %3cg id='svg_19'%3e %3crect id='svg_20' height='6.34' width='33.26' class='st0' transform='matrix(0.11%2c-0.9939%2c0.9939%2c0.11%2c194.7608%2c392.0006) ' y='46.985071' x='325.728637'/%3e %3c/g%3e %3cg id='svg_21'%3e %3crect id='svg_22' height='33.26' width='6.34' class='st0' transform='matrix(0.9939%2c-0.11%2c0.11%2c0.9939%2c-7.5075%2c38.3801) ' y='37.060893' x='310.495485'/%3e %3c/g%3e %3cg id='svg_23'%3e %3cpath id='svg_24' d='m352.9%2c77.14l-15.15%2c0c-7.52%2c0 -13.64%2c-6.12 -13.64%2c-13.63l0%2c-29.61c0%2c-7.52 6.12%2c-13.64 13.64%2c-13.64l15.15%2c0c7.52%2c0 13.64%2c6.12 13.64%2c13.64l0%2c29.61c0%2c7.52 -6.12%2c13.63 -13.64%2c13.63zm-15.15%2c-50.54c-4.02%2c0 -7.3%2c3.27 -7.3%2c7.3l0%2c29.61c0%2c4.02 3.27%2c7.3 7.3%2c7.3l15.15%2c0c4.02%2c0 7.3%2c-3.27 7.3%2c-7.3l0%2c-29.61c0%2c-4.02 -3.27%2c-7.3 -7.3%2c-7.3l-15.15%2c0z' class='st0'/%3e %3c/g%3e %3cg id='svg_25'%3e %3cg id='svg_26'%3e %3crect id='svg_27' height='6.34' width='17.8' class='st0' y='37.2' x='336.43'/%3e %3c/g%3e %3cg id='svg_28'%3e %3crect id='svg_29' height='6.34' width='17.8' class='st0' y='53.87' x='336.43'/%3e %3c/g%3e %3c/g%3e %3cg id='svg_30'%3e %3cpath id='svg_31' d='m352.7%2c113.84l-37.98%2c0c-8%2c0 -14.5%2c-6.51 -14.5%2c-14.5l0%2c-16.14l6.34%2c0l0%2c16.13c0%2c4.5 3.66%2c8.17 8.17%2c8.17l37.98%2c0l0%2c6.34l-0.01%2c0z' class='st0'/%3e %3c/g%3e %3cg id='svg_32'%3e %3crect id='svg_33' height='6.34' width='23.57' class='st0' transform='matrix(0.2529%2c-0.9675%2c0.9675%2c0.2529%2c114.4986%2c402.9877) ' y='83.698593' x='326.836101'/%3e %3c/g%3e %3cg id='svg_34'%3e %3crect id='svg_35' height='6.34' width='20.52' class='st0' y='86.2' x='321.58'/%3e %3c/g%3e %3cg id='svg_36'%3e %3crect id='svg_37' height='24.75' width='6.34' class='st0' transform='matrix(0.9556%2c-0.2946%2c0.2946%2c0.9556%2c-19.7967%2c122.424) ' y='75.874073' x='369.686666'/%3e %3c/g%3e %3cg id='svg_38'%3e %3crect id='svg_39' height='6.34' width='71.83' class='st0' y='20.46' x='395.51'/%3e %3c/g%3e %3cg id='svg_40'%3e %3crect id='svg_41' height='6.34' width='90.81' class='st0' y='57.44' x='386.02'/%3e %3c/g%3e %3cg id='svg_42'%3e %3cpath id='svg_43' d='m463.12%2c113.64l-56%2c0c-4.5%2c0 -8.59%2c-2.29 -10.94%2c-6.14c-2.35%2c-3.84 -2.52%2c-8.53 -0.46%2c-12.53l17.68%2c-35.81l5.64%2c2.89l-17.68%2c35.81c-1.04%2c2.02 -0.95%2c4.39 0.23%2c6.33c1.19%2c1.94 3.25%2c3.1 5.53%2c3.1l56%2c0c1.51%2c0 2.88%2c-0.71 3.74%2c-1.95c0.81%2c-1.16 1.03%2c-2.57 0.63%2c-3.91l-7.8%2c-12.34l5.36%2c-3.39l8.18%2c12.94l0.12%2c0.31c1.24%2c3.34 0.76%2c7.08 -1.28%2c10.01c-2.04%2c2.94 -5.39%2c4.68 -8.95%2c4.68z' class='st0'/%3e %3c/g%3e %3c/g%3e %3c/g%3e%3c/svg%3e",height:"30"},void 0)},void 0),t,e("div",{className:"d-flex align-items-center",children:c(j,{navbar:!0,children:[e(j.Toggle,{as:je,className:"nav-link",children:e("i",{className:"bi bi-person-circle"},void 0)},void 0),e(j.Menu,{className:"shadow",children:i},void 0)]},void 0)},void 0)]},void 0)},void 0)}const Ae=o.header(Se||(Se=V(["\n height: 54px;\n"])));var De,Ee;o.div(De||(De=V(["\n position: relative;\n"])));const Pe=o.div(Ee||(Ee=V(["\n display: ",";\n position: absolute;\n top: 0 !important;\n left: 0 !important;\n width: 100%;\n height: 100%;\n text-align: center;\n vertical-align: middle;\n padding: 1em;\n background-color: ",";\n opacity: ",";\n line-height: 1;\n animation-fill-mode: both;\n animation-duration: .5s;\n transition: background-color .5s linear;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n user-select: none;\n will-change: opacity;\n z-index: 990;\n"])),(e=>e.active?"flex":"none"),(e=>e.inverted?"rgba(255, 255, 255, .85)":"rgba(0, 0, 0, .85)"),(e=>e.active?1:0));function Be(n){let{loading:t=!0,children:i,variant:r="success",animation:o="border",...a}=n;return t?(i&&(i=e("p",{className:"mt-3 text-secondary",children:i},void 0)),c(Pe,{inverted:!0,active:!0,children:[e(I,{animation:o,variant:r,...a},void 0),i]},void 0)):null}T.attach(),M.defaults.raxConfig={retryDelay:2e3,backoffType:"static",shouldRetry:e=>{var c,n;return"GET"===(null===(c=e.config.method)||void 0===c?void 0:c.toUpperCase())&&449===(null===(n=e.response)||void 0===n?void 0:n.status)}},M.defaults.baseURL="/api",M.interceptors.request.use((e=>{const c=sessionStorage.getItem("authorization");return c&&(e.headers.Authorization="Bearer ".concat(c)),e}),(e=>Promise.reject(e))),M.interceptors.response.use((e=>(201===e.status&&e.data.location&&(window.location.href=e.data.location,e.data=void 0),e)),(e=>{if(M.isAxiosError(e)&&e.response){const{data:c,status:n}=e.response;if(401===n){const{url:n}=c;if(n){sessionStorage.setItem("redirect_uri",window.location.pathname+window.location.search);const e=window.location.origin+"/login";window.location.href="".concat(n,"&redirect_uri=").concat(encodeURIComponent(e))}e.errors="Unauthorized"}else{let t={};if(422===n&&"object"==typeof c)for(let e in c)t[e]=c[e];else t="object"==typeof c&&"message"in c?c.message:c;e.errors=t}}return Promise.reject(e)}));const Fe=async function(e){e="string"==typeof e?{url:e}:e;const{data:c}=await M.request({...e});return c};function Oe(){const c=l(),n=O.parse(c.hash.substr(1));sessionStorage.setItem("authorization",n.access_token);const t=sessionStorage.getItem("redirect_uri");return t&&sessionStorage.removeItem("redirect_uri"),e(m,{to:t||"/",replace:!0},void 0)}function Me(){return p((()=>{Fe("/logout").catch((()=>{sessionStorage.removeItem("authorization")}))}),[]),e(Be,{},void 0)}function Te(n){let{children:t}=n;return e(d,{children:c(h,{children:[e(u,{path:"*",element:t},void 0),e(u,{path:"login",element:e(Oe,{},void 0)},void 0),e(u,{path:"logout",element:e(Me,{},void 0)},void 0)]},void 0)},void 0)}function Le(t){let{children:i,title:r,className:o,...a}=t;return e(A,{className:L("border-0 shadow-sm mb-3",o),...a,children:c("div",{className:"card-body",children:[r&&c(n,{children:[e("h5",{children:r},void 0),e("hr",{},void 0)]},void 0),i]},void 0)},void 0)}function Ue(c){let{errors:n}=c;return n?e(D,{variant:"danger",children:e("ul",{className:"mb-0",children:"string"==typeof n?e("li",{children:n},void 0):Object.entries(n).map((c=>{let[n,t]=c;return e("li",{children:t},n)}))},void 0)},void 0):null}const qe=g.createContext([null,()=>{}]),He=function(c){let{children:n,user:t}=c;const[i,r]=f(t);return p((()=>{r(t)}),[t]),i?e(qe.Provider,{value:[i,r],children:n},void 0):e(Be,{},void 0)};function Ke(){const[e,c]=b(qe);if(!e)throw new Error("please use `useUser` in UserContext");return[e,c]}function Re(c){let{require:t,children:i,fallback:r}=c;const[o]=Ke();let a=!1;return"function"==typeof t?a=t(o):("string"==typeof t&&(t=[t]),a=U(o.roles,t).length>0),a||(i=r),e(n,{children:i},void 0)}var Ve,Ge;function Ye(c){let{children:n,size:t="small"}=c;"string"==typeof t&&(t={small:8,middle:16,large:24}[t]);const i=x.map(n,(c=>e(Je,{size:t,children:c},void 0)));return e($e,{children:i},void 0)}const $e=o.div(Ve||(Ve=V(["\n display: inline-flex;\n align-items: center;\n"]))),Je=o.div(Ge||(Ge=V(["\n margin-right: ","px;\n\n &:last-child {\n margin-right: 0;\n }\n"])),(e=>e.size));function Qe(c){let{value:t,locale:i="zh-CN",currency:r=!0}=c;const o=v((()=>{let e={};return e=r?{style:"currency",currency:"CNY",...e}:{minimumFractionDigits:2},new Intl.NumberFormat(i,e)}),[r,i]);return e(n,{children:o.format(t)},void 0)}function We(c){let{loading:n,children:t,...i}=c;return e(E,{...i,disabled:n,children:n?"Loading…":t},void 0)}function Xe(e){let{url:c,method:n,confirm:t,onSuccess:i,children:r,disabled:o,as:a=E,...l}=e;const[s,d]=f(!1),h=y((async e=>{e.preventDefault();try{if(d(!0),t&&!await ve.confirm({text:t}))return;const e="string"==typeof c?{url:c,method:n}:{method:n,...c},r=await Fe(e);i&&i(r)}catch(e){if(!M.isAxiosError(e))throw e;{let c=e.errors;"string"!=typeof e.errors&&(c=Object.values(e.errors).join("<br />")),ve.error({text:c})}}finally{d(!1)}}),[c,n,d]);return w(a,{...l,disabled:o||s,onClick:h},r)}const Ze=require("ajv-i18n/localize/zh"),ec=_(((c,n)=>{let{action:t,method:i="post",onSuccess:r,formData:o,onSubmit:a,onChange:l,children:s,...d}=c;const[h,u]=f(),[m,g]=f(!1),[v,p]=f(o),b=y((async(e,c)=>{try{if(g(!0),t){const{formData:c}=e;try{const e=await Fe({url:t,method:i,data:c});u(void 0),r&&await r(e)}catch(e){throw M.isAxiosError(e)&&u((e=>{const c=e.errors;return"string"==typeof c?{__errors:[c]}:q(c,(e=>({__errors:[e]})))})(e)),e}}else a&&await a(e,c)}finally{g(!1)}}),[t,i,a]),x=y((e=>{const{formData:c}=e;p(c),l&&l(e)}),[p,l]),w=y((e=>(e=e.map((e=>({keyword:e.name,dataPath:e.property,...e}))),Ze(e),e)),[]);return e(H,{ref:n,extraErrors:h,onSubmit:b,transformErrors:w,noHtml5Validate:!0,noValidate:!0,...d,formData:v,onChange:x,children:s||e("div",{className:"col-12",children:e(We,{loading:m,type:"submit",variant:"primary",children:"提交"},void 0)},void 0)},void 0)}));var cc,nc,tc,ic,rc;const oc=o.div(cc||(cc=V(["\n width: 100%;\n"]))),ac=o.div(nc||(nc=V(["\n background-color: #fff;\n display: flex;\n\n .container {\n padding: 0 24px;\n display: flex;\n justify-content: space-between;\n align-items: center;\n }\n"]))),lc=o.div(tc||(tc=V(["\n margin-top: 24px;\n"]))),sc=o.div(ic||(ic=V(["\n font-size: 22px;\n line-height: 64px;\n height: 64px;\n"]))),dc=o.div(rc||(rc=V(["\n\n"])));function hc(n){let{title:t,children:i,extra:r}=n;return c(oc,{children:[e(ac,{children:c("div",{className:"container",children:[e(sc,{children:t},void 0),e(dc,{children:r},void 0)]},void 0)},void 0),e(lc,{className:"container",children:i},void 0)]},void 0)}function uc(){}function mc(e){return"number"==typeof e&&isFinite(e)&&Math.floor(e)===e}var gc,vc,pc,fc,bc,xc;const yc=o(B)(gc||(gc=V(["\n .rc-table-thead {\n border-top: none;\n }\n"]))),wc={table:c=>e(yc,{...c,className:"align-middle table-hover"},void 0)},_c=o((function(c){let{total:n=0,onChange:t=uc,defaultCurrent:i=1,defaultPageSize:r=10,className:o,...a}=c;const[l,s]=f(i),[d,h]=f(r);p((()=>{mc(a.current)&&s(a.current)}),[a.current]),p((()=>{mc(a.pageSize)&&h(a.pageSize)}),[a.pageSize]);const u=v((()=>Math.floor((n-1)/d)+1),[n,d]),m=y((e=>()=>{e!==l&&(s(e),t(e,d))}),[t,l,d]),g=l-1>0?l-1:0,b=l+1<u?l+1:u,x=[];let w=null,_=null,k=null,z=null;if(u<=7)for(let c=1;c<=u;c+=1){const n=l===c;x.push(e(P.Item,{active:n,onClick:m(c),children:c},c))}else{z=e(P.Last,{onClick:m(u)},"last"),k=e(P.First,{onClick:m(1)},"first"),w=e(P.Prev,{onClick:m(g)},"prev"),_=e(P.Next,{onClick:m(b)},"next");let c=Math.max(1,l-2),n=Math.min(l+2,u);l-1<=2&&(n=5),u-l<=2&&(c=u-4);for(let t=c;t<=n;t+=1){const c=l===t;x.push(e(P.Item,{active:c,onClick:m(t),children:t},t))}l-1>=4&&3!==l&&x.unshift(w),u-l>=4&&l!==u-2&&x.push(_),1!==c&&x.unshift(k),n!==u&&x.push(z)}return e(P,{className:o,children:x},void 0)}))(vc||(vc=V(["\n margin-bottom: 0;\n justify-content: flex-end;\n"])));function kc(e){return"current_page"in e}const zc=_(((n,t)=>{let{source:i,rowKey:r="id",paginate:o=!0,toolBarRender:a,columns:l=[],...s}=n;const[d,h]=f([]),[u,m]=f(o?{total:0,current:1,pageSize:10}:null),[g,b]=f(!0),x=y((async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};b(!0);try{let c;if("string"==typeof i){const n={};u&&(n.page=e.page||u.current),c=await Fe({url:i,params:n})}else c=await i();o&&kc(c)&&(m({total:c.total,current:c.current_page,pageSize:c.per_page}),c=c.data),h(c)}catch(e){}finally{b(!1)}}),[i,h,u]);p((()=>{x()}),[]);const w=k({reload:x});p((()=>{w.current={reload:x}}),[x]),z(t,(()=>w.current));const _=v((()=>l.map((e=>{const c={...e,render:void 0};if("render"in e&&e.render){const n=e.render;c.render=(e,c,t)=>n({value:e,record:c,index:t,action:w.current})}return c}))),[l,w]),C=y((e=>{x({page:e})}),[]);return c(Le,{children:[e(Be,{loading:g},void 0),c(Cc,{children:[e(Sc,{children:a&&a(w.current)},void 0),e(Nc,{children:e(jc,{onClick:w.current.reload,children:e("i",{className:"bi bi-arrow-repeat"},void 0)},void 0)},void 0)]},void 0),e(K,{...s,rowKey:r,columns:_,components:wc,data:d},void 0),u&&e(_c,{...u,onChange:C},void 0)]},void 0)})),Cc=o.div(pc||(pc=V(["\n display: flex;\n justify-content: space-between;\n padding-bottom: 1rem;\n"]))),Nc=o(Ye)(fc||(fc=V(["\n\n"]))),Sc=o(Ye)(bc||(bc=V(["\n\n"]))),jc=o.span(xc||(xc=V(["\n cursor: pointer;\n font-size: 20px;\n line-height: 1;\n\n &:hover {\n color: var(--bs-primary);\n }\n"]))),Ic=_(((t,i)=>{let{text:r,variant:o="primary",header:a=r,footer:l=!0,onOk:s,size:d,children:h}=t;const[u,m]=f(!1),[g,v]=f(!1),p=()=>m(!1);z(i,(()=>({close:p})));return c(n,{children:[e(E,{variant:o,onClick:()=>m(!0),children:r},void 0),c(F,{size:d,show:u,onHide:p,children:[a&&e(F.Header,{closeButton:!0,children:e(F.Title,{as:"h5",children:a},void 0)},void 0),e(F.Body,{children:h},void 0),l&&c(F.Footer,{children:[e(E,{variant:"secondary",onClick:p,children:"取消"},void 0),e(We,{loading:g,variant:"primary",onClick:async()=>{if(s){v(!0);const e=await s();if(v(!1),!1===e)return}p()},children:"确定"},void 0)]},void 0)]},void 0)]},void 0)}));function Ac(c){let{text:n,header:t,schema:i,uiSchema:r,action:o,method:a,formData:l,variant:s,onSuccess:d,onChange:h,fields:u,size:m}=c;const g=k(null),v=k(null),p=y((async()=>{try{var e;return await(null===(e=g.current)||void 0===e?void 0:e.submit()),!0}catch{return!1}}),[]);return e(Ic,{ref:v,text:n,onOk:p,header:t,variant:s,size:m,children:e(ec,{ref:g,schema:i,uiSchema:r,action:o,method:a,formData:l,fields:u,onChange:h,onSuccess:d,children:e(C,{},void 0)},void 0)},void 0)}function Dc(e){let{manual:c,refreshDeps:n,...t}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{execute:i,currentParams:r,error:o,...a}=R((async c=>(e="string"==typeof e?{url:e}:e,await Fe({...e,...c}))),t);p((()=>{c||n||i()}),[]),p((()=>{n&&l()}),n);const l=y((()=>{r?i(...r):i()}),[i,r]);return{refresh:l,execute:i,...a}}export{Re as Access,Le as Card,hc as Content,Ue as Error,$ as Footer,ec as Form,Ie as Header,Be as Loader,We as LoadingButton,ve as Message,Ic as ModalButton,Ac as ModalForm,Qe as NumberFormat,Xe as RequestButton,Ce as Result,Te as Root,oe as SiderLayout,Ye as Space,zc as Table,He as UserProvider,Fe as request,Dc as useRequest,Ke as useUser};
|
|
1
|
+
import{jsx as e,jsxs as c,Fragment as n}from"react/jsx-runtime";import t,{SubMenu as r,MenuItem as i}from"rc-menu";import o from"styled-components";import{useRoutes as a,useLocation as l,Link as s,BrowserRouter as d,Routes as h,Route as u,Navigate as m}from"react-router-dom";import g,{useMemo as p,useEffect as f,useState as v,useContext as b,Children as x,useCallback as y,createElement as w,forwardRef as _,useRef as k,useImperativeHandle as z,Fragment as C}from"react";import"rc-menu/assets/index.css";import N from"sweetalert2/dist/sweetalert2.js";import S from"sweetalert2-react-content";import{Dropdown as j,Spinner as I,Card as E,Alert as A,Button as D,Pagination as P,Table as B,Modal as F}from"react-bootstrap";import O from"query-string";import H from"axios";import*as M from"retry-axios";import T from"classnames";import{intersection as L,mapValues as U}from"lodash";import q from"@topthink/json-form";import K from"rc-table";import{useAsyncCallback as R}from"react-async-hook";function V(e,c){return c||(c=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(c)}}))}var G;const Y=o.footer(G||(G=V(["\n\n"])));function $(){return e(Y,{children:e("div",{className:"container"})})}const J=function(e){let c=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"/";const n=[];for(const o of e){var t,r,i;if(null!==(t=o.meta)&&void 0!==t&&t.hideInMenu)continue;const e=null===(r=o.meta)||void 0===r?void 0:r.title;if(!e)continue;let a=o.path||"";a="".concat(c,"/").concat(a),a=a.replace(/\/+/,"/").replace(/\/$/,"");const l={title:e,path:a,children:[]};null!==(i=o.meta)&&void 0!==i&&i.hideChildrenInMenu||o.children&&o.children.length>0&&(l.children=J(o.children,a)),n.push(l)}return n};var Q,W,X,Z,ee,ce;const ne=c=>c.map((c=>c.children.length>0?e(r,{title:c.title,children:ne(c.children)},c.path):e(i,{children:e(s,{to:c.path,children:c.title})},c.path))),te=()=>({height:0}),re=e=>({height:e.scrollHeight}),ie={motionName:"rc-menu-collapse",motionAppear:!0,onAppearStart:te,onAppearActive:re,onEnterStart:te,onEnterActive:re,onLeaveStart:re,onLeaveActive:te};function oe(n){let{routes:t,basename:r,title:i}=n;const o=a(t),s=p((()=>function(e){return J(e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:"/")}(t,r)),[t,r]),{pathname:d}=l(),h=p((()=>{const e=[];return d.split("/").reduce(((c,n)=>(c.length>1&&e.push(c.join("/")),[...c,n])),[]),e}),[d]),u=p((()=>[...h,d]),[d,h]);return c(ae,{children:[c(le,{children:[e(se,{children:i}),e(ue,{mode:"inline",motion:ie,defaultOpenKeys:h,selectedKeys:u,children:ne(s)})]}),c(de,{children:[e(he,{children:o}),e($,{})]})]})}const ae=o.div(Q||(Q=V(["\n display: flex;\n flex-wrap: nowrap;\n width: 100%;\n"]))),le=o.nav(W||(W=V(["\n position: fixed;\n top: 0;\n bottom: 0;\n left: 0;\n z-index: 100;\n padding: 54px 0 0;\n border-right: 1px solid #e3e3e3;\n width: 230px;\n background-color: #f5f5f5;\n"]))),se=o.div(X||(X=V(["\n padding: 10px 0;\n height: 64px;\n line-height: 44px;\n text-indent: 24px;\n text-overflow: ellipsis;\n white-space: nowrap;\n overflow: hidden;\n font-size: 16px;\n"]))),de=o.div(Z||(Z=V(["\n margin-left: 230px;\n flex: 1;\n"]))),he=o.main(ee||(ee=V(["\n min-height: calc(100vh - 54px);\n position: relative;\n"]))),ue=o(t)(ce||(ce=V(["\n border: none;\n box-shadow: none;\n padding: 0;\n\n .rc-menu-item {\n display: flex;\n\n &:hover {\n background-color: #f0f0f0;\n }\n\n a {\n flex: 1;\n text-decoration: none;\n color: inherit;\n }\n }\n\n .rc-menu-sub {\n background-color: #eee;\n border-top: 1px solid #eee;\n border-bottom: 1px solid #eee;\n\n & > li {\n &:first-child {\n margin-top: 4px;\n }\n\n &:last-child {\n margin-bottom: 4px;\n }\n }\n\n .rc-menu-item-selected {\n background-color: #eee;\n color: var(--bs-primary);\n }\n\n .rc-menu-item-active {\n background-color: #eee;\n }\n\n .rc-menu-item {\n &:hover {\n background-color: #e7e7e7;\n }\n }\n }\n\n .rc-menu-submenu {\n & > .rc-menu-submenu-title {\n &:hover {\n background-color: #e7e7e7;\n }\n }\n }\n\n .rc-menu-submenu-active > .rc-menu-submenu-title {\n background-color: #eee;\n }\n\n .rc-menu-item,\n .rc-menu-submenu > .rc-menu-submenu-title {\n padding: 0 8px 0 24px;\n font-size: 14px;\n line-height: 36px;\n cursor: pointer;\n }\n\n .rc-menu-sub > .rc-menu-item,\n .rc-menu-sub > .rc-menu-submenu > .rc-menu-submenu-title {\n padding-top: 0;\n padding-bottom: 0;\n padding-right: 0;\n }\n\n .rc-menu-submenu-arrow {\n line-height: 38px;\n }\n\n .rc-menu-item-selected {\n background-color: #f5f5f5;\n color: var(--bs-primary);\n }\n\n .rc-menu-submenu-selected {\n background-color: #eee;\n\n .rc-menu-submenu-title {\n color: var(--bs-primary);\n font-weight: 500;\n }\n }\n\n & > .rc-menu-item {\n line-height: 38px;\n }\n\n & > .rc-menu-submenu {\n &.rc-menu-submenu-selected {\n background-color: #f5f5f5;\n }\n\n & > .rc-menu-submenu-title {\n line-height: 38px;\n\n &:hover {\n background-color: #f0f0f0;\n }\n }\n\n &.rc-menu-submenu-active > .rc-menu-submenu-title {\n background-color: #f5f5f5;\n }\n\n & > .rc-menu-sub {\n border-top: 1px solid #e6e6e6;\n border-bottom: 1px solid #e6e6e6;\n\n & > li {\n &:first-child {\n margin-top: 9px;\n }\n\n &:last-child {\n margin-bottom: 9px;\n }\n }\n }\n }\n\n"]))),me=S(N),ge={confirmButtonText:"确定",cancelButtonText:"取消"},pe={confirm:async e=>{const{isConfirmed:c}=await me.fire({...ge,icon:"warning",showCancelButton:!0,...e});return c},error:e=>{me.fire({...ge,toast:!0,position:"top",icon:"error",timer:3e3,showConfirmButton:!1,...e})}};var fe,ve,be,xe;const ye=o.div(fe||(fe=V(["\n padding: 48px 32px;\n"]))),we=o.div(ve||(ve=V(["\n margin-bottom: 24px;\n text-align: center;\n font-size: 72px;\n"]))),_e=o.div(be||(be=V(["\n color: rgba(0, 0, 0, .85);\n font-size: 24px;\n line-height: 1.8;\n text-align: center;\n"]))),ke=o.div(xe||(xe=V(["\n margin-top: 32px;\n text-align: center;\n"]))),ze={success:e("i",{className:"bi bi-check-circle-fill text-success"}),error:e("i",{className:"bi bi-exclamation-circle-fill text-danger"}),info:e("i",{className:"bi bi-info-circle-fill text-info"}),warning:e("i",{className:"bi bi-exclamation-triangle-fill text-warning"})};function Ce(n){let{status:t,title:r,icon:i,extra:o}=n;return!i&&t&&(i=ze[t]),c(ye,{children:[i&&e(we,{children:i}),r&&e(_e,{children:r}),o&&e(ke,{children:o})]})}var Ne,Se;const je=o.a(Ne||(Ne=V(["\n cursor: pointer;\n"])));function Ie(n){let{children:t,menus:r}=n;return e(Ee,{className:"navbar navbar-light bg-white border-bottom sticky-top",children:c("div",{className:"container-fluid",children:[e("a",{className:"navbar-brand",href:"https://www.topthink.com",children:e("img",{src:"data:image/svg+xml,%3csvg width='485' height='132' xmlns='http://www.w3.org/2000/svg' xml:space='preserve' style='enable-background:new 0 0 531.69 198.43%3b' version='1.1'%3e %3cstyle type='text/css'%3e.st0%7bfill:%233C60FF%3b%7d%3c/style%3e %3cg%3e %3ctitle%3ebackground%3c/title%3e %3crect fill='none' id='canvas_background' height='134' width='487' y='-1' x='-1'/%3e %3c/g%3e %3cg%3e %3ctitle%3eLayer 1%3c/title%3e %3cpath id='svg_1' d='m132.29%2c62.34c-1.19%2c-18.77 -10.34%2c-35.36 -24.11%2c-46.46c-11.15%2c-8.99 -25.34%2c-14.38 -40.79%2c-14.38c-0.55%2c0 -1.09%2c0.01 -1.63%2c0.02c-3.32%2c0.08 -6.57%2c0.41 -9.75%2c0.98c-30.49%2c5.38 -53.65%2c32 -53.65%2c64.04c0%2c1.87 0.08%2c3.73 0.24%2c5.57c2.5%2c29.51 24.7%2c53.4 53.41%2c58.47c2.38%2c0.42 4.8%2c0.72 7.26%2c0.86c0.83%2c0.05 1.66%2c0.09 2.5%2c0.11c0.54%2c0.01 1.08%2c0.02 1.63%2c0.02c34.04%2c0 61.97%2c-26.16 64.79%2c-59.46c0.16%2c-1.83 0.24%2c-3.69 0.24%2c-5.57c0%2c-1.42 -0.05%2c-2.82 -0.14%2c-4.2zm-76.27%2c32.5c-0.26%2c0.01 -0.53%2c0.01 -0.79%2c0.01c-14.56%2c0 -26.88%2c-9.57 -31.03%2c-22.76c-0.97%2c-3.08 -1.49%2c-6.35 -1.49%2c-9.75c0%2c-17.95 14.56%2c-32.52 32.51%2c-32.52c0.26%2c0 0.53%2c0 0.79%2c0.01c3.41%2c0.08 6.69%2c0.68 9.75%2c1.74c6.5%2c2.22 12.06%2c6.45 15.97%2c11.94c1.98%2c2.78 3.54%2c5.9 4.57%2c9.25c0.94%2c3.03 1.44%2c6.24 1.44%2c9.58l-9.75%2c0c0%2c-2.18 -0.31%2c-4.29 -0.88%2c-6.28c-0.92%2c-3.23 -2.55%2c-6.17 -4.69%2c-8.64c-1.86%2c-2.14 -4.12%2c-3.93 -6.65%2c-5.25c-2.93%2c-1.54 -6.24%2c-2.46 -9.75%2c-2.58c-0.26%2c-0.01 -0.52%2c-0.01 -0.79%2c-0.01c-12.57%2c0 -22.76%2c10.19 -22.76%2c22.76c0%2c3.49 0.79%2c6.8 2.19%2c9.75c3.65%2c7.69 11.49%2c13.01 20.57%2c13.01c0.27%2c0 0.53%2c-0.01 0.79%2c-0.01l0%2c9.75zm55.7%2c-17.92c-3.35%2c10.5 -13.18%2c18.09 -24.78%2c18.09c-3.13%2c0 -6.13%2c-0.55 -8.91%2c-1.57c-2.18%2c-0.8 -4.24%2c-1.88 -6.11%2c-3.21c-2.38%2c-1.68 -4.47%2c-3.76 -6.16%2c-6.13c-0.28%2c-0.39 -0.55%2c-0.79 -0.81%2c-1.2c-2.03%2c-3.2 -3.38%2c-6.87 -3.85%2c-10.82l9.87%2c0c0.33%2c1.71 0.92%2c3.32 1.74%2c4.8c1.61%2c2.91 4.09%2c5.26 7.09%2c6.72c0.57%2c0.28 1.15%2c0.53 1.76%2c0.73c1.68%2c0.6 3.49%2c0.92 5.37%2c0.92c7.92%2c0 14.52%2c-5.67 15.96%2c-13.17c0.2%2c-1 0.3%2c-2.04 0.3%2c-3.09c0%2c-2.37 -0.51%2c-4.63 -1.43%2c-6.67c-1.66%2c-3.71 -4.68%2c-6.68 -8.43%2c-8.28l3.54%2c-9.1c7.43%2c3.08 13.13%2c9.49 15.21%2c17.38c0.44%2c1.64 0.72%2c3.34 0.81%2c5.09c0.04%2c0.52 0.05%2c1.05 0.05%2c1.58c0%2c1.05 -0.07%2c2.07 -0.18%2c3.09c-0.18%2c1.68 -0.54%2c3.3 -1.04%2c4.84z' class='st0'/%3e %3cg id='svg_2'%3e %3cg id='svg_3'%3e %3crect id='svg_4' height='6.34' width='94.12' class='st0' y='20.46' x='163.29'/%3e %3c/g%3e %3cg id='svg_5'%3e %3cpath id='svg_6' d='m169.31%2c113.72l0%2c-6.34c6.49%2c0 11.77%2c-5.28 11.77%2c-11.77l0%2c-71.98l6.34%2c0l0%2c71.98c0%2c9.98 -8.12%2c18.11 -18.11%2c18.11z' class='st0'/%3e %3c/g%3e %3cg id='svg_7'%3e %3cpath id='svg_8' d='m255.49%2c91.27l-6.34%2c0l0%2c-38.2c0%2c-5.06 -4.12%2c-9.18 -9.18%2c-9.18l-19.37%2c0c-5.06%2c0 -9.18%2c4.12 -9.18%2c9.18l0%2c38.2l-6.34%2c0l0%2c-38.2c0%2c-8.55 6.96%2c-15.51 15.51%2c-15.51l19.38%2c0c8.55%2c0 15.51%2c6.96 15.51%2c15.51l0%2c38.2l0.01%2c0z' class='st0'/%3e %3c/g%3e %3cg id='svg_9'%3e %3crect id='svg_10' height='17.09' width='6.34' class='st0' y='23.63' x='227.12'/%3e %3c/g%3e %3cg id='svg_11'%3e %3cpath id='svg_12' d='m206.43%2c113.84l-3.34%2c0l0%2c-6.34l3.34%2c0c6.3%2c0 12.9%2c-3.56 15.35%2c-8.29c3.49%2c-6.71 5.33%2c-14.25 5.33%2c-21.81l0%2c-26.13l6.34%2c0l0%2c26.13c0%2c8.58 -2.09%2c17.13 -6.05%2c24.74c-3.98%2c7.68 -13.57%2c11.7 -20.97%2c11.7z' class='st0'/%3e %3c/g%3e %3cg id='svg_13'%3e %3cpath id='svg_14' d='m257.48%2c113.84l-3.34%2c0c-7.4%2c0 -16.98%2c-4.02 -20.98%2c-11.7c-3.96%2c-7.61 -6.05%2c-16.16 -6.05%2c-24.74l6.34%2c0c0%2c7.56 1.84%2c15.1 5.33%2c21.81c2.46%2c4.73 9.06%2c8.29 15.35%2c8.29l3.34%2c0l0%2c6.34l0.01%2c0z' class='st0'/%3e %3c/g%3e %3cg id='svg_15'%3e %3crect id='svg_16' height='6.34' width='42.87' class='st0' y='27.89' x='274.07'/%3e %3c/g%3e %3cg id='svg_17'%3e %3crect id='svg_18' height='61.38' width='6.34' class='st0' y='14.89' x='293.05'/%3e %3c/g%3e %3cg id='svg_19'%3e %3crect id='svg_20' height='6.34' width='33.26' class='st0' transform='matrix(0.11%2c-0.9939%2c0.9939%2c0.11%2c194.7608%2c392.0006) ' y='46.985071' x='325.728637'/%3e %3c/g%3e %3cg id='svg_21'%3e %3crect id='svg_22' height='33.26' width='6.34' class='st0' transform='matrix(0.9939%2c-0.11%2c0.11%2c0.9939%2c-7.5075%2c38.3801) ' y='37.060893' x='310.495485'/%3e %3c/g%3e %3cg id='svg_23'%3e %3cpath id='svg_24' d='m352.9%2c77.14l-15.15%2c0c-7.52%2c0 -13.64%2c-6.12 -13.64%2c-13.63l0%2c-29.61c0%2c-7.52 6.12%2c-13.64 13.64%2c-13.64l15.15%2c0c7.52%2c0 13.64%2c6.12 13.64%2c13.64l0%2c29.61c0%2c7.52 -6.12%2c13.63 -13.64%2c13.63zm-15.15%2c-50.54c-4.02%2c0 -7.3%2c3.27 -7.3%2c7.3l0%2c29.61c0%2c4.02 3.27%2c7.3 7.3%2c7.3l15.15%2c0c4.02%2c0 7.3%2c-3.27 7.3%2c-7.3l0%2c-29.61c0%2c-4.02 -3.27%2c-7.3 -7.3%2c-7.3l-15.15%2c0z' class='st0'/%3e %3c/g%3e %3cg id='svg_25'%3e %3cg id='svg_26'%3e %3crect id='svg_27' height='6.34' width='17.8' class='st0' y='37.2' x='336.43'/%3e %3c/g%3e %3cg id='svg_28'%3e %3crect id='svg_29' height='6.34' width='17.8' class='st0' y='53.87' x='336.43'/%3e %3c/g%3e %3c/g%3e %3cg id='svg_30'%3e %3cpath id='svg_31' d='m352.7%2c113.84l-37.98%2c0c-8%2c0 -14.5%2c-6.51 -14.5%2c-14.5l0%2c-16.14l6.34%2c0l0%2c16.13c0%2c4.5 3.66%2c8.17 8.17%2c8.17l37.98%2c0l0%2c6.34l-0.01%2c0z' class='st0'/%3e %3c/g%3e %3cg id='svg_32'%3e %3crect id='svg_33' height='6.34' width='23.57' class='st0' transform='matrix(0.2529%2c-0.9675%2c0.9675%2c0.2529%2c114.4986%2c402.9877) ' y='83.698593' x='326.836101'/%3e %3c/g%3e %3cg id='svg_34'%3e %3crect id='svg_35' height='6.34' width='20.52' class='st0' y='86.2' x='321.58'/%3e %3c/g%3e %3cg id='svg_36'%3e %3crect id='svg_37' height='24.75' width='6.34' class='st0' transform='matrix(0.9556%2c-0.2946%2c0.2946%2c0.9556%2c-19.7967%2c122.424) ' y='75.874073' x='369.686666'/%3e %3c/g%3e %3cg id='svg_38'%3e %3crect id='svg_39' height='6.34' width='71.83' class='st0' y='20.46' x='395.51'/%3e %3c/g%3e %3cg id='svg_40'%3e %3crect id='svg_41' height='6.34' width='90.81' class='st0' y='57.44' x='386.02'/%3e %3c/g%3e %3cg id='svg_42'%3e %3cpath id='svg_43' d='m463.12%2c113.64l-56%2c0c-4.5%2c0 -8.59%2c-2.29 -10.94%2c-6.14c-2.35%2c-3.84 -2.52%2c-8.53 -0.46%2c-12.53l17.68%2c-35.81l5.64%2c2.89l-17.68%2c35.81c-1.04%2c2.02 -0.95%2c4.39 0.23%2c6.33c1.19%2c1.94 3.25%2c3.1 5.53%2c3.1l56%2c0c1.51%2c0 2.88%2c-0.71 3.74%2c-1.95c0.81%2c-1.16 1.03%2c-2.57 0.63%2c-3.91l-7.8%2c-12.34l5.36%2c-3.39l8.18%2c12.94l0.12%2c0.31c1.24%2c3.34 0.76%2c7.08 -1.28%2c10.01c-2.04%2c2.94 -5.39%2c4.68 -8.95%2c4.68z' class='st0'/%3e %3c/g%3e %3c/g%3e %3c/g%3e%3c/svg%3e",height:"30"})}),t,e("div",{className:"d-flex align-items-center",children:c(j,{navbar:!0,children:[e(j.Toggle,{as:je,className:"nav-link",children:e("i",{className:"bi bi-person-circle"})}),e(j.Menu,{className:"shadow",children:r})]})})]})})}const Ee=o.header(Se||(Se=V(["\n height: 54px;\n"])));var Ae,De;o.div(Ae||(Ae=V(["\n position: relative;\n"])));const Pe=o.div(De||(De=V(["\n display: ",";\n position: absolute;\n top: 0 !important;\n left: 0 !important;\n width: 100%;\n height: 100%;\n text-align: center;\n vertical-align: middle;\n padding: 1em;\n background-color: ",";\n opacity: ",";\n line-height: 1;\n animation-fill-mode: both;\n animation-duration: .5s;\n transition: background-color .5s linear;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n user-select: none;\n will-change: opacity;\n z-index: 990;\n"])),(e=>e.active?"flex":"none"),(e=>e.inverted?"rgba(255, 255, 255, .85)":"rgba(0, 0, 0, .85)"),(e=>e.active?1:0));function Be(n){let{loading:t=!0,children:r,variant:i="success",animation:o="border",...a}=n;return t?(r&&(r=e("p",{className:"mt-3 text-secondary",children:r})),c(Pe,{inverted:!0,active:!0,children:[e(I,{animation:o,variant:i,...a}),r]})):null}M.attach(),H.defaults.raxConfig={retryDelay:2e3,backoffType:"static",shouldRetry:e=>{var c,n;return"GET"===(null===(c=e.config.method)||void 0===c?void 0:c.toUpperCase())&&449===(null===(n=e.response)||void 0===n?void 0:n.status)}},H.defaults.baseURL="/api",H.interceptors.request.use((e=>{const c=sessionStorage.getItem("authorization");return c&&(e.headers.Authorization="Bearer ".concat(c)),e}),(e=>Promise.reject(e))),H.interceptors.response.use((e=>(201===e.status&&e.data.location&&(window.location.href=e.data.location,e.data=void 0),e)),(e=>{if(H.isAxiosError(e)&&e.response){const{data:c,status:n}=e.response;if(401===n){const{url:n}=c;if(n){"/logout"!==window.location.pathname&&sessionStorage.setItem("redirect_uri",window.location.pathname+window.location.search);const e=window.location.origin+"/login";window.location.href="".concat(n,"&redirect_uri=").concat(encodeURIComponent(e))}e.errors="Unauthorized"}else{let t={};if(422===n&&"object"==typeof c)for(let e in c)t[e]=c[e];else t="object"==typeof c&&"message"in c?c.message:c;e.errors=t}}return Promise.reject(e)}));const Fe=async function(e){e="string"==typeof e?{url:e}:e;const{data:c}=await H.request({...e});return c};function Oe(){const c=l(),n=O.parse(c.hash.substr(1));sessionStorage.setItem("authorization",n.access_token);const t=sessionStorage.getItem("redirect_uri");return t&&sessionStorage.removeItem("redirect_uri"),e(m,{to:t||"/",replace:!0})}function He(){return f((()=>{Fe("/logout").catch((()=>{sessionStorage.removeItem("authorization")}))}),[]),e(Be,{})}function Me(n){let{children:t}=n;return e(d,{children:c(h,{children:[e(u,{path:"*",element:t}),e(u,{path:"login",element:e(Oe,{})}),e(u,{path:"logout",element:e(He,{})})]})})}function Te(t){let{children:r,title:i,className:o,...a}=t;return e(E,{className:T("border-0 shadow-sm mb-3",o),...a,children:c("div",{className:"card-body",children:[i&&c(n,{children:[e("h5",{children:i}),e("hr",{})]}),r]})})}function Le(c){let{errors:n}=c;return n?e(A,{variant:"danger",children:e("ul",{className:"mb-0",children:"string"==typeof n?e("li",{children:n}):Object.entries(n).map((c=>{let[n,t]=c;return e("li",{children:t},n)}))})}):null}const Ue=g.createContext([null,()=>{}]),qe=function(c){let{children:n,user:t}=c;const[r,i]=v(t);return f((()=>{i(t)}),[t]),r?e(Ue.Provider,{value:[r,i],children:n}):e(Be,{})};function Ke(){const[e,c]=b(Ue);if(!e)throw new Error("please use `useUser` in UserContext");return[e,c]}function Re(c){let{require:t,children:r,fallback:i}=c;const[o]=Ke();let a=!1;return"function"==typeof t?a=t(o):("string"==typeof t&&(t=[t]),a=L(o.roles,t).length>0),a||(r=i),e(n,{children:r})}var Ve,Ge;function Ye(c){let{children:n,size:t="small"}=c;"string"==typeof t&&(t={small:8,middle:16,large:24}[t]);const r=x.map(n,(c=>e(Je,{size:t,children:c})));return e($e,{children:r})}const $e=o.div(Ve||(Ve=V(["\n display: inline-flex;\n align-items: center;\n"]))),Je=o.div(Ge||(Ge=V(["\n margin-right: ","px;\n\n &:last-child {\n margin-right: 0;\n }\n"])),(e=>e.size));function Qe(c){let{value:t,locale:r="zh-CN",currency:i=!0}=c;const o=p((()=>{let e={};return e=i?{style:"currency",currency:"CNY",...e}:{minimumFractionDigits:2},new Intl.NumberFormat(r,e)}),[i,r]);return e(n,{children:o.format(t)})}function We(c){let{loading:n,children:t,...r}=c;return e(D,{...r,disabled:n,children:n?"Loading…":t})}function Xe(e){let{url:c,method:n,confirm:t,onSuccess:r,children:i,disabled:o,as:a=D,...l}=e;const[s,d]=v(!1),h=y((async e=>{e.preventDefault();try{if(d(!0),t&&!await pe.confirm({text:t}))return;const e="string"==typeof c?{url:c,method:n}:{method:n,...c},i=await Fe(e);r&&r(i)}catch(e){if(!H.isAxiosError(e))throw e;{let c=e.errors;"string"!=typeof e.errors&&(c=Object.values(e.errors).join("<br />")),pe.error({text:c})}}finally{d(!1)}}),[c,n,d]);return w(a,{...l,disabled:o||s,onClick:h},i)}const Ze=require("ajv-i18n/localize/zh"),ec=_(((c,n)=>{let{action:t,method:r="post",onSuccess:i,formData:o,onSubmit:a,onChange:l,children:s,...d}=c;const[h,u]=v(),[m,g]=v(!1),[p,f]=v(o),b=y((async(e,c)=>{try{if(g(!0),t){const{formData:c}=e;try{const e=await Fe({url:t,method:r,data:c});u(void 0),i&&await i(e)}catch(e){throw H.isAxiosError(e)&&u((e=>{const c=e.errors;return"string"==typeof c?{__errors:[c]}:U(c,(e=>({__errors:[e]})))})(e)),e}}else a&&await a(e,c)}finally{g(!1)}}),[t,r,a]),x=y((e=>{const{formData:c}=e;f(c),l&&l(e)}),[f,l]),w=y((e=>(e=e.map((e=>({keyword:e.name,dataPath:e.property,...e}))),Ze(e),e)),[]);return e(q,{ref:n,extraErrors:h,onSubmit:b,transformErrors:w,noHtml5Validate:!0,noValidate:!0,...d,formData:p,onChange:x,children:s||e("div",{className:"col-12",children:e(We,{loading:m,type:"submit",variant:"primary",children:"提交"})})})}));var cc,nc,tc,rc,ic;const oc=o.div(cc||(cc=V(["\n width: 100%;\n"]))),ac=o.div(nc||(nc=V(["\n background-color: #fff;\n display: flex;\n\n .container {\n padding: 0 24px;\n display: flex;\n justify-content: space-between;\n align-items: center;\n }\n"]))),lc=o.div(tc||(tc=V(["\n margin-top: 24px;\n"]))),sc=o.div(rc||(rc=V(["\n font-size: 22px;\n line-height: 64px;\n height: 64px;\n"]))),dc=o.div(ic||(ic=V(["\n\n"])));function hc(n){let{title:t,children:r,extra:i}=n;return c(oc,{children:[e(ac,{children:c("div",{className:"container",children:[e(sc,{children:t}),e(dc,{children:i})]})}),e(lc,{className:"container",children:r})]})}function uc(){}function mc(e){return"number"==typeof e&&isFinite(e)&&Math.floor(e)===e}var gc,pc,fc,vc,bc,xc;const yc=o(B)(gc||(gc=V(["\n .rc-table-thead {\n border-top: none;\n }\n"]))),wc={table:c=>e(yc,{...c,className:"align-middle table-hover"})},_c=o((function(c){let{total:n=0,onChange:t=uc,defaultCurrent:r=1,defaultPageSize:i=10,className:o,...a}=c;const[l,s]=v(r),[d,h]=v(i);f((()=>{mc(a.current)&&s(a.current)}),[a.current]),f((()=>{mc(a.pageSize)&&h(a.pageSize)}),[a.pageSize]);const u=p((()=>Math.floor((n-1)/d)+1),[n,d]),m=y((e=>()=>{e!==l&&(s(e),t(e,d))}),[t,l,d]),g=l-1>0?l-1:0,b=l+1<u?l+1:u,x=[];let w=null,_=null,k=null,z=null;if(u<=7)for(let c=1;c<=u;c+=1){const n=l===c;x.push(e(P.Item,{active:n,onClick:m(c),children:c},c))}else{z=e(P.Last,{onClick:m(u)},"last"),k=e(P.First,{onClick:m(1)},"first"),w=e(P.Prev,{onClick:m(g)},"prev"),_=e(P.Next,{onClick:m(b)},"next");let c=Math.max(1,l-2),n=Math.min(l+2,u);l-1<=2&&(n=5),u-l<=2&&(c=u-4);for(let t=c;t<=n;t+=1){const c=l===t;x.push(e(P.Item,{active:c,onClick:m(t),children:t},t))}l-1>=4&&3!==l&&x.unshift(w),u-l>=4&&l!==u-2&&x.push(_),1!==c&&x.unshift(k),n!==u&&x.push(z)}return e(P,{className:o,children:x})}))(pc||(pc=V(["\n margin-bottom: 0;\n justify-content: flex-end;\n"])));function kc(e){return"current_page"in e}const zc=_(((n,t)=>{let{source:r,rowKey:i="id",paginate:o=!0,toolBarRender:a,columns:l=[],...s}=n;const[d,h]=v([]),[u,m]=v(o?{total:0,current:1,pageSize:10}:null),[g,b]=v(!0),x=y((async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};b(!0);try{let c;if("string"==typeof r){const n={};u&&(n.page=e.page||u.current),c=await Fe({url:r,params:n})}else c=await r();o&&kc(c)&&(m({total:c.total,current:c.current_page,pageSize:c.per_page}),c=c.data),h(c)}catch(e){}finally{b(!1)}}),[r,h,u]);f((()=>{x()}),[]);const w=k({reload:x});f((()=>{w.current={reload:x}}),[x]),z(t,(()=>w.current));const _=p((()=>l.map((e=>{const c={...e,render:void 0};if("render"in e&&e.render){const n=e.render;c.render=(e,c,t)=>n({value:e,record:c,index:t,action:w.current})}return c}))),[l,w]),C=y((e=>{x({page:e})}),[]);return c(Te,{children:[e(Be,{loading:g}),c(Cc,{children:[e(Sc,{children:a&&a(w.current)}),e(Nc,{children:e(jc,{onClick:w.current.reload,children:e("i",{className:"bi bi-arrow-repeat"})})})]}),e(K,{...s,rowKey:i,columns:_,components:wc,data:d}),u&&e(_c,{...u,onChange:C})]})})),Cc=o.div(fc||(fc=V(["\n display: flex;\n justify-content: space-between;\n padding-bottom: 1rem;\n"]))),Nc=o(Ye)(vc||(vc=V(["\n\n"]))),Sc=o(Ye)(bc||(bc=V(["\n\n"]))),jc=o.span(xc||(xc=V(["\n cursor: pointer;\n font-size: 20px;\n line-height: 1;\n\n &:hover {\n color: var(--bs-primary);\n }\n"]))),Ic=_(((t,r)=>{let{text:i,variant:o="primary",header:a=i,footer:l=!0,onOk:s,size:d,children:h}=t;const[u,m]=v(!1),[g,p]=v(!1),f=()=>m(!1);z(r,(()=>({close:f})));return c(n,{children:[e(D,{variant:o,onClick:()=>m(!0),children:i}),c(F,{size:d,show:u,onHide:f,children:[a&&e(F.Header,{closeButton:!0,children:e(F.Title,{as:"h5",children:a})}),e(F.Body,{children:h}),l&&c(F.Footer,{children:[e(D,{variant:"secondary",onClick:f,children:"取消"}),e(We,{loading:g,variant:"primary",onClick:async()=>{if(s){p(!0);const e=await s();if(p(!1),!1===e)return}f()},children:"确定"})]})]})]})}));function Ec(c){let{text:n,header:t,schema:r,uiSchema:i,action:o,method:a,formData:l,variant:s,onSuccess:d,onChange:h,fields:u,size:m}=c;const g=k(null),p=k(null),f=y((async()=>{try{var e;return await(null===(e=g.current)||void 0===e?void 0:e.submit()),!0}catch{return!1}}),[]);return e(Ic,{ref:p,text:n,onOk:f,header:t,variant:s,size:m,children:e(ec,{ref:g,schema:r,uiSchema:i,action:o,method:a,formData:l,fields:u,onChange:h,onSuccess:d,children:e(C,{})})})}function Ac(e){let{manual:c,refreshDeps:n,...t}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{execute:r,currentParams:i,error:o,...a}=R((async c=>(e="string"==typeof e?{url:e}:e,await Fe({...e,...c}))),t);f((()=>{c||n||r()}),[]),f((()=>{n&&l()}),n);const l=y((()=>{i?r(...i):r()}),[r,i]);return{refresh:l,execute:r,...a}}let Dc=0;function Pc(){let{onHide:e,onShow:c}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const[n,t]=v(!1),[r,i]=v("visible-".concat(Dc)),o=y((()=>{t(!1),e&&e()}),[t,e]),a=y((()=>{i("visible-".concat(++Dc))}),[i,Dc]),l=y((()=>{t(!0),c&&c()}),[t,c]),s={show:n,onHide:o,onExited:a,key:r};return{visible:n,show:l,hide:o,state:s}}export{Re as Access,Te as Card,hc as Content,Le as Error,$ as Footer,ec as Form,Ie as Header,Be as Loader,We as LoadingButton,pe as Message,Ic as ModalButton,Ec as ModalForm,Qe as NumberFormat,Xe as RequestButton,Ce as Result,Me as Root,oe as SiderLayout,Ye as Space,zc as Table,qe as UserProvider,Fe as request,Pc as useOverlayState,Ac as useRequest,Ke as useUser};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../node_modules/@babel/runtime/helpers/esm/taggedTemplateLiteral.js","../src/components/footer.tsx","../src/utils/get-menu-data.ts","../src/layout/sider.tsx","../src/utils/message.ts","../src/components/result.tsx","../src/images/logo.svg","../src/components/header.tsx","../src/components/dimmer.tsx","../src/components/loader.tsx","../src/request.ts","../src/components/root.tsx","../src/components/card.tsx","../src/components/error.tsx","../src/components/user-provider.tsx","../src/components/access.tsx","../src/components/space.tsx","../src/components/number-format.tsx","../src/components/loading-button.tsx","../src/components/request-button.tsx","../src/components/form.tsx","../src/components/content.tsx","../src/components/pagination.tsx","../src/components/table.tsx","../src/components/modal-button.tsx","../src/components/modal-form.tsx","../src/hooks/use-request.ts"],"sourcesContent":["export default function _taggedTemplateLiteral(strings, raw) {\n if (!raw) {\n raw = strings.slice(0);\n }\n\n return Object.freeze(Object.defineProperties(strings, {\n raw: {\n value: Object.freeze(raw)\n }\n }));\n}","import styled from 'styled-components';\r\n\r\nconst FooterWrapper = styled.footer`\r\n\r\n`;\r\n\r\n\r\nexport default function Footer() {\r\n return <FooterWrapper>\r\n <div className='container'>\r\n\r\n </div>\r\n </FooterWrapper>;\r\n}\r\n","import type { RouteObject } from 'react-router';\r\n\r\nexport interface MenuData {\r\n path: string;\r\n title: string;\r\n children: MenuData[];\r\n}\r\n\r\nconst formatRelativePath = (\r\n routes: RouteObject[],\r\n parent: string = '/',\r\n): MenuData[] => {\r\n\r\n const menus: MenuData[] = [];\r\n\r\n for (const route of routes) {\r\n\r\n if (route.meta?.hideInMenu) {\r\n continue;\r\n }\r\n\r\n const title = route.meta?.title;\r\n if (!title) {\r\n continue;\r\n }\r\n\r\n let path = route.path || '';\r\n\r\n path = `${parent}/${path}`;\r\n\r\n path = path.replace(/\\/+/, '/').replace(/\\/$/, '');\r\n\r\n const menu: MenuData = {\r\n title,\r\n path,\r\n children: []\r\n };\r\n\r\n if (!route.meta?.hideChildrenInMenu) {\r\n if (route.children && route.children.length > 0) {\r\n menu.children = formatRelativePath(route.children, path);\r\n }\r\n }\r\n\r\n menus.push(menu);\r\n }\r\n\r\n return menus;\r\n};\r\n\r\nexport default function getMenuData(routes: RouteObject[], base: string = '/'): MenuData[] {\r\n return formatRelativePath(routes, base);\r\n}\r\n","import RcMenu, { MenuItem, SubMenu } from 'rc-menu';\r\nimport Footer from '../components/footer';\r\nimport { Link, useLocation, useRoutes } from 'react-router-dom';\r\nimport { useMemo } from 'react';\r\nimport styled from 'styled-components';\r\nimport 'rc-menu/assets/index.css';\r\nimport type { RouteObject } from 'react-router';\r\nimport getMenuData, { MenuData } from '../utils/get-menu-data';\r\nimport type { CSSMotionProps } from 'rc-motion';\r\n\r\ninterface Props {\r\n title: string;\r\n routes: RouteObject[];\r\n basename: string;\r\n}\r\n\r\nconst renderMenuItems = (items: MenuData[]) => {\r\n return items.map((item) => {\r\n if (item.children.length > 0) {\r\n return <SubMenu title={item.title} key={item.path}>\r\n {renderMenuItems(item.children)}\r\n </SubMenu>;\r\n } else {\r\n return <MenuItem key={item.path}>\r\n <Link to={item.path}>{item.title}</Link>\r\n </MenuItem>;\r\n }\r\n });\r\n};\r\n\r\nconst collapseNode = () => {\r\n return { height: 0 };\r\n};\r\nconst expandNode = (node: HTMLElement) => {\r\n return { height: node.scrollHeight };\r\n};\r\n\r\nconst motion: CSSMotionProps = {\r\n motionName: 'rc-menu-collapse',\r\n motionAppear: true,\r\n onAppearStart: collapseNode,\r\n onAppearActive: expandNode,\r\n onEnterStart: collapseNode,\r\n onEnterActive: expandNode,\r\n onLeaveStart: expandNode,\r\n onLeaveActive: collapseNode,\r\n};\r\n\r\n\r\nexport default function SiderLayout({ routes, basename, title }: Props) {\r\n\r\n const children = useRoutes(routes);\r\n\r\n const menu = useMemo(() => getMenuData(routes, basename), [routes, basename]);\r\n\r\n const { pathname } = useLocation();\r\n\r\n const openKeys = useMemo(() => {\r\n const keys: string[] = [];\r\n const parts = pathname.split('/');\r\n parts.reduce<string[]>((pre, curr) => {\r\n if (pre.length > 1) {\r\n keys.push(pre.join('/'));\r\n }\r\n return [...pre, curr];\r\n }, []);\r\n\r\n return keys;\r\n }, [pathname]);\r\n\r\n const selectedKeys = useMemo(() => {\r\n return [...openKeys, pathname];\r\n }, [pathname, openKeys]);\r\n\r\n return <Container>\r\n <Sidebar>\r\n <Header>{title}</Header>\r\n <Menu mode='inline' motion={motion} defaultOpenKeys={openKeys} selectedKeys={selectedKeys}>\r\n {renderMenuItems(menu)}\r\n </Menu>\r\n </Sidebar>\r\n <Content>\r\n <Main>{children}</Main>\r\n <Footer />\r\n </Content>\r\n </Container>;\r\n}\r\n\r\nconst Container = styled.div`\r\n display: flex;\r\n flex-wrap: nowrap;\r\n width: 100%;\r\n`;\r\n\r\nconst Sidebar = styled.nav`\r\n position: fixed;\r\n top: 0;\r\n bottom: 0;\r\n left: 0;\r\n z-index: 100;\r\n padding: 54px 0 0;\r\n border-right: 1px solid #e3e3e3;\r\n width: 230px;\r\n background-color: #f5f5f5;\r\n`;\r\n\r\nconst Header = styled.div`\r\n padding: 10px 0;\r\n height: 64px;\r\n line-height: 44px;\r\n text-indent: 24px;\r\n text-overflow: ellipsis;\r\n white-space: nowrap;\r\n overflow: hidden;\r\n font-size: 16px;\r\n`;\r\n\r\nconst Content = styled.div`\r\n margin-left: 230px;\r\n flex: 1;\r\n`;\r\n\r\nconst Main = styled.main`\r\n min-height: calc(100vh - 54px);\r\n position: relative;\r\n`;\r\n\r\nconst Menu = styled(RcMenu)`\r\n border: none;\r\n box-shadow: none;\r\n padding: 0;\r\n\r\n .rc-menu-item {\r\n display: flex;\r\n\r\n &:hover {\r\n background-color: #f0f0f0;\r\n }\r\n\r\n a {\r\n flex: 1;\r\n text-decoration: none;\r\n color: inherit;\r\n }\r\n }\r\n\r\n .rc-menu-sub {\r\n background-color: #eee;\r\n border-top: 1px solid #eee;\r\n border-bottom: 1px solid #eee;\r\n\r\n & > li {\r\n &:first-child {\r\n margin-top: 4px;\r\n }\r\n\r\n &:last-child {\r\n margin-bottom: 4px;\r\n }\r\n }\r\n\r\n .rc-menu-item-selected {\r\n background-color: #eee;\r\n color: var(--bs-primary);\r\n }\r\n\r\n .rc-menu-item-active {\r\n background-color: #eee;\r\n }\r\n\r\n .rc-menu-item {\r\n &:hover {\r\n background-color: #e7e7e7;\r\n }\r\n }\r\n }\r\n\r\n .rc-menu-submenu {\r\n & > .rc-menu-submenu-title {\r\n &:hover {\r\n background-color: #e7e7e7;\r\n }\r\n }\r\n }\r\n\r\n .rc-menu-submenu-active > .rc-menu-submenu-title {\r\n background-color: #eee;\r\n }\r\n\r\n .rc-menu-item,\r\n .rc-menu-submenu > .rc-menu-submenu-title {\r\n padding: 0 8px 0 24px;\r\n font-size: 14px;\r\n line-height: 36px;\r\n cursor: pointer;\r\n }\r\n\r\n .rc-menu-sub > .rc-menu-item,\r\n .rc-menu-sub > .rc-menu-submenu > .rc-menu-submenu-title {\r\n padding-top: 0;\r\n padding-bottom: 0;\r\n padding-right: 0;\r\n }\r\n\r\n .rc-menu-submenu-arrow {\r\n line-height: 38px;\r\n }\r\n\r\n .rc-menu-item-selected {\r\n background-color: #f5f5f5;\r\n color: var(--bs-primary);\r\n }\r\n\r\n .rc-menu-submenu-selected {\r\n background-color: #eee;\r\n\r\n .rc-menu-submenu-title {\r\n color: var(--bs-primary);\r\n font-weight: 500;\r\n }\r\n }\r\n\r\n & > .rc-menu-item {\r\n line-height: 38px;\r\n }\r\n\r\n & > .rc-menu-submenu {\r\n &.rc-menu-submenu-selected {\r\n background-color: #f5f5f5;\r\n }\r\n\r\n & > .rc-menu-submenu-title {\r\n line-height: 38px;\r\n\r\n &:hover {\r\n background-color: #f0f0f0;\r\n }\r\n }\r\n\r\n &.rc-menu-submenu-active > .rc-menu-submenu-title {\r\n background-color: #f5f5f5;\r\n }\r\n\r\n & > .rc-menu-sub {\r\n border-top: 1px solid #e6e6e6;\r\n border-bottom: 1px solid #e6e6e6;\r\n\r\n & > li {\r\n &:first-child {\r\n margin-top: 9px;\r\n }\r\n\r\n &:last-child {\r\n margin-bottom: 9px;\r\n }\r\n }\r\n }\r\n }\r\n\r\n`;\r\n","import Swal from 'sweetalert2/dist/sweetalert2.js';\r\nimport withReactContent from 'sweetalert2-react-content';\r\n\r\nconst CustomSwal = withReactContent(Swal);\r\n\r\ninterface MessageOptions {\r\n title?: string;\r\n text?: string;\r\n}\r\n\r\nconst defaultOptions = {\r\n confirmButtonText: '确定',\r\n cancelButtonText: '取消'\r\n};\r\n\r\nconst Message = {\r\n confirm: async (options: MessageOptions) => {\r\n const { isConfirmed } = await CustomSwal.fire({\r\n ...defaultOptions,\r\n icon: 'warning',\r\n showCancelButton: true,\r\n ...options\r\n });\r\n\r\n return isConfirmed;\r\n },\r\n error: (options: MessageOptions) => {\r\n CustomSwal.fire({\r\n ...defaultOptions,\r\n toast: true,\r\n position: 'top',\r\n icon: 'error',\r\n timer: 3000,\r\n showConfirmButton: false,\r\n ...options\r\n });\r\n }\r\n};\r\n\r\nexport default Message;\r\n","import { ReactNode } from 'react';\r\nimport styled from 'styled-components';\r\n\r\nconst Container = styled.div`\r\n padding: 48px 32px;\r\n`;\r\n\r\nconst Icon = styled.div`\r\n margin-bottom: 24px;\r\n text-align: center;\r\n font-size: 72px;\r\n`;\r\n\r\nconst Title = styled.div`\r\n color: rgba(0, 0, 0, .85);\r\n font-size: 24px;\r\n line-height: 1.8;\r\n text-align: center;\r\n`;\r\n\r\nconst Extra = styled.div`\r\n margin-top: 32px;\r\n text-align: center;\r\n`;\r\n\r\nconst IconMap = {\r\n success: <i className='bi bi-check-circle-fill text-success' />,\r\n error: <i className='bi bi-exclamation-circle-fill text-danger' />,\r\n info: <i className='bi bi-info-circle-fill text-info' />,\r\n warning: <i className='bi bi-exclamation-triangle-fill text-warning' />,\r\n};\r\n\r\ninterface ResultProps {\r\n status?: keyof typeof IconMap\r\n icon?: ReactNode\r\n title?: string\r\n extra?: ReactNode;\r\n}\r\n\r\nexport default function Result({ status, title, icon, extra }: ResultProps) {\r\n\r\n if (!icon && status) {\r\n icon = IconMap[status];\r\n }\r\n\r\n return <Container>\r\n {icon && <Icon>{icon}</Icon>}\r\n {title && <Title>{title}</Title>}\r\n {extra && <Extra>{extra}</Extra>}\r\n </Container>;\r\n}\r\n","var img = \"data:image/svg+xml,%3csvg width='485' height='132' xmlns='http://www.w3.org/2000/svg' xml:space='preserve' style='enable-background:new 0 0 531.69 198.43%3b' version='1.1'%3e %3cstyle type='text/css'%3e.st0%7bfill:%233C60FF%3b%7d%3c/style%3e %3cg%3e %3ctitle%3ebackground%3c/title%3e %3crect fill='none' id='canvas_background' height='134' width='487' y='-1' x='-1'/%3e %3c/g%3e %3cg%3e %3ctitle%3eLayer 1%3c/title%3e %3cpath id='svg_1' d='m132.29%2c62.34c-1.19%2c-18.77 -10.34%2c-35.36 -24.11%2c-46.46c-11.15%2c-8.99 -25.34%2c-14.38 -40.79%2c-14.38c-0.55%2c0 -1.09%2c0.01 -1.63%2c0.02c-3.32%2c0.08 -6.57%2c0.41 -9.75%2c0.98c-30.49%2c5.38 -53.65%2c32 -53.65%2c64.04c0%2c1.87 0.08%2c3.73 0.24%2c5.57c2.5%2c29.51 24.7%2c53.4 53.41%2c58.47c2.38%2c0.42 4.8%2c0.72 7.26%2c0.86c0.83%2c0.05 1.66%2c0.09 2.5%2c0.11c0.54%2c0.01 1.08%2c0.02 1.63%2c0.02c34.04%2c0 61.97%2c-26.16 64.79%2c-59.46c0.16%2c-1.83 0.24%2c-3.69 0.24%2c-5.57c0%2c-1.42 -0.05%2c-2.82 -0.14%2c-4.2zm-76.27%2c32.5c-0.26%2c0.01 -0.53%2c0.01 -0.79%2c0.01c-14.56%2c0 -26.88%2c-9.57 -31.03%2c-22.76c-0.97%2c-3.08 -1.49%2c-6.35 -1.49%2c-9.75c0%2c-17.95 14.56%2c-32.52 32.51%2c-32.52c0.26%2c0 0.53%2c0 0.79%2c0.01c3.41%2c0.08 6.69%2c0.68 9.75%2c1.74c6.5%2c2.22 12.06%2c6.45 15.97%2c11.94c1.98%2c2.78 3.54%2c5.9 4.57%2c9.25c0.94%2c3.03 1.44%2c6.24 1.44%2c9.58l-9.75%2c0c0%2c-2.18 -0.31%2c-4.29 -0.88%2c-6.28c-0.92%2c-3.23 -2.55%2c-6.17 -4.69%2c-8.64c-1.86%2c-2.14 -4.12%2c-3.93 -6.65%2c-5.25c-2.93%2c-1.54 -6.24%2c-2.46 -9.75%2c-2.58c-0.26%2c-0.01 -0.52%2c-0.01 -0.79%2c-0.01c-12.57%2c0 -22.76%2c10.19 -22.76%2c22.76c0%2c3.49 0.79%2c6.8 2.19%2c9.75c3.65%2c7.69 11.49%2c13.01 20.57%2c13.01c0.27%2c0 0.53%2c-0.01 0.79%2c-0.01l0%2c9.75zm55.7%2c-17.92c-3.35%2c10.5 -13.18%2c18.09 -24.78%2c18.09c-3.13%2c0 -6.13%2c-0.55 -8.91%2c-1.57c-2.18%2c-0.8 -4.24%2c-1.88 -6.11%2c-3.21c-2.38%2c-1.68 -4.47%2c-3.76 -6.16%2c-6.13c-0.28%2c-0.39 -0.55%2c-0.79 -0.81%2c-1.2c-2.03%2c-3.2 -3.38%2c-6.87 -3.85%2c-10.82l9.87%2c0c0.33%2c1.71 0.92%2c3.32 1.74%2c4.8c1.61%2c2.91 4.09%2c5.26 7.09%2c6.72c0.57%2c0.28 1.15%2c0.53 1.76%2c0.73c1.68%2c0.6 3.49%2c0.92 5.37%2c0.92c7.92%2c0 14.52%2c-5.67 15.96%2c-13.17c0.2%2c-1 0.3%2c-2.04 0.3%2c-3.09c0%2c-2.37 -0.51%2c-4.63 -1.43%2c-6.67c-1.66%2c-3.71 -4.68%2c-6.68 -8.43%2c-8.28l3.54%2c-9.1c7.43%2c3.08 13.13%2c9.49 15.21%2c17.38c0.44%2c1.64 0.72%2c3.34 0.81%2c5.09c0.04%2c0.52 0.05%2c1.05 0.05%2c1.58c0%2c1.05 -0.07%2c2.07 -0.18%2c3.09c-0.18%2c1.68 -0.54%2c3.3 -1.04%2c4.84z' class='st0'/%3e %3cg id='svg_2'%3e %3cg id='svg_3'%3e %3crect id='svg_4' height='6.34' width='94.12' class='st0' y='20.46' x='163.29'/%3e %3c/g%3e %3cg id='svg_5'%3e %3cpath id='svg_6' d='m169.31%2c113.72l0%2c-6.34c6.49%2c0 11.77%2c-5.28 11.77%2c-11.77l0%2c-71.98l6.34%2c0l0%2c71.98c0%2c9.98 -8.12%2c18.11 -18.11%2c18.11z' class='st0'/%3e %3c/g%3e %3cg id='svg_7'%3e %3cpath id='svg_8' d='m255.49%2c91.27l-6.34%2c0l0%2c-38.2c0%2c-5.06 -4.12%2c-9.18 -9.18%2c-9.18l-19.37%2c0c-5.06%2c0 -9.18%2c4.12 -9.18%2c9.18l0%2c38.2l-6.34%2c0l0%2c-38.2c0%2c-8.55 6.96%2c-15.51 15.51%2c-15.51l19.38%2c0c8.55%2c0 15.51%2c6.96 15.51%2c15.51l0%2c38.2l0.01%2c0z' class='st0'/%3e %3c/g%3e %3cg id='svg_9'%3e %3crect id='svg_10' height='17.09' width='6.34' class='st0' y='23.63' x='227.12'/%3e %3c/g%3e %3cg id='svg_11'%3e %3cpath id='svg_12' d='m206.43%2c113.84l-3.34%2c0l0%2c-6.34l3.34%2c0c6.3%2c0 12.9%2c-3.56 15.35%2c-8.29c3.49%2c-6.71 5.33%2c-14.25 5.33%2c-21.81l0%2c-26.13l6.34%2c0l0%2c26.13c0%2c8.58 -2.09%2c17.13 -6.05%2c24.74c-3.98%2c7.68 -13.57%2c11.7 -20.97%2c11.7z' class='st0'/%3e %3c/g%3e %3cg id='svg_13'%3e %3cpath id='svg_14' d='m257.48%2c113.84l-3.34%2c0c-7.4%2c0 -16.98%2c-4.02 -20.98%2c-11.7c-3.96%2c-7.61 -6.05%2c-16.16 -6.05%2c-24.74l6.34%2c0c0%2c7.56 1.84%2c15.1 5.33%2c21.81c2.46%2c4.73 9.06%2c8.29 15.35%2c8.29l3.34%2c0l0%2c6.34l0.01%2c0z' class='st0'/%3e %3c/g%3e %3cg id='svg_15'%3e %3crect id='svg_16' height='6.34' width='42.87' class='st0' y='27.89' x='274.07'/%3e %3c/g%3e %3cg id='svg_17'%3e %3crect id='svg_18' height='61.38' width='6.34' class='st0' y='14.89' x='293.05'/%3e %3c/g%3e %3cg id='svg_19'%3e %3crect id='svg_20' height='6.34' width='33.26' class='st0' transform='matrix(0.11%2c-0.9939%2c0.9939%2c0.11%2c194.7608%2c392.0006) ' y='46.985071' x='325.728637'/%3e %3c/g%3e %3cg id='svg_21'%3e %3crect id='svg_22' height='33.26' width='6.34' class='st0' transform='matrix(0.9939%2c-0.11%2c0.11%2c0.9939%2c-7.5075%2c38.3801) ' y='37.060893' x='310.495485'/%3e %3c/g%3e %3cg id='svg_23'%3e %3cpath id='svg_24' d='m352.9%2c77.14l-15.15%2c0c-7.52%2c0 -13.64%2c-6.12 -13.64%2c-13.63l0%2c-29.61c0%2c-7.52 6.12%2c-13.64 13.64%2c-13.64l15.15%2c0c7.52%2c0 13.64%2c6.12 13.64%2c13.64l0%2c29.61c0%2c7.52 -6.12%2c13.63 -13.64%2c13.63zm-15.15%2c-50.54c-4.02%2c0 -7.3%2c3.27 -7.3%2c7.3l0%2c29.61c0%2c4.02 3.27%2c7.3 7.3%2c7.3l15.15%2c0c4.02%2c0 7.3%2c-3.27 7.3%2c-7.3l0%2c-29.61c0%2c-4.02 -3.27%2c-7.3 -7.3%2c-7.3l-15.15%2c0z' class='st0'/%3e %3c/g%3e %3cg id='svg_25'%3e %3cg id='svg_26'%3e %3crect id='svg_27' height='6.34' width='17.8' class='st0' y='37.2' x='336.43'/%3e %3c/g%3e %3cg id='svg_28'%3e %3crect id='svg_29' height='6.34' width='17.8' class='st0' y='53.87' x='336.43'/%3e %3c/g%3e %3c/g%3e %3cg id='svg_30'%3e %3cpath id='svg_31' d='m352.7%2c113.84l-37.98%2c0c-8%2c0 -14.5%2c-6.51 -14.5%2c-14.5l0%2c-16.14l6.34%2c0l0%2c16.13c0%2c4.5 3.66%2c8.17 8.17%2c8.17l37.98%2c0l0%2c6.34l-0.01%2c0z' class='st0'/%3e %3c/g%3e %3cg id='svg_32'%3e %3crect id='svg_33' height='6.34' width='23.57' class='st0' transform='matrix(0.2529%2c-0.9675%2c0.9675%2c0.2529%2c114.4986%2c402.9877) ' y='83.698593' x='326.836101'/%3e %3c/g%3e %3cg id='svg_34'%3e %3crect id='svg_35' height='6.34' width='20.52' class='st0' y='86.2' x='321.58'/%3e %3c/g%3e %3cg id='svg_36'%3e %3crect id='svg_37' height='24.75' width='6.34' class='st0' transform='matrix(0.9556%2c-0.2946%2c0.2946%2c0.9556%2c-19.7967%2c122.424) ' y='75.874073' x='369.686666'/%3e %3c/g%3e %3cg id='svg_38'%3e %3crect id='svg_39' height='6.34' width='71.83' class='st0' y='20.46' x='395.51'/%3e %3c/g%3e %3cg id='svg_40'%3e %3crect id='svg_41' height='6.34' width='90.81' class='st0' y='57.44' x='386.02'/%3e %3c/g%3e %3cg id='svg_42'%3e %3cpath id='svg_43' d='m463.12%2c113.64l-56%2c0c-4.5%2c0 -8.59%2c-2.29 -10.94%2c-6.14c-2.35%2c-3.84 -2.52%2c-8.53 -0.46%2c-12.53l17.68%2c-35.81l5.64%2c2.89l-17.68%2c35.81c-1.04%2c2.02 -0.95%2c4.39 0.23%2c6.33c1.19%2c1.94 3.25%2c3.1 5.53%2c3.1l56%2c0c1.51%2c0 2.88%2c-0.71 3.74%2c-1.95c0.81%2c-1.16 1.03%2c-2.57 0.63%2c-3.91l-7.8%2c-12.34l5.36%2c-3.39l8.18%2c12.94l0.12%2c0.31c1.24%2c3.34 0.76%2c7.08 -1.28%2c10.01c-2.04%2c2.94 -5.39%2c4.68 -8.95%2c4.68z' class='st0'/%3e %3c/g%3e %3c/g%3e %3c/g%3e%3c/svg%3e\";\n export default img;","import logo from '../images/logo.svg';\r\nimport { Dropdown } from 'react-bootstrap';\r\nimport styled from 'styled-components';\r\nimport { PropsWithChildren, ReactNode } from 'react';\r\n\r\nconst Avatar = styled.a`\r\n cursor: pointer;\r\n`;\r\n\r\ninterface Props {\r\n menus: ReactNode;\r\n}\r\n\r\nexport default function Header({ children, menus }: PropsWithChildren<Props>) {\r\n\r\n return <Container className='navbar navbar-light bg-white border-bottom sticky-top'>\r\n <div className='container-fluid'>\r\n <a className='navbar-brand' href='https://www.topthink.com'>\r\n <img src={logo} height='30' />\r\n </a>\r\n {children}\r\n <div className='d-flex align-items-center'>\r\n <Dropdown navbar>\r\n <Dropdown.Toggle as={Avatar} className='nav-link'>\r\n <i className='bi bi-person-circle' />\r\n </Dropdown.Toggle>\r\n <Dropdown.Menu className={'shadow'}>\r\n {menus}\r\n </Dropdown.Menu>\r\n </Dropdown>\r\n </div>\r\n </div>\r\n </Container>;\r\n}\r\n\r\nconst Container = styled.header`\r\n height: 54px;\r\n`;\r\n","import styled from 'styled-components';\r\n\r\nexport const Dimmable = styled.div`\r\n position: relative;\r\n`;\r\n\r\ninterface DimmerProps {\r\n active?: boolean\r\n inverted?: boolean\r\n}\r\n\r\nconst Dimmer = styled.div<DimmerProps>`\r\n display: ${props => props.active ? 'flex' : 'none'};\r\n position: absolute;\r\n top: 0 !important;\r\n left: 0 !important;\r\n width: 100%;\r\n height: 100%;\r\n text-align: center;\r\n vertical-align: middle;\r\n padding: 1em;\r\n background-color: ${props => props.inverted ? 'rgba(255, 255, 255, .85)' : 'rgba(0, 0, 0, .85)'};\r\n opacity: ${props => props.active ? 1 : 0};\r\n line-height: 1;\r\n animation-fill-mode: both;\r\n animation-duration: .5s;\r\n transition: background-color .5s linear;\r\n flex-direction: column;\r\n align-items: center;\r\n justify-content: center;\r\n user-select: none;\r\n will-change: opacity;\r\n z-index: 990;\r\n`;\r\n\r\nexport default Dimmer;\r\n","import { PropsWithChildren } from 'react';\r\nimport { Spinner, SpinnerProps } from 'react-bootstrap';\r\nimport Dimmer from './dimmer';\r\n\r\ninterface LoaderProps {\r\n loading?: boolean\r\n animation?: SpinnerProps['animation']\r\n}\r\n\r\nexport default function Loader({\r\n loading = true,\r\n children,\r\n variant = 'success',\r\n animation = 'border',\r\n ...props\r\n}: PropsWithChildren<LoaderProps & Omit<SpinnerProps, 'animation'>>) {\r\n if (!loading) {\r\n return null;\r\n }\r\n\r\n if (children) {\r\n children = <p className='mt-3 text-secondary'>{children}</p>;\r\n }\r\n\r\n return <Dimmer inverted active>\r\n <Spinner animation={animation} variant={variant} {...props} />\r\n {children}\r\n </Dimmer>;\r\n}\r\n","import axios, { AxiosRequestConfig } from 'axios';\r\nimport * as rax from 'retry-axios';\r\n\r\nexport type Errors = string | {\r\n [key: string]: string\r\n}\r\n\r\ndeclare module 'axios' {\r\n interface AxiosError {\r\n errors: Errors;\r\n }\r\n}\r\n\r\nrax.attach();\r\naxios.defaults.raxConfig = {\r\n retryDelay: 2000,\r\n backoffType: 'static',\r\n shouldRetry: (err) => {\r\n return (\r\n err.config.method?.toUpperCase() === 'GET'\r\n && err.response?.status === 449\r\n );\r\n }\r\n};\r\naxios.defaults.baseURL = '/api';\r\naxios.interceptors.request.use(\r\n config => {\r\n const token = sessionStorage.getItem('authorization');\r\n\r\n if (token) {\r\n config.headers.Authorization = `Bearer ${token}`;\r\n }\r\n return config;\r\n },\r\n error => {\r\n return Promise.reject(error);\r\n }\r\n);\r\n\r\naxios.interceptors.response.use(\r\n response => {\r\n if (response.status === 201 && response.data.location) {\r\n window.location.href = response.data.location;\r\n response.data = undefined;\r\n }\r\n\r\n return response;\r\n },\r\n e => {\r\n if (axios.isAxiosError(e)) {\r\n if (e.response) {\r\n const { data, status } = e.response;\r\n if (status === 401) {\r\n const { url } = data;\r\n if (url) {\r\n sessionStorage.setItem('redirect_uri', window.location.pathname + window.location.search);\r\n const redirectUri = window.location.origin + '/login';\r\n window.location.href = `${url}&redirect_uri=${encodeURIComponent(redirectUri)}`;\r\n }\r\n e.errors = 'Unauthorized';\r\n } else {\r\n let errors: Errors = {};\r\n if (status === 422 && typeof data === 'object') {\r\n for (let name in data) {\r\n errors[name] = data[name];\r\n }\r\n } else if ((typeof data === 'object') && ('message' in data)) {\r\n errors = data['message'];\r\n } else {\r\n errors = data;\r\n }\r\n e.errors = errors;\r\n }\r\n }\r\n }\r\n return Promise.reject(e);\r\n }\r\n);\r\n\r\nexport type Config = AxiosRequestConfig | string\r\n\r\nconst request = async function <T = any>(config: Config) {\r\n config = typeof config === 'string' ? { url: config } : config;\r\n\r\n const { data } = await axios.request<T>({\r\n ...config\r\n });\r\n\r\n return data;\r\n};\r\n\r\nexport default request;\r\n","import { PropsWithChildren, useEffect } from 'react';\r\nimport { BrowserRouter, Navigate, Route, Routes, useLocation } from 'react-router-dom';\r\nimport queryString from 'query-string';\r\nimport Loader from './loader';\r\nimport request from '../request';\r\n\r\nfunction Login() {\r\n\r\n const location = useLocation();\r\n\r\n const parsed = queryString.parse(location.hash.substr(1));\r\n\r\n sessionStorage.setItem('authorization', parsed.access_token as string);\r\n\r\n const redirectUri = sessionStorage.getItem('redirect_uri');\r\n if (redirectUri) {\r\n sessionStorage.removeItem('redirect_uri');\r\n }\r\n\r\n return <Navigate to={redirectUri || '/'} replace />;\r\n}\r\n\r\nfunction Logout() {\r\n\r\n useEffect(() => {\r\n request('/logout').catch(() => {\r\n sessionStorage.removeItem('authorization');\r\n });\r\n }, []);\r\n\r\n return <Loader />;\r\n}\r\n\r\nexport default function Root({ children }: PropsWithChildren<any>) {\r\n\r\n return <BrowserRouter>\r\n <Routes>\r\n <Route path='*' element={children} />\r\n <Route path='login' element={<Login />} />\r\n <Route path='logout' element={<Logout />} />\r\n </Routes>\r\n </BrowserRouter>;\r\n}\r\n","import { PropsWithChildren } from 'react';\r\nimport { Card as BsCard, CardProps as BsCardProps } from 'react-bootstrap';\r\nimport classNames from 'classnames';\r\n\r\ninterface CardProps extends BsCardProps {\r\n title?: string;\r\n}\r\n\r\nexport default function Card({ children, title, className, ...props }: PropsWithChildren<CardProps>) {\r\n\r\n return <BsCard className={classNames('border-0 shadow-sm mb-3', className)} {...props}>\r\n <div className='card-body'>\r\n {title && <>\r\n <h5>{title}</h5>\r\n <hr />\r\n </>}\r\n {children}\r\n </div>\r\n </BsCard>;\r\n}\r\n","import { Alert } from 'react-bootstrap';\r\nimport { Errors } from '../request';\r\n\r\nexport default function Error({ errors }: { errors?: Errors }) {\r\n if (!errors) {\r\n return null;\r\n }\r\n return <Alert variant='danger'>\r\n <ul className='mb-0'>\r\n {typeof errors === 'string'\r\n ? <li>{errors}</li>\r\n : Object.entries(errors).map(([name, error]) => <li key={name}>{error}</li>)\r\n }\r\n </ul>\r\n </Alert>;\r\n}\r\n","import React, { PropsWithChildren, useContext, useEffect, useState } from 'react';\r\nimport Loader from './loader';\r\n\r\nexport interface User {\r\n id: number;\r\n name: string;\r\n email: string;\r\n mobile: string;\r\n is_certified: boolean;\r\n roles: [];\r\n}\r\n\r\nexport const UserContext = React.createContext<[(User | null), ((user: User) => void)]>([null, () => {\r\n}]);\r\n\r\ninterface Props {\r\n user: User;\r\n}\r\n\r\nconst UserProvider = function({ children, user }: PropsWithChildren<Props>) {\r\n const [state, setState] = useState(user);\r\n\r\n useEffect(() => {\r\n setState(user);\r\n }, [user]);\r\n\r\n if (!state) {\r\n return <Loader />;\r\n }\r\n\r\n return <UserContext.Provider value={[state, setState]}>\r\n {children}\r\n </UserContext.Provider>;\r\n};\r\n\r\nexport function useUser(): [User, ((user: User) => void)] {\r\n const [user, setUser] = useContext(UserContext);\r\n if (!user) {\r\n throw new Error('please use `useUser` in UserContext');\r\n }\r\n\r\n return [user, setUser];\r\n}\r\n\r\nexport default UserProvider;\r\n","import { ReactNode } from 'react';\r\nimport { intersection } from 'lodash';\r\nimport { User, useUser } from './user-provider';\r\n\r\nexport interface AccessProps {\r\n require?: string | string[] | ((user: User) => boolean);\r\n fallback?: ReactNode;\r\n children: ReactNode;\r\n}\r\n\r\nexport default function Access({\r\n require,\r\n children,\r\n fallback\r\n}: AccessProps) {\r\n const [user,] = useUser();\r\n let passed = false;\r\n if (typeof require === 'function') {\r\n passed = require(user);\r\n } else {\r\n if (typeof require === 'string') {\r\n require = [require];\r\n }\r\n passed = intersection(user.roles, require).length > 0;\r\n }\r\n if (!passed) {\r\n children = fallback;\r\n }\r\n\r\n return <>{children}</>;\r\n}\r\n","import { Children, ReactNode } from 'react';\r\nimport styled from 'styled-components';\r\n\r\ninterface SpaceProps {\r\n children: ReactNode;\r\n size?: 'small' | 'middle' | 'large' | number;\r\n}\r\n\r\n\r\nexport default function Space({ children, size = 'small' }: SpaceProps) {\r\n\r\n if (typeof size === 'string') {\r\n size = {\r\n small: 8,\r\n middle: 16,\r\n large: 24\r\n }[size];\r\n }\r\n\r\n const items = Children.map(children, (child) => {\r\n return <Item size={size as number}>{child}</Item>;\r\n });\r\n\r\n return <Container>\r\n {items}\r\n </Container>;\r\n}\r\n\r\nconst Container = styled.div`\r\n display: inline-flex;\r\n align-items: center;\r\n`;\r\n\r\nconst Item = styled.div<{ size: number }>`\r\n margin-right: ${props => props.size}px;\r\n\r\n &:last-child {\r\n margin-right: 0;\r\n }\r\n`;\r\n","import { useMemo } from 'react';\r\n\r\ninterface Props {\r\n value: number;\r\n currency?: boolean;\r\n locale?: string;\r\n}\r\n\r\nexport default function NumberFormat({ value, locale = 'zh-CN', currency = true }: Props) {\r\n\r\n const formatter = useMemo(() => {\r\n\r\n let options = {};\r\n\r\n if (currency) {\r\n options = {\r\n style: 'currency',\r\n currency: 'CNY',\r\n ...options\r\n };\r\n } else {\r\n options = {\r\n minimumFractionDigits: 2,\r\n };\r\n }\r\n\r\n return new Intl.NumberFormat(locale, options);\r\n }, [currency, locale]);\r\n\r\n return <>{formatter.format(value)}</>;\r\n}\r\n","import { Button, ButtonProps } from 'react-bootstrap';\r\n\r\ninterface CustomButtonProps extends ButtonProps {\r\n loading: boolean\r\n}\r\n\r\nexport default function LoadingButton({ loading, children, ...props }: CustomButtonProps) {\r\n\r\n return <Button {...props} disabled={loading}>\r\n {loading ? 'Loading…' : children}\r\n </Button>;\r\n}\r\n","import { Button, ButtonProps } from 'react-bootstrap';\r\nimport request, { Config } from '../request';\r\nimport { createElement, ElementType, MouseEvent, useCallback, useState } from 'react';\r\nimport Message from '../utils/message';\r\nimport axios, { AxiosRequestConfig } from 'axios';\r\n\r\ninterface Props extends Omit<ButtonProps, 'as'> {\r\n url: Config;\r\n method?: AxiosRequestConfig['method'];\r\n confirm?: string;\r\n onSuccess?: (result: any) => void;\r\n as?: ElementType | ButtonProps['as'];\r\n}\r\n\r\nexport default function RequestButton({\r\n url,\r\n method,\r\n confirm,\r\n onSuccess,\r\n children,\r\n disabled,\r\n as = Button,\r\n ...props\r\n}: Props) {\r\n\r\n const [fetching, setFetching] = useState(false);\r\n\r\n const handleClick = useCallback(async (e: MouseEvent) => {\r\n e.preventDefault();\r\n try {\r\n setFetching(true);\r\n if (confirm) {\r\n if (!await Message.confirm({ text: confirm })) {\r\n return;\r\n }\r\n }\r\n\r\n const config = typeof url === 'string' ? { url, method } : { method, ...url };\r\n\r\n const result = await request(config);\r\n\r\n if (onSuccess) {\r\n onSuccess(result);\r\n }\r\n } catch (e) {\r\n if (axios.isAxiosError(e)) {\r\n let errors = e.errors;\r\n if (typeof e.errors !== 'string') {\r\n errors = Object.values(e.errors).join('<br />');\r\n }\r\n Message.error({ text: errors as string });\r\n } else {\r\n throw e;\r\n }\r\n } finally {\r\n setFetching(false);\r\n }\r\n }, [url, method, setFetching]);\r\n\r\n return createElement(as, {\r\n ...props,\r\n disabled: disabled || fetching,\r\n onClick: handleClick\r\n }, children);\r\n}\r\n","import JsonForm, { JsonFormProps, JsonFormType } from '@topthink/json-form';\r\nimport * as React from 'react';\r\nimport { forwardRef, ForwardRefExoticComponent, PropsWithoutRef, RefAttributes, useCallback, useState } from 'react';\r\nimport axios, { AxiosError, Method } from 'axios';\r\nimport LoadingButton from './loading-button';\r\nimport request from '../request';\r\nimport { mapValues } from 'lodash';\r\nimport { AjvError, ISubmitEvent } from '@rjsf/core';\r\n\r\nconst localize = require('ajv-i18n/localize/zh');\r\n\r\nexport interface FormProps<T = any> extends JsonFormProps<T> {\r\n onSuccess?: (data: any) => void;\r\n method?: Method;\r\n}\r\n\r\ntype Error = {\r\n __errors: string[]\r\n}\r\n\r\ntype Errors = Error | {\r\n [key: string]: Error\r\n}\r\n\r\nconst toExtraErrors = (error: AxiosError): Errors => {\r\n const errors = error.errors;\r\n if (typeof errors === 'string') {\r\n return {\r\n __errors: [errors]\r\n };\r\n }\r\n return mapValues(errors, (e) => {\r\n return {\r\n __errors: [e]\r\n };\r\n });\r\n};\r\n\r\nexport interface FormType extends JsonFormType {\r\n\r\n}\r\n\r\ntype Form<T = any> = ForwardRefExoticComponent<PropsWithoutRef<FormProps<T>> & RefAttributes<FormType>>\r\n\r\nconst Form: Form = forwardRef(({\r\n action,\r\n method = 'post',\r\n onSuccess,\r\n formData,\r\n onSubmit,\r\n onChange,\r\n children,\r\n ...props\r\n}, ref) => {\r\n\r\n const [extraErrors, setExtraErrors] = useState<Errors>();\r\n const [loading, setLoading] = useState(false);\r\n const [data, setData] = useState(formData);\r\n\r\n const handleSubmit = useCallback(async (e: ISubmitEvent<any>, nativeEvent: React.FormEvent<HTMLFormElement>) => {\r\n try {\r\n setLoading(true);\r\n if (action) {\r\n const { formData } = e;\r\n try {\r\n const data = await request({\r\n url: action,\r\n method,\r\n data: formData\r\n });\r\n setExtraErrors(undefined);\r\n if (onSuccess) {\r\n await onSuccess(data);\r\n }\r\n } catch (e) {\r\n if (axios.isAxiosError(e)) {\r\n setExtraErrors(toExtraErrors(e));\r\n }\r\n\r\n throw e;\r\n }\r\n } else if (onSubmit) {\r\n await onSubmit(e, nativeEvent);\r\n }\r\n } finally {\r\n setLoading(false);\r\n }\r\n }, [action, method, onSubmit]);\r\n\r\n const handleChange = useCallback((e: ISubmitEvent<any>) => {\r\n const { formData } = e;\r\n setData(formData);\r\n if (onChange) {\r\n onChange(e);\r\n }\r\n }, [setData, onChange]);\r\n\r\n const transformErrors = useCallback((errors: AjvError[]) => {\r\n errors = errors.map(error => ({\r\n keyword: error.name,\r\n dataPath: error.property,\r\n ...error\r\n }));\r\n\r\n localize(errors);\r\n\r\n return errors;\r\n }, []);\r\n\r\n return <JsonForm\r\n ref={ref}\r\n extraErrors={extraErrors}\r\n onSubmit={handleSubmit}\r\n transformErrors={transformErrors}\r\n noHtml5Validate\r\n noValidate\r\n {...props}\r\n formData={data}\r\n onChange={handleChange}\r\n >\r\n {children || <div className='col-12'>\r\n <LoadingButton loading={loading} type='submit' variant='primary'>提交</LoadingButton>\r\n </div>}\r\n </JsonForm>;\r\n});\r\n\r\nexport default Form;\r\n","import styled from 'styled-components';\r\nimport { PropsWithChildren, ReactNode } from 'react';\r\n\r\nconst Container = styled.div`\r\n width: 100%;\r\n`;\r\n\r\nconst Header = styled.div`\r\n background-color: #fff;\r\n display: flex;\r\n\r\n .container {\r\n padding: 0 24px;\r\n display: flex;\r\n justify-content: space-between;\r\n align-items: center;\r\n }\r\n`;\r\n\r\nconst Body = styled.div`\r\n margin-top: 24px;\r\n`;\r\n\r\nconst Title = styled.div`\r\n font-size: 22px;\r\n line-height: 64px;\r\n height: 64px;\r\n`;\r\n\r\nconst Extra = styled.div`\r\n\r\n`;\r\n\r\ninterface ContentProps {\r\n title: string\r\n extra?: ReactNode\r\n}\r\n\r\nexport default function Content({ title, children, extra }: PropsWithChildren<ContentProps>) {\r\n return <Container>\r\n <Header>\r\n <div className='container'>\r\n <Title>{title}</Title>\r\n <Extra>{extra}</Extra>\r\n </div>\r\n </Header>\r\n <Body className='container'>\r\n {children}\r\n </Body>\r\n </Container>;\r\n};\r\n","import { useCallback, useEffect, useMemo, useState } from 'react';\r\nimport { Pagination as BsPagination } from 'react-bootstrap';\r\n\r\nfunction noop() {\r\n}\r\n\r\n\r\nfunction isInteger(value: any): value is number {\r\n return (\r\n typeof value === 'number' && isFinite(value) && Math.floor(value) === value\r\n );\r\n}\r\n\r\nexport interface PaginationProps {\r\n className?: string\r\n total: number\r\n current?: number\r\n defaultCurrent?: number\r\n pageSize?: number\r\n defaultPageSize?: number,\r\n onChange?: (current: number, pageSize: number) => void\r\n}\r\n\r\nexport default function Pagination({\r\n total = 0,\r\n onChange = noop,\r\n defaultCurrent = 1,\r\n defaultPageSize = 10,\r\n className,\r\n ...props\r\n}: PaginationProps) {\r\n\r\n const [current, setCurrent] = useState(defaultCurrent);\r\n const [pageSize, setPageSize] = useState(defaultPageSize);\r\n\r\n useEffect(() => {\r\n if (isInteger(props.current)) {\r\n setCurrent(props.current);\r\n }\r\n }, [props.current]);\r\n\r\n useEffect(() => {\r\n if (isInteger(props.pageSize)) {\r\n setPageSize(props.pageSize);\r\n }\r\n }, [props.pageSize]);\r\n\r\n const allPages = useMemo(() => {\r\n return Math.floor((total - 1) / pageSize) + 1;\r\n }, [total, pageSize]);\r\n\r\n const handleChange = useCallback((p: number) => {\r\n return () => {\r\n if (p !== current) {\r\n setCurrent(p);\r\n onChange(p, pageSize);\r\n }\r\n };\r\n }, [onChange, current, pageSize]);\r\n\r\n const pageBufferSize = 2;\r\n const prevPage = current - 1 > 0 ? current - 1 : 0;\r\n const nextPage = current + 1 < allPages ? current + 1 : allPages;\r\n\r\n const pagerList = [];\r\n let jumpPrev = null;\r\n let jumpNext = null;\r\n let firstPager = null;\r\n let lastPager = null;\r\n\r\n if (allPages <= 3 + pageBufferSize * 2) {\r\n for (let i = 1; i <= allPages; i += 1) {\r\n const active = current === i;\r\n pagerList.push(\r\n <BsPagination.Item key={i} active={active} onClick={handleChange(i)}>{i}</BsPagination.Item>\r\n );\r\n }\r\n } else {\r\n lastPager = <BsPagination.Last key='last' onClick={handleChange(allPages)} />;\r\n firstPager = <BsPagination.First key='first' onClick={handleChange(1)} />;\r\n jumpPrev = <BsPagination.Prev key='prev' onClick={handleChange(prevPage)} />;\r\n jumpNext = <BsPagination.Next key='next' onClick={handleChange(nextPage)} />;\r\n\r\n let left = Math.max(1, current - pageBufferSize);\r\n let right = Math.min(current + pageBufferSize, allPages);\r\n\r\n if (current - 1 <= pageBufferSize) {\r\n right = 1 + pageBufferSize * 2;\r\n }\r\n\r\n if (allPages - current <= pageBufferSize) {\r\n left = allPages - pageBufferSize * 2;\r\n }\r\n\r\n for (let i = left; i <= right; i += 1) {\r\n const active = current === i;\r\n pagerList.push(\r\n <BsPagination.Item key={i} active={active} onClick={handleChange(i)}>{i}</BsPagination.Item>\r\n );\r\n }\r\n\r\n if (current - 1 >= pageBufferSize * 2 && current !== 1 + 2) {\r\n pagerList.unshift(jumpPrev);\r\n }\r\n if (\r\n allPages - current >= pageBufferSize * 2 &&\r\n current !== allPages - 2\r\n ) {\r\n pagerList.push(jumpNext);\r\n }\r\n\r\n if (left !== 1) {\r\n pagerList.unshift(firstPager);\r\n }\r\n if (right !== allPages) {\r\n pagerList.push(lastPager);\r\n }\r\n }\r\n\r\n return <BsPagination className={className}>\r\n {pagerList}\r\n </BsPagination>;\r\n\r\n}\r\n","import RcTable from 'rc-table';\r\nimport { TableProps as RcTableProps } from 'rc-table/lib/Table';\r\nimport { ColumnGroupType, ColumnsType, ColumnType as BsColumnType, RenderedCell } from 'rc-table/lib/interface';\r\nimport { Table as BsTable, TableProps as BsTableProps } from 'react-bootstrap';\r\nimport {\r\n forwardRef,\r\n ForwardRefExoticComponent,\r\n PropsWithChildren,\r\n PropsWithoutRef,\r\n ReactNode,\r\n RefAttributes,\r\n useCallback,\r\n useEffect,\r\n useImperativeHandle,\r\n useMemo,\r\n useRef,\r\n useState\r\n} from 'react';\r\nimport Pagination from './pagination';\r\nimport styled from 'styled-components';\r\nimport request from '../request';\r\nimport Card from './card';\r\nimport Loader from './loader';\r\nimport Space from './space';\r\n\r\nexport interface TableType {\r\n reload: () => void;\r\n}\r\n\r\ninterface ColumnType<RecordType> extends Omit<BsColumnType<RecordType>, 'render'> {\r\n render?: (data: { value: any, record: RecordType, index: number, action: TableType }) => ReactNode | RenderedCell<RecordType>;\r\n}\r\n\r\nexport type Columns<RecordType = any> = (ColumnGroupType<RecordType> | ColumnType<RecordType>)[]\r\n\r\nconst CustomTable = styled(BsTable)`\r\n .rc-table-thead {\r\n border-top: none;\r\n }\r\n`;\r\n\r\nconst components: RcTableProps['components'] = {\r\n table: (props: BsTableProps) => {\r\n return <CustomTable {...props} className='align-middle table-hover' />;\r\n },\r\n};\r\n\r\nexport interface PaginationType<T = any> {\r\n total: number;\r\n current_page: number;\r\n per_page: number;\r\n last_page: number;\r\n data: T[];\r\n}\r\n\r\nconst CustomPagination = styled(Pagination)`\r\n margin-bottom: 0;\r\n justify-content: flex-end;\r\n`;\r\n\r\nfunction isPagination<T>(data: any): data is PaginationType<T> {\r\n return 'current_page' in data;\r\n}\r\n\r\nexport interface TableProps<RecordType = any> extends Omit<RcTableProps<RecordType>, 'children' | 'columns'> {\r\n source: string | (() => Promise<any>);\r\n paginate?: boolean;\r\n columns: Columns<RecordType>;\r\n toolBarRender?: (action: TableType) => ReactNode;\r\n}\r\n\r\ntype Params = {\r\n page?: number;\r\n sortField?: string;\r\n sortOrder?: number;\r\n [key: string]: any;\r\n};\r\n\r\ntype CustomTableType<T = any> = ForwardRefExoticComponent<PropsWithoutRef<PropsWithChildren<TableProps<T>>>\r\n & RefAttributes<TableType>>\r\n\r\nconst Table: CustomTableType = forwardRef((\r\n { source, rowKey = 'id', paginate = true, toolBarRender, columns = [], ...props },\r\n ref\r\n) => {\r\n const [data, setData] = useState<any[]>([]);\r\n const [pagination, setPagination] = useState(paginate ? { total: 0, current: 1, pageSize: 10 } : null);\r\n const [loading, setLoading] = useState(true);\r\n\r\n const fetchData = useCallback(async (options: Params = {}) => {\r\n setLoading(true);\r\n try {\r\n let result;\r\n if (typeof source === 'string') {\r\n const params: any = {};\r\n if (pagination) {\r\n params.page = options.page || pagination.current;\r\n }\r\n result = await request({\r\n url: source,\r\n params\r\n });\r\n } else {\r\n result = await source();\r\n }\r\n\r\n if (paginate && isPagination<any>(result)) {\r\n setPagination({\r\n total: result.total,\r\n current: result.current_page,\r\n pageSize: result.per_page\r\n });\r\n result = result.data;\r\n }\r\n setData(result);\r\n } catch (e) {\r\n\r\n } finally {\r\n setLoading(false);\r\n }\r\n }, [source, setData, pagination]);\r\n\r\n useEffect(() => {\r\n fetchData();\r\n }, []);\r\n\r\n const action = useRef<TableType>({\r\n reload: fetchData\r\n });\r\n\r\n useEffect(() => {\r\n action.current = {\r\n reload: fetchData\r\n };\r\n }, [fetchData]);\r\n\r\n useImperativeHandle(ref, () => action.current);\r\n\r\n const customColumns = useMemo(() => {\r\n return columns.map((column) => {\r\n const customColumn: BsColumnType<any> = { ...column, render: undefined };\r\n\r\n if ('render' in column && column.render) {\r\n const defaultRender = column.render;\r\n customColumn.render = (value, record, index) => {\r\n return defaultRender({ value, record, index, action: action.current });\r\n };\r\n }\r\n return customColumn;\r\n }) as ColumnsType<any>;\r\n }, [columns, action]);\r\n\r\n const handlePageChange = useCallback((current: number) => {\r\n fetchData({\r\n page: current\r\n });\r\n }, []);\r\n\r\n return <Card>\r\n <Loader loading={loading} />\r\n <Header>\r\n <LeftTools>\r\n {toolBarRender && toolBarRender(action.current)}\r\n </LeftTools>\r\n <RightTools>\r\n <Action onClick={action.current.reload}><i className='bi bi-arrow-repeat' /></Action>\r\n </RightTools>\r\n </Header>\r\n <RcTable {...props} rowKey={rowKey} columns={customColumns} components={components} data={data} />\r\n {pagination && <CustomPagination {...pagination} onChange={handlePageChange} />}\r\n </Card>;\r\n});\r\n\r\nexport default Table;\r\n\r\nconst Header = styled.div`\r\n display: flex;\r\n justify-content: space-between;\r\n padding-bottom: 1rem;\r\n`;\r\n\r\nconst RightTools = styled(Space)`\r\n\r\n`;\r\nconst LeftTools = styled(Space)`\r\n\r\n`;\r\n\r\nconst Action = styled.span`\r\n cursor: pointer;\r\n font-size: 20px;\r\n line-height: 1;\r\n\r\n &:hover {\r\n color: var(--bs-primary);\r\n }\r\n`;\r\n","import {\r\n forwardRef,\r\n ForwardRefExoticComponent,\r\n PropsWithChildren,\r\n PropsWithoutRef,\r\n RefAttributes,\r\n useImperativeHandle,\r\n useState\r\n} from 'react';\r\nimport { Button, ButtonProps, Modal, ModalProps } from 'react-bootstrap';\r\nimport LoadingButton from './loading-button';\r\n\r\nexport interface ModalButtonProps extends ModalProps {\r\n text: string;\r\n variant?: ButtonProps['variant'];\r\n header?: string;\r\n onOk?: () => any;\r\n footer?: boolean;\r\n}\r\n\r\nexport interface ModalType {\r\n close: () => void;\r\n}\r\n\r\ntype ModalButtonType = ForwardRefExoticComponent<PropsWithoutRef<PropsWithChildren<ModalButtonProps>>\r\n & RefAttributes<ModalType>>\r\n\r\nconst ModalButton: ModalButtonType = forwardRef(({\r\n text,\r\n variant = 'primary',\r\n header = text,\r\n footer = true,\r\n onOk,\r\n size,\r\n children\r\n}, ref) => {\r\n\r\n const [show, setShow] = useState(false);\r\n const [loading, setLoading] = useState(false);\r\n const handleClose = () => setShow(false);\r\n const handleShow = () => setShow(true);\r\n\r\n useImperativeHandle(ref, () => ({\r\n close: handleClose\r\n }));\r\n\r\n const handleOk = async () => {\r\n if (onOk) {\r\n setLoading(true);\r\n const result = await onOk();\r\n setLoading(false);\r\n if (result === false) {\r\n return;\r\n }\r\n }\r\n handleClose();\r\n };\r\n\r\n return <>\r\n <Button variant={variant} onClick={handleShow}>{text}</Button>\r\n <Modal size={size} show={show} onHide={handleClose}>\r\n {header && <Modal.Header closeButton>\r\n <Modal.Title as='h5'>{header}</Modal.Title>\r\n </Modal.Header>}\r\n <Modal.Body>{children}</Modal.Body>\r\n {footer && <Modal.Footer>\r\n <Button variant='secondary' onClick={handleClose}>\r\n 取消\r\n </Button>\r\n <LoadingButton loading={loading} variant='primary' onClick={handleOk}>\r\n 确定\r\n </LoadingButton>\r\n </Modal.Footer>}\r\n </Modal>\r\n </>;\r\n});\r\n\r\nexport default ModalButton;\r\n","import ModalButton, { ModalButtonProps, ModalType } from './modal-button';\r\nimport { Fragment, useCallback, useRef } from 'react';\r\nimport Form, { FormProps, FormType } from './form';\r\n\r\nexport type ModalFormProps<T = any> =\r\n Pick<ModalButtonProps, 'text' | 'variant' | 'header' | 'size'> &\r\n Pick<FormProps<T>, 'schema' | 'formData' | 'uiSchema' | 'action' | 'method' | 'onSuccess' | 'onChange' | 'fields' | 'formContext'>\r\n\r\nexport default function ModalForm<T = any>({\r\n text,\r\n header,\r\n schema,\r\n uiSchema,\r\n action,\r\n method,\r\n formData,\r\n variant,\r\n onSuccess,\r\n onChange,\r\n fields,\r\n size\r\n}: ModalFormProps<T>) {\r\n\r\n const form = useRef<FormType>(null);\r\n const modal = useRef<ModalType>(null);\r\n\r\n const handleOk = useCallback(async () => {\r\n try {\r\n await form.current?.submit();\r\n return true;\r\n } catch {\r\n return false;\r\n }\r\n }, []);\r\n\r\n return <ModalButton ref={modal} text={text} onOk={handleOk} header={header} variant={variant} size={size}>\r\n <Form\r\n ref={form}\r\n schema={schema}\r\n uiSchema={uiSchema}\r\n action={action}\r\n method={method}\r\n formData={formData}\r\n fields={fields}\r\n onChange={onChange}\r\n onSuccess={onSuccess}\r\n >\r\n <Fragment />\r\n </Form>\r\n </ModalButton>;\r\n}\r\n","import { useAsyncCallback, UseAsyncCallbackOptions } from 'react-async-hook';\r\nimport request, { Config } from '../request';\r\nimport { DependencyList, useCallback, useEffect } from 'react';\r\nimport { AxiosRequestConfig } from 'axios';\r\n\r\ntype UseRequestOptions<T> = {\r\n manual?: boolean\r\n refreshDeps?: DependencyList;\r\n} & UseAsyncCallbackOptions<T>;\r\n\r\nexport default function useRequest<T = any>(config: Config, {\r\n manual,\r\n refreshDeps,\r\n ...options\r\n}: UseRequestOptions<T> = {}) {\r\n const { execute, currentParams, error, ...others } = useAsyncCallback(async (params?: AxiosRequestConfig) => {\r\n\r\n config = typeof config === 'string' ? { url: config } : config;\r\n\r\n return await request<T>({\r\n ...config,\r\n ...params\r\n });\r\n }, options);\r\n\r\n useEffect(() => {\r\n if (!manual && !refreshDeps) {\r\n execute();\r\n }\r\n }, []);\r\n\r\n useEffect(() => {\r\n if (refreshDeps) {\r\n refresh();\r\n }\r\n }, refreshDeps);\r\n\r\n\r\n const refresh = useCallback(() => {\r\n if (currentParams) {\r\n execute(...currentParams);\r\n } else {\r\n execute();\r\n }\r\n }, [execute, currentParams]);\r\n\r\n return {\r\n refresh,\r\n execute,\r\n ...others\r\n };\r\n}\r\n"],"names":["_taggedTemplateLiteral","strings","raw","slice","Object","freeze","defineProperties","value","FooterWrapper","styled","footer","Footer","_jsx","className","formatRelativePath","routes","parent","menus","route","meta","_route$meta","hideInMenu","title","_route$meta2","path","replace","menu","children","_route$meta3","hideChildrenInMenu","length","push","renderMenuItems","items","map","item","SubMenu","MenuItem","Link","to","collapseNode","height","expandNode","node","scrollHeight","motion","motionName","motionAppear","onAppearStart","onAppearActive","onEnterStart","onEnterActive","onLeaveStart","onLeaveActive","SiderLayout","basename","useRoutes","useMemo","getMenuData","pathname","useLocation","openKeys","keys","split","reduce","pre","curr","join","selectedKeys","_jsxs","Container","Sidebar","Header","Menu","mode","defaultOpenKeys","Content","Main","div","nav","main","RcMenu","CustomSwal","withReactContent","Swal","defaultOptions","confirmButtonText","cancelButtonText","Message","confirm","async","isConfirmed","fire","icon","showCancelButton","options","error","toast","position","timer","showConfirmButton","Icon","Title","Extra","IconMap","success","info","warning","Result","status","extra","Avatar","a","href","src","Dropdown","navbar","Toggle","as","header","Dimmer","props","active","inverted","Loader","loading","variant","animation","Spinner","rax","attach","axios","defaults","raxConfig","retryDelay","backoffType","shouldRetry","err","config","method","toUpperCase","response","baseURL","interceptors","request","use","token","sessionStorage","getItem","headers","Authorization","Promise","reject","data","location","window","undefined","e","isAxiosError","url","setItem","search","redirectUri","origin","encodeURIComponent","errors","name","Login","parsed","queryString","parse","hash","substr","access_token","removeItem","Navigate","Logout","useEffect","catch","Root","BrowserRouter","Routes","Route","element","Card","BsCard","classNames","Error","Alert","entries","_ref2","UserContext","React","createContext","UserProvider","user","state","setState","useState","Provider","useUser","setUser","useContext","Access","require","fallback","passed","intersection","roles","Space","size","small","middle","large","Children","child","Item","NumberFormat","locale","currency","formatter","style","minimumFractionDigits","Intl","format","LoadingButton","Button","disabled","RequestButton","onSuccess","fetching","setFetching","handleClick","useCallback","preventDefault","text","result","values","createElement","onClick","localize","Form","forwardRef","ref","action","formData","onSubmit","onChange","extraErrors","setExtraErrors","setLoading","setData","handleSubmit","nativeEvent","__errors","mapValues","toExtraErrors","handleChange","transformErrors","keyword","dataPath","property","JsonForm","noHtml5Validate","noValidate","type","Body","noop","isInteger","isFinite","Math","floor","CustomTable","BsTable","components","table","CustomPagination","total","defaultCurrent","defaultPageSize","current","setCurrent","pageSize","setPageSize","allPages","p","prevPage","nextPage","pagerList","jumpPrev","jumpNext","firstPager","lastPager","i","BsPagination","Last","First","Prev","Next","left","max","right","min","pageBufferSize","unshift","isPagination","Table","source","rowKey","paginate","toolBarRender","columns","pagination","setPagination","fetchData","params","page","current_page","per_page","useRef","reload","useImperativeHandle","customColumns","column","customColumn","render","defaultRender","record","index","handlePageChange","LeftTools","RightTools","Action","RcTable","span","ModalButton","onOk","show","setShow","handleClose","close","Modal","onHide","closeButton","ModalForm","schema","uiSchema","fields","form","modal","handleOk","_form$current","submit","Fragment","useRequest","manual","refreshDeps","execute","currentParams","others","useAsyncCallback","refresh"],"mappings":"89BAAe,SAASA,EAAuBC,EAASC,UACjDA,IACHA,EAAMD,EAAQE,MAAM,IAGfC,OAAOC,OAAOD,OAAOE,iBAAiBL,EAAS,CACpDC,IAAK,CACHK,MAAOH,OAAOC,OAAOH,aCL3B,MAAMM,EAAgBC,EAAOC,oCAKLC,WACbC,EAACJ,YACJI,SAAKC,UAAU,8BCDvB,MAAMC,EAAqB,SACvBC,OACAC,yDAAiB,UAGXC,EAAoB,OAErB,MAAMC,KAASH,EAAQ,wBAEpBG,EAAMC,mBAANC,EAAYC,0BAIVC,YAAQJ,EAAMC,yBAANI,EAAYD,UACrBA,eAIDE,EAAON,EAAMM,MAAQ,GAEzBA,YAAUR,cAAUQ,GAEpBA,EAAOA,EAAKC,QAAQ,MAAO,KAAKA,QAAQ,MAAO,UAEzCC,EAAiB,CACnBJ,MAAAA,EACAE,KAAAA,EACAG,SAAU,cAGTT,EAAMC,mBAANS,EAAYC,oBACTX,EAAMS,UAAYT,EAAMS,SAASG,OAAS,IAC1CJ,EAAKC,SAAWb,EAAmBI,EAAMS,SAAUH,IAI3DP,EAAMc,KAAKL,UAGRT,qBC/BX,MAAMe,GAAmBC,GACdA,EAAMC,KAAK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KyG,EACLH,OAAQA,EACRC,SAAUA,EACVtG,OAAQA,EACRzG,OAAQA,EACR0G,SAAUA,EACVsG,OAAQA,EACRpG,SAAUA,EACVlB,UAAWA,WAEXzN,EAACqV,wCCrCWC,GAAoBxN,OAAgByN,OACxDA,EADwDC,YAExDA,KACGrQ,0DACmB,SAChBsQ,QAAEA,EAAFC,cAAWA,EAAXtQ,MAA0BA,KAAUuQ,GAAWC,GAAiB9Q,MAAAA,IAElEgD,EAA2B,iBAAXA,EAAsB,CAAEqB,IAAKrB,GAAWA,QAE3CM,GAAW,IACjBN,KACAiL,MAER5N,GAEHkF,GAAU,KACDkL,GAAWC,GACZC,MAEL,IAEHpL,GAAU,KACFmL,GACAK,MAELL,SAGGK,EAAUhI,GAAY,KACpB6H,EACAD,KAAWC,GAEXD,MAEL,CAACA,EAASC,UAEN,CACHG,QAAAA,EACAJ,QAAAA,KACGE"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../node_modules/@babel/runtime/helpers/esm/taggedTemplateLiteral.js","../src/components/footer.tsx","../src/utils/get-menu-data.ts","../src/layout/sider.tsx","../src/utils/message.ts","../src/components/result.tsx","../src/images/logo.svg","../src/components/header.tsx","../src/components/dimmer.tsx","../src/components/loader.tsx","../src/request.ts","../src/components/root.tsx","../src/components/card.tsx","../src/components/error.tsx","../src/components/user-provider.tsx","../src/components/access.tsx","../src/components/space.tsx","../src/components/number-format.tsx","../src/components/loading-button.tsx","../src/components/request-button.tsx","../src/components/form.tsx","../src/components/content.tsx","../src/components/pagination.tsx","../src/components/table.tsx","../src/components/modal-button.tsx","../src/components/modal-form.tsx","../src/hooks/use-request.ts","../src/hooks/use-overlay-state.ts"],"sourcesContent":["export default function _taggedTemplateLiteral(strings, raw) {\n if (!raw) {\n raw = strings.slice(0);\n }\n\n return Object.freeze(Object.defineProperties(strings, {\n raw: {\n value: Object.freeze(raw)\n }\n }));\n}","import styled from 'styled-components';\r\n\r\nconst FooterWrapper = styled.footer`\r\n\r\n`;\r\n\r\n\r\nexport default function Footer() {\r\n return <FooterWrapper>\r\n <div className='container'>\r\n\r\n </div>\r\n </FooterWrapper>;\r\n}\r\n","import type { RouteObject } from 'react-router';\r\n\r\nexport interface MenuData {\r\n path: string;\r\n title: string;\r\n children: MenuData[];\r\n}\r\n\r\nconst formatRelativePath = (\r\n routes: RouteObject[],\r\n parent: string = '/',\r\n): MenuData[] => {\r\n\r\n const menus: MenuData[] = [];\r\n\r\n for (const route of routes) {\r\n\r\n if (route.meta?.hideInMenu) {\r\n continue;\r\n }\r\n\r\n const title = route.meta?.title;\r\n if (!title) {\r\n continue;\r\n }\r\n\r\n let path = route.path || '';\r\n\r\n path = `${parent}/${path}`;\r\n\r\n path = path.replace(/\\/+/, '/').replace(/\\/$/, '');\r\n\r\n const menu: MenuData = {\r\n title,\r\n path,\r\n children: []\r\n };\r\n\r\n if (!route.meta?.hideChildrenInMenu) {\r\n if (route.children && route.children.length > 0) {\r\n menu.children = formatRelativePath(route.children, path);\r\n }\r\n }\r\n\r\n menus.push(menu);\r\n }\r\n\r\n return menus;\r\n};\r\n\r\nexport default function getMenuData(routes: RouteObject[], base: string = '/'): MenuData[] {\r\n return formatRelativePath(routes, base);\r\n}\r\n","import RcMenu, { MenuItem, SubMenu } from 'rc-menu';\r\nimport Footer from '../components/footer';\r\nimport { Link, useLocation, useRoutes } from 'react-router-dom';\r\nimport { useMemo } from 'react';\r\nimport styled from 'styled-components';\r\nimport 'rc-menu/assets/index.css';\r\nimport type { RouteObject } from 'react-router';\r\nimport getMenuData, { MenuData } from '../utils/get-menu-data';\r\nimport type { CSSMotionProps } from 'rc-motion';\r\n\r\ninterface Props {\r\n title: string;\r\n routes: RouteObject[];\r\n basename: string;\r\n}\r\n\r\nconst renderMenuItems = (items: MenuData[]) => {\r\n return items.map((item) => {\r\n if (item.children.length > 0) {\r\n return <SubMenu title={item.title} key={item.path}>\r\n {renderMenuItems(item.children)}\r\n </SubMenu>;\r\n } else {\r\n return <MenuItem key={item.path}>\r\n <Link to={item.path}>{item.title}</Link>\r\n </MenuItem>;\r\n }\r\n });\r\n};\r\n\r\nconst collapseNode = () => {\r\n return { height: 0 };\r\n};\r\nconst expandNode = (node: HTMLElement) => {\r\n return { height: node.scrollHeight };\r\n};\r\n\r\nconst motion: CSSMotionProps = {\r\n motionName: 'rc-menu-collapse',\r\n motionAppear: true,\r\n onAppearStart: collapseNode,\r\n onAppearActive: expandNode,\r\n onEnterStart: collapseNode,\r\n onEnterActive: expandNode,\r\n onLeaveStart: expandNode,\r\n onLeaveActive: collapseNode,\r\n};\r\n\r\n\r\nexport default function SiderLayout({ routes, basename, title }: Props) {\r\n\r\n const children = useRoutes(routes);\r\n\r\n const menu = useMemo(() => getMenuData(routes, basename), [routes, basename]);\r\n\r\n const { pathname } = useLocation();\r\n\r\n const openKeys = useMemo(() => {\r\n const keys: string[] = [];\r\n const parts = pathname.split('/');\r\n parts.reduce<string[]>((pre, curr) => {\r\n if (pre.length > 1) {\r\n keys.push(pre.join('/'));\r\n }\r\n return [...pre, curr];\r\n }, []);\r\n\r\n return keys;\r\n }, [pathname]);\r\n\r\n const selectedKeys = useMemo(() => {\r\n return [...openKeys, pathname];\r\n }, [pathname, openKeys]);\r\n\r\n return <Container>\r\n <Sidebar>\r\n <Header>{title}</Header>\r\n <Menu mode='inline' motion={motion} defaultOpenKeys={openKeys} selectedKeys={selectedKeys}>\r\n {renderMenuItems(menu)}\r\n </Menu>\r\n </Sidebar>\r\n <Content>\r\n <Main>{children}</Main>\r\n <Footer />\r\n </Content>\r\n </Container>;\r\n}\r\n\r\nconst Container = styled.div`\r\n display: flex;\r\n flex-wrap: nowrap;\r\n width: 100%;\r\n`;\r\n\r\nconst Sidebar = styled.nav`\r\n position: fixed;\r\n top: 0;\r\n bottom: 0;\r\n left: 0;\r\n z-index: 100;\r\n padding: 54px 0 0;\r\n border-right: 1px solid #e3e3e3;\r\n width: 230px;\r\n background-color: #f5f5f5;\r\n`;\r\n\r\nconst Header = styled.div`\r\n padding: 10px 0;\r\n height: 64px;\r\n line-height: 44px;\r\n text-indent: 24px;\r\n text-overflow: ellipsis;\r\n white-space: nowrap;\r\n overflow: hidden;\r\n font-size: 16px;\r\n`;\r\n\r\nconst Content = styled.div`\r\n margin-left: 230px;\r\n flex: 1;\r\n`;\r\n\r\nconst Main = styled.main`\r\n min-height: calc(100vh - 54px);\r\n position: relative;\r\n`;\r\n\r\nconst Menu = styled(RcMenu)`\r\n border: none;\r\n box-shadow: none;\r\n padding: 0;\r\n\r\n .rc-menu-item {\r\n display: flex;\r\n\r\n &:hover {\r\n background-color: #f0f0f0;\r\n }\r\n\r\n a {\r\n flex: 1;\r\n text-decoration: none;\r\n color: inherit;\r\n }\r\n }\r\n\r\n .rc-menu-sub {\r\n background-color: #eee;\r\n border-top: 1px solid #eee;\r\n border-bottom: 1px solid #eee;\r\n\r\n & > li {\r\n &:first-child {\r\n margin-top: 4px;\r\n }\r\n\r\n &:last-child {\r\n margin-bottom: 4px;\r\n }\r\n }\r\n\r\n .rc-menu-item-selected {\r\n background-color: #eee;\r\n color: var(--bs-primary);\r\n }\r\n\r\n .rc-menu-item-active {\r\n background-color: #eee;\r\n }\r\n\r\n .rc-menu-item {\r\n &:hover {\r\n background-color: #e7e7e7;\r\n }\r\n }\r\n }\r\n\r\n .rc-menu-submenu {\r\n & > .rc-menu-submenu-title {\r\n &:hover {\r\n background-color: #e7e7e7;\r\n }\r\n }\r\n }\r\n\r\n .rc-menu-submenu-active > .rc-menu-submenu-title {\r\n background-color: #eee;\r\n }\r\n\r\n .rc-menu-item,\r\n .rc-menu-submenu > .rc-menu-submenu-title {\r\n padding: 0 8px 0 24px;\r\n font-size: 14px;\r\n line-height: 36px;\r\n cursor: pointer;\r\n }\r\n\r\n .rc-menu-sub > .rc-menu-item,\r\n .rc-menu-sub > .rc-menu-submenu > .rc-menu-submenu-title {\r\n padding-top: 0;\r\n padding-bottom: 0;\r\n padding-right: 0;\r\n }\r\n\r\n .rc-menu-submenu-arrow {\r\n line-height: 38px;\r\n }\r\n\r\n .rc-menu-item-selected {\r\n background-color: #f5f5f5;\r\n color: var(--bs-primary);\r\n }\r\n\r\n .rc-menu-submenu-selected {\r\n background-color: #eee;\r\n\r\n .rc-menu-submenu-title {\r\n color: var(--bs-primary);\r\n font-weight: 500;\r\n }\r\n }\r\n\r\n & > .rc-menu-item {\r\n line-height: 38px;\r\n }\r\n\r\n & > .rc-menu-submenu {\r\n &.rc-menu-submenu-selected {\r\n background-color: #f5f5f5;\r\n }\r\n\r\n & > .rc-menu-submenu-title {\r\n line-height: 38px;\r\n\r\n &:hover {\r\n background-color: #f0f0f0;\r\n }\r\n }\r\n\r\n &.rc-menu-submenu-active > .rc-menu-submenu-title {\r\n background-color: #f5f5f5;\r\n }\r\n\r\n & > .rc-menu-sub {\r\n border-top: 1px solid #e6e6e6;\r\n border-bottom: 1px solid #e6e6e6;\r\n\r\n & > li {\r\n &:first-child {\r\n margin-top: 9px;\r\n }\r\n\r\n &:last-child {\r\n margin-bottom: 9px;\r\n }\r\n }\r\n }\r\n }\r\n\r\n`;\r\n","import Swal from 'sweetalert2/dist/sweetalert2.js';\r\nimport withReactContent from 'sweetalert2-react-content';\r\n\r\nconst CustomSwal = withReactContent(Swal);\r\n\r\ninterface MessageOptions {\r\n title?: string;\r\n text?: string;\r\n}\r\n\r\nconst defaultOptions = {\r\n confirmButtonText: '确定',\r\n cancelButtonText: '取消'\r\n};\r\n\r\nconst Message = {\r\n confirm: async (options: MessageOptions) => {\r\n const { isConfirmed } = await CustomSwal.fire({\r\n ...defaultOptions,\r\n icon: 'warning',\r\n showCancelButton: true,\r\n ...options\r\n });\r\n\r\n return isConfirmed;\r\n },\r\n error: (options: MessageOptions) => {\r\n CustomSwal.fire({\r\n ...defaultOptions,\r\n toast: true,\r\n position: 'top',\r\n icon: 'error',\r\n timer: 3000,\r\n showConfirmButton: false,\r\n ...options\r\n });\r\n }\r\n};\r\n\r\nexport default Message;\r\n","import { ReactNode } from 'react';\r\nimport styled from 'styled-components';\r\n\r\nconst Container = styled.div`\r\n padding: 48px 32px;\r\n`;\r\n\r\nconst Icon = styled.div`\r\n margin-bottom: 24px;\r\n text-align: center;\r\n font-size: 72px;\r\n`;\r\n\r\nconst Title = styled.div`\r\n color: rgba(0, 0, 0, .85);\r\n font-size: 24px;\r\n line-height: 1.8;\r\n text-align: center;\r\n`;\r\n\r\nconst Extra = styled.div`\r\n margin-top: 32px;\r\n text-align: center;\r\n`;\r\n\r\nconst IconMap = {\r\n success: <i className='bi bi-check-circle-fill text-success' />,\r\n error: <i className='bi bi-exclamation-circle-fill text-danger' />,\r\n info: <i className='bi bi-info-circle-fill text-info' />,\r\n warning: <i className='bi bi-exclamation-triangle-fill text-warning' />,\r\n};\r\n\r\ninterface ResultProps {\r\n status?: keyof typeof IconMap\r\n icon?: ReactNode\r\n title?: string\r\n extra?: ReactNode;\r\n}\r\n\r\nexport default function Result({ status, title, icon, extra }: ResultProps) {\r\n\r\n if (!icon && status) {\r\n icon = IconMap[status];\r\n }\r\n\r\n return <Container>\r\n {icon && <Icon>{icon}</Icon>}\r\n {title && <Title>{title}</Title>}\r\n {extra && <Extra>{extra}</Extra>}\r\n </Container>;\r\n}\r\n","var img = \"data:image/svg+xml,%3csvg width='485' height='132' xmlns='http://www.w3.org/2000/svg' xml:space='preserve' style='enable-background:new 0 0 531.69 198.43%3b' version='1.1'%3e %3cstyle type='text/css'%3e.st0%7bfill:%233C60FF%3b%7d%3c/style%3e %3cg%3e %3ctitle%3ebackground%3c/title%3e %3crect fill='none' id='canvas_background' height='134' width='487' y='-1' x='-1'/%3e %3c/g%3e %3cg%3e %3ctitle%3eLayer 1%3c/title%3e %3cpath id='svg_1' d='m132.29%2c62.34c-1.19%2c-18.77 -10.34%2c-35.36 -24.11%2c-46.46c-11.15%2c-8.99 -25.34%2c-14.38 -40.79%2c-14.38c-0.55%2c0 -1.09%2c0.01 -1.63%2c0.02c-3.32%2c0.08 -6.57%2c0.41 -9.75%2c0.98c-30.49%2c5.38 -53.65%2c32 -53.65%2c64.04c0%2c1.87 0.08%2c3.73 0.24%2c5.57c2.5%2c29.51 24.7%2c53.4 53.41%2c58.47c2.38%2c0.42 4.8%2c0.72 7.26%2c0.86c0.83%2c0.05 1.66%2c0.09 2.5%2c0.11c0.54%2c0.01 1.08%2c0.02 1.63%2c0.02c34.04%2c0 61.97%2c-26.16 64.79%2c-59.46c0.16%2c-1.83 0.24%2c-3.69 0.24%2c-5.57c0%2c-1.42 -0.05%2c-2.82 -0.14%2c-4.2zm-76.27%2c32.5c-0.26%2c0.01 -0.53%2c0.01 -0.79%2c0.01c-14.56%2c0 -26.88%2c-9.57 -31.03%2c-22.76c-0.97%2c-3.08 -1.49%2c-6.35 -1.49%2c-9.75c0%2c-17.95 14.56%2c-32.52 32.51%2c-32.52c0.26%2c0 0.53%2c0 0.79%2c0.01c3.41%2c0.08 6.69%2c0.68 9.75%2c1.74c6.5%2c2.22 12.06%2c6.45 15.97%2c11.94c1.98%2c2.78 3.54%2c5.9 4.57%2c9.25c0.94%2c3.03 1.44%2c6.24 1.44%2c9.58l-9.75%2c0c0%2c-2.18 -0.31%2c-4.29 -0.88%2c-6.28c-0.92%2c-3.23 -2.55%2c-6.17 -4.69%2c-8.64c-1.86%2c-2.14 -4.12%2c-3.93 -6.65%2c-5.25c-2.93%2c-1.54 -6.24%2c-2.46 -9.75%2c-2.58c-0.26%2c-0.01 -0.52%2c-0.01 -0.79%2c-0.01c-12.57%2c0 -22.76%2c10.19 -22.76%2c22.76c0%2c3.49 0.79%2c6.8 2.19%2c9.75c3.65%2c7.69 11.49%2c13.01 20.57%2c13.01c0.27%2c0 0.53%2c-0.01 0.79%2c-0.01l0%2c9.75zm55.7%2c-17.92c-3.35%2c10.5 -13.18%2c18.09 -24.78%2c18.09c-3.13%2c0 -6.13%2c-0.55 -8.91%2c-1.57c-2.18%2c-0.8 -4.24%2c-1.88 -6.11%2c-3.21c-2.38%2c-1.68 -4.47%2c-3.76 -6.16%2c-6.13c-0.28%2c-0.39 -0.55%2c-0.79 -0.81%2c-1.2c-2.03%2c-3.2 -3.38%2c-6.87 -3.85%2c-10.82l9.87%2c0c0.33%2c1.71 0.92%2c3.32 1.74%2c4.8c1.61%2c2.91 4.09%2c5.26 7.09%2c6.72c0.57%2c0.28 1.15%2c0.53 1.76%2c0.73c1.68%2c0.6 3.49%2c0.92 5.37%2c0.92c7.92%2c0 14.52%2c-5.67 15.96%2c-13.17c0.2%2c-1 0.3%2c-2.04 0.3%2c-3.09c0%2c-2.37 -0.51%2c-4.63 -1.43%2c-6.67c-1.66%2c-3.71 -4.68%2c-6.68 -8.43%2c-8.28l3.54%2c-9.1c7.43%2c3.08 13.13%2c9.49 15.21%2c17.38c0.44%2c1.64 0.72%2c3.34 0.81%2c5.09c0.04%2c0.52 0.05%2c1.05 0.05%2c1.58c0%2c1.05 -0.07%2c2.07 -0.18%2c3.09c-0.18%2c1.68 -0.54%2c3.3 -1.04%2c4.84z' class='st0'/%3e %3cg id='svg_2'%3e %3cg id='svg_3'%3e %3crect id='svg_4' height='6.34' width='94.12' class='st0' y='20.46' x='163.29'/%3e %3c/g%3e %3cg id='svg_5'%3e %3cpath id='svg_6' d='m169.31%2c113.72l0%2c-6.34c6.49%2c0 11.77%2c-5.28 11.77%2c-11.77l0%2c-71.98l6.34%2c0l0%2c71.98c0%2c9.98 -8.12%2c18.11 -18.11%2c18.11z' class='st0'/%3e %3c/g%3e %3cg id='svg_7'%3e %3cpath id='svg_8' d='m255.49%2c91.27l-6.34%2c0l0%2c-38.2c0%2c-5.06 -4.12%2c-9.18 -9.18%2c-9.18l-19.37%2c0c-5.06%2c0 -9.18%2c4.12 -9.18%2c9.18l0%2c38.2l-6.34%2c0l0%2c-38.2c0%2c-8.55 6.96%2c-15.51 15.51%2c-15.51l19.38%2c0c8.55%2c0 15.51%2c6.96 15.51%2c15.51l0%2c38.2l0.01%2c0z' class='st0'/%3e %3c/g%3e %3cg id='svg_9'%3e %3crect id='svg_10' height='17.09' width='6.34' class='st0' y='23.63' x='227.12'/%3e %3c/g%3e %3cg id='svg_11'%3e %3cpath id='svg_12' d='m206.43%2c113.84l-3.34%2c0l0%2c-6.34l3.34%2c0c6.3%2c0 12.9%2c-3.56 15.35%2c-8.29c3.49%2c-6.71 5.33%2c-14.25 5.33%2c-21.81l0%2c-26.13l6.34%2c0l0%2c26.13c0%2c8.58 -2.09%2c17.13 -6.05%2c24.74c-3.98%2c7.68 -13.57%2c11.7 -20.97%2c11.7z' class='st0'/%3e %3c/g%3e %3cg id='svg_13'%3e %3cpath id='svg_14' d='m257.48%2c113.84l-3.34%2c0c-7.4%2c0 -16.98%2c-4.02 -20.98%2c-11.7c-3.96%2c-7.61 -6.05%2c-16.16 -6.05%2c-24.74l6.34%2c0c0%2c7.56 1.84%2c15.1 5.33%2c21.81c2.46%2c4.73 9.06%2c8.29 15.35%2c8.29l3.34%2c0l0%2c6.34l0.01%2c0z' class='st0'/%3e %3c/g%3e %3cg id='svg_15'%3e %3crect id='svg_16' height='6.34' width='42.87' class='st0' y='27.89' x='274.07'/%3e %3c/g%3e %3cg id='svg_17'%3e %3crect id='svg_18' height='61.38' width='6.34' class='st0' y='14.89' x='293.05'/%3e %3c/g%3e %3cg id='svg_19'%3e %3crect id='svg_20' height='6.34' width='33.26' class='st0' transform='matrix(0.11%2c-0.9939%2c0.9939%2c0.11%2c194.7608%2c392.0006) ' y='46.985071' x='325.728637'/%3e %3c/g%3e %3cg id='svg_21'%3e %3crect id='svg_22' height='33.26' width='6.34' class='st0' transform='matrix(0.9939%2c-0.11%2c0.11%2c0.9939%2c-7.5075%2c38.3801) ' y='37.060893' x='310.495485'/%3e %3c/g%3e %3cg id='svg_23'%3e %3cpath id='svg_24' d='m352.9%2c77.14l-15.15%2c0c-7.52%2c0 -13.64%2c-6.12 -13.64%2c-13.63l0%2c-29.61c0%2c-7.52 6.12%2c-13.64 13.64%2c-13.64l15.15%2c0c7.52%2c0 13.64%2c6.12 13.64%2c13.64l0%2c29.61c0%2c7.52 -6.12%2c13.63 -13.64%2c13.63zm-15.15%2c-50.54c-4.02%2c0 -7.3%2c3.27 -7.3%2c7.3l0%2c29.61c0%2c4.02 3.27%2c7.3 7.3%2c7.3l15.15%2c0c4.02%2c0 7.3%2c-3.27 7.3%2c-7.3l0%2c-29.61c0%2c-4.02 -3.27%2c-7.3 -7.3%2c-7.3l-15.15%2c0z' class='st0'/%3e %3c/g%3e %3cg id='svg_25'%3e %3cg id='svg_26'%3e %3crect id='svg_27' height='6.34' width='17.8' class='st0' y='37.2' x='336.43'/%3e %3c/g%3e %3cg id='svg_28'%3e %3crect id='svg_29' height='6.34' width='17.8' class='st0' y='53.87' x='336.43'/%3e %3c/g%3e %3c/g%3e %3cg id='svg_30'%3e %3cpath id='svg_31' d='m352.7%2c113.84l-37.98%2c0c-8%2c0 -14.5%2c-6.51 -14.5%2c-14.5l0%2c-16.14l6.34%2c0l0%2c16.13c0%2c4.5 3.66%2c8.17 8.17%2c8.17l37.98%2c0l0%2c6.34l-0.01%2c0z' class='st0'/%3e %3c/g%3e %3cg id='svg_32'%3e %3crect id='svg_33' height='6.34' width='23.57' class='st0' transform='matrix(0.2529%2c-0.9675%2c0.9675%2c0.2529%2c114.4986%2c402.9877) ' y='83.698593' x='326.836101'/%3e %3c/g%3e %3cg id='svg_34'%3e %3crect id='svg_35' height='6.34' width='20.52' class='st0' y='86.2' x='321.58'/%3e %3c/g%3e %3cg id='svg_36'%3e %3crect id='svg_37' height='24.75' width='6.34' class='st0' transform='matrix(0.9556%2c-0.2946%2c0.2946%2c0.9556%2c-19.7967%2c122.424) ' y='75.874073' x='369.686666'/%3e %3c/g%3e %3cg id='svg_38'%3e %3crect id='svg_39' height='6.34' width='71.83' class='st0' y='20.46' x='395.51'/%3e %3c/g%3e %3cg id='svg_40'%3e %3crect id='svg_41' height='6.34' width='90.81' class='st0' y='57.44' x='386.02'/%3e %3c/g%3e %3cg id='svg_42'%3e %3cpath id='svg_43' d='m463.12%2c113.64l-56%2c0c-4.5%2c0 -8.59%2c-2.29 -10.94%2c-6.14c-2.35%2c-3.84 -2.52%2c-8.53 -0.46%2c-12.53l17.68%2c-35.81l5.64%2c2.89l-17.68%2c35.81c-1.04%2c2.02 -0.95%2c4.39 0.23%2c6.33c1.19%2c1.94 3.25%2c3.1 5.53%2c3.1l56%2c0c1.51%2c0 2.88%2c-0.71 3.74%2c-1.95c0.81%2c-1.16 1.03%2c-2.57 0.63%2c-3.91l-7.8%2c-12.34l5.36%2c-3.39l8.18%2c12.94l0.12%2c0.31c1.24%2c3.34 0.76%2c7.08 -1.28%2c10.01c-2.04%2c2.94 -5.39%2c4.68 -8.95%2c4.68z' class='st0'/%3e %3c/g%3e %3c/g%3e %3c/g%3e%3c/svg%3e\";\n export default img;","import logo from '../images/logo.svg';\r\nimport { Dropdown } from 'react-bootstrap';\r\nimport styled from 'styled-components';\r\nimport { PropsWithChildren, ReactNode } from 'react';\r\n\r\nconst Avatar = styled.a`\r\n cursor: pointer;\r\n`;\r\n\r\ninterface Props {\r\n menus: ReactNode;\r\n}\r\n\r\nexport default function Header({ children, menus }: PropsWithChildren<Props>) {\r\n\r\n return <Container className='navbar navbar-light bg-white border-bottom sticky-top'>\r\n <div className='container-fluid'>\r\n <a className='navbar-brand' href='https://www.topthink.com'>\r\n <img src={logo} height='30' />\r\n </a>\r\n {children}\r\n <div className='d-flex align-items-center'>\r\n <Dropdown navbar>\r\n <Dropdown.Toggle as={Avatar} className='nav-link'>\r\n <i className='bi bi-person-circle' />\r\n </Dropdown.Toggle>\r\n <Dropdown.Menu className={'shadow'}>\r\n {menus}\r\n </Dropdown.Menu>\r\n </Dropdown>\r\n </div>\r\n </div>\r\n </Container>;\r\n}\r\n\r\nconst Container = styled.header`\r\n height: 54px;\r\n`;\r\n","import styled from 'styled-components';\r\n\r\nexport const Dimmable = styled.div`\r\n position: relative;\r\n`;\r\n\r\ninterface DimmerProps {\r\n active?: boolean\r\n inverted?: boolean\r\n}\r\n\r\nconst Dimmer = styled.div<DimmerProps>`\r\n display: ${props => props.active ? 'flex' : 'none'};\r\n position: absolute;\r\n top: 0 !important;\r\n left: 0 !important;\r\n width: 100%;\r\n height: 100%;\r\n text-align: center;\r\n vertical-align: middle;\r\n padding: 1em;\r\n background-color: ${props => props.inverted ? 'rgba(255, 255, 255, .85)' : 'rgba(0, 0, 0, .85)'};\r\n opacity: ${props => props.active ? 1 : 0};\r\n line-height: 1;\r\n animation-fill-mode: both;\r\n animation-duration: .5s;\r\n transition: background-color .5s linear;\r\n flex-direction: column;\r\n align-items: center;\r\n justify-content: center;\r\n user-select: none;\r\n will-change: opacity;\r\n z-index: 990;\r\n`;\r\n\r\nexport default Dimmer;\r\n","import { PropsWithChildren } from 'react';\r\nimport { Spinner, SpinnerProps } from 'react-bootstrap';\r\nimport Dimmer from './dimmer';\r\n\r\ninterface LoaderProps {\r\n loading?: boolean\r\n animation?: SpinnerProps['animation']\r\n}\r\n\r\nexport default function Loader({\r\n loading = true,\r\n children,\r\n variant = 'success',\r\n animation = 'border',\r\n ...props\r\n}: PropsWithChildren<LoaderProps & Omit<SpinnerProps, 'animation'>>) {\r\n if (!loading) {\r\n return null;\r\n }\r\n\r\n if (children) {\r\n children = <p className='mt-3 text-secondary'>{children}</p>;\r\n }\r\n\r\n return <Dimmer inverted active>\r\n <Spinner animation={animation} variant={variant} {...props} />\r\n {children}\r\n </Dimmer>;\r\n}\r\n","import axios, { AxiosRequestConfig } from 'axios';\r\nimport * as rax from 'retry-axios';\r\n\r\nexport type Errors = string | {\r\n [key: string]: string\r\n}\r\n\r\ndeclare module 'axios' {\r\n interface AxiosError {\r\n errors: Errors;\r\n }\r\n}\r\n\r\nrax.attach();\r\naxios.defaults.raxConfig = {\r\n retryDelay: 2000,\r\n backoffType: 'static',\r\n shouldRetry: (err) => {\r\n return (\r\n err.config.method?.toUpperCase() === 'GET'\r\n && err.response?.status === 449\r\n );\r\n }\r\n};\r\naxios.defaults.baseURL = '/api';\r\naxios.interceptors.request.use(\r\n config => {\r\n const token = sessionStorage.getItem('authorization');\r\n\r\n if (token) {\r\n config.headers.Authorization = `Bearer ${token}`;\r\n }\r\n return config;\r\n },\r\n error => {\r\n return Promise.reject(error);\r\n }\r\n);\r\n\r\naxios.interceptors.response.use(\r\n response => {\r\n if (response.status === 201 && response.data.location) {\r\n window.location.href = response.data.location;\r\n response.data = undefined;\r\n }\r\n\r\n return response;\r\n },\r\n e => {\r\n if (axios.isAxiosError(e)) {\r\n if (e.response) {\r\n const { data, status } = e.response;\r\n if (status === 401) {\r\n const { url } = data;\r\n if (url) {\r\n if (window.location.pathname !== '/logout') {\r\n sessionStorage.setItem('redirect_uri', window.location.pathname + window.location.search);\r\n }\r\n const redirectUri = window.location.origin + '/login';\r\n window.location.href = `${url}&redirect_uri=${encodeURIComponent(redirectUri)}`;\r\n }\r\n e.errors = 'Unauthorized';\r\n } else {\r\n let errors: Errors = {};\r\n if (status === 422 && typeof data === 'object') {\r\n for (let name in data) {\r\n errors[name] = data[name];\r\n }\r\n } else if ((typeof data === 'object') && ('message' in data)) {\r\n errors = data['message'];\r\n } else {\r\n errors = data;\r\n }\r\n e.errors = errors;\r\n }\r\n }\r\n }\r\n return Promise.reject(e);\r\n }\r\n);\r\n\r\nexport type Config = AxiosRequestConfig | string\r\n\r\nconst request = async function <T = any>(config: Config) {\r\n config = typeof config === 'string' ? { url: config } : config;\r\n\r\n const { data } = await axios.request<T>({\r\n ...config\r\n });\r\n\r\n return data;\r\n};\r\n\r\nexport default request;\r\n","import { PropsWithChildren, useEffect } from 'react';\r\nimport { BrowserRouter, Navigate, Route, Routes, useLocation } from 'react-router-dom';\r\nimport queryString from 'query-string';\r\nimport Loader from './loader';\r\nimport request from '../request';\r\n\r\nfunction Login() {\r\n\r\n const location = useLocation();\r\n\r\n const parsed = queryString.parse(location.hash.substr(1));\r\n\r\n sessionStorage.setItem('authorization', parsed.access_token as string);\r\n\r\n const redirectUri = sessionStorage.getItem('redirect_uri');\r\n if (redirectUri) {\r\n sessionStorage.removeItem('redirect_uri');\r\n }\r\n\r\n return <Navigate to={redirectUri || '/'} replace />;\r\n}\r\n\r\nfunction Logout() {\r\n\r\n useEffect(() => {\r\n request('/logout').catch(() => {\r\n sessionStorage.removeItem('authorization');\r\n });\r\n }, []);\r\n\r\n return <Loader />;\r\n}\r\n\r\nexport default function Root({ children }: PropsWithChildren<any>) {\r\n\r\n return <BrowserRouter>\r\n <Routes>\r\n <Route path='*' element={children} />\r\n <Route path='login' element={<Login />} />\r\n <Route path='logout' element={<Logout />} />\r\n </Routes>\r\n </BrowserRouter>;\r\n}\r\n","import { PropsWithChildren } from 'react';\r\nimport { Card as BsCard, CardProps as BsCardProps } from 'react-bootstrap';\r\nimport classNames from 'classnames';\r\n\r\ninterface CardProps extends BsCardProps {\r\n title?: string;\r\n}\r\n\r\nexport default function Card({ children, title, className, ...props }: PropsWithChildren<CardProps>) {\r\n\r\n return <BsCard className={classNames('border-0 shadow-sm mb-3', className)} {...props}>\r\n <div className='card-body'>\r\n {title && <>\r\n <h5>{title}</h5>\r\n <hr />\r\n </>}\r\n {children}\r\n </div>\r\n </BsCard>;\r\n}\r\n","import { Alert } from 'react-bootstrap';\r\nimport { Errors } from '../request';\r\n\r\nexport default function Error({ errors }: { errors?: Errors }) {\r\n if (!errors) {\r\n return null;\r\n }\r\n return <Alert variant='danger'>\r\n <ul className='mb-0'>\r\n {typeof errors === 'string'\r\n ? <li>{errors}</li>\r\n : Object.entries(errors).map(([name, error]) => <li key={name}>{error}</li>)\r\n }\r\n </ul>\r\n </Alert>;\r\n}\r\n","import React, { PropsWithChildren, useContext, useEffect, useState } from 'react';\r\nimport Loader from './loader';\r\n\r\nexport interface User {\r\n id: number;\r\n name: string;\r\n email: string;\r\n avatar: string;\r\n mobile: string;\r\n is_certified: boolean;\r\n roles: [];\r\n}\r\n\r\nexport const UserContext = React.createContext<[(User | null), ((user: User) => void)]>([null, () => {\r\n}]);\r\n\r\ninterface Props {\r\n user: User;\r\n}\r\n\r\nconst UserProvider = function({ children, user }: PropsWithChildren<Props>) {\r\n const [state, setState] = useState(user);\r\n\r\n useEffect(() => {\r\n setState(user);\r\n }, [user]);\r\n\r\n if (!state) {\r\n return <Loader />;\r\n }\r\n\r\n return <UserContext.Provider value={[state, setState]}>\r\n {children}\r\n </UserContext.Provider>;\r\n};\r\n\r\nexport function useUser(): [User, ((user: User) => void)] {\r\n const [user, setUser] = useContext(UserContext);\r\n if (!user) {\r\n throw new Error('please use `useUser` in UserContext');\r\n }\r\n\r\n return [user, setUser];\r\n}\r\n\r\nexport default UserProvider;\r\n","import { ReactNode } from 'react';\r\nimport { intersection } from 'lodash';\r\nimport { User, useUser } from './user-provider';\r\n\r\nexport interface AccessProps {\r\n require?: string | string[] | ((user: User) => boolean);\r\n fallback?: ReactNode;\r\n children: ReactNode;\r\n}\r\n\r\nexport default function Access({\r\n require,\r\n children,\r\n fallback\r\n}: AccessProps) {\r\n const [user,] = useUser();\r\n let passed = false;\r\n if (typeof require === 'function') {\r\n passed = require(user);\r\n } else {\r\n if (typeof require === 'string') {\r\n require = [require];\r\n }\r\n passed = intersection(user.roles, require).length > 0;\r\n }\r\n if (!passed) {\r\n children = fallback;\r\n }\r\n\r\n return <>{children}</>;\r\n}\r\n","import { Children, ReactNode } from 'react';\r\nimport styled from 'styled-components';\r\n\r\ninterface SpaceProps {\r\n children: ReactNode;\r\n size?: 'small' | 'middle' | 'large' | number;\r\n}\r\n\r\n\r\nexport default function Space({ children, size = 'small' }: SpaceProps) {\r\n\r\n if (typeof size === 'string') {\r\n size = {\r\n small: 8,\r\n middle: 16,\r\n large: 24\r\n }[size];\r\n }\r\n\r\n const items = Children.map(children, (child) => {\r\n return <Item size={size as number}>{child}</Item>;\r\n });\r\n\r\n return <Container>\r\n {items}\r\n </Container>;\r\n}\r\n\r\nconst Container = styled.div`\r\n display: inline-flex;\r\n align-items: center;\r\n`;\r\n\r\nconst Item = styled.div<{ size: number }>`\r\n margin-right: ${props => props.size}px;\r\n\r\n &:last-child {\r\n margin-right: 0;\r\n }\r\n`;\r\n","import { useMemo } from 'react';\r\n\r\ninterface Props {\r\n value: number;\r\n currency?: boolean;\r\n locale?: string;\r\n}\r\n\r\nexport default function NumberFormat({ value, locale = 'zh-CN', currency = true }: Props) {\r\n\r\n const formatter = useMemo(() => {\r\n\r\n let options = {};\r\n\r\n if (currency) {\r\n options = {\r\n style: 'currency',\r\n currency: 'CNY',\r\n ...options\r\n };\r\n } else {\r\n options = {\r\n minimumFractionDigits: 2,\r\n };\r\n }\r\n\r\n return new Intl.NumberFormat(locale, options);\r\n }, [currency, locale]);\r\n\r\n return <>{formatter.format(value)}</>;\r\n}\r\n","import { Button, ButtonProps } from 'react-bootstrap';\r\n\r\ninterface CustomButtonProps extends ButtonProps {\r\n loading: boolean\r\n}\r\n\r\nexport default function LoadingButton({ loading, children, ...props }: CustomButtonProps) {\r\n\r\n return <Button {...props} disabled={loading}>\r\n {loading ? 'Loading…' : children}\r\n </Button>;\r\n}\r\n","import { Button, ButtonProps } from 'react-bootstrap';\r\nimport request, { Config } from '../request';\r\nimport { createElement, ElementType, MouseEvent, useCallback, useState } from 'react';\r\nimport Message from '../utils/message';\r\nimport axios, { AxiosRequestConfig } from 'axios';\r\n\r\ninterface Props extends Omit<ButtonProps, 'as'> {\r\n url: Config;\r\n method?: AxiosRequestConfig['method'];\r\n confirm?: string;\r\n onSuccess?: (result: any) => void;\r\n as?: ElementType | ButtonProps['as'];\r\n}\r\n\r\nexport default function RequestButton({\r\n url,\r\n method,\r\n confirm,\r\n onSuccess,\r\n children,\r\n disabled,\r\n as = Button,\r\n ...props\r\n}: Props) {\r\n\r\n const [fetching, setFetching] = useState(false);\r\n\r\n const handleClick = useCallback(async (e: MouseEvent) => {\r\n e.preventDefault();\r\n try {\r\n setFetching(true);\r\n if (confirm) {\r\n if (!await Message.confirm({ text: confirm })) {\r\n return;\r\n }\r\n }\r\n\r\n const config = typeof url === 'string' ? { url, method } : { method, ...url };\r\n\r\n const result = await request(config);\r\n\r\n if (onSuccess) {\r\n onSuccess(result);\r\n }\r\n } catch (e) {\r\n if (axios.isAxiosError(e)) {\r\n let errors = e.errors;\r\n if (typeof e.errors !== 'string') {\r\n errors = Object.values(e.errors).join('<br />');\r\n }\r\n Message.error({ text: errors as string });\r\n } else {\r\n throw e;\r\n }\r\n } finally {\r\n setFetching(false);\r\n }\r\n }, [url, method, setFetching]);\r\n\r\n return createElement(as, {\r\n ...props,\r\n disabled: disabled || fetching,\r\n onClick: handleClick\r\n }, children);\r\n}\r\n","import JsonForm, { JsonFormProps, JsonFormType } from '@topthink/json-form';\r\nimport * as React from 'react';\r\nimport { forwardRef, ForwardRefExoticComponent, PropsWithoutRef, RefAttributes, useCallback, useState } from 'react';\r\nimport axios, { AxiosError, Method } from 'axios';\r\nimport LoadingButton from './loading-button';\r\nimport request from '../request';\r\nimport { mapValues } from 'lodash';\r\nimport { AjvError, ISubmitEvent } from '@rjsf/core';\r\n\r\nconst localize = require('ajv-i18n/localize/zh');\r\n\r\nexport interface FormProps<T = any> extends JsonFormProps<T> {\r\n onSuccess?: (data: any) => void;\r\n method?: Method;\r\n}\r\n\r\ntype Error = {\r\n __errors: string[]\r\n}\r\n\r\ntype Errors = Error | {\r\n [key: string]: Error\r\n}\r\n\r\nconst toExtraErrors = (error: AxiosError): Errors => {\r\n const errors = error.errors;\r\n if (typeof errors === 'string') {\r\n return {\r\n __errors: [errors]\r\n };\r\n }\r\n return mapValues(errors, (e) => {\r\n return {\r\n __errors: [e]\r\n };\r\n });\r\n};\r\n\r\nexport interface FormType extends JsonFormType {\r\n\r\n}\r\n\r\ntype Form<T = any> = ForwardRefExoticComponent<PropsWithoutRef<FormProps<T>> & RefAttributes<FormType>>\r\n\r\nconst Form: Form = forwardRef(({\r\n action,\r\n method = 'post',\r\n onSuccess,\r\n formData,\r\n onSubmit,\r\n onChange,\r\n children,\r\n ...props\r\n}, ref) => {\r\n\r\n const [extraErrors, setExtraErrors] = useState<Errors>();\r\n const [loading, setLoading] = useState(false);\r\n const [data, setData] = useState(formData);\r\n\r\n const handleSubmit = useCallback(async (e: ISubmitEvent<any>, nativeEvent: React.FormEvent<HTMLFormElement>) => {\r\n try {\r\n setLoading(true);\r\n if (action) {\r\n const { formData } = e;\r\n try {\r\n const data = await request({\r\n url: action,\r\n method,\r\n data: formData\r\n });\r\n setExtraErrors(undefined);\r\n if (onSuccess) {\r\n await onSuccess(data);\r\n }\r\n } catch (e) {\r\n if (axios.isAxiosError(e)) {\r\n setExtraErrors(toExtraErrors(e));\r\n }\r\n\r\n throw e;\r\n }\r\n } else if (onSubmit) {\r\n await onSubmit(e, nativeEvent);\r\n }\r\n } finally {\r\n setLoading(false);\r\n }\r\n }, [action, method, onSubmit]);\r\n\r\n const handleChange = useCallback((e: ISubmitEvent<any>) => {\r\n const { formData } = e;\r\n setData(formData);\r\n if (onChange) {\r\n onChange(e);\r\n }\r\n }, [setData, onChange]);\r\n\r\n const transformErrors = useCallback((errors: AjvError[]) => {\r\n errors = errors.map(error => ({\r\n keyword: error.name,\r\n dataPath: error.property,\r\n ...error\r\n }));\r\n\r\n localize(errors);\r\n\r\n return errors;\r\n }, []);\r\n\r\n return <JsonForm\r\n ref={ref}\r\n extraErrors={extraErrors}\r\n onSubmit={handleSubmit}\r\n transformErrors={transformErrors}\r\n noHtml5Validate\r\n noValidate\r\n {...props}\r\n formData={data}\r\n onChange={handleChange}\r\n >\r\n {children || <div className='col-12'>\r\n <LoadingButton loading={loading} type='submit' variant='primary'>提交</LoadingButton>\r\n </div>}\r\n </JsonForm>;\r\n});\r\n\r\nexport default Form;\r\n","import styled from 'styled-components';\r\nimport { PropsWithChildren, ReactNode } from 'react';\r\n\r\nconst Container = styled.div`\r\n width: 100%;\r\n`;\r\n\r\nconst Header = styled.div`\r\n background-color: #fff;\r\n display: flex;\r\n\r\n .container {\r\n padding: 0 24px;\r\n display: flex;\r\n justify-content: space-between;\r\n align-items: center;\r\n }\r\n`;\r\n\r\nconst Body = styled.div`\r\n margin-top: 24px;\r\n`;\r\n\r\nconst Title = styled.div`\r\n font-size: 22px;\r\n line-height: 64px;\r\n height: 64px;\r\n`;\r\n\r\nconst Extra = styled.div`\r\n\r\n`;\r\n\r\ninterface ContentProps {\r\n title: string\r\n extra?: ReactNode\r\n}\r\n\r\nexport default function Content({ title, children, extra }: PropsWithChildren<ContentProps>) {\r\n return <Container>\r\n <Header>\r\n <div className='container'>\r\n <Title>{title}</Title>\r\n <Extra>{extra}</Extra>\r\n </div>\r\n </Header>\r\n <Body className='container'>\r\n {children}\r\n </Body>\r\n </Container>;\r\n};\r\n","import { useCallback, useEffect, useMemo, useState } from 'react';\r\nimport { Pagination as BsPagination } from 'react-bootstrap';\r\n\r\nfunction noop() {\r\n}\r\n\r\n\r\nfunction isInteger(value: any): value is number {\r\n return (\r\n typeof value === 'number' && isFinite(value) && Math.floor(value) === value\r\n );\r\n}\r\n\r\nexport interface PaginationProps {\r\n className?: string\r\n total: number\r\n current?: number\r\n defaultCurrent?: number\r\n pageSize?: number\r\n defaultPageSize?: number,\r\n onChange?: (current: number, pageSize: number) => void\r\n}\r\n\r\nexport default function Pagination({\r\n total = 0,\r\n onChange = noop,\r\n defaultCurrent = 1,\r\n defaultPageSize = 10,\r\n className,\r\n ...props\r\n}: PaginationProps) {\r\n\r\n const [current, setCurrent] = useState(defaultCurrent);\r\n const [pageSize, setPageSize] = useState(defaultPageSize);\r\n\r\n useEffect(() => {\r\n if (isInteger(props.current)) {\r\n setCurrent(props.current);\r\n }\r\n }, [props.current]);\r\n\r\n useEffect(() => {\r\n if (isInteger(props.pageSize)) {\r\n setPageSize(props.pageSize);\r\n }\r\n }, [props.pageSize]);\r\n\r\n const allPages = useMemo(() => {\r\n return Math.floor((total - 1) / pageSize) + 1;\r\n }, [total, pageSize]);\r\n\r\n const handleChange = useCallback((p: number) => {\r\n return () => {\r\n if (p !== current) {\r\n setCurrent(p);\r\n onChange(p, pageSize);\r\n }\r\n };\r\n }, [onChange, current, pageSize]);\r\n\r\n const pageBufferSize = 2;\r\n const prevPage = current - 1 > 0 ? current - 1 : 0;\r\n const nextPage = current + 1 < allPages ? current + 1 : allPages;\r\n\r\n const pagerList = [];\r\n let jumpPrev = null;\r\n let jumpNext = null;\r\n let firstPager = null;\r\n let lastPager = null;\r\n\r\n if (allPages <= 3 + pageBufferSize * 2) {\r\n for (let i = 1; i <= allPages; i += 1) {\r\n const active = current === i;\r\n pagerList.push(\r\n <BsPagination.Item key={i} active={active} onClick={handleChange(i)}>{i}</BsPagination.Item>\r\n );\r\n }\r\n } else {\r\n lastPager = <BsPagination.Last key='last' onClick={handleChange(allPages)} />;\r\n firstPager = <BsPagination.First key='first' onClick={handleChange(1)} />;\r\n jumpPrev = <BsPagination.Prev key='prev' onClick={handleChange(prevPage)} />;\r\n jumpNext = <BsPagination.Next key='next' onClick={handleChange(nextPage)} />;\r\n\r\n let left = Math.max(1, current - pageBufferSize);\r\n let right = Math.min(current + pageBufferSize, allPages);\r\n\r\n if (current - 1 <= pageBufferSize) {\r\n right = 1 + pageBufferSize * 2;\r\n }\r\n\r\n if (allPages - current <= pageBufferSize) {\r\n left = allPages - pageBufferSize * 2;\r\n }\r\n\r\n for (let i = left; i <= right; i += 1) {\r\n const active = current === i;\r\n pagerList.push(\r\n <BsPagination.Item key={i} active={active} onClick={handleChange(i)}>{i}</BsPagination.Item>\r\n );\r\n }\r\n\r\n if (current - 1 >= pageBufferSize * 2 && current !== 1 + 2) {\r\n pagerList.unshift(jumpPrev);\r\n }\r\n if (\r\n allPages - current >= pageBufferSize * 2 &&\r\n current !== allPages - 2\r\n ) {\r\n pagerList.push(jumpNext);\r\n }\r\n\r\n if (left !== 1) {\r\n pagerList.unshift(firstPager);\r\n }\r\n if (right !== allPages) {\r\n pagerList.push(lastPager);\r\n }\r\n }\r\n\r\n return <BsPagination className={className}>\r\n {pagerList}\r\n </BsPagination>;\r\n\r\n}\r\n","import RcTable from 'rc-table';\r\nimport { TableProps as RcTableProps } from 'rc-table/lib/Table';\r\nimport { ColumnGroupType, ColumnsType, ColumnType as BsColumnType, RenderedCell } from 'rc-table/lib/interface';\r\nimport { Table as BsTable, TableProps as BsTableProps } from 'react-bootstrap';\r\nimport {\r\n forwardRef,\r\n ForwardRefExoticComponent,\r\n PropsWithChildren,\r\n PropsWithoutRef,\r\n ReactNode,\r\n RefAttributes,\r\n useCallback,\r\n useEffect,\r\n useImperativeHandle,\r\n useMemo,\r\n useRef,\r\n useState\r\n} from 'react';\r\nimport Pagination from './pagination';\r\nimport styled from 'styled-components';\r\nimport request from '../request';\r\nimport Card from './card';\r\nimport Loader from './loader';\r\nimport Space from './space';\r\n\r\nexport interface TableType {\r\n reload: () => void;\r\n}\r\n\r\ninterface ColumnType<RecordType> extends Omit<BsColumnType<RecordType>, 'render'> {\r\n render?: (data: { value: any, record: RecordType, index: number, action: TableType }) => ReactNode | RenderedCell<RecordType>;\r\n}\r\n\r\nexport type Columns<RecordType = any> = (ColumnGroupType<RecordType> | ColumnType<RecordType>)[]\r\n\r\nconst CustomTable = styled(BsTable)`\r\n .rc-table-thead {\r\n border-top: none;\r\n }\r\n`;\r\n\r\nconst components: RcTableProps['components'] = {\r\n table: (props: BsTableProps) => {\r\n return <CustomTable {...props} className='align-middle table-hover' />;\r\n },\r\n};\r\n\r\nexport interface PaginationType<T = any> {\r\n total: number;\r\n current_page: number;\r\n per_page: number;\r\n last_page: number;\r\n data: T[];\r\n}\r\n\r\nconst CustomPagination = styled(Pagination)`\r\n margin-bottom: 0;\r\n justify-content: flex-end;\r\n`;\r\n\r\nfunction isPagination<T>(data: any): data is PaginationType<T> {\r\n return 'current_page' in data;\r\n}\r\n\r\nexport interface TableProps<RecordType = any> extends Omit<RcTableProps<RecordType>, 'children' | 'columns'> {\r\n source: string | (() => Promise<any>);\r\n paginate?: boolean;\r\n columns: Columns<RecordType>;\r\n toolBarRender?: (action: TableType) => ReactNode;\r\n}\r\n\r\ntype Params = {\r\n page?: number;\r\n sortField?: string;\r\n sortOrder?: number;\r\n [key: string]: any;\r\n};\r\n\r\ntype CustomTableType<T = any> = ForwardRefExoticComponent<PropsWithoutRef<PropsWithChildren<TableProps<T>>>\r\n & RefAttributes<TableType>>\r\n\r\nconst Table: CustomTableType = forwardRef((\r\n { source, rowKey = 'id', paginate = true, toolBarRender, columns = [], ...props },\r\n ref\r\n) => {\r\n const [data, setData] = useState<any[]>([]);\r\n const [pagination, setPagination] = useState(paginate ? { total: 0, current: 1, pageSize: 10 } : null);\r\n const [loading, setLoading] = useState(true);\r\n\r\n const fetchData = useCallback(async (options: Params = {}) => {\r\n setLoading(true);\r\n try {\r\n let result;\r\n if (typeof source === 'string') {\r\n const params: any = {};\r\n if (pagination) {\r\n params.page = options.page || pagination.current;\r\n }\r\n result = await request({\r\n url: source,\r\n params\r\n });\r\n } else {\r\n result = await source();\r\n }\r\n\r\n if (paginate && isPagination<any>(result)) {\r\n setPagination({\r\n total: result.total,\r\n current: result.current_page,\r\n pageSize: result.per_page\r\n });\r\n result = result.data;\r\n }\r\n setData(result);\r\n } catch (e) {\r\n\r\n } finally {\r\n setLoading(false);\r\n }\r\n }, [source, setData, pagination]);\r\n\r\n useEffect(() => {\r\n fetchData();\r\n }, []);\r\n\r\n const action = useRef<TableType>({\r\n reload: fetchData\r\n });\r\n\r\n useEffect(() => {\r\n action.current = {\r\n reload: fetchData\r\n };\r\n }, [fetchData]);\r\n\r\n useImperativeHandle(ref, () => action.current);\r\n\r\n const customColumns = useMemo(() => {\r\n return columns.map((column) => {\r\n const customColumn: BsColumnType<any> = { ...column, render: undefined };\r\n\r\n if ('render' in column && column.render) {\r\n const defaultRender = column.render;\r\n customColumn.render = (value, record, index) => {\r\n return defaultRender({ value, record, index, action: action.current });\r\n };\r\n }\r\n return customColumn;\r\n }) as ColumnsType<any>;\r\n }, [columns, action]);\r\n\r\n const handlePageChange = useCallback((current: number) => {\r\n fetchData({\r\n page: current\r\n });\r\n }, []);\r\n\r\n return <Card>\r\n <Loader loading={loading} />\r\n <Header>\r\n <LeftTools>\r\n {toolBarRender && toolBarRender(action.current)}\r\n </LeftTools>\r\n <RightTools>\r\n <Action onClick={action.current.reload}><i className='bi bi-arrow-repeat' /></Action>\r\n </RightTools>\r\n </Header>\r\n <RcTable {...props} rowKey={rowKey} columns={customColumns} components={components} data={data} />\r\n {pagination && <CustomPagination {...pagination} onChange={handlePageChange} />}\r\n </Card>;\r\n});\r\n\r\nexport default Table;\r\n\r\nconst Header = styled.div`\r\n display: flex;\r\n justify-content: space-between;\r\n padding-bottom: 1rem;\r\n`;\r\n\r\nconst RightTools = styled(Space)`\r\n\r\n`;\r\nconst LeftTools = styled(Space)`\r\n\r\n`;\r\n\r\nconst Action = styled.span`\r\n cursor: pointer;\r\n font-size: 20px;\r\n line-height: 1;\r\n\r\n &:hover {\r\n color: var(--bs-primary);\r\n }\r\n`;\r\n","import {\r\n forwardRef,\r\n ForwardRefExoticComponent,\r\n PropsWithChildren,\r\n PropsWithoutRef,\r\n RefAttributes,\r\n useImperativeHandle,\r\n useState\r\n} from 'react';\r\nimport { Button, ButtonProps, Modal, ModalProps } from 'react-bootstrap';\r\nimport LoadingButton from './loading-button';\r\n\r\nexport interface ModalButtonProps extends ModalProps {\r\n text: string;\r\n variant?: ButtonProps['variant'];\r\n header?: string;\r\n onOk?: () => any;\r\n footer?: boolean;\r\n}\r\n\r\nexport interface ModalType {\r\n close: () => void;\r\n}\r\n\r\ntype ModalButtonType = ForwardRefExoticComponent<PropsWithoutRef<PropsWithChildren<ModalButtonProps>>\r\n & RefAttributes<ModalType>>\r\n\r\nconst ModalButton: ModalButtonType = forwardRef(({\r\n text,\r\n variant = 'primary',\r\n header = text,\r\n footer = true,\r\n onOk,\r\n size,\r\n children\r\n}, ref) => {\r\n\r\n const [show, setShow] = useState(false);\r\n const [loading, setLoading] = useState(false);\r\n const handleClose = () => setShow(false);\r\n const handleShow = () => setShow(true);\r\n\r\n useImperativeHandle(ref, () => ({\r\n close: handleClose\r\n }));\r\n\r\n const handleOk = async () => {\r\n if (onOk) {\r\n setLoading(true);\r\n const result = await onOk();\r\n setLoading(false);\r\n if (result === false) {\r\n return;\r\n }\r\n }\r\n handleClose();\r\n };\r\n\r\n return <>\r\n <Button variant={variant} onClick={handleShow}>{text}</Button>\r\n <Modal size={size} show={show} onHide={handleClose}>\r\n {header && <Modal.Header closeButton>\r\n <Modal.Title as='h5'>{header}</Modal.Title>\r\n </Modal.Header>}\r\n <Modal.Body>{children}</Modal.Body>\r\n {footer && <Modal.Footer>\r\n <Button variant='secondary' onClick={handleClose}>\r\n 取消\r\n </Button>\r\n <LoadingButton loading={loading} variant='primary' onClick={handleOk}>\r\n 确定\r\n </LoadingButton>\r\n </Modal.Footer>}\r\n </Modal>\r\n </>;\r\n});\r\n\r\nexport default ModalButton;\r\n","import ModalButton, { ModalButtonProps, ModalType } from './modal-button';\r\nimport { Fragment, useCallback, useRef } from 'react';\r\nimport Form, { FormProps, FormType } from './form';\r\n\r\nexport type ModalFormProps<T = any> =\r\n Pick<ModalButtonProps, 'text' | 'variant' | 'header' | 'size'> &\r\n Pick<FormProps<T>, 'schema' | 'formData' | 'uiSchema' | 'action' | 'method' | 'onSuccess' | 'onChange' | 'fields' | 'formContext'>\r\n\r\nexport default function ModalForm<T = any>({\r\n text,\r\n header,\r\n schema,\r\n uiSchema,\r\n action,\r\n method,\r\n formData,\r\n variant,\r\n onSuccess,\r\n onChange,\r\n fields,\r\n size\r\n}: ModalFormProps<T>) {\r\n\r\n const form = useRef<FormType>(null);\r\n const modal = useRef<ModalType>(null);\r\n\r\n const handleOk = useCallback(async () => {\r\n try {\r\n await form.current?.submit();\r\n return true;\r\n } catch {\r\n return false;\r\n }\r\n }, []);\r\n\r\n return <ModalButton ref={modal} text={text} onOk={handleOk} header={header} variant={variant} size={size}>\r\n <Form\r\n ref={form}\r\n schema={schema}\r\n uiSchema={uiSchema}\r\n action={action}\r\n method={method}\r\n formData={formData}\r\n fields={fields}\r\n onChange={onChange}\r\n onSuccess={onSuccess}\r\n >\r\n <Fragment />\r\n </Form>\r\n </ModalButton>;\r\n}\r\n","import { useAsyncCallback, UseAsyncCallbackOptions } from 'react-async-hook';\r\nimport request, { Config } from '../request';\r\nimport { DependencyList, useCallback, useEffect } from 'react';\r\nimport { AxiosRequestConfig } from 'axios';\r\n\r\ntype UseRequestOptions<T> = {\r\n manual?: boolean\r\n refreshDeps?: DependencyList;\r\n} & UseAsyncCallbackOptions<T>;\r\n\r\nexport default function useRequest<T = any>(config: Config, {\r\n manual,\r\n refreshDeps,\r\n ...options\r\n}: UseRequestOptions<T> = {}) {\r\n const { execute, currentParams, error, ...others } = useAsyncCallback(async (params?: AxiosRequestConfig) => {\r\n\r\n config = typeof config === 'string' ? { url: config } : config;\r\n\r\n return await request<T>({\r\n ...config,\r\n ...params\r\n });\r\n }, options);\r\n\r\n useEffect(() => {\r\n if (!manual && !refreshDeps) {\r\n execute();\r\n }\r\n }, []);\r\n\r\n useEffect(() => {\r\n if (refreshDeps) {\r\n refresh();\r\n }\r\n }, refreshDeps);\r\n\r\n\r\n const refresh = useCallback(() => {\r\n if (currentParams) {\r\n execute(...currentParams);\r\n } else {\r\n execute();\r\n }\r\n }, [execute, currentParams]);\r\n\r\n return {\r\n refresh,\r\n execute,\r\n ...others\r\n };\r\n}\r\n","import { useCallback, useState } from 'react';\r\n\r\ninterface Options {\r\n onHide?: () => void;\r\n onShow?: () => void;\r\n}\r\n\r\nlet id = 0;\r\n\r\nexport default function useOverlayState({ onHide, onShow }: Options = {}) {\r\n const [visible, setVisible] = useState(false);\r\n\r\n const [key, setKey] = useState(`visible-${id}`);\r\n\r\n const hide = useCallback(() => {\r\n setVisible(false);\r\n if (onHide) {\r\n onHide();\r\n }\r\n }, [setVisible, onHide]);\r\n\r\n const exit = useCallback(() => {\r\n setKey(`visible-${++id}`);\r\n }, [setKey, id]);\r\n\r\n const show = useCallback(() => {\r\n setVisible(true);\r\n if (onShow) {\r\n onShow();\r\n }\r\n }, [setVisible, onShow]);\r\n\r\n const state = {\r\n show: visible,\r\n onHide: hide,\r\n onExited: exit,\r\n key\r\n };\r\n\r\n return {\r\n visible,\r\n show,\r\n hide,\r\n state\r\n };\r\n}\r\n"],"names":["_taggedTemplateLiteral","strings","raw","slice","Object","freeze","defineProperties","value","FooterWrapper","styled","footer","Footer","_jsx","className","formatRelativePath","routes","parent","menus","route","meta","_route$meta","hideInMenu","title","_route$meta2","path","replace","menu","children","_route$meta3","hideChildrenInMenu","length","push","renderMenuItems","items","map","item","SubMenu","MenuItem","Link","to","collapseNode","height","expandNode","node","scrollHeight","motion","motionName","motionAppear","onAppearStart","onAppearActive","onEnterStart","onEnterActive","onLeaveStart","onLeaveActive","SiderLayout","basename","useRoutes","useMemo","getMenuData","pathname","useLocation","openKeys","keys","split","reduce","pre","curr","join","selectedKeys","_jsxs","Container","Sidebar","Header","Menu","mode","defaultOpenKeys","Content","Main","div","nav","main","RcMenu","CustomSwal","withReactContent","Swal","defaultOptions","confirmButtonText","cancelButtonText","Message","confirm","async","isConfirmed","fire","icon","showCancelButton","options","error","toast","position","timer","showConfirmButton","Icon","Title","Extra","IconMap","success","info","warning","Result","status","extra","Avatar","a","href","src","Dropdown","navbar","Toggle","as","header","Dimmer","props","active","inverted","Loader","loading","variant","animation","Spinner","rax","attach","axios","defaults","raxConfig","retryDelay","backoffType","shouldRetry","err","config","method","toUpperCase","response","baseURL","interceptors","request","use","token","sessionStorage","getItem","headers","Authorization","Promise","reject","data","location","window","undefined","e","isAxiosError","url","setItem","search","redirectUri","origin","encodeURIComponent","errors","name","Login","parsed","queryString","parse","hash","substr","access_token","removeItem","Navigate","Logout","useEffect","catch","Root","BrowserRouter","Routes","Route","element","Card","BsCard","classNames","Error","Alert","entries","_ref2","UserContext","React","createContext","UserProvider","user","state","setState","useState","Provider","useUser","setUser","useContext","Access","require","fallback","passed","intersection","roles","Space","size","small","middle","large","Children","child","Item","NumberFormat","locale","currency","formatter","style","minimumFractionDigits","Intl","format","LoadingButton","Button","disabled","RequestButton","onSuccess","fetching","setFetching","handleClick","useCallback","preventDefault","text","result","values","createElement","onClick","localize","Form","forwardRef","ref","action","formData","onSubmit","onChange","extraErrors","setExtraErrors","setLoading","setData","handleSubmit","nativeEvent","__errors","mapValues","toExtraErrors","handleChange","transformErrors","keyword","dataPath","property","JsonForm","noHtml5Validate","noValidate","type","Body","noop","isInteger","isFinite","Math","floor","CustomTable","BsTable","components","table","CustomPagination","total","defaultCurrent","defaultPageSize","current","setCurrent","pageSize","setPageSize","allPages","p","prevPage","nextPage","pagerList","jumpPrev","jumpNext","firstPager","lastPager","i","BsPagination","Last","First","Prev","Next","left","max","right","min","pageBufferSize","unshift","isPagination","Table","source","rowKey","paginate","toolBarRender","columns","pagination","setPagination","fetchData","params","page","current_page","per_page","useRef","reload","useImperativeHandle","customColumns","column","customColumn","render","defaultRender","record","index","handlePageChange","LeftTools","RightTools","Action","RcTable","span","ModalButton","onOk","show","setShow","handleClose","close","Modal","onHide","closeButton","ModalForm","schema","uiSchema","fields","form","modal","handleOk","_form$current","submit","Fragment","useRequest","manual","refreshDeps","execute","currentParams","others","useAsyncCallback","refresh","id","useOverlayState","onShow","visible","setVisible","key","setKey","hide","exit","onExited"],"mappings":"89BAAe,SAASA,EAAuBC,EAASC,UACjDA,IACHA,EAAMD,EAAQE,MAAM,IAGfC,OAAOC,OAAOD,OAAOE,iBAAiBL,EAAS,CACpDC,IAAK,CACHK,MAAOH,OAAOC,OAAOH,aCL3B,MAAMM,EAAgBC,EAAOC,oCAKLC,WACbC,EAACJ,YACJI,SAAKC,UAAU,gBCDvB,MAAMC,EAAqB,SACvBC,OACAC,yDAAiB,UAGXC,EAAoB,OAErB,MAAMC,KAASH,EAAQ,wBAEpBG,EAAMC,mBAANC,EAAYC,0BAIVC,YAAQJ,EAAMC,yBAANI,EAAYD,UACrBA,eAIDE,EAAON,EAAMM,MAAQ,GAEzBA,YAAUR,cAAUQ,GAEpBA,EAAOA,EAAKC,QAAQ,MAAO,KAAKA,QAAQ,MAAO,UAEzCC,EAAiB,CACnBJ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AA,EACAgC,KAAAA,EACA7K,MAAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@topthink/common",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.20",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"build": "rollup -c --environment NODE_ENV:production",
|
|
6
6
|
"build:dev": "rollup -c",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
],
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"@topthink/bootstrap": "^1.0.8",
|
|
19
|
-
"@topthink/json-form": "^1.0.
|
|
19
|
+
"@topthink/json-form": "^1.0.7",
|
|
20
20
|
"@types/lodash": "^4.14.161",
|
|
21
21
|
"ajv-i18n": "^4.0.0",
|
|
22
22
|
"axios": "^0.21.1",
|
|
@@ -64,5 +64,5 @@
|
|
|
64
64
|
},
|
|
65
65
|
"author": "yunwuxin <tzzhangyajun@qq.com> (https://github.com/yunwuxin)",
|
|
66
66
|
"license": "MIT",
|
|
67
|
-
"gitHead": "
|
|
67
|
+
"gitHead": "995a1b2e70477c57c1e1e77f01dd26e6711d5775"
|
|
68
68
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
interface Options {
|
|
2
|
+
onHide?: () => void;
|
|
3
|
+
onShow?: () => void;
|
|
4
|
+
}
|
|
5
|
+
export default function useOverlayState({ onHide, onShow }?: Options): {
|
|
6
|
+
visible: boolean;
|
|
7
|
+
show: () => void;
|
|
8
|
+
hide: () => void;
|
|
9
|
+
state: {
|
|
10
|
+
show: boolean;
|
|
11
|
+
onHide: () => void;
|
|
12
|
+
onExited: () => void;
|
|
13
|
+
key: string;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
export {};
|
package/types/index.d.ts
CHANGED
|
@@ -27,6 +27,7 @@ export { default as Table, TableProps, Columns, TableType } from './components/t
|
|
|
27
27
|
export { default as ModalForm, ModalFormProps } from './components/modal-form';
|
|
28
28
|
export { default as ModalButton, ModalType, ModalButtonProps } from './components/modal-button';
|
|
29
29
|
export { default as useRequest } from './hooks/use-request';
|
|
30
|
-
export { default as
|
|
30
|
+
export { default as useOverlayState } from './hooks/use-overlay-state';
|
|
31
|
+
export { default as UserProvider, useUser, User } from './components/user-provider';
|
|
31
32
|
export { default as request, Config as RequestConfig } from './request';
|
|
32
33
|
export { UiSchema as FormUiSchema, Schema as FormSchema, WidgetProps as FormWidgetProps, Widget as FormWidget, IChangeEvent as FormChangeEvent, ISubmitEvent as FormSubmitEvent } from '@topthink/json-form';
|