beancount-gs/public/static/js/13.d2465d25.chunk.js

1 line
13 KiB
JavaScript

(this["webpackJsonpbeancount-web"]=this["webpackJsonpbeancount-web"]||[]).push([[13],{122:function(t,e,r){"use strict";r.r(e),r.d(e,"Headers",(function(){return p})),r.d(e,"Request",(function(){return j})),r.d(e,"Response",(function(){return O})),r.d(e,"DOMException",(function(){return E})),r.d(e,"fetch",(function(){return _}));var n="undefined"!==typeof globalThis&&globalThis||"undefined"!==typeof self&&self||"undefined"!==typeof n&&n,o="URLSearchParams"in n,i="Symbol"in n&&"iterator"in Symbol,s="FileReader"in n&&"Blob"in n&&function(){try{return new Blob,!0}catch(t){return!1}}(),a="FormData"in n,c="ArrayBuffer"in n;if(c)var u=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],h=ArrayBuffer.isView||function(t){return t&&u.indexOf(Object.prototype.toString.call(t))>-1};function f(t){if("string"!==typeof t&&(t=String(t)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(t)||""===t)throw new TypeError('Invalid character in header field name: "'+t+'"');return t.toLowerCase()}function d(t){return"string"!==typeof t&&(t=String(t)),t}function l(t){var e={next:function(){var e=t.shift();return{done:void 0===e,value:e}}};return i&&(e[Symbol.iterator]=function(){return e}),e}function p(t){this.map={},t instanceof p?t.forEach((function(t,e){this.append(e,t)}),this):Array.isArray(t)?t.forEach((function(t){this.append(t[0],t[1])}),this):t&&Object.getOwnPropertyNames(t).forEach((function(e){this.append(e,t[e])}),this)}function y(t){if(t.bodyUsed)return Promise.reject(new TypeError("Already read"));t.bodyUsed=!0}function b(t){return new Promise((function(e,r){t.onload=function(){e(t.result)},t.onerror=function(){r(t.error)}}))}function m(t){var e=new FileReader,r=b(e);return e.readAsArrayBuffer(t),r}function g(t){if(t.slice)return t.slice(0);var e=new Uint8Array(t.byteLength);return e.set(new Uint8Array(t)),e.buffer}function v(){return this.bodyUsed=!1,this._initBody=function(t){var e;this.bodyUsed=this.bodyUsed,this._bodyInit=t,t?"string"===typeof t?this._bodyText=t:s&&Blob.prototype.isPrototypeOf(t)?this._bodyBlob=t:a&&FormData.prototype.isPrototypeOf(t)?this._bodyFormData=t:o&&URLSearchParams.prototype.isPrototypeOf(t)?this._bodyText=t.toString():c&&s&&((e=t)&&DataView.prototype.isPrototypeOf(e))?(this._bodyArrayBuffer=g(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):c&&(ArrayBuffer.prototype.isPrototypeOf(t)||h(t))?this._bodyArrayBuffer=g(t):this._bodyText=t=Object.prototype.toString.call(t):this._bodyText="",this.headers.get("content-type")||("string"===typeof t?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):o&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},s&&(this.blob=function(){var t=y(this);if(t)return t;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){if(this._bodyArrayBuffer){var t=y(this);return t||(ArrayBuffer.isView(this._bodyArrayBuffer)?Promise.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):Promise.resolve(this._bodyArrayBuffer))}return this.blob().then(m)}),this.text=function(){var t=y(this);if(t)return t;if(this._bodyBlob)return function(t){var e=new FileReader,r=b(e);return e.readAsText(t),r}(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(function(t){for(var e=new Uint8Array(t),r=new Array(e.length),n=0;n<e.length;n++)r[n]=String.fromCharCode(e[n]);return r.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},a&&(this.formData=function(){return this.text().then(x)}),this.json=function(){return this.text().then(JSON.parse)},this}p.prototype.append=function(t,e){t=f(t),e=d(e);var r=this.map[t];this.map[t]=r?r+", "+e:e},p.prototype.delete=function(t){delete this.map[f(t)]},p.prototype.get=function(t){return t=f(t),this.has(t)?this.map[t]:null},p.prototype.has=function(t){return this.map.hasOwnProperty(f(t))},p.prototype.set=function(t,e){this.map[f(t)]=d(e)},p.prototype.forEach=function(t,e){for(var r in this.map)this.map.hasOwnProperty(r)&&t.call(e,this.map[r],r,this)},p.prototype.keys=function(){var t=[];return this.forEach((function(e,r){t.push(r)})),l(t)},p.prototype.values=function(){var t=[];return this.forEach((function(e){t.push(e)})),l(t)},p.prototype.entries=function(){var t=[];return this.forEach((function(e,r){t.push([r,e])})),l(t)},i&&(p.prototype[Symbol.iterator]=p.prototype.entries);var w=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function j(t,e){if(!(this instanceof j))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');var r=(e=e||{}).body;if(t instanceof j){if(t.bodyUsed)throw new TypeError("Already read");this.url=t.url,this.credentials=t.credentials,e.headers||(this.headers=new p(t.headers)),this.method=t.method,this.mode=t.mode,this.signal=t.signal,r||null==t._bodyInit||(r=t._bodyInit,t.bodyUsed=!0)}else this.url=String(t);if(this.credentials=e.credentials||this.credentials||"same-origin",!e.headers&&this.headers||(this.headers=new p(e.headers)),this.method=function(t){var e=t.toUpperCase();return w.indexOf(e)>-1?e:t}(e.method||this.method||"GET"),this.mode=e.mode||this.mode||null,this.signal=e.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&r)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(r),("GET"===this.method||"HEAD"===this.method)&&("no-store"===e.cache||"no-cache"===e.cache)){var n=/([?&])_=[^&]*/;if(n.test(this.url))this.url=this.url.replace(n,"$1_="+(new Date).getTime());else{this.url+=(/\?/.test(this.url)?"&":"?")+"_="+(new Date).getTime()}}}function x(t){var e=new FormData;return t.trim().split("&").forEach((function(t){if(t){var r=t.split("="),n=r.shift().replace(/\+/g," "),o=r.join("=").replace(/\+/g," ");e.append(decodeURIComponent(n),decodeURIComponent(o))}})),e}function A(t){var e=new p;return t.replace(/\r?\n[\t ]+/g," ").split("\r").map((function(t){return 0===t.indexOf("\n")?t.substr(1,t.length):t})).forEach((function(t){var r=t.split(":"),n=r.shift().trim();if(n){var o=r.join(":").trim();e.append(n,o)}})),e}function O(t,e){if(!(this instanceof O))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');e||(e={}),this.type="default",this.status=void 0===e.status?200:e.status,this.ok=this.status>=200&&this.status<300,this.statusText=void 0===e.statusText?"":""+e.statusText,this.headers=new p(e.headers),this.url=e.url||"",this._initBody(t)}j.prototype.clone=function(){return new j(this,{body:this._bodyInit})},v.call(j.prototype),v.call(O.prototype),O.prototype.clone=function(){return new O(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new p(this.headers),url:this.url})},O.error=function(){var t=new O(null,{status:0,statusText:""});return t.type="error",t};var T=[301,302,303,307,308];O.redirect=function(t,e){if(-1===T.indexOf(e))throw new RangeError("Invalid status code");return new O(null,{status:e,headers:{location:t}})};var E=n.DOMException;try{new E}catch(B){(E=function(t,e){this.message=t,this.name=e;var r=Error(t);this.stack=r.stack}).prototype=Object.create(Error.prototype),E.prototype.constructor=E}function _(t,e){return new Promise((function(r,o){var i=new j(t,e);if(i.signal&&i.signal.aborted)return o(new E("Aborted","AbortError"));var a=new XMLHttpRequest;function u(){a.abort()}a.onload=function(){var t={status:a.status,statusText:a.statusText,headers:A(a.getAllResponseHeaders()||"")};t.url="responseURL"in a?a.responseURL:t.headers.get("X-Request-URL");var e="response"in a?a.response:a.responseText;setTimeout((function(){r(new O(e,t))}),0)},a.onerror=function(){setTimeout((function(){o(new TypeError("Network request failed"))}),0)},a.ontimeout=function(){setTimeout((function(){o(new TypeError("Network request failed"))}),0)},a.onabort=function(){setTimeout((function(){o(new E("Aborted","AbortError"))}),0)},a.open(i.method,function(t){try{return""===t&&n.location.href?n.location.href:t}catch(e){return t}}(i.url),!0),"include"===i.credentials?a.withCredentials=!0:"omit"===i.credentials&&(a.withCredentials=!1),"responseType"in a&&(s?a.responseType="blob":c&&i.headers.get("Content-Type")&&-1!==i.headers.get("Content-Type").indexOf("application/octet-stream")&&(a.responseType="arraybuffer")),!e||"object"!==typeof e.headers||e.headers instanceof p?i.headers.forEach((function(t,e){a.setRequestHeader(e,t)})):Object.getOwnPropertyNames(e.headers).forEach((function(t){a.setRequestHeader(t,d(e.headers[t]))})),i.signal&&(i.signal.addEventListener("abort",u),a.onreadystatechange=function(){4===a.readyState&&i.signal.removeEventListener("abort",u)}),a.send("undefined"===typeof i._bodyInit?null:i._bodyInit)}))}_.polyfill=!0,n.fetch||(n.fetch=_,n.Headers=p,n.Request=j,n.Response=O)},204:function(t,e,r){},564:function(t,e,r){"use strict";r.r(e);var n=r(11),o=r(12),i=r(14),s=r(13),a=r(561),c=r(562),u=r(569),h=r(88),f=r.n(h),d=r(0),l=r(73),p=r(15),y=r(64),b=(r(204),r(1)),m=function(t){Object(i.a)(r,t);var e=Object(s.a)(r);function r(){var t;Object(n.a)(this,r);for(var o=arguments.length,i=new Array(o),s=0;s<o;s++)i[s]=arguments[s];return(t=e.call.apply(e,[this].concat(i))).theme=t.context.theme,t.ledgerId=window.localStorage.getItem("ledgerId"),t.state={loading:!1,Assets:0,Income:0,Expenses:0,Liabilities:0},t.queryStatsTotalAmount=function(){t.setState({loading:!0}),f()("/api/auth/stats/total",{headers:{ledgerId:t.ledgerId}}).then((function(t){return t.json()})).then((function(e){if(200===e.code){var r=e.data,n=r.Income,o=r.Expenses,i=r.Liabilities,s=r.Assets;t.setState({Assets:s,Income:n,Expenses:o,Liabilities:i})}})).catch(console.error).finally((function(){t.setState({loading:!1})}))},t.navigateTo=function(e){t.props.history.push(e)},t}return Object(o.a)(r,[{key:"componentDidMount",value:function(){this.queryStatsTotalAmount()}},{key:"render",value:function(){var t=this;this.context.theme!==this.theme&&(this.theme=this.context.theme);var e=this.state.loading;return Object(b.jsxs)("div",{className:"stats-page",children:[Object(b.jsx)("div",{style:{textAlign:"center"},children:Object(b.jsx)(a.a,{gutter:16,children:Object(b.jsx)(c.a,{span:8,onClick:function(){t.navigateTo("/stats/assets")},children:Object(b.jsx)(u.a,{style:{cursor:"pointer"},title:"".concat(l.a.Assets,"\u603b\u989d"),value:this.state.Assets||0,loading:e})})})}),Object(b.jsx)("div",{style:{textAlign:"center",marginTop:"1rem"},children:Object(b.jsxs)(a.a,{gutter:16,children:[Object(b.jsx)(c.a,{span:8,children:Object(b.jsx)(u.a,{title:"\u7d2f\u8ba1".concat(l.a.Income),value:-this.state.Income||0,loading:e,prefix:"+",valueStyle:{color:"#cf1322"}})}),Object(b.jsx)(c.a,{span:8,children:Object(b.jsx)(u.a,{title:"\u7d2f\u8ba1".concat(l.a.Expenses),value:this.state.Expenses||0,loading:e,prefix:"-",valueStyle:{color:"#3f8600"}})}),Object(b.jsx)(c.a,{span:8,children:Object(b.jsx)(u.a,{title:"\u7d2f\u8ba1".concat(l.a.Liabilities),value:-this.state.Liabilities||0,loading:e,prefix:"-",valueStyle:{color:"#3f8600"}})})]})})]})}}]),r}(d.Component);m.contextType=p.a,e.default=Object(y.a)(m)},64:function(t,e,r){"use strict";var n=r(86),o=r(11),i=r(12),s=r(14),a=r(13),c=r(0),u=r(1);e.a=function(t){return function(e){Object(s.a)(c,e);var r=Object(a.a)(c);function c(){return Object(o.a)(this,c),r.apply(this,arguments)}return Object(i.a)(c,[{key:"render",value:function(){return Object(u.jsx)(t,Object(n.a)({},this.props))}}]),c}(c.Component)}},73:function(t,e,r){"use strict";r.d(e,"c",(function(){return s})),r.d(e,"e",(function(){return a})),r.d(e,"d",(function(){return c})),r.d(e,"a",(function(){return u})),r.d(e,"b",(function(){return f}));var n=r(558),o=r(88),i=r.n(o),s=function(t){var e=t.split(":");return e&&e.length>=1?t.split(":")[0]:""},a=function(t){var e=t.split(":");return e&&2===e.length?t.split(":")[1]:e&&e.length>=3?t.split(":")[e.length-2]:""},c=function(t){var e=t.split(":");return e&&e.length>=2?t.split(":")[e.length-1]:""},u={Income:"\u6536\u5165",Expenses:"\u652f\u51fa",Liabilities:"\u8d1f\u503a",Assets:"\u8d44\u4ea7"},h=function(t){return t},f=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=e.method,o=e.headers,s=e.body,a={"Content-Type":"application/json",ledgerId:window.localStorage.getItem("ledgerId")};return new Promise((function(e,c){i()(t,{method:r,headers:Object.assign({},a,o),body:JSON.stringify(s)}).then(h).then((function(t){return t.json()})).then((function(t){var r=t.code;200===r?e(t.data):200!==r&&(400===r?n.b.error("\u8bf7\u6c42\u53c2\u6570\u9519\u8bef"):1001===r?n.b.error("\u8d26\u76ee\u4e0d\u5e73\u8861"):1003===r?n.b.error("\u65e0\u6548\u8d26\u6237"):1005===r?n.b.error("\u65e0\u6548\u547d\u4ee4"):1006===r?n.b.error("\u5bc6\u7801\u9519\u8bef"):1010===r?window.location.href="/#/ledger":n.b.error("\u8bf7\u6c42\u5931\u8d25\uff0c\u8bf7\u5237\u65b0\u9875\u9762\u91cd\u8bd5"),c(t))})).catch((function(t){n.b.error("\u8bf7\u6c42\u5931\u8d25\uff0c\u8bf7\u5237\u65b0\u9875\u9762\u91cd\u8bd5"),c(t)}))}))}},88:function(t,e,r){r(122),t.exports=self.fetch.bind(self)}}]);