@@ -12,25 +12,46 @@ import React, { Component } from "react";
1212import Routes from "./components/routes" ;
1313import Navbar from "./components/navbar" ;
1414import Footer from "./components/footer" ;
15+ import * as api from "react-json-schema-form/api" ;
16+ import RenderJson from "./components/renderJson" ;
1517
1618var App = function ( _Component ) {
1719 _inherits ( App , _Component ) ;
1820
19- function App ( ) {
21+ function App ( props ) {
2022 _classCallCheck ( this , App ) ;
2123
22- return _possibleConstructorReturn ( this , ( App . __proto__ || Object . getPrototypeOf ( App ) ) . apply ( this , arguments ) ) ;
24+ var _this = _possibleConstructorReturn ( this , ( App . __proto__ || Object . getPrototypeOf ( App ) ) . call ( this , props ) ) ;
25+
26+ _this . state = {
27+ Schema : props . Schema
28+ } ;
29+ return _this ;
2330 }
2431
2532 _createClass ( App , [ {
33+ key : "componentDidMount" ,
34+ value : function componentDidMount ( ) {
35+ var _this2 = this ;
36+
37+ if ( ! this . props . Schema && this . props . SchemaUrl ) {
38+ api . get ( this . props . SchemaUrl , function ( json ) {
39+ return _this2 . setState ( { Schema : json } ) ;
40+ } ) ;
41+ }
42+ }
43+ } , {
2644 key : "render" ,
2745 value : function render ( ) {
28- var _props = Object . assign ( { } , this . props ) ,
29- Schema = _props . Schema ;
30-
31- var leftLinks = Schema . leftLinks ,
32- rightLinks = Schema . rightLinks ,
33- footer = Schema . footer ;
46+ if ( ! this . state . Schema ) {
47+ return null ;
48+ }
49+ var _state$Schema = this . state . Schema ,
50+ leftLinks = _state$Schema . leftLinks ,
51+ rightLinks = _state$Schema . rightLinks ,
52+ footer = _state$Schema . footer ,
53+ logo = _state$Schema . logo ,
54+ others = _state$Schema . others ;
3455
3556 var routes = [ ] . concat ( _toConsumableArray ( leftLinks . links ) , _toConsumableArray ( rightLinks . links ) ) . reduce ( function ( a , b ) {
3657 return b . children ? a . concat . apply ( a , _toConsumableArray ( b . children ) ) . concat ( b ) : a . concat ( b ) ;
@@ -44,14 +65,15 @@ var App = function (_Component) {
4465 metas : _ . metas
4566 } ;
4667 } ) ;
47-
68+ routes . push ( { url : logo . link } ) ;
4869 return React . createElement (
4970 "div" ,
5071 { className : "w3-row w3-wrapper" } ,
51- React . createElement ( Navbar , { links : Schema } ) ,
72+ React . createElement ( Navbar , { links : this . state . Schema } ) ,
5273 React . createElement (
5374 "div" ,
5475 { className : "w3-main" } ,
76+ React . createElement ( RenderJson , { json : others } ) ,
5577 React . createElement ( Routes , { routeList : routes } )
5678 ) ,
5779 React . createElement ( "div" , { className : "w3-push" } ) ,
0 commit comments