import React, { PureComponent as Component } from 'react' import PropTypes from 'prop-types' import { connect } from 'react-redux'; import { getToken } from '../../../client/reducer/modules/project.js' import './Services.scss'; @connect( state => { return { token: state.project.token } }, { getToken } ) export default class Services extends Component { static propTypes = { projectId: PropTypes.number, token: PropTypes.string, getToken: PropTypes.func } async componentDidMount() { const id = this.props.projectId; await this.props.getToken(id); } render () { const id = this.props.projectId; return (
安装工具
{`
  npm i sm2tsservice -D
  `}
配置【3.2.0及以上版本】
{`
  touch json2service.json
  `}
{`
  {
    "url": "yapi-swagger.json",
    "remoteUrl": "${location.protocol}//${location.hostname}${location.port ? `:${location.port}` : ''}/api/open/plugin/export-full?type=json&pid=${id}&status=all&token=${this.props.token}",
    "type": "yapi",
    "swaggerParser": {}
  }
  `}
            
配置【3.2.0以下版本】
{`
  touch json2service.json
  `}
{`
  {
    "url": "${location.protocol}//${location.hostname}${location.port ? `:${location.port}` : ''}/api/open/plugin/export-full?type=json&pid=${id}&status=all&token=${this.props.token}",
    "type": "yapi",
    "swaggerParser": {}
  }
  `}
            
生成services代码
{`
  (./node_modules/.bin/)sm2tsservice --clear
  `}
更多说明 sm2tsservice
); } }