1
0
mirror of https://github.com/chillzhuang/Sword synced 2024-11-22 02:09:26 +08:00

🎉 2.6.0发布 升级Hoxton.SR1 适配最新架构

This commit is contained in:
smallchill 2019-12-23 11:02:31 +08:00
parent 9921323463
commit 79d58cd5c0
12 changed files with 317 additions and 204 deletions

View File

@ -1,9 +1,9 @@
<p align="center"> <p align="center">
<img src="https://img.shields.io/badge/Release-V2.5.1-green.svg" alt="Downloads"> <img src="https://img.shields.io/badge/Release-V2.6.0-green.svg" alt="Downloads">
<img src="https://img.shields.io/badge/JDK-1.8+-green.svg" alt="Build Status"> <img src="https://img.shields.io/badge/JDK-1.8+-green.svg" alt="Build Status">
<img src="https://img.shields.io/badge/license-Apache%202-blue.svg" alt="Build Status"> <img src="https://img.shields.io/badge/license-Apache%202-blue.svg" alt="Build Status">
<img src="https://img.shields.io/badge/Spring%20Cloud-Greenwich.SR3-blue.svg" alt="Coverage Status"> <img src="https://img.shields.io/badge/Spring%20Cloud-Hoxton.SR1-blue.svg" alt="Coverage Status">
<img src="https://img.shields.io/badge/Spring%20Boot-2.1.8.RELEASE-blue.svg" alt="Downloads"> <img src="https://img.shields.io/badge/Spring%20Boot-2.2.2.RELEASE-blue.svg" alt="Downloads">
<a target="_blank" href="https://bladex.vip"> <a target="_blank" href="https://bladex.vip">
<img src="https://img.shields.io/badge/Author-Small%20Chill-ff69b4.svg" alt="Downloads"> <img src="https://img.shields.io/badge/Author-Small%20Chill-ff69b4.svg" alt="Downloads">
</a> </a>

View File

