@ozo/react-rock
Version:
React 移动端开发脚手架,基于CRA3,通用、开箱即用。
2 lines • 2.61 kB
JavaScript
(this["webpackJsonp@ozo/react-rock"]=this["webpackJsonp@ozo/react-rock"]||[]).push([["cqaL"],{cqaL:function(t,e,r){"use strict";r.r(e);r("yXV3"),r("rB9j"),r("Rm1S"),r("UxlC");var a,n=r("2bPg"),i=r("BRlI"),o=r("tLe6"),c=r("00an"),s=r("q1tI"),u=r.n(s),l=r("Ty5D"),h=r("Kvkj"),f=new(function(){function t(){var e=this;Object(n.a)(this,t),this.navigation={_blank:{category:"route100",desc:"\u65b0\u5f00\u65b9\u5f0f\u8df3\u8f6c\u7cfb\u7edf\u81ea\u5e26\u6d4f\u89c8\u5668",target:""}},this.queryNavByType=function(t){return e.navigation[String(t)]}}return Object(i.a)(t,[{key:"navigate",value:function(t,e){var r=e.history,a=e.routeUrl,n=void 0===a?"":a,i=(e.title,e.token,this.queryNavByType(t));switch(i.category){case"route1":r.push(i.target+n);break;case"route2":r.push(i.target);break;case"route3":r.push(n);break;case"route100":if(!n)return!1;window.open(n,"_blank","location=no");break;default:console.log("\u8bf7\u8f93\u5165\u6b63\u786e\u7684\u8df3\u8f6c\u7c7b\u578b")}}}]),t}()),p=["https://www.jianshu.com/","https://github.com/"],v=Object(l.h)(a=function(t){Object(c.a)(r,t);var e=Object(o.a)(r);function r(t){var a;Object(n.a)(this,r),(a=e.call(this,t)).onClick=function(t){try{var e=a.getClosest(t.target,".clickable");if(e){var r=e.getAttribute("data-type"),n=e.getAttribute("data-url"),i=e.getAttribute("data-title");r&&f.navigate(r,{title:i,routeUrl:n,history:a.props.history})}}catch(o){console.warn(o)}};var i=a.props,o=i.location,c=i.match;return a.url=decodeURIComponent(o.state.url),a.urlInBlackList(a.url)&&window.location.replace(a.url),a.state={title:c.params.title||"\u52a0\u8f7d\u4e2d"},a.iframeRef=u.a.createRef(),a}return Object(i.a)(r,[{key:"componentDidMount",value:function(){this.iframeRef.current.onload=this.onLoaded.bind(this)}},{key:"onLoaded",value:function(){var t=this.iframeRef.current.contentDocument,e="";t&&(e=t.title),!this.props.match.params.title&&this.setState({title:e})}},{key:"getClosest",value:function(t,e){var r=t;if(r.matches(e))return r;for(;r&&"root"!==r.id;r=r.parentNode)if(r.matches(e))return r;return null}},{key:"urlInBlackList",value:function(t){for(var e=0;e<p.length;e++){var r=p[e];if(t.indexOf(r)>=0)return!0}return!1}},{key:"render",value:function(){var t=this.state.title,e=this.props.history;return u.a.createElement(h.a,{header:u.a.createElement(h.c,{title:t,onLeftClick:e.goBack})},u.a.createElement(h.e,{styles:{height:"100%"}},u.a.createElement("iframe",{id:"iframe",src:this.url,title:t,ref:this.iframeRef,style:{height:"100%",width:"100%",border:"none"}})))}}]),r}(s.Component))||a;e.default=v}}]);
//# sourceMappingURL=cqaL.ad7ffd7e.chunk.js.map