-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbundle.js
More file actions
2 lines (2 loc) · 13.7 KB
/
bundle.js
File metadata and controls
2 lines (2 loc) · 13.7 KB
1
2
!function(){"use strict";var e={},t=[],n=[];function o(o,r){var a,s,i,l,c=n;for(l=arguments.length;l-- >2;)t.push(arguments[l]);for(r&&null!=r.children&&(t.length||t.push(r.children),delete r.children);t.length;)if((s=t.pop())&&void 0!==s.pop)for(l=s.length;l--;)t.push(s[l]);else"boolean"==typeof s&&(s=null),(i="function"!=typeof o)&&(null==s?s="":"number"==typeof s?s=String(s):"string"!=typeof s&&(i=!1)),i&&a?c[c.length-1]+=s:c===n?c=[s]:c.push(s),a=i;var u=new function(){};return u.nodeName=o,u.children=c,u.attributes=null==r?void 0:r,u.key=null==r?void 0:r.key,void 0!==e.vnode&&e.vnode(u),u}function r(e,t){for(var n in t)e[n]=t[n];return e}var a="function"==typeof Promise?Promise.resolve().then.bind(Promise.resolve()):setTimeout,s=/acit|ex(?:s|g|n|p|$)|rph|ows|mnc|ntw|ine[ch]|zoo|^ord/i,i=[];function l(t){!t._dirty&&(t._dirty=!0)&&1==i.push(t)&&(e.debounceRendering||a)(c)}function c(){var e,t=i;for(i=[];e=t.pop();)e._dirty&&U(e)}function u(e,t){return e.normalizedNodeName===t||e.nodeName.toLowerCase()===t.toLowerCase()}function p(e){var t=r({},e.attributes);t.children=e.children;var n=e.nodeName.defaultProps;if(void 0!==n)for(var o in n)void 0===t[o]&&(t[o]=n[o]);return t}function d(e){var t=e.parentNode;t&&t.removeChild(e)}function f(e,t,n,o,r){if("className"===t&&(t="class"),"key"===t);else if("ref"===t)n&&n(null),o&&o(e);else if("class"!==t||r)if("style"===t){if(o&&"string"!=typeof o&&"string"!=typeof n||(e.style.cssText=o||""),o&&"object"==typeof o){if("string"!=typeof n)for(var a in n)a in o||(e.style[a]="");for(var a in o)e.style[a]="number"==typeof o[a]&&!1===s.test(a)?o[a]+"px":o[a]}}else if("dangerouslySetInnerHTML"===t)o&&(e.innerHTML=o.__html||"");else if("o"==t[0]&&"n"==t[1]){var i=t!==(t=t.replace(/Capture$/,""));t=t.toLowerCase().substring(2),o?n||e.addEventListener(t,m,i):e.removeEventListener(t,m,i),(e._listeners||(e._listeners={}))[t]=o}else if("list"!==t&&"type"!==t&&!r&&t in e)!function(e,t,n){try{e[t]=n}catch(e){}}(e,t,null==o?"":o),null!=o&&!1!==o||e.removeAttribute(t);else{var l=r&&t!==(t=t.replace(/^xlink:?/,""));null==o||!1===o?l?e.removeAttributeNS("http://www.w3.org/1999/xlink",t.toLowerCase()):e.removeAttribute(t):"function"!=typeof o&&(l?e.setAttributeNS("http://www.w3.org/1999/xlink",t.toLowerCase(),o):e.setAttribute(t,o))}else e.className=o||""}function m(t){return this._listeners[t.type](e.event&&e.event(t)||t)}var v=[],h=0,_=!1,b=!1;function g(){for(var t;t=v.pop();)e.afterMount&&e.afterMount(t),t.componentDidMount&&t.componentDidMount()}function y(e,t,n,o,r,a){h++||(_=null!=r&&void 0!==r.ownerSVGElement,b=null!=e&&!("__preactattr_"in e));var s=N(e,t,n,o,a);return r&&s.parentNode!==r&&r.appendChild(s),--h||(b=!1,a||g()),s}function N(e,t,n,o,r){var a=e,s=_;if(null!=t&&"boolean"!=typeof t||(t=""),"string"==typeof t||"number"==typeof t)return e&&void 0!==e.splitText&&e.parentNode&&(!e._component||r)?e.nodeValue!=t&&(e.nodeValue=t):(a=document.createTextNode(t),e&&(e.parentNode&&e.parentNode.replaceChild(a,e),x(e,!0))),a.__preactattr_=!0,a;var i,l,c=t.nodeName;if("function"==typeof c)return function(e,t,n,o){var r=e&&e._component,a=r,s=e,i=r&&e._componentConstructor===t.nodeName,l=i,c=p(t);for(;r&&!l&&(r=r._parentComponent);)l=r.constructor===t.nodeName;r&&l&&(!o||r._component)?(P(r,c,3,n,o),e=r.base):(a&&!i&&(O(a),e=s=null),r=w(t.nodeName,c,n),e&&!r.nextBase&&(r.nextBase=e,s=null),P(r,c,1,n,o),e=r.base,s&&e!==s&&(s._component=null,x(s,!1)));return e}(e,t,n,o);if(_="svg"===c||"foreignObject"!==c&&_,c=String(c),(!e||!u(e,c))&&(i=c,(l=_?document.createElementNS("http://www.w3.org/2000/svg",i):document.createElement(i)).normalizedNodeName=i,a=l,e)){for(;e.firstChild;)a.appendChild(e.firstChild);e.parentNode&&e.parentNode.replaceChild(a,e),x(e,!0)}var m=a.firstChild,v=a.__preactattr_,h=t.children;if(null==v){v=a.__preactattr_={};for(var g=a.attributes,y=g.length;y--;)v[g[y].name]=g[y].value}return!b&&h&&1===h.length&&"string"==typeof h[0]&&null!=m&&void 0!==m.splitText&&null==m.nextSibling?m.nodeValue!=h[0]&&(m.nodeValue=h[0]):(h&&h.length||null!=m)&&function(e,t,n,o,r){var a,s,i,l,c,p=e.childNodes,f=[],m={},v=0,h=0,_=p.length,b=0,g=t?t.length:0;if(0!==_)for(var y=0;y<_;y++){var C=p[y],k=C.__preactattr_,w=g&&k?C._component?C._component.__key:k.key:null;null!=w?(v++,m[w]=C):(k||(void 0!==C.splitText?!r||C.nodeValue.trim():r))&&(f[b++]=C)}if(0!==g)for(var y=0;y<g;y++){l=t[y],c=null;var w=l.key;if(null!=w)v&&void 0!==m[w]&&(c=m[w],m[w]=void 0,v--);else if(!c&&h<b)for(a=h;a<b;a++)if(void 0!==f[a]&&(S=s=f[a],U=r,"string"==typeof(P=l)||"number"==typeof P?void 0!==S.splitText:"string"==typeof P.nodeName?!S._componentConstructor&&u(S,P.nodeName):U||S._componentConstructor===P.nodeName)){c=s,f[a]=void 0,a===b-1&&b--,a===h&&h++;break}c=N(c,l,n,o),i=p[y],c&&c!==e&&c!==i&&(null==i?e.appendChild(c):c===i.nextSibling?d(i):e.insertBefore(c,i))}var S,P,U;if(v)for(var y in m)void 0!==m[y]&&x(m[y],!1);for(;h<=b;)void 0!==(c=f[b--])&&x(c,!1)}(a,h,n,o,b||null!=v.dangerouslySetInnerHTML),function(e,t,n){var o;for(o in n)t&&null!=t[o]||null==n[o]||f(e,o,n[o],n[o]=void 0,_);for(o in t)"children"===o||"innerHTML"===o||o in n&&t[o]===("value"===o||"checked"===o?e[o]:n[o])||f(e,o,n[o],n[o]=t[o],_)}(a,t.attributes,v),_=s,a}function x(e,t){var n=e._component;n?O(n):(null!=e.__preactattr_&&e.__preactattr_.ref&&e.__preactattr_.ref(null),!1!==t&&null!=e.__preactattr_||d(e),C(e))}function C(e){for(e=e.lastChild;e;){var t=e.previousSibling;x(e,!0),e=t}}var k={};function w(e,t,n){var o,r=k[e.name];if(e.prototype&&e.prototype.render?(o=new e(t,n),L.call(o,t,n)):((o=new L(t,n)).constructor=e,o.render=S),r)for(var a=r.length;a--;)if(r[a].constructor===e){o.nextBase=r[a].nextBase,r.splice(a,1);break}return o}function S(e,t,n){return this.constructor(e,n)}function P(t,n,o,r,a){t._disable||(t._disable=!0,(t.__ref=n.ref)&&delete n.ref,(t.__key=n.key)&&delete n.key,!t.base||a?t.componentWillMount&&t.componentWillMount():t.componentWillReceiveProps&&t.componentWillReceiveProps(n,r),r&&r!==t.context&&(t.prevContext||(t.prevContext=t.context),t.context=r),t.prevProps||(t.prevProps=t.props),t.props=n,t._disable=!1,0!==o&&(1!==o&&!1===e.syncComponentUpdates&&t.base?l(t):U(t,1,a)),t.__ref&&t.__ref(t))}function U(t,n,o,a){if(!t._disable){var s,i,l,c=t.props,u=t.state,d=t.context,f=t.prevProps||c,m=t.prevState||u,_=t.prevContext||d,b=t.base,N=t.nextBase,C=b||N,k=t._component,S=!1;if(b&&(t.props=f,t.state=m,t.context=_,2!==n&&t.shouldComponentUpdate&&!1===t.shouldComponentUpdate(c,u,d)?S=!0:t.componentWillUpdate&&t.componentWillUpdate(c,u,d),t.props=c,t.state=u,t.context=d),t.prevProps=t.prevState=t.prevContext=t.nextBase=null,t._dirty=!1,!S){s=t.render(c,u,d),t.getChildContext&&(d=r(r({},d),t.getChildContext()));var L,T,j=s&&s.nodeName;if("function"==typeof j){var M=p(s);(i=k)&&i.constructor===j&&M.key==i.__key?P(i,M,1,d,!1):(L=i,t._component=i=w(j,M,d),i.nextBase=i.nextBase||N,i._parentComponent=t,P(i,M,0,d,!1),U(i,1,o,!0)),T=i.base}else l=C,(L=k)&&(l=t._component=null),(C||1===n)&&(l&&(l._component=null),T=y(l,s,d,o||!b,C&&C.parentNode,!0));if(C&&T!==C&&i!==k){var B=C.parentNode;B&&T!==B&&(B.replaceChild(T,C),L||(C._component=null,x(C,!1)))}if(L&&O(L),t.base=T,T&&!a){for(var E=t,W=t;W=W._parentComponent;)(E=W).base=T;T._component=E,T._componentConstructor=E.constructor}}if(!b||o?v.unshift(t):S||(t.componentDidUpdate&&t.componentDidUpdate(f,m,_),e.afterUpdate&&e.afterUpdate(t)),null!=t._renderCallbacks)for(;t._renderCallbacks.length;)t._renderCallbacks.pop().call(t);h||a||g()}}function O(t){e.beforeUnmount&&e.beforeUnmount(t);var n=t.base;t._disable=!0,t.componentWillUnmount&&t.componentWillUnmount(),t.base=null;var o=t._component;o?O(o):n&&(n.__preactattr_&&n.__preactattr_.ref&&n.__preactattr_.ref(null),t.nextBase=n,d(n),function(e){var t=e.constructor.name;(k[t]||(k[t]=[])).push(e)}(t),C(n)),t.__ref&&t.__ref(null)}function L(e,t){this._dirty=!0,this.context=t,this.props=e,this.state=this.state||{}}r(L.prototype,{setState:function(e,t){var n=this.state;this.prevState||(this.prevState=r({},n)),r(n,"function"==typeof e?e(n,this.props):e),t&&(this._renderCallbacks=this._renderCallbacks||[]).push(t),l(this)},forceUpdate:function(e){e&&(this._renderCallbacks=this._renderCallbacks||[]).push(e),U(this,2)},render:function(){}});var T,j=(T=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},function(e,t){function n(){this.constructor=e}T(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),M=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},B=function(e,t){var n=Object.keys(e),o=Object.keys(t);return n.length===o.length&&(n.length+o.length===0||n.every(function(n){return e[n]===t[n]}))};const{connect:E,getState:W,dispatch:$}=function(e){void 0===e&&(e={});var t=e,n=[];return{connect:function(e,t){return function(r){return function(a){function s(e){var t=a.call(this,e)||this,o=t;return o.execProps=o.execProps.bind(o),o.tempProps=o.execProps(),o.tempUpdate=function(){var e=o.execProps();B(o.tempProps,e)||(o.tempProps=e,o.forceUpdate&&o.forceUpdate())},n.push(o.tempUpdate),t}return j(s,a),s.prototype.execProps=function(){var n=this.props,o=e(n),r={};return t&&(r=t(Object.assign({},n,o))),Object.assign({},n,o,r)},s.prototype.componentWillUnmount=function(){n.splice(n.indexOf(this.tempUpdate),1)},s.prototype.render=function(){return o(r,M({},this.tempProps))},s}(L)}},getState:function(){return t},dispatch:function(e,o){var r=e(t);I&&I.map(function(e){return e(t,r,o)}),r!==t&&(t=r,n.map(function(e){return e()}))}}}({pageNum:1,list:[],focus:-1,status:"list"});var I;const D=(e,t)=>fetch(e,t).then(e=>e.json()),A=()=>D("/api/note").then(({list:e})=>$(t=>Object.assign({},t,{status:"list",list:e}))),H=e=>{e.title&&e.content?D("/api/note",{method:"POST",body:JSON.stringify(e)}).then(A):alert("标题和内容需要填写!")},V=e=>D(`/api/note/${e}`,{method:"DELETE"}).then(A),z=e=>$(t=>Object.assign({},t,{status:e}));var R=E(()=>({changeStatus:z,save:H}))(class extends L{constructor(){super(...arguments),this.note={},this.onInput=((e,t)=>{this.note[e]=t}),this.onSubmit=(e=>{e.preventDefault();const{save:t}=this.props;t&&t(this.note)})}render(){const{onSubmit:e,onInput:t}=this,{changeStatus:n}=this.props;return o("div",{class:"panel"},o("p",{class:"panel-heading"},"新建"),o("div",{className:"panel-block"},o("form",{onSubmit:e},o("div",{className:"field"},o("label",{className:"label"},"标题"),o("div",{className:"control"},o("input",{className:"input",placeholder:"标题",onInput:e=>t("title",e.target.value)}))),o("div",{className:"field"},o("label",{className:"label"},"内容"),o("div",{className:"control"},o("textarea",{className:"textarea",placeholder:"内容",onInput:e=>t("content",e.target.value)}))),o("div",{className:"field is-grouped"},o("div",{className:"control"},o("input",{className:"button is-primary",type:"submit",value:"提交"})),o("div",{className:"control"},o("input",{className:"button is-text",type:"reset",onClick:()=>n("list"),value:"取消"}))))))}}),F=E(()=>{const{focus:e,list:t=[]}=W();return{changeStatus:z,note:t[e]||{}}})(e=>o("div",{class:"panel"},o("p",{class:"panel-heading"},o("div",{className:"columns is-mobile"},o("span",{class:"column"},"详情"),o("div",{className:"column has-text-right"},o("a",{className:"button is-text",onClick:()=>e.changeStatus("list")},"返回")))),o("div",{className:"panel-block"},o("div",{className:"content"},o("h2",null,e.note.title),o("div",{dangerouslySetInnerHTML:{__html:e.note.content}})))));const G=e=>{if(!e)return e;const t=new Date;return t.setTime(e),`${t.getFullYear()}-${t.getMonth()+1}-${t.getDate()} ${t.getHours()}:${t.getMinutes()}:${t.getSeconds()}`.replace(/\b(\d)\b/g,"0$1")};const J=e=>((e,t)=>$(n=>Object.assign({},n,{status:t,focus:e})))(e,"focus");var Y=E(()=>{const{pageNum:e,list:t}=W();return{pageNum:e,list:t,changeStatus:z,edit:J,remove:V}})(class extends L{render(){const{list:e=[],changeStatus:t,edit:n,remove:r}=this.props;return o("div",{class:"panel"},o("p",{class:"panel-heading"},o("div",{className:"buttons"},o("a",{className:"button is-success is-small",onClick:()=>t("add")},"新建"),o("a",{className:"button is-primary is-small",disabled:!0},"拉取全部"),o("a",{className:"button is-primary is-small",disabled:!0},"推送全部"))),o("div",{className:"panel-block"},o("table",{className:"table is-fullwidth"},o("thead",null,o("th",null,"序号"),o("th",null,"标题"),o("th",{className:"is-hidden-mobile"},"创建时间"),o("th",{className:"is-hidden-mobile"},"最后更新"),o("th",null,"操作")),o("tbody",null,e.map((e,t)=>o("tr",{key:`${t}`},o("th",null,t+1),o("th",null,e.title),o("th",{className:"is-hidden-mobile"},G(e.createTime)),o("th",{className:"is-hidden-mobile"},G(e.updateTime)),o("th",null,o("a",{className:"button is-text is-small",onClick:()=>n(t)},"详情"),e.serverId&&navigator.onLine&&o("a",{className:"button is-text is-small",disabled:!0},"拉取"),e.needUpdate&&o("a",{className:"button is-text is-small",disabled:!0},"推送"),(!e.serverId||navigator.onLine)&&o("a",{className:"button is-text is-small",onClick:()=>confirm("确定删除?")&&r(e.id)},"删除"))))))))}});var q,K,Q,X=E(()=>{const{status:e}=W();return{status:e}})(class extends L{render(){const{status:e}=this.props;return o("div",{className:"inner is-status-"+e},o(R,null),o(Y,null),o(F,null))}});addEventListener("error",function(e){alert(e),alert(e.message)}),"serviceWorker"in navigator&&addEventListener("load",function(){return e=this,t=void 0,o=function*(){navigator.serviceWorker.register("/sw.js",{scope:"/"})},new((n=void 0)||(n=Promise))(function(r,a){function s(e){try{l(o.next(e))}catch(e){a(e)}}function i(e){try{l(o.throw(e))}catch(e){a(e)}}function l(e){e.done?r(e.value):new n(function(t){t(e.value)}).then(s,i)}l((o=o.apply(e,t||[])).next())});var e,t,n,o}),A(),q=o(X,{}),K=document.getElementById("app"),y(Q,q,{},!1,K,!1)}();
//# sourceMappingURL=bundle.js.map