@ -64,7 +64,7 @@ export default [
component: './Account/Settings/NotificationView', component: './Account/Settings/NotificationView',
}, },
], ],
} },
], ],
}, },
{ {

View File

@ -1,6 +1,6 @@
{ {
"name": "sword", "name": "sword",
"version": "2.5.4", "version": "2.6.0",
"description": "An out-of-box UI solution for enterprise applications", "description": "An out-of-box UI solution for enterprise applications",
"private": true, "private": true,
"scripts": { "scripts": {
@ -60,7 +60,8 @@
"react-media": "^1.9.2", "react-media": "^1.9.2",
"react-router-dom": "^4.3.1", "react-router-dom": "^4.3.1",
"roadhog-api-doc": "^1.1.2", "roadhog-api-doc": "^1.1.2",
"js-base64": "^2.5.1" "js-base64": "^2.5.1",
"umi": "^2.4.4"
}, },
"devDependencies": { "devDependencies": {
"@types/react": "^16.8.1", "@types/react": "^16.8.1",

View File

@ -1,12 +1,11 @@
import React, { PureComponent } from 'react'; import React, { PureComponent } from 'react';
import { Card, Col, Collapse, Row } from 'antd'; import { Card, Col, Collapse, Row, Divider, Tag } from 'antd';
import styles from '../../layouts/Sword.less'; import styles from '../../layouts/Sword.less';
import PageHeaderWrapper from '@/components/PageHeaderWrapper'; import PageHeaderWrapper from '@/components/PageHeaderWrapper';
const { Panel } = Collapse; const { Panel } = Collapse;
class Workplace extends PureComponent { class Workplace extends PureComponent {
render() { render() {
return ( return (
@ -15,14 +14,14 @@ class Workplace extends PureComponent {
<Row gutter={24}> <Row gutter={24}>
<Col span={24}> <Col span={24}>
<div style={{ textAlign: 'center' }}> <div style={{ textAlign: 'center' }}>
<img src="https://img.shields.io/badge/Release-V2.5.4-green.svg" alt="Downloads" /> <img src="https://img.shields.io/badge/Release-V2.6.0-green.svg" alt="Downloads" />
<img src="https://img.shields.io/badge/JDK-1.8+-green.svg" alt="Build Status" /> <img src="https://img.shields.io/badge/JDK-1.8+-green.svg" alt="Build Status" />
<img <img
src="https://img.shields.io/badge/Spring%20Cloud-Greenwich.SR3-blue.svg" src="https://img.shields.io/badge/Spring%20Cloud-Hoxton.SR1-blue.svg"
alt="Coverage Status" alt="Coverage Status"
/> />
<img <img
src="https://img.shields.io/badge/Spring%20Boot-2.1.9.RELEASE-blue.svg" src="https://img.shields.io/badge/Spring%20Boot-2.2.2.RELEASE-blue.svg"
alt="Downloads" alt="Downloads"
/> />
<a href="https://bladex.vip"> <a href="https://bladex.vip">
@ -40,8 +39,10 @@ class Workplace extends PureComponent {
</div> </div>
</Col> </Col>
</Row> </Row>
</Card>
<Row gutter={24}> <Row gutter={24}>
<Col span={16}> <Col span={16}>
<Card className={styles.card} bordered={false}>
<Collapse bordered={false} defaultActiveKey={['1', '2', '3', '5']}> <Collapse bordered={false} defaultActiveKey={['1', '2', '3', '5']}>
<Panel header="欢迎使用Sword" key="1"> <Panel header="欢迎使用Sword" key="1">
<div>1.Sword是SpringBlade前端UI系统</div> <div>1.Sword是SpringBlade前端UI系统</div>
@ -56,54 +57,167 @@ class Workplace extends PureComponent {
<div>3.基于稳定生产的商业项目升级优化而来更加贴近企业级的需求</div> <div>3.基于稳定生产的商业项目升级优化而来更加贴近企业级的需求</div>
<div>4.追求企业开发更加高效部署更加方便生产更加稳定</div> <div>4.追求企业开发更加高效部署更加方便生产更加稳定</div>
<div>5.GVP-码云最有价值开源项目</div> <div>5.GVP-码云最有价值开源项目</div>
<div>6.BladeX授权地址:<a href="https://bladex.vip/#/vip">点击授权</a></div> <div>
6.BladeX授权地址:<a href="https://bladex.vip/#/vip">点击授权</a>
</div>
</Panel> </Panel>
<Panel header="为何需要BladeX" key="3"> <Panel header="为何需要BladeX" key="3">
<div>1.经历过较长的线上生产积累了很多企业痛点的解决方案</div> <div>1.经历过较长的线上生产积累了很多企业痛点的解决方案</div>
<div>2.一套代码兼容MySqlOraclePostgreSQL适应企业各种不同场景的需求</div> <div>2.一套代码兼容MySqlOraclePostgreSQL适应企业各种不同场景的需求</div>
<div>3.集成了很多企业急切所需的例如多租户Oauth2授权认证工作流分布式事务等等功能</div> <div>
<div>4.深度定制了Flowable工作流完美支持SpringCloud分布式服务的场景以远程调用的方式进行操作</div> 3.集成了很多企业急切所需的例如多租户Oauth2授权认证工作流分布式事务等等功能
<div>5.升级了核心驱动新功能完全可以开箱即用而开源版需要自己再花时间进行集成需要花掉更多的时间成本</div> </div>
<div>6.拥抱微服务时代很多企业由于项目转型或升级传统的技术已然不能满足反而会花更多成本而BladeX就是为此而生</div> <div>
<div>7.同时提供SpringCloud版本和SpringBoot版本两个版本的api可以与Sword和Saber无缝对接为小型项目至大型项目保驾护航</div> 4.深度定制了Flowable工作流完美支持SpringCloud分布式服务的场景以远程调用的方式进行操作
<div>8.授权购买即永久源码没有混淆后续升级完全免费企业只需花很少的钱即可获得一整套成熟的解决方案你还在等什么</div> </div>
<div>
5.升级了核心驱动新功能完全可以开箱即用而开源版需要自己再花时间进行集成需要花掉更多的时间成本
</div>
<div>
6.拥抱微服务时代很多企业由于项目转型或升级传统的技术已然不能满足反而会花更多成本而BladeX就是为此而生
</div>
<div>
7.同时提供SpringCloud版本和SpringBoot版本两个版本的api可以与Sword和Saber无缝对接为小型项目至大型项目保驾护航
</div>
<div>
8.授权购买即永久源码没有混淆后续升级完全免费企业只需花很少的钱即可获得一整套成熟的解决方案你还在等什么
</div>
</Panel> </Panel>
<Panel header="拥有的核心功能" key="4"> <Panel header="拥有的核心功能" key="4">
<div>1.前后端分离-采用前后端分离模式前端提供两套架构Sword基于ReactSaber基于Vue</div> <div>
<div>2. 分布式单体式后端架构-提供两套后端架构基于SpringCloud的分布式架构以及基于SpringBoot的单体式架构</div> 1.前后端分离-采用前后端分离模式前端提供两套架构Sword基于ReactSaber基于Vue
<div>3.API完全兼容-两套后端架构与两套前端架构共四套架构可以任意组合所有API完全兼容</div> </div>
<div>4.前后端代码生成-定制针对两套前端与后端的代码生成模板轻松生成整个模块的前后端代码减少重复工作量</div> <div>
<div>5.组件化插件化架构-针对功能深度定制各个starter引入开箱即用为整个架构解耦提升效率</div> 2.
分布式单体式后端架构-提供两套后端架构基于SpringCloud的分布式架构以及基于SpringBoot的单体式架构
</div>
<div>
3.API完全兼容-两套后端架构与两套前端架构共四套架构可以任意组合所有API完全兼容
</div>
<div>
4.前后端代码生成-定制针对两套前端与后端的代码生成模板轻松生成整个模块的前后端代码减少重复工作量
</div>
<div>
5.组件化插件化架构-针对功能深度定制各个starter引入开箱即用为整个架构解耦提升效率
</div>
<div>6.Nacos-集成阿里巴巴的Nacos完成统一的服务注册与配置</div> <div>6.Nacos-集成阿里巴巴的Nacos完成统一的服务注册与配置</div>
<div>7.Sentinel-集成Sentinel从流量控制熔断降级系统负载等多个维度保护服务的稳定性</div> <div>
7.Sentinel-集成Sentinel从流量控制熔断降级系统负载等多个维度保护服务的稳定性
</div>
<div>8.Dubbo-完美集成Dubbo最新版支持远程RPC调用</div> <div>8.Dubbo-完美集成Dubbo最新版支持远程RPC调用</div>
<div>9.多租户系统-完整的SaaS多租户架构</div> <div>9.多租户系统-完整的SaaS多租户架构</div>
<div>10.Oauth2-集成Oauth2协议完美支持多终端的接入与认证授权</div> <div>10.Oauth2-集成Oauth2协议完美支持多终端的接入与认证授权</div>
<div>11.工作流-深度定制SpringCloud分布式场景的Flowable工作流为复杂流程保驾护航同时提供SpringBoot集成版本</div> <div>
11.工作流-深度定制SpringCloud分布式场景的Flowable工作流为复杂流程保驾护航同时提供SpringBoot集成版本
</div>
<div>12.独立流程设计器-提供独立的完全汉化的流程设计器轻松定制流程模型</div> <div>12.独立流程设计器-提供独立的完全汉化的流程设计器轻松定制流程模型</div>
<div>13.动态网关-集成基于Nacos的轻量级高拓展性动态网关</div> <div>13.动态网关-集成基于Nacos的轻量级高拓展性动态网关</div>
<div>14.动态聚合文档-实现基于Nacos的Swagger SpringCloud聚合文档</div> <div>14.动态聚合文档-实现基于Nacos的Swagger SpringCloud聚合文档</div>
<div>15.分布式文件服务-集成minioqiniualioss等优秀的第三方提供便捷的文件上传与管理</div> <div>
<div>16.多租户对象存储系统-在SaaS系统中各租户可自行配置文件上传至自己的私有OSS</div> 15.分布式文件服务-集成minioqiniualioss等优秀的第三方提供便捷的文件上传与管理
</div>
<div>
16.多租户对象存储系统-在SaaS系统中各租户可自行配置文件上传至自己的私有OSS
</div>
<div>17.权限管理-精心设计的权限管理方案角色权限精确到按钮</div> <div>17.权限管理-精心设计的权限管理方案角色权限精确到按钮</div>
<div>18.动态数据权限-高度灵活的动态数据权限提供注解+Web可视化两种配置方式Web配置无需重启直接生效</div> <div>
<div>19.动态接口权限-高度灵活的动态接口权限提供注解+Web可视化两种配置方式Web配置无需重启直接生效</div> 18.动态数据权限-高度灵活的动态数据权限提供注解+Web可视化两种配置方式Web配置无需重启直接生效
<div>20.多租户顶部菜单配置-提供给每个租户独立的顶部菜单配置模块可以自定义顶部菜单切换</div> </div>
<div>21.主流数据库兼容-一套代码完全兼容MysqlPostgresqlOracle三大主流数据库</div> <div>
19.动态接口权限-高度灵活的动态接口权限提供注解+Web可视化两种配置方式Web配置无需重启直接生效
</div>
<div>
20.多租户顶部菜单配置-提供给每个租户独立的顶部菜单配置模块可以自定义顶部菜单切换
</div>
<div>
21.主流数据库兼容-一套代码完全兼容MysqlPostgresqlOracle三大主流数据库
</div>
<div>22.动态网关鉴权-基于Nacos的动态网关鉴权可在线配置实时生效</div> <div>22.动态网关鉴权-基于Nacos的动态网关鉴权可在线配置实时生效</div>
<div>23.全能代码生成器-支持自定义模型模版 业务建模支持多种模板引擎在线配置大幅度提升开发效率不再为重复工作发愁</div> <div>
<div>24.Seata分布式事务-定制集成Seata支持分布式事务无代码侵入不失灵活与简洁</div> 23.全能代码生成器-支持自定义模型模版
业务建模支持多种模板引擎在线配置大幅度提升开发效率不再为重复工作发愁
</div>
<div>
24.Seata分布式事务-定制集成Seata支持分布式事务无代码侵入不失灵活与简洁
</div>
<div>25.未完待续...</div> <div>25.未完待续...</div>
</Panel> </Panel>
<Panel header="软件定制开发合作" key="5"> <Panel header="软件定制开发合作" key="5">
<div>1.接BladeX系列架构的定制服务</div> <div>1.接BladeX系列架构的定制服务</div>
<div>2.接3个月以内工期的reactvuespringbootspringcloudapp小程序等软件定制服务</div> <div>
2.接3个月以内工期的reactvuespringbootspringcloudapp小程序等软件定制服务
</div>
<div>3.有意向请联系唯一指定QQ:85088620</div> <div>3.有意向请联系唯一指定QQ:85088620</div>
</Panel> </Panel>
</Collapse> </Collapse>
</Card>
</Col> </Col>
<Col span={8}> <Col span={8}>
<Collapse bordered={false} defaultActiveKey={['13']}> <Row gutter={24}>
<Card className={styles.card} bordered={false}>
<span>产品名称</span>
<Divider type="vertical" />
<Tag color="#108ee9">SpringBlade企业级微服务开发平台</Tag>
<Divider style={{ margin: '12px 0' }} />
<span>账号密码</span>
<Divider type="vertical" />
<Tag color="magenta">管理员(admin)</Tag>
<Divider style={{ margin: '12px 0' }} />
<span>官网地址</span>
<Divider type="vertical" />
<a href="https://bladex.vip" target="_blank">
https://bladex.vip
</a>
<Divider style={{ margin: '12px 0' }} />
<span>社区地址</span>
<Divider type="vertical" />
<a href="https://sns.bladex.vip" target="_blank">
https://sns.bladex.vip
</a>
<Divider style={{ margin: '12px 0' }} />
<span>获取文档</span>
<Divider type="vertical" />
<Tag color="#91e253" style={{ cursor: 'pointer' }}>
<a href="https://sns.bladex.vip/note/view/1.html" target="_blank">
免费版
</a>
</Tag>
<Divider type="vertical" />
<Tag color="#f5827b" style={{ cursor: 'pointer' }}>
<a href="https://www.kancloud.cn/@smallchill" target="_blank">
收费版
</a>
</Tag>
<Divider style={{ margin: '12px 0' }} />
<span>获取源码</span>
<Divider type="vertical" />
<Tag color="#87d068" style={{ cursor: 'pointer' }}>
<a href="https://gitee.com/smallc/SpringBlade" target="_blank">
开源版
</a>
</Tag>
<Divider type="vertical" />
<Tag color="#f50" style={{ cursor: 'pointer' }}>
<a href="https://bladex.vip/#/vip" target="_blank">
商业版
</a>
</Tag>
</Card>
</Row>
<Row gutter={24}>
<Card className={styles.card} bordered={false}>
<Collapse bordered={false} defaultActiveKey={['14']}>
<Panel header="2.6.0发布 升级Hoxton.SR1 适配最新架构" key="14">
<div>1.升级SpringCloud Hoxton.SR1</div>
<div>2.升级SpringBoot 2.2.2.RELEASE</div>
<div>3.升级Alibaba Cloud 2.1.1.RELEASE</div>
<div>4.升级Seata 1.0.0</div>
<div>5.升级Swagger-Bootstrap-UI为最新的Knife4j 2.0.1</div>
<div>6.升级Xss过滤机制以适配最新架构</div>
<div>7.升级前端请求机制以适配最新架构</div>
<div>8.修复blade-resource无法进行docker打包的问题</div>
<div>9.修复blade-demo没有配置LauncherService导致启动失败的问题</div>
</Panel>
<Panel header="2.5.4发布 增加多数据源示例工程" key="13"> <Panel header="2.5.4发布 增加多数据源示例工程" key="13">
<div>1.增加示例工程增加多种常见场景的解决方案</div> <div>1.增加示例工程增加多种常见场景的解决方案</div>
<div>2.增加不同包名运行的示例</div> <div>2.增加不同包名运行的示例</div>
@ -185,7 +299,10 @@ class Workplace extends PureComponent {
</Panel> </Panel>
<Panel header="2.3.0发布 升级SpringCloud Greenwich与SpringBoot" key="3"> <Panel header="2.3.0发布 升级SpringCloud Greenwich与SpringBoot" key="3">
<div>1.升级 SpringCloud Greenwich</div> <div>1.升级 SpringCloud Greenwich</div>
<div>2.升级 SpringCloud Alibaba 组件版本为0.9.0.RELEASE支持最新版本的nacos与sentinel</div> <div>
2.升级 SpringCloud Alibaba
组件版本为0.9.0.RELEASE支持最新版本的nacos与sentinel
</div>
<div>3.升级 SpringBoot 2.1.4</div> <div>3.升级 SpringBoot 2.1.4</div>
<div>4.升级 mysql 驱动版本</div> <div>4.升级 mysql 驱动版本</div>
<div>5.优化 LauncherService 关于环境的判断逻辑</div> <div>5.优化 LauncherService 关于环境的判断逻辑</div>
@ -210,14 +327,25 @@ class Workplace extends PureComponent {
<div>6.增加父子角色过滤使得角色无法越权配置</div> <div>6.增加父子角色过滤使得角色无法越权配置</div>
</Panel> </Panel>
<Panel header="2.0.0发布 全面升级为SpringCloud微服务架构" key="0"> <Panel header="2.0.0发布 全面升级为SpringCloud微服务架构" key="0">
<div>1.SpringBlade 2.0 是由一个商业级项目升级优化而来的SpringCloud微服务架构采用Java8 API重构了业务代码完全遵循阿里巴巴编码规范</div> <div>
<div>2.采用Spring Boot 2 Spring Cloud Greenwich Mybatis 等核心技术用于快速搭建企业级的微服务系统平台</div> 1.SpringBlade 2.0
<div>3.SpringBlade 致力于创造新颖的开发模式将开发中遇到的痛点生产中所踩的坑整理归纳并将解决方案都融合到框架中</div> 是由一个商业级项目升级优化而来的SpringCloud微服务架构采用Java8
API重构了业务代码完全遵循阿里巴巴编码规范
</div>
<div>
2.采用Spring Boot 2 Spring Cloud Greenwich Mybatis
等核心技术用于快速搭建企业级的微服务系统平台
</div>
<div>
3.SpringBlade
致力于创造新颖的开发模式将开发中遇到的痛点生产中所踩的坑整理归纳并将解决方案都融合到框架中
</div>
</Panel> </Panel>
</Collapse> </Collapse>
</Card>
</Row>
</Col> </Col>
</Row> </Row>
</Card>
</PageHeaderWrapper> </PageHeaderWrapper>
); );
} }

View File

@ -1,7 +1,7 @@
import React, { Component } from 'react'; import React, { Component } from 'react';
import { connect } from 'dva'; import { connect } from 'dva';
import { formatMessage, FormattedMessage } from 'umi/locale'; import { formatMessage, FormattedMessage } from 'umi/locale';
import { Checkbox, Alert, notification, Icon } from 'antd'; import { Checkbox, Alert } from 'antd';
import Login from '../../components/Login'; import Login from '../../components/Login';
import styles from './Login.less'; import styles from './Login.less';
import { tenantMode } from '../../defaultSettings'; import { tenantMode } from '../../defaultSettings';
@ -18,44 +18,6 @@ class LoginPage extends Component {
autoLogin: true, autoLogin: true,
}; };
componentWillMount() {
notification.config({
placement: 'bottomRight',
});
notification.destroy();
notification.open({
message: '手册信息',
description: (
<div>
<p>Sword开发手册<a target="_blank" href="https://www.kancloud.cn/smallchill/sword">点击查看</a></p>
<p>SpringBlade开发手册<a target="_blank" href="https://www.kancloud.cn/smallchill/blade">点击查看</a></p>
</div>
),
icon: <Icon type="smile" style={{ color: '#108ee9' }} />,
duration: 0,
});
setTimeout(() => {
notification.open({
message: '授权信息',
description: (
<div>
<p>欢迎使用Sword!</p>
<p>该系统可用BladeX增强开发</p>
<p>若要商用强烈推荐高度定制的商业化框架具体授权信息请访问如下地址</p>
<p>
BladeX 授权地址
<a target="_blank" href="https://bladex.vip/#/vip">
点击授权
</a>
</p>
</div>
),
icon: <Icon type="smile" style={{ color: '#108ee9' }} />,
duration: 0,
});
}, 500);
}
onTabChange = type => { onTabChange = type => {
this.setState({ type }); this.setState({ type });
}; };

View File

@ -1,6 +1,6 @@
import React, { Fragment, PureComponent } from 'react'; import React, { Fragment, PureComponent } from 'react';
import { connect } from 'dva'; import { connect } from 'dva';
import { Button, Col, Divider, Form, Input, message, Modal, Row } from "antd"; import { Button, Col, Divider, Form, Input, message, Modal, Row } from 'antd';
import Panel from '../../../components/Panel'; import Panel from '../../../components/Panel';
import Grid from '../../../components/Sword/Grid'; import Grid from '../../../components/Sword/Grid';
import { CODE_LIST } from '../../../actions/code'; import { CODE_LIST } from '../../../actions/code';

View File

@ -1,5 +1,5 @@
import React, { PureComponent } from 'react'; import React, { PureComponent } from 'react';
import { Form, Input, Card, Row, Col, Button, InputNumber, TreeSelect, message } from "antd"; import { Form, Input, Card, Row, Col, Button, InputNumber, TreeSelect, message } from 'antd';
import { connect } from 'dva'; import { connect } from 'dva';
import Panel from '../../../components/Panel'; import Panel from '../../../components/Panel';
import styles from '../../../layouts/Sword.less'; import styles from '../../../layouts/Sword.less';

View File

@ -1,5 +1,5 @@
import React, { PureComponent } from 'react'; import React, { PureComponent } from 'react';
import { Form, Input, Card, Row, Col, Button, InputNumber, TreeSelect, message } from "antd"; import { Form, Input, Card, Row, Col, Button, InputNumber, TreeSelect, message } from 'antd';
import { connect } from 'dva'; import { connect } from 'dva';
import Panel from '../../../components/Panel'; import Panel from '../../../components/Panel';
import styles from '../../../layouts/Sword.less'; import styles from '../../../layouts/Sword.less';

View File

@ -1,5 +1,5 @@
import React, { PureComponent } from 'react'; import React, { PureComponent } from 'react';
import { Form, Input, Card, Row, Col, Button, InputNumber, TreeSelect, message } from "antd"; import { Form, Input, Card, Row, Col, Button, InputNumber, TreeSelect, message } from 'antd';
import { connect } from 'dva'; import { connect } from 'dva';
import Panel from '../../../components/Panel'; import Panel from '../../../components/Panel';
import styles from '../../../layouts/Sword.less'; import styles from '../../../layouts/Sword.less';

View File

@ -1,4 +1,5 @@
import moment from 'moment'; import moment from 'moment';
import RequestForm from '@/utils/RequestForm';
/** /**
* 通用工具类 * 通用工具类
@ -46,14 +47,10 @@ export default class Func {
/** /**
* Json强转为Form类型 * Json强转为Form类型
* @param obj * @param obj
* @returns {FormData} * @returns {RequestForm}
*/ */
static toFormData(obj) { static toFormData(obj) {
const data = new FormData(); return new RequestForm(obj);
Object.keys(obj).forEach(key => {
data.append(key, Array.isArray(obj[key]) ? obj[key].join(',') : obj[key]);
});
return data;
} }
/** /**

17
src/utils/RequestForm.js Normal file
View File

@ -0,0 +1,17 @@
import { stringify } from 'qs';
export default class RequestForm {
constructor(params) {
const values = params;
Object.keys(params).forEach(key => {
if (Array.isArray(params[key])) {
values[key] = params[key].join(',');
}
});
this.params = values;
}
parse() {
return stringify(this.params);
}
}

View File

@ -5,6 +5,7 @@ import hash from 'hash.js';
import { Base64 } from 'js-base64'; import { Base64 } from 'js-base64';
import { clientId, clientSecret } from '../defaultSettings'; import { clientId, clientSecret } from '../defaultSettings';
import { getToken, removeAll } from './authority'; import { getToken, removeAll } from './authority';
import RequestForm from '@/utils/RequestForm';
const codeMessage = { const codeMessage = {
200: '服务器成功返回请求的数据。', 200: '服务器成功返回请求的数据。',
@ -135,13 +136,20 @@ export default function request(url, option) {
newOptions.method === 'PUT' || newOptions.method === 'PUT' ||
newOptions.method === 'DELETE' newOptions.method === 'DELETE'
) { ) {
if (!(newOptions.body instanceof FormData)) { if (!(newOptions.body instanceof FormData) && !(newOptions.body instanceof RequestForm)) {
newOptions.headers = { newOptions.headers = {
Accept: 'application/json', Accept: 'application/json',
'Content-Type': 'application/json;charset=utf-8', 'Content-Type': 'application/json;charset=utf-8',
...newOptions.headers, ...newOptions.headers,
}; };
newOptions.body = JSON.stringify(newOptions.body); newOptions.body = JSON.stringify(newOptions.body);
} else if (newOptions.body instanceof RequestForm) {
newOptions.headers = {
Accept: 'application/json',
'Content-Type': 'application/x-www-form-urlencoded',
...newOptions.headers,
};
newOptions.body = newOptions.body.parse();
} else { } else {
// newOptions.body is FormData // newOptions.body is FormData
newOptions.headers = { newOptions.headers = {