1 Star 0 Fork 5

mickalpeng / amis-editor-demo

forked from openwjh / amis-editor-demo 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
App.tsx 2.23 KB
一键复制 编辑 原始数据 按行查看 历史
liaoxuezhi 提交于 2019-09-30 21:52 . first blood
import React from 'react';
import {Provider} from 'mobx-react';
import {toast, alert, confirm} from 'amis';
import axios from 'axios';
import {MainStore} from './store/index';
import RootRoute from './route/index';
import copy from 'copy-to-clipboard';
export default function(): JSX.Element {
const store = ((window as any).store = MainStore.create(
{},
{
fetcher: ({url, method, data, config}: any) => {
config = config || {};
config.headers = config.headers || {};
config.withCredentials = true;
if (method !== 'post' && method !== 'put' && method !== 'patch') {
if (data) {
config.params = data;
}
return (axios as any)[method](url, config);
} else if (data && data instanceof FormData) {
// config.headers = config.headers || {};
// config.headers['Content-Type'] = 'multipart/form-data';
} else if (
data &&
typeof data !== 'string' &&
!(data instanceof Blob) &&
!(data instanceof ArrayBuffer)
) {
data = JSON.stringify(data);
config.headers['Content-Type'] = 'application/json';
}
return (axios as any)[method](url, data, config);
},
isCancel: (e: any) => axios.isCancel(e),
notify: (type: 'success' | 'error' | 'info', msg: string) => {
toast[type]
? toast[type](msg, type === 'error' ? '系统错误' : '系统消息')
: console.warn('[Notify]', type, msg);
console.log('[notify]', type, msg);
},
alert,
confirm,
copy: (contents: string, options: any = {}) => {
const ret = copy(contents, options);
ret && (!options || options.shutup !== true) && toast.info('内容已拷贝到剪切板');
return ret;
}
}
));
return (
<Provider store={store}>
<RootRoute store={store} />
</Provider>
);
}
1
https://gitee.com/mickalpeng/amis-editor-demo.git
git@gitee.com:mickalpeng/amis-editor-demo.git
mickalpeng
amis-editor-demo
amis-editor-demo
master

搜索帮助