Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
54sword committed Jul 1, 2018
2 parents d6bd050 + 920173c commit 4b37921
Show file tree
Hide file tree
Showing 34 changed files with 818 additions and 384 deletions.
4 changes: 2 additions & 2 deletions .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
"presets": ["react", "es2015", "stage-2"],
"env": {
"server": {
"plugins": ["syntax-dynamic-import", "dynamic-import-node"]
"plugins": ["transform-decorators-legacy","syntax-dynamic-import", "dynamic-import-node"]
},
"client": {
"plugins": ["dynamic-import-webpack"]
"plugins": ["transform-decorators-legacy","dynamic-import-webpack"]
}
}
}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ dist
*.DS_Store
package-lock.json
config/index.js
config/index_*.js
2 changes: 0 additions & 2 deletions client/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ if (__DEV__) {

const me = getProfile(store.getState())

// console.log(me);

const _Router = Router({ userinfo: me })

ReactDOM.hydrate((
Expand Down
116 changes: 0 additions & 116 deletions config/errors.js

This file was deleted.

11 changes: 8 additions & 3 deletions config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
let config = {
debug: false,
host: 'localhost',
port: 4000,
port: 9001,

auth_cookie_name: 'admin.xiaoduyu.com',

Expand All @@ -14,15 +14,20 @@ let config = {
public_path: '//admin.xiaoduyu.com',

// api
api_url: 'http://admin.xiaoduyu.com'
api_url: 'http://admin.xiaoduyu.com',

graphql_url: 'http://admin.xiaoduyu.com/graphql'
}

// 开发环境配置
if (process.env.NODE_ENV == 'development') {
config.debug = true
config.port = 5000
config.class_scoped_name = '[name]_[local]__[hash:base64:5]'
config.public_path = '//localhost:4000'
config.public_path = '//localhost:5000'
config.api_url = 'http://localhost:3000'
// config.api_url = 'http://admin.xiaoduyu.com'
config.graphql_url = 'http://localhost:3000/graphql'
}

module.exports = config
18 changes: 14 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"babel-loader": "^7.1.2",
"babel-plugin-dynamic-import-node": "^1.2.0",
"babel-plugin-syntax-dynamic-import": "^6.18.0",
"babel-plugin-transform-decorators-legacy": "^1.3.4",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"babel-preset-stage-0": "^6.24.1",
Expand Down
8 changes: 4 additions & 4 deletions server/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require('babel-register')
require('babel-polyfill')
require('css-modules-require-hook/preset')
require('./server')
require('babel-register');
require('babel-polyfill');
require('css-modules-require-hook/preset');
require('./server');
14 changes: 11 additions & 3 deletions server/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { Provider } from 'react-redux'

import configureStore from '../src/store'

import { loadUserInfo } from '../src/actions/user'
import { loadUserInfo, removeUserInfo } from '../src/actions/user'
import { addAccessToken } from '../src/actions/sign'

// 路由组件
Expand Down Expand Up @@ -121,9 +121,17 @@ app.get('*', async (req, res)=>{
// 验证 token 是否有效
if (accessToken) {

[ err, userinfo ] = await loadUserInfo({ accessToken })(store.dispatch, store.getState)
[ err, userinfo ] = await loadUserInfo({ accessToken })(store.dispatch, store.getState);

if (userinfo && userinfo.role != 100) {
userinfo = null;
store.dispatch(removeUserInfo());
}

if (userinfo) {
store.dispatch(addAccessToken({ access_token: accessToken }))
}

if (userinfo) store.dispatch(addAccessToken({ access_token: accessToken }))
}

let _route = null,
Expand Down
25 changes: 17 additions & 8 deletions src/actions/analysis.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,22 @@ export function loadSummary({ name, filters = {} }) {

let sql = `
{
analysis${variables}{
user_count
posts_count
comment_count
notification_count
userNotification_count
countPosts${variables}{
count
}
countUsers${variables}{
count
}
countComments${variables}{
count
}
countUserNotifications${variables}{
count
}
countNotifications${variables}{
count
}
}
`

Expand All @@ -51,12 +60,12 @@ export function loadSummary({ name, filters = {} }) {
headers: accessToken ? { 'AccessToken': accessToken } : null
})

if (err) return alert('提交失败')
if (err) return

dispatch({
type: 'SET_ANALYSIS_LIST_BY_NAME',
name,
data: res.data.analysis
data: res.data
})

/*
Expand Down
46 changes: 43 additions & 3 deletions src/actions/captcha.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,40 @@

import graphql from './common/graphql'

/**
* [添加] 验证码
* @param {String} id
* @param {Object} [args={}] 参数
* @param {String} [fields=``] 返回字段
* @return {Object} promise
*/
export const addCaptcha = ({ id = new Date().getTime(), args, fields = `success` }) => {
return (dispatch, getState) => {
return new Promise(async (resolve)=> {

let accessToken = accessToken || getState().user.accessToken;

let [ err, res ] = await graphql({
type: 'mutation',
api: 'addCaptcha',
args,
fields,
headers: accessToken ? { 'AccessToken': accessToken } : null
});

if (res && res._id && res.url) {
dispatch({ type: 'ADD_CAPRCHA_ID', id, data: res });
}

resolve([ err, res ])

})

}
}


/*
import grapgQLClient from '../common/grapgql-client'
import Ajax from '../common/ajax'
Expand All @@ -23,8 +60,8 @@ export const getCaptchaId = () => {
// let accessToken = getState().user.accessToken
let sql = `
{
captcha{
mutation {
addCaptcha(type:"sign-in"){
_id
url
}
Expand All @@ -39,6 +76,9 @@ export const getCaptchaId = () => {
fetchPolicy: 'network-only'
})
console.log(err);
console.log(res);
if (err) {
reject([err])
} else {
Expand All @@ -49,7 +89,7 @@ export const getCaptchaId = () => {
}
}

*/
/*
export function addCaptchaByIP(callback) {
return (dispatch, getState) => {
Expand Down
Loading

0 comments on commit 4b37921

Please sign in to comment.