Bladeren bron

修改页面跳转url

Csy817 7 jaren geleden
bovenliggende
commit
6942a9fddb

+ 17 - 5
src/components/app/App.jsx

@@ -256,10 +256,10 @@ class App extends Component {
                                 key={locale ? locale.locale : 'en'/* Have to refresh for production environment */}>
                             <Switch>
                                 <Route path="/" exact component={TrialCase}/>
-                                <Route path="/graphql-service/:sidebar/:case" component={TrialCase}/>
-                                <Route path="/wechat-service/:sidebar/:case" component={WechatService}/>
+                                <Route path="/graphql-service/:sidebar" component={TrialCase}/>
+                                <Route path="/wechat-service/:sidebar" component={WechatService}/>
                                 <Route path="/quant-service/" component={QuantService}/>
-                                <Route path="/table/:name" component={Column}/>
+                                <Route path="/table" component={Column}/>
                                 <Route path="/login" component={Login}/>
                                 <Redirect path="*" to="/"/>
                             </Switch>
@@ -337,7 +337,13 @@ class GraphqlSidebar extends Component {
                                     {
                                         data.caseSchema.map((schema) =>
                                             <Menu.Item key={schema.schemaName}>
-                                                <Link to={`/graphql-service/trial-case/${schema.schemaName}?id=${schema.id}`}>{schema.schemaName}</Link>
+                                                <Link to={{
+                                                    pathname: "/graphql-service/trial-case",
+                                                    state:{
+                                                        schemaName:schema.schemaName,
+                                                        schemaId:schema.id
+                                                    }
+                                                }}>{schema.schemaName}</Link>
                                             </Menu.Item>)
                                     }
                                 </SubMenu>
@@ -357,7 +363,13 @@ class GraphqlSidebar extends Component {
                                     {
                                         data.userSchema.map((schema) =>
                                             <Menu.Item key={schema.schemaName}>
-                                                <Link to={`/graphql-service/my-create/${schema.schemaName}?id=${schema.id}`}>{schema.schemaName}</Link>
+                                                <Link to={{
+                                                    pathname: "/graphql-service/my-create",
+                                                    state:{
+                                                        schemaName:schema.schemaName,
+                                                        schemaId:schema.id
+                                                    }
+                                                }}>{schema.schemaName}</Link>
                                             </Menu.Item>)
                                     }
                                 </SubMenu>

+ 2 - 2
src/components/common/schema/Column.jsx

@@ -105,14 +105,14 @@ class Column extends Component {
 
     render() {
         console.log('columns',this.state.columns);
-        let schemaID = this.props.location.search.substr(this.props.location.search.indexOf("=")+1);
+        let {schemaId:schemaID,schemaName} = this.props.history.location.state;
         let userID = this.props.userID || getCookie('user_id');
         console.log('schemaID',schemaID,'userID',userID);
 
         return (
             <div>
                 <div className="column-menu" onClick={()=>this.props.history.goBack()}>
-                    <Icon type="left" style={{color:'#3187FA'}} /> {this.props.match.params.name}
+                    <Icon type="left" style={{color:'#3187FA'}} /> {schemaName}
                 </div>
 
                 <Layout style={{padding: '24px', zIndex: '0'}}>

+ 8 - 1
src/components/common/schema/Create.js

@@ -59,7 +59,14 @@ class Create extends Component {
             });
         }, 1000);
         this.props.hideModal();
-        this.props.history.push(`/table/${this.state.schemaName}?id=${varobj.id}`);
+        // this.props.history.push(`/table/${this.state.schemaName}?id=${varobj.id}`);
+        this.props.history.push({
+            pathname: `/table`,
+            state:{
+                schemaName:this.state.schemaName,
+                schemaId:varobj.id
+            }
+        });
     };
 
     render() {

+ 2 - 1
src/components/trialCase/TrialCase.jsx

@@ -15,6 +15,7 @@ const {Content} = Layout;
 class TrialCase extends Component {
     constructor(props) {
         super(props);
+        console.log('TrialCase props',props);
         this.state = {
             menuLevel2: "schema",
             // default user
@@ -47,7 +48,7 @@ class TrialCase extends Component {
 
 
     render() {
-        let schemaID = this.props.location.search.substr(this.props.location.search.indexOf("=")+1) || "schema_1542243424669_92094965";
+        let schemaID = this.props.history.location.state ? this.props.history.location.state.schemaId : "schema_1542243424669_92094965";
         console.log('schemaID',schemaID);
         return (
             <div>