Skip to content
This repository has been archived by the owner on Jan 31, 2019. It is now read-only.

Commit

Permalink
优化代码 | jslint format
Browse files Browse the repository at this point in the history
  • Loading branch information
3lang3 committed Jul 17, 2017
1 parent 6e8b927 commit 513c0d8
Show file tree
Hide file tree
Showing 127 changed files with 7,607 additions and 2,810 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules
build
config
2 changes: 1 addition & 1 deletion config/domain.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export default 'http://localhost';
export default 'http://localhost';
8 changes: 4 additions & 4 deletions config/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import domain from './domain.js';

export default {
HOST: `${domain}`,
ENDHOST: `${domain}:3000`,
ChatHOST: `${domain}:3001`,
}
HOST: `${domain}`,
ENDHOST: `${domain}:3000`,
ChatHOST: `${domain}:3001`,
};
5,210 changes: 5,210 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"author": "",
"license": "ISC",
"dependencies": {
"classnames": "^2.2.5",
"eslint-config-airbnb": "^14.1.0",
"isomorphic-fetch": "^2.2.1",
"lodash": "^4.16.4",
Expand Down
12 changes: 6 additions & 6 deletions src/actions/alertActions.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
const OPEN = 'ALERT/OPEN';

export const alertActions = {
OPEN: OPEN
}
OPEN,
};

