Skip to content

Commit

Permalink
feat: upgrade redux-alita v
Browse files Browse the repository at this point in the history
  • Loading branch information
yezihaohao committed Jul 26, 2020
1 parent f7ad537 commit d5c60d3
Show file tree
Hide file tree
Showing 14 changed files with 168 additions and 2,568 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
"react-qmap": "^0.1.6",
"react-router-dom": "^5.1.2",
"recharts": "^1.7.1",
"redux-alita": "^2.1.5",
"redux-alita": "^2.3.1",
"resolve": "1.12.0",
"resolve-url-loader": "3.1.0",
"sass-loader": "7.2.0",
Expand Down
9 changes: 5 additions & 4 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ import SiderCustom from './components/SiderCustom';
import HeaderCustom from './components/HeaderCustom';
import { ThemePicker, Copyright } from './components/widget';
import { checkLogin } from './utils';
import { fetchMenu } from './axios';
import './App.less';
import { fetchMenu } from './service';

const { Content, Footer } = Layout;

Expand Down Expand Up @@ -120,7 +119,7 @@ class App extends Component<AppProps> {

render() {
const { title } = this.state;
const { auth = { data: {} }, responsive = { data: {} } } = this.props;
const { auth, responsive } = this.props;
return (
<DocumentTitle title={title}>
<Layout>
Expand All @@ -147,4 +146,6 @@ class App extends Component<AppProps> {
}
}

export default connectAlita(['auth', 'responsive'])(App);
export default connectAlita([{ auth: { permissions: null } }, { responsive: { isMobile: false } }])(
App
);
6 changes: 3 additions & 3 deletions src/components/HeaderCustom.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import screenfull from 'screenfull';
import avater from '../style/imgs/b1.jpg';
import SiderCustom from './SiderCustom';
import { Menu, Icon, Layout, Badge, Popover } from 'antd';
import { gitOauthToken, gitOauthInfo } from '../axios';
import { gitOauthToken, gitOauthInfo } from '../service';
import { queryString } from '../utils';
import { withRouter, RouteComponentProps } from 'react-router-dom';
import { PwaInstaller } from './widget';
Expand Down Expand Up @@ -74,7 +74,7 @@ class HeaderCustom extends Component<HeaderCustomProps, HeaderCustomState> {
this.setState({ visible });
};
render() {
const { responsive = { data: {} } } = this.props;
const { responsive } = this.props;
return (
<Header className="custom-theme header">
{responsive.data.isMobile ? (
Expand Down Expand Up @@ -140,6 +140,6 @@ class HeaderCustom extends Component<HeaderCustomProps, HeaderCustomState> {
const HeaderCustomConnect: React.ComponentClass<
HeaderCustomProps,
HeaderCustomState
> = connectAlita(['responsive'])(HeaderCustom);
> = connectAlita([{ responsive: { isMobile: false } }])(HeaderCustom);

export default withRouter(HeaderCustomConnect);
8 changes: 4 additions & 4 deletions src/components/charts/EchartsGraphnpm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/
import React from 'react';
import ReactEcharts from 'echarts-for-react';
import { npmDependencies } from '../../axios';
import { npmDependencies } from '../../service';

class EchartsGraphnpm extends React.Component {
state = {
Expand Down Expand Up @@ -40,12 +40,12 @@ class EchartsGraphnpm extends React.Component {
},
};
componentDidMount() {
npmDependencies().then(npm => {
npmDependencies().then((npm) => {
this.setState({
option: {
series: [
{
data: npm.nodes.map(function(node: any) {
data: npm.nodes.map(function (node: any) {
return {
x: node.x,
y: node.y,
Expand All @@ -59,7 +59,7 @@ class EchartsGraphnpm extends React.Component {
},
};
}),
edges: npm.edges.map(function(edge: any) {
edges: npm.edges.map(function (edge: any) {
return {
source: edge.sourceID,
target: edge.targetID,
Expand Down
6 changes: 3 additions & 3 deletions src/components/charts/EchartsScatter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/
import React from 'react';
import ReactEcharts from 'echarts-for-react';
import { weibo } from '../../axios';
import { weibo } from '../../service';
require('echarts/map/js/china.js');

class EchartsScatter extends React.Component {
Expand Down Expand Up @@ -95,8 +95,8 @@ class EchartsScatter extends React.Component {
},
};
componentDidMount() {
weibo().then(weiboData => {
weiboData = weiboData.map(function(serieData: any) {
weibo().then((weiboData) => {
weiboData = weiboData.map(function (serieData: any) {
var px = serieData[0] / 1000;
var py = serieData[1] / 1000;
var res = [[px, py]];
Expand Down
2 changes: 1 addition & 1 deletion src/components/tables/AsynchronousTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/
import React from 'react';
import { Table, Button, Row, Col, Card } from 'antd';
import { getBbcNews } from '../../axios';
import { getBbcNews } from '../../service';
import BreadcrumbCustom from '../BreadcrumbCustom';
import { TableRowSelection } from 'antd/lib/table';

Expand Down
2 changes: 1 addition & 1 deletion src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { AlitaProvider, setConfig } from 'redux-alita';
import umbrella from 'umbrella-storage';
import Page from './Page';
import * as serviceWorker from './serviceWorker';
import * as apis from './axios';
import * as apis from './service';
// import { AppContainer } from 'react-hot-loader';
import './style/lib/animate.css';
import './style/index.less';
Expand Down
2 changes: 1 addition & 1 deletion src/axios/config.ts → src/service/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const MOCK_API = 'https://react-admin-mock.now.sh/api';
export const MOCK_AUTH_ADMIN = MOCK_API + '/admin.js'; // 管理员权限接口
export const MOCK_AUTH_VISITOR = MOCK_API + '/visitor.js'; // 访问权限接口
/** 服务端异步菜单接口 */
export const MOCK_MENU = MOCK_API + '/menu.js'
export const MOCK_MENU = MOCK_API + '/menu.js';

// github授权
export const GIT_OAUTH = 'https://github.com/login/oauth';
Expand Down
8 changes: 4 additions & 4 deletions src/axios/index.ts → src/service/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ export const getBbcNews = () => get({ url: config.NEWS_BBC });
export const npmDependencies = () =>
axios
.get('./npm.json')
.then(res => res.data)
.catch(err => console.log(err));
.then((res) => res.data)
.catch((err) => console.log(err));

export const weibo = () =>
axios
.get('./weibo.json')
.then(res => res.data)
.catch(err => console.log(err));
.then((res) => res.data)
.catch((err) => console.log(err));

export const gitOauthLogin = () =>
get({
Expand Down
8 changes: 4 additions & 4 deletions src/axios/tools.ts → src/service/tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ interface IFRequestParam {
export const get = ({ url, msg = '接口异常', config }: IFRequestParam) =>
axios
.get(url, config)
.then(res => res.data)
.catch(err => {
.then((res) => res.data)
.catch((err) => {
console.log(err);
message.warn(msg);
});
Expand All @@ -36,8 +36,8 @@ export const get = ({ url, msg = '接口异常', config }: IFRequestParam) =>
export const post = ({ url, data, msg = '接口异常', config }: IFRequestParam) =>
axios
.post(url, data, config)
.then(res => res.data)
.catch(err => {
.then((res) => res.data)
.catch((err) => {
console.log(err);
message.warn(msg);
});
135 changes: 0 additions & 135 deletions src/serviceWorker.js

This file was deleted.

10 changes: 5 additions & 5 deletions src/App.less → src/style/app.less
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/*
* File: App.less
* Desc: app 样式
* File Created: 2020-04-12 22:58:46
* Author: chenghao
* File: app.less
* Desc: 描述
* File Created: 2020-07-26 18:27:37
* Author: yezi
* ------
* Copyright 2020 - present, karakal
* Copyright 2020 - present, yezi
*/
@prefix: app;

Expand Down
Loading

0 comments on commit d5c60d3

Please sign in to comment.