1 line
15 KiB
JavaScript
1 line
15 KiB
JavaScript
(this["webpackJsonpbeancount-web"]=this["webpackJsonpbeancount-web"]||[]).push([[12],{120:function(e,t,n){var a=n(72),r=n(121),c=n(94),i=Math.max,o=Math.min;e.exports=function(e,t,n){var s,l,u,p,d,f,m=0,b=!1,h=!1,j=!0;if("function"!=typeof e)throw new TypeError("Expected a function");function v(t){var n=s,a=l;return s=l=void 0,m=t,p=e.apply(a,n)}function g(e){return m=e,d=setTimeout(O,t),b?v(e):p}function y(e){var n=e-f;return void 0===f||n>=t||n<0||h&&e-m>=u}function O(){var e=r();if(y(e))return x(e);d=setTimeout(O,function(e){var n=t-(e-f);return h?o(n,u-(e-m)):n}(e))}function x(e){return d=void 0,j&&s?v(e):(s=l=void 0,p)}function S(){var e=r(),n=y(e);if(s=arguments,l=this,f=e,n){if(void 0===d)return g(f);if(h)return clearTimeout(d),d=setTimeout(O,t),v(f)}return void 0===d&&(d=setTimeout(O,t)),p}return t=c(t)||0,a(n)&&(b=!!n.leading,u=(h="maxWait"in n)?i(c(n.maxWait)||0,t):u,j="trailing"in n?!!n.trailing:j),S.cancel=function(){void 0!==d&&clearTimeout(d),m=0,s=f=l=d=void 0},S.flush=function(){return void 0===d?p:x(r())},S}},121:function(e,t,n){var a=n(55);e.exports=function(){return a.Date.now()}},122:function(e,t,n){var a=n(123),r=/^\s+/;e.exports=function(e){return e?e.slice(0,a(e)+1).replace(r,""):e}},123:function(e,t){var n=/\s/;e.exports=function(e){for(var t=e.length;t--&&n.test(e.charAt(t)););return t}},209:function(e,t,n){"use strict";var a=n(3),r=n(40),c=n(45),i=n(47),o=n(48),s=n(49),l=n(0),u=n(39),p=n.n(u),d=n(52),f=n(120),m=n.n(f),b=n(222),h=n(66),j=n(59),v=function(e,t){var n={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&t.indexOf(a)<0&&(n[a]=e[a]);if(null!=e&&"function"===typeof Object.getOwnPropertySymbols){var r=0;for(a=Object.getOwnPropertySymbols(e);r<a.length;r++)t.indexOf(a[r])<0&&Object.prototype.propertyIsEnumerable.call(e,a[r])&&(n[a[r]]=e[a[r]])}return n},g=(Object(h.a)("small","default","large"),null);var y=function(e){Object(o.a)(n,e);var t=Object(s.a)(n);function n(e){var i;Object(c.a)(this,n),(i=t.call(this,e)).debouncifyUpdateSpinning=function(e){var t=(e||i.props).delay;t&&(i.cancelExistingSpin(),i.updateSpinning=m()(i.originalUpdateSpinning,t))},i.updateSpinning=function(){var e=i.props.spinning;i.state.spinning!==e&&i.setState({spinning:e})},i.renderSpin=function(e){var t,n=e.getPrefixCls,c=e.direction,o=i.props,s=o.prefixCls,u=o.className,f=o.size,m=o.tip,b=o.wrapperClassName,h=o.style,y=v(o,["prefixCls","className","size","tip","wrapperClassName","style"]),O=i.state.spinning,x=n("spin",s),S=p()(x,(t={},Object(r.a)(t,"".concat(x,"-sm"),"small"===f),Object(r.a)(t,"".concat(x,"-lg"),"large"===f),Object(r.a)(t,"".concat(x,"-spinning"),O),Object(r.a)(t,"".concat(x,"-show-text"),!!m),Object(r.a)(t,"".concat(x,"-rtl"),"rtl"===c),t),u),N=Object(d.a)(y,["spinning","delay","indicator"]),w=l.createElement("div",Object(a.a)({},N,{style:h,className:S}),function(e,t){var n=t.indicator,a="".concat(e,"-dot");return null===n?null:Object(j.b)(n)?Object(j.a)(n,{className:p()(n.props.className,a)}):Object(j.b)(g)?Object(j.a)(g,{className:p()(g.props.className,a)}):l.createElement("span",{className:p()(a,"".concat(e,"-dot-spin"))},l.createElement("i",{className:"".concat(e,"-dot-item")}),l.createElement("i",{className:"".concat(e,"-dot-item")}),l.createElement("i",{className:"".concat(e,"-dot-item")}),l.createElement("i",{className:"".concat(e,"-dot-item")}))}(x,i.props),m?l.createElement("div",{className:"".concat(x,"-text")},m):null);if(i.isNestedPattern()){var k=p()("".concat(x,"-container"),Object(r.a)({},"".concat(x,"-blur"),O));return l.createElement("div",Object(a.a)({},N,{className:p()("".concat(x,"-nested-loading"),b)}),O&&l.createElement("div",{key:"loading"},w),l.createElement("div",{className:k,key:"container"},i.props.children))}return w};var o=e.spinning,s=function(e,t){return!!e&&!!t&&!isNaN(Number(t))}(o,e.delay);return i.state={spinning:o&&!s},i.originalUpdateSpinning=i.updateSpinning,i.debouncifyUpdateSpinning(e),i}return Object(i.a)(n,[{key:"componentDidMount",value:function(){this.updateSpinning()}},{key:"componentDidUpdate",value:function(){this.debouncifyUpdateSpinning(),this.updateSpinning()}},{key:"componentWillUnmount",value:function(){this.cancelExistingSpin()}},{key:"cancelExistingSpin",value:function(){var e=this.updateSpinning;e&&e.cancel&&e.cancel()}},{key:"isNestedPattern",value:function(){return!(!this.props||"undefined"===typeof this.props.children)}},{key:"render",value:function(){return l.createElement(b.a,null,this.renderSpin)}}],[{key:"setDefaultIndicator",value:function(e){g=e}}]),n}(l.Component);y.defaultProps={spinning:!0,size:"default",wrapperClassName:""},t.a=y},460:function(e,t,n){"use strict";var a=n(3),r=n(40),c=n(41),i=n(0),o=n(90),s=n(279),l=n(282),u=n(280),p=n(281),d=n(130),f=n(140),m=n(283),b=n(97),h=n(78),j=n(39),v=n.n(j),g=n(222);var y=n(45),O=n(47),x=n(48),S=n(49),N=function(e){Object(x.a)(n,e);var t=Object(S.a)(n);function n(){var e;return Object(y.a)(this,n),(e=t.apply(this,arguments)).state={error:void 0,info:{componentStack:""}},e}return Object(O.a)(n,[{key:"componentDidCatch",value:function(e,t){this.setState({error:e,info:t})}},{key:"render",value:function(){var e=this.props,t=e.message,n=e.description,a=e.children,r=this.state,c=r.error,o=r.info,s=o&&o.componentStack?o.componentStack:null,l="undefined"===typeof t?(c||"").toString():t,u="undefined"===typeof n?s:n;return c?i.createElement(P,{type:"error",message:l,description:i.createElement("pre",null,u)}):a}}]),n}(i.Component),w=n(59),k=function(e,t){var n={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&t.indexOf(a)<0&&(n[a]=e[a]);if(null!=e&&"function"===typeof Object.getOwnPropertySymbols){var r=0;for(a=Object.getOwnPropertySymbols(e);r<a.length;r++)t.indexOf(a[r])<0&&Object.prototype.propertyIsEnumerable.call(e,a[r])&&(n[a[r]]=e[a[r]])}return n},E={success:d.a,info:m.a,error:b.a,warning:f.a},C={success:s.a,info:u.a,error:p.a,warning:l.a},I=function(e){var t,n=e.description,s=e.prefixCls,l=e.message,u=e.banner,p=e.className,d=void 0===p?"":p,f=e.style,m=e.onMouseEnter,b=e.onMouseLeave,j=e.onClick,y=e.afterClose,O=e.showIcon,x=e.closable,S=e.closeText,N=e.action,I=k(e,["description","prefixCls","message","banner","className","style","onMouseEnter","onMouseLeave","onClick","afterClose","showIcon","closable","closeText","action"]),P=i.useState(!1),T=Object(c.a)(P,2),q=T[0],M=T[1],R=i.useRef(),D=i.useContext(g.b),L=D.getPrefixCls,U=D.direction,A=L("alert",s),B=function(e){var t;M(!0),null===(t=I.onClose)||void 0===t||t.call(I,e)},F=!!S||x,V=function(){var e=I.type;return void 0!==e?e:u?"warning":"info"}(),z=!(!u||void 0!==O)||O,J=v()(A,"".concat(A,"-").concat(V),(t={},Object(r.a)(t,"".concat(A,"-with-description"),!!n),Object(r.a)(t,"".concat(A,"-no-icon"),!z),Object(r.a)(t,"".concat(A,"-banner"),!!u),Object(r.a)(t,"".concat(A,"-rtl"),"rtl"===U),t),d),$=function(e){return Object.keys(e).reduce((function(t,n){return"data-"!==n.substr(0,5)&&"aria-"!==n.substr(0,5)&&"role"!==n||"data-__"===n.substr(0,7)||(t[n]=e[n]),t}),{})}(I);return i.createElement(h.b,{visible:!q,motionName:"".concat(A,"-motion"),motionAppear:!1,motionEnter:!1,onLeaveStart:function(e){return{maxHeight:e.offsetHeight}},onLeaveEnd:y},(function(e){var t=e.className,c=e.style;return i.createElement("div",Object(a.a)({ref:R,"data-show":!q,className:v()(J,t),style:Object(a.a)(Object(a.a)({},f),c),onMouseEnter:m,onMouseLeave:b,onClick:j,role:"alert"},$),z?function(){var e=I.icon,t=(n?C:E)[V]||null;return e?Object(w.c)(e,i.createElement("span",{className:"".concat(A,"-icon")},e),(function(){return{className:v()("".concat(A,"-icon"),Object(r.a)({},e.props.className,e.props.className))}})):i.createElement(t,{className:"".concat(A,"-icon")})}():null,i.createElement("div",{className:"".concat(A,"-content")},i.createElement("div",{className:"".concat(A,"-message")},l),i.createElement("div",{className:"".concat(A,"-description")},n)),N?i.createElement("div",{className:"".concat(A,"-action")},N):null,F?i.createElement("button",{type:"button",onClick:B,className:"".concat(A,"-close-icon"),tabIndex:0},S?i.createElement("span",{className:"".concat(A,"-close-text")},S):i.createElement(o.a,null)):null)}))};I.ErrorBoundary=N;var P=t.a=I},472:function(e,t,n){"use strict";n.r(t);var a=n(11),r=n(12),c=n(14),i=n(13),o=n(460),s=n(338),l=n(337),u=n(476),p=n(478),d=n(209),f=n(0),m=n.n(f),b=n(58),h=n(15),j=n(79),v=n(1),g={required:"${label} \u4e0d\u80fd\u4e3a\u7a7a\uff01"},y=function(e){Object(c.a)(n,e);var t=Object(i.a)(n);function n(){var e;Object(a.a)(this,n);for(var r=arguments.length,c=new Array(r),i=0;i<r;i++)c[i]=arguments[i];return(e=t.call.apply(t,[this].concat(c))).formRef=m.a.createRef(),e.state={loading:!1,checkStatus:"loading",showForm:!1,config:{}},e.checkReq=function(){e.setState({loading:!0}),Object(b.b)("/api/check",{method:"POST"}).then((function(t){e.setState({checkStatus:"ok"})})).catch((function(){e.setState({checkStatus:"error"})})).finally((function(){e.setState({loading:!1})}))},e.handleNextStep=function(){e.setState({loading:!0}),Object(b.b)("/api/config",{method:"GET"}).then((function(t){e.setState({config:t,showForm:!0})})).finally((function(){e.setState({loading:!1})}))},e.handleReCheck=function(){e.checkReq()},e.handleSubmitServerConfig=function(t){e.setState({loading:!0}),Object(b.b)("/api/config",{method:"POST",body:t}).then((function(){e.props.history.replace("/ledger")})).finally((function(){e.setState({loading:!1})}))},e}return Object(r.a)(n,[{key:"componentDidMount",value:function(){this.checkReq()}},{key:"render",value:function(){return"error"===this.state.checkStatus?Object(v.jsxs)("div",{children:[Object(v.jsx)(o.a,{message:"\u68c0\u6d4b\u5931\u8d25",description:"\u4f9d\u8d56\u672a\u5b89\u88c5\uff0c\u8bf7\u5148\u5b89\u88c5 beancount",type:"error",showIcon:!0}),Object(v.jsx)("div",{style:{marginTop:"1rem"},children:Object(v.jsx)(s.a,{block:!0,type:"danger",loading:this.state.loading,onClick:this.handleReCheck,children:"\u91cd\u65b0\u68c0\u6d4b"})}),Object(v.jsx)("div",{style:{marginTop:"1rem"},children:Object(v.jsx)("a",{href:"https://www.yuque.com/chuyi-ble7p/beancount-ns/sqwwqa#RwqnF",target:"_blank",children:"\u600e\u4e48\u5b89\u88c5 beancount ?"})})]}):"ok"===this.state.checkStatus?this.state.showForm?Object(v.jsx)("div",{children:Object(v.jsxs)(l.a,{name:"init-form",className:"page-form",size:"middle",layout:"vertical",style:{textAlign:"left"},ref:this.formRef,onFinish:this.handleSubmitServerConfig,validateMessages:g,children:[Object(v.jsx)(l.a.Item,{label:"\u8d26\u672c\u5b58\u50a8\u4f4d\u7f6e",name:"dataPath",initialValue:this.state.config.dataPath,rules:[{required:!0}],children:Object(v.jsx)(u.a,{placeholder:"\u8d26\u672c\u5b58\u50a8\u4f4d\u7f6e"})}),Object(v.jsx)(l.a.Item,{label:"\u521d\u59cb\u5316\u65e5\u671f",name:"startDate",initialValue:this.state.config.startDate,rules:[{required:!0}],children:Object(v.jsx)(u.a,{type:"date",placeholder:"\u521d\u59cb\u5316\u65e5\u671f"})}),Object(v.jsx)(l.a.Item,{label:"\u672c\u5e01\u4f4d",name:"operatingCurrency",initialValue:this.state.config.operatingCurrency,rules:[{required:!0}],children:Object(v.jsx)(u.a,{placeholder:"\u672c\u5e01\u4f4d"})}),Object(v.jsx)(l.a.Item,{label:"\u5e73\u8861\u8d26\u6237",name:"openingBalances",initialValue:this.state.config.openingBalances,rules:[{required:!0}],children:Object(v.jsx)(u.a,{placeholder:"\u5e73\u8861\u8d26\u6237"})}),Object(v.jsx)(l.a.Item,{label:"\u4fee\u6539\u6e90\u6587\u4ef6\u65f6\u662f\u5426\u5907\u4efd\u6570\u636e",name:"isBak",valuePropName:"checked",initialValue:this.state.config.isBak,children:Object(v.jsx)(p.a,{})}),Object(v.jsx)(l.a.Item,{label:"\u5bc6\u94a5",name:"secret",rules:[{required:!0}],children:Object(v.jsx)(u.a.Password,{placeholder:"\u5bc6\u94a5"})}),Object(v.jsx)(l.a.Item,{children:Object(v.jsx)(s.a,{block:!0,type:"primary",htmlType:"submit",loading:this.state.loading,className:"submit-button",children:"\u786e\u8ba4"})})]})}):Object(v.jsxs)("div",{children:[Object(v.jsx)(o.a,{message:"\u68c0\u6d4b\u901a\u8fc7",description:"beancount\u5df2\u5b89\u88c5\uff0c\u70b9\u51fb\u4e0b\u4e00\u6b65\u6765\u5b8c\u6210\u521d\u59cb\u914d\u7f6e",type:"success",showIcon:!0}),Object(v.jsx)("div",{style:{marginTop:"1rem"}}),Object(v.jsx)(s.a,{type:"primary",block:!0,onClick:this.handleNextStep,children:"\u4e0b\u4e00\u6b65"})]}):Object(v.jsx)(d.a,{tip:"Loading...",children:Object(v.jsx)(o.a,{message:"\u68c0\u6d4b\u4e2d",description:"\u6b63\u5728\u68c0\u6d4b beancount \u662f\u5426\u5df2\u5b89\u88c5",type:"info",showIcon:!0})})}}]),n}(f.Component);y.contextType=h.a,t.default=Object(j.a)(y)},58:function(e,t,n){"use strict";n.d(t,"c",(function(){return i})),n.d(t,"d",(function(){return o})),n.d(t,"e",(function(){return s})),n.d(t,"a",(function(){return l})),n.d(t,"b",(function(){return p}));var a=n(462),r=(n(80),n(131)),c=n.n(r),i=function(e){var t=e.split(":");return t&&t.length>=1?e.split(":")[0]:""},o=function(e){return e.split(":").join("_")},s=function(e){var t=e.split(":");return t&&t.length>=2?e.split(":")[t.length-1]:""},l={Income:"\u6536\u5165",Expenses:"\u652f\u51fa",Liabilities:"\u8d1f\u503a",Assets:"\u8d44\u4ea7"},u=function(e){return e},p=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.method,r=t.headers,i=t.body,o={"Content-Type":"application/json",ledgerId:window.localStorage.getItem("ledgerId")};return new Promise((function(t,s){c()(e,{method:n,headers:Object.assign({},o,r),body:JSON.stringify(i)}).then(u).then((function(e){return e.json()})).then((function(e){var n=e.code;200===n?t(e.data):200!==n&&(400===n?a.b.error("\u8bf7\u6c42\u53c2\u6570\u9519\u8bef"):1001===n?a.b.error("\u8d26\u76ee\u4e0d\u5e73\u8861"):1003===n?a.b.error("\u65e0\u6548\u8d26\u6237"):1005===n?a.b.error("\u65e0\u6548\u547d\u4ee4"):1006===n?a.b.error("\u5bc6\u7801\u9519\u8bef"):1007===n?a.b.error("\u8d26\u6237\u5df2\u5b58\u5728"):1008===n?a.b.error("\u5bc6\u94a5\u4e0d\u5339\u914d"):1010===n||401===n?window.location.href="/web/#/ledger":a.b.error("\u8bf7\u6c42\u5931\u8d25\uff0c\u8bf7\u5237\u65b0\u9875\u9762\u91cd\u8bd5"),s(e))})).catch((function(e){a.b.error("\u8bf7\u6c42\u5931\u8d25\uff0c\u8bf7\u5237\u65b0\u9875\u9762\u91cd\u8bd5"),s(e)}))}))}},79:function(e,t,n){"use strict";var a=n(60),r=n(11),c=n(12),i=n(14),o=n(13),s=n(0),l=n(1);t.a=function(e){return function(t){Object(i.a)(s,t);var n=Object(o.a)(s);function s(){var e;Object(r.a)(this,s);for(var t=arguments.length,a=new Array(t),c=0;c<t;c++)a[c]=arguments[c];return(e=n.call.apply(n,[this].concat(a))).defaultCommodity={currency:"CNY",symbol:"\uffe5"},e.currentCommodity=window.localStorage.getItem("ledgerCurrency"),e}return Object(c.a)(s,[{key:"render",value:function(){return Object(l.jsx)(e,Object(a.a)(Object(a.a)({},this.props),{},{commodity:this.currentCommodity?JSON.parse(this.currentCommodity):this.defaultCommodity}))}}]),s}(s.Component)}},94:function(e,t,n){var a=n(122),r=n(72),c=n(95),i=/^[-+]0x[0-9a-f]+$/i,o=/^0b[01]+$/i,s=/^0o[0-7]+$/i,l=parseInt;e.exports=function(e){if("number"==typeof e)return e;if(c(e))return NaN;if(r(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=r(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=a(e);var n=o.test(e);return n||s.test(e)?l(e.slice(2),n?2:8):i.test(e)?NaN:+e}},95:function(e,t,n){var a=n(67),r=n(68);e.exports=function(e){return"symbol"==typeof e||r(e)&&"[object Symbol]"==a(e)}}}]); |