const alertOpen = (payload) => ({
const alertOpen = payload => ({
type: OPEN,
payload
payload,
});

export {
alertOpen
}
alertOpen,
};
2 changes: 1 addition & 1 deletion src/actions/categoryActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import fetch from 'isomorphic-fetch';
import config from '../../config';

const API_HOST = `${config.ENDHOST}`
const API_HOST = `${config.ENDHOST}`;
const url = '/api/categorys';

const REQUEST = 'category/REQUEST';
Expand Down
10 changes: 5 additions & 5 deletions src/actions/categorysActions.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* global API_HOST */
import fetch from 'isomorphic-fetch';
import {layoutsOpen} from 'actions';
import config from '../../config';
const API_HOST = `${config.ENDHOST}`

const API_HOST = `${config.ENDHOST}`;
const url = '/api/categorys/';

const REQUEST = 'categorys/REQUEST';
Expand Down Expand Up @@ -34,9 +34,9 @@ const getCategorysError = payload => ({
const filterCategorys = payload => ({
type: FILTER,
payload,
})
});

const getCategorys = (name) => (dispatch) => {
const getCategorys = name => (dispatch) => {
dispatch(getCategorysRequest());
dispatch(filterCategorys(''));
return fetch(`${API_HOST}${url}${name}`)
Expand All @@ -47,5 +47,5 @@ const getCategorys = (name) => (dispatch) => {

export {
getCategorys,
filterCategorys
filterCategorys,
};
2 changes: 1 addition & 1 deletion src/actions/cheeseActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import fetch from 'isomorphic-fetch';
import config from '../../config';

const API_HOST = `${config.ENDHOST}`
const API_HOST = `${config.ENDHOST}`;
const url = '/api/cheese';

const REQUEST = 'cheese/REQUEST';
Expand Down
4 changes: 2 additions & 2 deletions src/actions/emojiActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ export const emojiActions = {
TOGGLE,
};

const emojiToggle = payload => ({
type: TOGGLE
const emojiToggle = () => ({
type: TOGGLE,
});

export {
Expand Down
6 changes: 1 addition & 5 deletions src/actions/favoriteActions.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
/* global API_HOST */

const GET = 'favorite/GET';
const SET = 'favorite/SET';
const ADD = 'favorite/ADD';
const REMOVE = 'favorite/REMOVE';

Expand All @@ -23,5 +19,5 @@ const removeFavorite = payload => ({

export {
addFavorite,
removeFavorite
removeFavorite,
};
2 changes: 1 addition & 1 deletion src/actions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ export * from './cheeseActions';
export * from './favoriteActions';
export * from './onlineActions';
export * from './recommendActions';
export * from './randomActions';
export * from './randomActions';
6 changes: 3 additions & 3 deletions src/actions/inviteActions.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* global API_HOST */
import fetch from 'isomorphic-fetch';

import config from '../../config';
const API_HOST = `${config.ENDHOST}`

const API_HOST = `${config.ENDHOST}`;
const url = '/api/invite/';

const REQUEST = 'invite/REQUEST';
Expand All @@ -29,7 +29,7 @@ const getInviteError = payload => ({
payload,
});

const getInvite = (code) => (dispatch) => {
const getInvite = code => (dispatch) => {
dispatch(getInviteRequest());
return fetch(`${API_HOST}${url}${code}`)
.then(res => res.json())
Expand Down
1 change: 0 additions & 1 deletion src/actions/layoutsActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ const layoutsChat = payload => ({
});



export {
layoutsOpen,
layoutsWidth,
Expand Down
7 changes: 3 additions & 4 deletions src/actions/metadataActions.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
/* global API_HOST */
import fetch from 'isomorphic-fetch';
import {layoutsOpen} from 'actions';

import config from '../../config';
const API_HOST = `${config.ENDHOST}`

const API_HOST = `${config.ENDHOST}`;
const url = '/api/metadata';

const REQUEST = 'metadata/REQUEST';
Expand Down Expand Up @@ -31,7 +30,7 @@ const getMetadataError = payload => ({
});

export const getMetadata = (host = API_HOST) => (dispatch) => {
dispatch(getMetadataRequest())
dispatch(getMetadataRequest());
return fetch(`${host}${url}`, { credentials: 'include' })
.then(response => response.json())
.then(json => dispatch(getMetadataOk(json)))
Expand Down
14 changes: 7 additions & 7 deletions src/actions/onlineActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import fetch from 'isomorphic-fetch';
import config from '../../config';

const API_HOST = `${config.ENDHOST}`
const API_HOST = `${config.ENDHOST}`;
const url = '/api/online';

const REQUEST = 'online/REQUEST';
Expand Down Expand Up @@ -30,16 +30,16 @@ const getOnlineError = payload => ({
});


const getOnline = (data) => (dispatch) => {
const getOnline = data => (dispatch) => {
dispatch(getOnlineRequest());

let form = new FormData();
form.append( "json", JSON.stringify(data) );
const form = new FormData();
form.append('json', JSON.stringify(data));

return fetch(`${API_HOST}${url}`, {
method: 'POST',
body: form,
})
method: 'POST',
body: form,
})
.then(res => res.json())
.then(json => dispatch(getOnlineOk(json)))
.catch(err => dispatch(getOnlineError(err)));
Expand Down
8 changes: 4 additions & 4 deletions src/actions/randomActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import fetch from 'isomorphic-fetch';
import config from '../../config';

const API_HOST = `${config.ENDHOST}`
const API_HOST = `${config.ENDHOST}`;
const url = '/api/random';

const REQUEST = 'random/REQUEST';
Expand Down Expand Up @@ -33,11 +33,11 @@ const getRandomError = payload => ({

const getRandom = () => (dispatch) => {
dispatch(getRandomRequest());

return fetch(`${API_HOST}${url}`)
.then(res => res.json())
.then(json => {
dispatch(getRandomOk(json))
.then((json) => {
dispatch(getRandomOk(json));
})
.catch(err => dispatch(getRandomError(err)));
};
Expand Down
8 changes: 4 additions & 4 deletions src/actions/recommendActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import fetch from 'isomorphic-fetch';
import config from '../../config';

const API_HOST = `${config.ENDHOST}`
const API_HOST = `${config.ENDHOST}`;
const url = '/api/recommend';

const REQUEST = 'recommend/REQUEST';
Expand Down Expand Up @@ -32,11 +32,11 @@ const getRecommendError = payload => ({

const getRecommend = () => (dispatch) => {
dispatch(getRecommendRequest());

return fetch(`${API_HOST}${url}`)
.then(res => res.json())
.then(json => {
dispatch(getRecommendOk(json))
.then((json) => {
dispatch(getRecommendOk(json));
})
.catch(err => dispatch(getRecommendError(err)));
};
Expand Down
48 changes: 24 additions & 24 deletions src/actions/screenItemsActions.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Link, browserHistory } from 'react-router';
import store from '../store';

import fetch from 'isomorphic-fetch';
import { browserHistory } from 'react-router';
import store from '../store';
import config from '../../config';

const API_HOST = `${config.ENDHOST}`

const API_HOST = `${config.ENDHOST}`;
const url = '/api/screen/';

const ADD = 'screenItems/ADD';
Expand All @@ -24,38 +24,38 @@ export const screenItemsActions = {
};

const preUrlHandler = (items) => {
let _preUrl = '?rooms=';
let preUrl = '?rooms=';

if(!items.length) return '';
if (!items.length) return '';

items.forEach((el, index) => {
let _id = el.roomId;
items.forEach((el) => {
let id = el.roomId;

if(typeof _id == 'object') _id = JSON.stringify(_id);
_preUrl += `${el.platform}_${_id}--`;
})
if (typeof id === 'object') id = JSON.stringify(id);
preUrl += `${el.platform}_${id}--`;
});

return _preUrl;
}
return preUrl;
};

const getPreUrl = () => {
let items = store.getState().screenItems.data;
const items = store.getState().screenItems.data;
return preUrlHandler(items);
}
};

const replaceLocationHandler = () => {
let preUrl = getPreUrl();
const preUrl = getPreUrl();

browserHistory.push(`/live${preUrl}`);
}
};

const screenItemsUrl = () => {
let payload = getPreUrl();
const payload = getPreUrl();

return {
type: URL,
payload,
}
};
};

const screenItemsAddHander = payload => ({
Expand All @@ -82,24 +82,24 @@ const getScreenItemsError = payload => ({
payload,
});

const getScreenItems = (par) => (dispatch) => {
const getScreenItems = par => (dispatch) => {
dispatch(getScreenItemsRequest());
return fetch(`${API_HOST}${url}${par}`)
.then(res => res.json())
.then(json => {
dispatch(getScreenItemsOk(json))
.then((json) => {
dispatch(getScreenItemsOk(json));
dispatch(screenItemsUrl());
})
.catch(err => dispatch(getScreenItemsError(err)));
};

const screenItemsAdd = (payload) => (dispatch) => {
const screenItemsAdd = payload => (dispatch) => {
dispatch(screenItemsAddHander(payload));
dispatch(screenItemsUrl());
replaceLocationHandler();
};

const screenItemsRemove = (payload) => (dispatch) => {
const screenItemsRemove = payload => (dispatch) => {
dispatch(screenItemsRemoveHander(payload));
dispatch(screenItemsUrl());
replaceLocationHandler();
Expand Down
4 changes: 2 additions & 2 deletions src/actions/screensActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
const OK = 'screens/OK';

export const screensActions = {
OK
}
OK,
};

const screensActive = payload => ({
type: OK,
Expand Down
5 changes: 3 additions & 2 deletions src/actions/searchActions.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
/* global API_HOST */
import fetch from 'isomorphic-fetch';
import config from '../../config';
const API_HOST = `${config.ENDHOST}`

const API_HOST = `${config.ENDHOST}`;
const url = '/api/search/';

const REQUEST = 'search/REQUEST';
Expand Down Expand Up @@ -29,7 +30,7 @@ const getSearchError = payload => ({
});


const getSearch = (keyword) => (dispatch) => {
const getSearch = keyword => (dispatch) => {
dispatch(getSearchRequest());
return fetch(`${API_HOST}${url}${keyword}`)
.then(res => res.json())
Expand Down
Loading

0 comments on commit 513c0d8

Please sign in to comment.