xy 7 years ago
parent
commit
d1b03a21ae

+ 0 - 1
README.md

@@ -9,7 +9,6 @@
 * graphiql-local: http://localhost:3000/graphql
 * fc-tencent: http://service-28dm054z-1254337200.ap-shanghai.apigateway.myqcloud.com/release/graphql
 * graphiql-tencent: http://123.206.193.98:3000/ql
-* 
 
 ### TODO
 * a lot, cannot list

+ 8 - 6
src/app/common/deploy/Deploy.jsx

@@ -9,6 +9,8 @@ import './index.css';
 import {SHOW_FC_SCHEMA, SHOW_FC_CONFIG, SEARCH_SCHEMA, SHOW_CLOUD, SHOW_WXCONTENT} from "../../../gql";
 import {request} from 'graphql-request'
 
+import {graphqlUrl} from "../../../config";
+
 const tabListNoTitle = [{
     key: 'tencent',
     tab: 'Tencent',
@@ -50,15 +52,15 @@ class Deploy extends Component {
 
     fetch = () => {
         if (this.state.schemaID !== '' && this.state.schemaID !== undefined) {
-            request('http://123.206.193.98:3000/graphql', SHOW_FC_SCHEMA, {schema_id: this.state.schemaID}).then(
+            request(graphqlUrl, SHOW_FC_SCHEMA, {schema_id: this.state.schemaID}).then(
                 // 根据 schemaID 查询 fc 是否成功
                 data => {
-                    request('http://123.206.193.98:3000/graphql', SEARCH_SCHEMA, {id: this.state.schemaID}).then(
+                    request(graphqlUrl, SEARCH_SCHEMA, {id: this.state.schemaID}).then(
                         // 根据 schemaID 查询 schemaName
                         _data => {
                             if (data.fc_by_props.length === 0) {
                                 // 如果没有 fc,根据 userID 查 cloudId
-                                request('http://123.206.193.98:3000/graphql', SHOW_CLOUD, {user_id: this.props.userID}).then(
+                                request(graphqlUrl, SHOW_CLOUD, {user_id: this.props.userID}).then(
                                     __data => {
                                         __data.cloud_by_props.forEach(cloud => {
                                             switch (cloud.cloudName) {
@@ -133,15 +135,15 @@ class Deploy extends Component {
                 }
             );
         } else {
-            request('http://123.206.193.98:3000/graphql', SHOW_FC_CONFIG, {wxConfig_id: this.state.configID}).then(
+            request(graphqlUrl, SHOW_FC_CONFIG, {wxConfig_id: this.state.configID}).then(
                 // 根据 configID 查询 fc 是否成功
                 data => {
-                    request('http://123.206.193.98:3000/graphql', SHOW_WXCONTENT, {id: this.state.configID}).then(
+                    request(graphqlUrl, SHOW_WXCONTENT, {id: this.state.configID}).then(
                         // 根据 configID 查询 appName
                         _data => {
                             if (data.fc_by_props.length === 0) {
                                 // 如果没有 fc,根据 userID 查 cloudId
-                                request('http://123.206.193.98:3000/graphql', SHOW_CLOUD, {user_id: this.props.userID}).then(
+                                request(graphqlUrl, SHOW_CLOUD, {user_id: this.props.userID}).then(
                                     __data => {
                                         __data.cloud_by_props.forEach(cloud => {
                                             switch (cloud.cloudName) {

+ 3 - 2
src/app/common/deploy/tencent/APIGroupCard.js

@@ -3,6 +3,7 @@ import {Input, Collapse, Button, Radio, Icon} from 'antd';
 import {ADD_APIGROUP, UPDATE_APIGROUP} from "../../../../gql";
 import {request} from 'graphql-request'
 import {idGen} from "../../../../func";
+import {graphqlUrl} from "../../../../config";
 
 const Panel = Collapse.Panel;
 
@@ -88,7 +89,7 @@ class APIGroupCard extends Component {
             updatedAt: ''
         };
         if (this.props.group === '') {
-            request('http://123.206.193.98:3000/graphql', ADD_APIGROUP, varObj).then(
+            request(graphqlUrl, ADD_APIGROUP, varObj).then(
                 data => {
                     if (data.create_apiGWGroup !== null) {
                         this.setState({
@@ -114,7 +115,7 @@ class APIGroupCard extends Component {
                 environmentName,
                 updatedAt: new Date().getTime()
             };
-            request('http://123.206.193.98:3000/graphql', UPDATE_APIGROUP, varObj).then(
+            request(graphqlUrl, UPDATE_APIGROUP, varObj).then(
                 data => {
                     if (data.update_apiGWGroup !== null) {
                         this.setState({

+ 3 - 2
src/app/common/deploy/tencent/APIPathCard.js

@@ -3,6 +3,7 @@ import {Input, Radio, Collapse, Button, Icon} from 'antd';
 import {request} from 'graphql-request'
 import {ADD_APIGWPATH, UPDATE_APIGWPATH} from "../../../../gql";
 import {idGen} from "../../../../func";
+import {graphqlUrl} from "../../../../config";
 
 const Panel = Collapse.Panel;
 
@@ -75,7 +76,7 @@ class APIPathCard extends Component {
         };
         if (this.props.path === '') {
             if(this.props.deployID !== '' && this.props.groupID!=='') {
-                request('http://123.206.193.98:3000/graphql', ADD_APIGWPATH, varObj).then(
+                request(graphqlUrl, ADD_APIGWPATH, varObj).then(
                     data => {
                         if (data.create_apiGWPath !== null) {
                             this.setState({
@@ -99,7 +100,7 @@ class APIPathCard extends Component {
                 requestMethod,
                 updatedAt: new Date().getTime()
             };
-            request('http://123.206.193.98:3000/graphql', UPDATE_APIGWPATH, varObj).then(
+            request(graphqlUrl, UPDATE_APIGWPATH, varObj).then(
                 data => {
                     if (data.update_apiGWPath !== null) {
                         this.setState({

+ 3 - 2
src/app/common/deploy/tencent/DeployCard.js

@@ -3,6 +3,7 @@ import {Input, Radio, Collapse, Button, Icon} from 'antd';
 import {ADD_DEPLOY, UPDATE_DEPLOY} from "../../../../gql";
 import {request} from 'graphql-request'
 import {idGen} from "../../../../func";
+import {graphqlUrl} from "../../../../config";
 
 const Panel = Collapse.Panel;
 
@@ -100,7 +101,7 @@ class DeployCard extends Component {
             updatedAt: ''
         };
         if (this.props.deploy === '') {
-            request('http://123.206.193.98:3000/graphql', ADD_DEPLOY, varObj).then(
+            request(graphqlUrl, ADD_DEPLOY, varObj).then(
                 data => {
                     if (data.create_deploy !== null) {
                         this.setState({
@@ -128,7 +129,7 @@ class DeployCard extends Component {
                 functionName,
                 updatedAt: new Date().getTime()
             };
-            request('http://123.206.193.98:3000/graphql', UPDATE_DEPLOY, varObj).then(
+            request(graphqlUrl, UPDATE_DEPLOY, varObj).then(
                 data => {
                     if (data.update_deploy !== null) {
                         this.setState({

+ 4 - 3
src/app/common/deploy/tencent/TencentConfig.js

@@ -7,6 +7,7 @@ import NotificationCard from './NotificationCard';
 
 import {SHOW_DEPLOY, SHOW_APIGWGROUP, SHOW_APIGWPATH} from "../../../../gql";
 import {request} from 'graphql-request'
+import {graphqlUrl} from "../../../../config";
 
 class TencentConfig extends Component {
     constructor(props) {
@@ -39,7 +40,7 @@ class TencentConfig extends Component {
         // todo: 没做每个 deploy 和 apigroup 和 apipath 的切换
         // todo: 换成 apollo 会更好
         if (this.state.fc === true) {
-            request('http://123.206.193.98:3000/graphql', SHOW_DEPLOY, {cloud_id: this.state.cloudID}).then(
+            request(graphqlUrl, SHOW_DEPLOY, {cloud_id: this.state.cloudID}).then(
                 data => {
                     this.setState({
                         deploys: data.deploy_by_props,
@@ -47,13 +48,13 @@ class TencentConfig extends Component {
                     })
                 }
             );
-            request('http://123.206.193.98:3000/graphql', SHOW_APIGWGROUP, {cloud_id: this.state.cloudID}).then(
+            request(graphqlUrl, SHOW_APIGWGROUP, {cloud_id: this.state.cloudID}).then(
                 data => {
                     this.setState({
                         groups: data.apiGWGroup_by_props,
                         currentGroup: data.apiGWGroup_by_props[0]
                     }, () => {
-                        request('http://123.206.193.98:3000/graphql', SHOW_APIGWPATH, {apiGWGroup_id: this.state.currentGroup.id}).then(
+                        request(graphqlUrl, SHOW_APIGWPATH, {apiGWGroup_id: this.state.currentGroup.id}).then(
                             data => {
                                 this.setState({
                                     paths: data.apiGWPath_by_props,

+ 2 - 2
src/app/graphqlService/UserCreate.jsx

@@ -7,6 +7,7 @@ import Schema from './component/schema/Schema';
 import Graphql from "./component/graphql/Graphql";
 import CaseMetabase from "./component/caseMetabase/CaseMetabase";
 import axios from 'axios';
+import {getIdUrl} from "../../config";
 
 axios.defaults.withCredentials = true;
 
@@ -18,13 +19,12 @@ class UserCreate extends Component {
         this.state = {
             menuLevel2: "schema",
             userID: "",
-            getID_url: 'http://123.206.193.98:8999/getuserid',
         }
     }
 
     componentWillMount() {
         let _this = this;
-        axios.get(this.state.getID_url)
+        axios.get(getIdUrl)
             .then((res) => {
                 if (res.data !== '') {
                     _this.setState({

+ 1 - 2
src/app/graphqlService/component/generateJs/GenerateJs.jsx

@@ -3,6 +3,7 @@ import axios from 'axios';
 import {BackTop, Tabs, Button, Spin} from 'antd';
 import saveAs from 'file-saver';
 import beautify from 'js-beautify';
+import {requestUrl} from '../../../../config';
 
 import './index.css';
 
@@ -22,7 +23,6 @@ class GenerateJs extends Component {
 
     componentDidMount() {
         this._isMounted = true;
-        let requestUrl = 'http://123.206.193.98:8999/graphql/genjs';
         let _this = this;
         let {schemaID} = this.state;
         axios.get(`${requestUrl}?schema=${schemaID}`)
@@ -56,7 +56,6 @@ class GenerateJs extends Component {
 
     componentDidUpdate() {
         this._isMounted = true;
-        let requestUrl = 'http://123.206.193.98:8999/graphql/genjs';
         let _this = this;
         let {schemaID} = this.state;
         axios.get(`${requestUrl}?schema=${schemaID}`)

+ 2 - 2
src/app/graphqlService/component/graphql/Graphql.jsx

@@ -2,7 +2,7 @@ import React, {Component} from 'react';
 import { Input, Alert} from 'antd';
 import GraphiQL from "graphiql";
 import fetch from "isomorphic-fetch";
-
+import {graphqlUrl} from "../../../../config";
 
 class Graphql extends Component {
 
@@ -11,7 +11,7 @@ class Graphql extends Component {
     this.state = {
       // api: 'http://service-ci2tk8iu-1254337200.ap-guangzhou.apigateway.myqcloud.com/release/graphql',
       // 便于开发调试,请删除并换成上面
-      api: 'http://123.206.193.98:3000/graphql'
+      api: graphqlUrl
       // api: 'http://service-28dm054z-1254337200.ap-shanghai.apigateway.myqcloud.com/release/graphql'
       // api: 'http://service-acb8p44v-1254337200.ap-beijing.apigateway.myqcloud.com/release/graphql'
 

+ 2 - 1
src/app/graphqlService/component/schema/Schema.jsx

@@ -17,6 +17,7 @@ import Table from "./Table";
 import {request} from 'graphql-request'
 import {getCookie} from "../../../../cookie";
 import {idGen} from "../../../../func";
+import {graphqlUrl} from "../../../../config";
 
 const confirm = Modal.confirm;
 const Search = Input.Search;
@@ -108,7 +109,7 @@ class Schema extends Component {
             return Promise.resolve(schemaData);
         } else {
             return new Promise((resolve, reject) => {
-                request('http://123.206.193.98:3000/graphql', SEARCH_SCHEMA, {id: referenceID}).then(
+                request(graphqlUrl, SEARCH_SCHEMA, {id: referenceID}).then(
                     data => {
                         console.log(data);
                         if (data.schema_by_id !== null) {

+ 4 - 2
src/app/wechatService/WxUserCreate.js

@@ -2,6 +2,8 @@ import React, {Component} from 'react';
 
 import {Layout, Menu} from 'antd';
 
+import {getIdUrl} from '../../config'
+
 import WxConfig from "./wxConfig/WxConfig";
 import WxDeploy from "../common/deploy/Deploy";
 import WxResult from './wxResult/WxResult';
@@ -17,13 +19,13 @@ class WxUserCreate extends Component {
         this.state = {
             menuLevel3: "wechat-config",
             userID: '',
-            getID_url: 'http://123.206.193.98:8999/getuserid',
+            getIdUrl
         }
     }
 
     componentWillMount() {
         let _this = this;
-        axios.get(this.state.getID_url)
+        axios.get(this.state.getIdUrl)
             .then((res) => {
                 if (res.data !== '') {
                     _this.setState({

+ 16 - 0
src/config.js

@@ -0,0 +1,16 @@
+// 基础配置
+const serverIP = 'http://123.206.193.98';
+const backendPort = '8999';
+const graphqlPort = '3000';
+const backend = serverIP + ':' + backendPort;
+
+// graphql 配置
+const graphqlUrl = serverIP + ':' + graphqlPort + '/graphql';
+
+// api 配置
+const requestUrl = backend + '/graphql/genjs';
+const getIdUrl = backend + '/getuserid';
+const loginUrl = backend +  '/login';
+const registerUrl = backend + '/resetpassword';
+
+export {requestUrl, getIdUrl, loginUrl, registerUrl, graphqlUrl}

+ 2 - 1
src/index.js

@@ -14,13 +14,14 @@ import zh from 'react-intl/locale-data/zh';
 import en from 'react-intl/locale-data/en';
 import zh_CN from './language/zh_CN.js';
 import en_US from './language/en_US.js';
+import {graphqlUrl} from "./config";
 
 addLocaleData([...en, ...zh]);
 
 
 const client = new ApolloClient({
     // uri: "http://service-eucrnpse-1254337200.ap-guangzhou.apigateway.myqcloud.com/release/graphql"
-    uri: "http://123.206.193.98:3000/graphql"
+    uri: graphqlUrl
 });
 
 let browserLanguage = (navigator.language || navigator.browserLanguage).toLowerCase().split('-')[0];

+ 4 - 3
src/login/CloudConfig.js

@@ -5,6 +5,7 @@ import {SHOW_CLOUD, ADD_CLOUD, UPDATE_CLOUD} from "../gql";
 import {request} from 'graphql-request'
 import {getCookie} from '../cookie';
 import {idGen} from "../func";
+import {graphqlUrl} from "../config";
 
 class CloudConfig extends Component {
     constructor(props) {
@@ -24,7 +25,7 @@ class CloudConfig extends Component {
             awsKey: '',
             userID: getCookie('user_id')
         };
-        request('http://123.206.193.98:3000/graphql', SHOW_CLOUD, {user_id: this.state.userID}).then(
+        request(graphqlUrl, SHOW_CLOUD, {user_id: this.state.userID}).then(
             data => {
                 let tencent = data.cloud_by_props.find(cloud => cloud.cloudName === 'tencent');
                 let aliyun = data.cloud_by_props.find(cloud => cloud.cloudName === 'aliyun');
@@ -67,7 +68,7 @@ class CloudConfig extends Component {
                     createdAt: new Date().getTime(),
                     updatedAt: ''
                 };
-                request('http://123.206.193.98:3000/graphql', ADD_CLOUD, varObj).then(
+                request(graphqlUrl, ADD_CLOUD, varObj).then(
                     data => {
                         if (data.create_cloud.length !== null) {
                             this.setState({
@@ -97,7 +98,7 @@ class CloudConfig extends Component {
                     secretKey,
                     updatedAt: new Date().getTime()
                 };
-                request('http://123.206.193.98:3000/graphql', UPDATE_CLOUD, varObj).then(
+                request(graphqlUrl, UPDATE_CLOUD, varObj).then(
                     data => {
                         if (data.update_cloud !== null) {
                             this.setState({

+ 8 - 9
src/login/LoginInput.js

@@ -10,6 +10,8 @@ import gql from "graphql-tag";
 import _ from 'lodash';
 import {idGen} from "../func";
 import {setCookie} from "../cookie";
+import {loginUrl, registerUrl, getIdUrl} from '../config'
+import {graphqlUrl} from "../config";
 
 axios.defaults.withCredentials = true;
 
@@ -28,9 +30,6 @@ class LoginInput extends Component {
             register_nickname: '',
             login_username: '',
             login_password: '',
-            login_url: 'http://123.206.193.98:8999/login',
-            register_url: 'http://123.206.193.98:8999/resetpassword',
-            getID_url: 'http://123.206.193.98:8999/getuserid',
             loginStatus: '',
             loginOnce: true,
             usernameTip: false
@@ -41,7 +40,7 @@ class LoginInput extends Component {
     login = () => {
         let _this = this;
 
-        axios.post(this.state.login_url, {
+        axios.post(loginUrl, {
             'user-name': this.state.login_username,
             password: this.state.login_password
         })
@@ -53,7 +52,7 @@ class LoginInput extends Component {
                 });
                 setCookie("user_id", res.data);
                 _this.props.getUserId(res.data);
-                request('http://123.206.193.98:3000/graphql', GET_USER, {id: res.data}).then(data => {
+                request(graphqlUrl, GET_USER, {id: res.data}).then(data => {
                         this.setState({
                             avatar: data.user_by_id.avatar,
                             nickname: data.user_by_id.nickname
@@ -123,7 +122,7 @@ class LoginInput extends Component {
                                 />
                             </div>
                             <Button type='primary' onClick={() => {
-                                request('http://123.206.193.98:3000/graphql', SEARCH_USER, {username: this.state.register_username}).then(data => {
+                                request(graphqlUrl, SEARCH_USER, {username: this.state.register_username}).then(data => {
                                     if (data.user_by_props.length === 0) {
                                         let id = idGen('user');
                                         let _this = this;
@@ -141,7 +140,7 @@ class LoginInput extends Component {
                                                 avatar: ''
                                             }
                                         });
-                                        axios.post(this.state.register_url,
+                                        axios.post(registerUrl,
                                             {
                                                 'user-id': id,
                                                 password: this.state.register_password,
@@ -179,7 +178,7 @@ class LoginInput extends Component {
 
     componentWillMount() {
         let _this = this;
-        axios.get(this.state.getID_url)
+        axios.get(getIdUrl)
             .then((res) => {
                 if (res.data !== '') {
                     setCookie("user_id", res.data);
@@ -189,7 +188,7 @@ class LoginInput extends Component {
                             loginOnce: false,
                             loginStatus: 'logined'
                         }, () => {
-                            request('http://123.206.193.98:3000/graphql', GET_USER, {id: res.data}).then(data => {
+                            request(graphqlUrl, GET_USER, {id: res.data}).then(data => {
                                     this.setState({
                                         avatar: data.user_by_id.avatar,
                                         nickname: data.user_by_id.nickname