mirror of
https://github.com/zuiidea/antd-admin
synced 2026-10-28 20:03:57 +00:00
eslint apply all
This commit is contained in:
+50
-50
@@ -1,103 +1,103 @@
|
||||
import {login, userInfo, logout} from '../services/app'
|
||||
import {parse} from 'qs'
|
||||
import { login, userInfo, logout } from '../services/app'
|
||||
import { parse } from 'qs'
|
||||
|
||||
export default {
|
||||
namespace: 'app',
|
||||
state: {
|
||||
login: false,
|
||||
user: {
|
||||
name: '吴彦祖'
|
||||
name: '吴彦祖',
|
||||
},
|
||||
loginButtonLoading: false,
|
||||
menuPopoverVisible: false,
|
||||
siderFold: localStorage.getItem('antdAdminSiderFold') === 'true',
|
||||
darkTheme: localStorage.getItem('antdAdminDarkTheme') !== 'false',
|
||||
isNavbar: document.body.clientWidth < 769,
|
||||
navOpenKeys: JSON.parse(localStorage.getItem('navOpenKeys') || '[]')
|
||||
navOpenKeys: JSON.parse(localStorage.getItem('navOpenKeys') || '[]'),
|
||||
},
|
||||
subscriptions: {
|
||||
setup ({dispatch}) {
|
||||
dispatch({type: 'queryUser'})
|
||||
window.onresize = function () {
|
||||
dispatch({type: 'changeNavbar'})
|
||||
setup ({ dispatch }) {
|
||||
dispatch({ type: 'queryUser' })
|
||||
window.onresize = () => {
|
||||
dispatch({ type: 'changeNavbar' })
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
effects: {
|
||||
*login ({
|
||||
payload
|
||||
}, {call, put}) {
|
||||
yield put({type: 'showLoginButtonLoading'})
|
||||
payload,
|
||||
}, { call, put }) {
|
||||
yield put({ type: 'showLoginButtonLoading' })
|
||||
const data = yield call(login, parse(payload))
|
||||
if (data.success) {
|
||||
yield put({
|
||||
type: 'loginSuccess',
|
||||
payload: {
|
||||
user: {
|
||||
name: payload.username
|
||||
}
|
||||
}})
|
||||
name: payload.username,
|
||||
},
|
||||
} })
|
||||
} else {
|
||||
yield put({
|
||||
type: 'loginFail'
|
||||
type: 'loginFail',
|
||||
})
|
||||
}
|
||||
},
|
||||
*queryUser ({
|
||||
payload
|
||||
}, {call, put}) {
|
||||
payload,
|
||||
}, { call, put }) {
|
||||
const data = yield call(userInfo, parse(payload))
|
||||
if (data.success) {
|
||||
yield put({
|
||||
type: 'loginSuccess',
|
||||
payload: {
|
||||
user: {
|
||||
name: data.username
|
||||
}
|
||||
}
|
||||
name: data.username,
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
},
|
||||
*logout ({
|
||||
payload
|
||||
}, {call, put}) {
|
||||
payload,
|
||||
}, { call, put }) {
|
||||
const data = yield call(logout, parse(payload))
|
||||
if (data.success) {
|
||||
yield put({
|
||||
type: 'logoutSuccess'
|
||||
type: 'logoutSuccess',
|
||||
})
|
||||
}
|
||||
},
|
||||
*switchSider ({
|
||||
payload
|
||||
}, {put}) {
|
||||
payload,
|
||||
}, { put }) {
|
||||
yield put({
|
||||
type: 'handleSwitchSider'
|
||||
type: 'handleSwitchSider',
|
||||
})
|
||||
},
|
||||
*changeTheme ({
|
||||
payload
|
||||
}, {put}) {
|
||||
payload,
|
||||
}, { put }) {
|
||||
yield put({
|
||||
type: 'handleChangeTheme'
|
||||
type: 'handleChangeTheme',
|
||||
})
|
||||
},
|
||||
*changeNavbar ({
|
||||
payload
|
||||
}, {put}) {
|
||||
payload,
|
||||
}, { put }) {
|
||||
if (document.body.clientWidth < 769) {
|
||||
yield put({type: 'showNavbar'})
|
||||
yield put({ type: 'showNavbar' })
|
||||
} else {
|
||||
yield put({type: 'hideNavbar'})
|
||||
yield put({ type: 'hideNavbar' })
|
||||
}
|
||||
},
|
||||
*switchMenuPopver ({
|
||||
payload
|
||||
}, {put}) {
|
||||
payload,
|
||||
}, { put }) {
|
||||
yield put({
|
||||
type: 'handleSwitchMenuPopver'
|
||||
type: 'handleSwitchMenuPopver',
|
||||
})
|
||||
}
|
||||
},
|
||||
},
|
||||
reducers: {
|
||||
loginSuccess (state, action) {
|
||||
@@ -105,65 +105,65 @@ export default {
|
||||
...state,
|
||||
...action.payload,
|
||||
login: true,
|
||||
loginButtonLoading: false
|
||||
loginButtonLoading: false,
|
||||
}
|
||||
},
|
||||
logoutSuccess (state) {
|
||||
return {
|
||||
...state,
|
||||
login: false
|
||||
login: false,
|
||||
}
|
||||
},
|
||||
loginFail (state) {
|
||||
return {
|
||||
...state,
|
||||
login: false,
|
||||
loginButtonLoading: false
|
||||
loginButtonLoading: false,
|
||||
}
|
||||
},
|
||||
showLoginButtonLoading (state) {
|
||||
return {
|
||||
...state,
|
||||
loginButtonLoading: true
|
||||
loginButtonLoading: true,
|
||||
}
|
||||
},
|
||||
handleSwitchSider (state) {
|
||||
localStorage.setItem('antdAdminSiderFold', !state.siderFold)
|
||||
return {
|
||||
...state,
|
||||
siderFold: !state.siderFold
|
||||
siderFold: !state.siderFold,
|
||||
}
|
||||
},
|
||||
handleChangeTheme (state) {
|
||||
localStorage.setItem('antdAdminDarkTheme', !state.darkTheme)
|
||||
return {
|
||||
...state,
|
||||
darkTheme: !state.darkTheme
|
||||
darkTheme: !state.darkTheme,
|
||||
}
|
||||
},
|
||||
showNavbar (state) {
|
||||
return {
|
||||
...state,
|
||||
isNavbar: true
|
||||
isNavbar: true,
|
||||
}
|
||||
},
|
||||
hideNavbar (state) {
|
||||
return {
|
||||
...state,
|
||||
isNavbar: false
|
||||
isNavbar: false,
|
||||
}
|
||||
},
|
||||
handleSwitchMenuPopver (state) {
|
||||
return {
|
||||
...state,
|
||||
menuPopoverVisible: !state.menuPopoverVisible
|
||||
menuPopoverVisible: !state.menuPopoverVisible,
|
||||
}
|
||||
},
|
||||
handleNavOpenKeys (state, action) {
|
||||
return {
|
||||
...state,
|
||||
...action.payload
|
||||
...action.payload,
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
+45
-45
@@ -1,51 +1,51 @@
|
||||
import {myCity, queryWeather, query} from '../services/dashboard'
|
||||
import {parse} from 'qs'
|
||||
import { myCity, queryWeather, query } from '../services/dashboard'
|
||||
import { parse } from 'qs'
|
||||
|
||||
// zuimei 摘自 http://www.zuimeitianqi.com/res/js/index.js
|
||||
let zuimei = {
|
||||
ParseActualData: function (actual, air) {
|
||||
parseActualData (actual) {
|
||||
let weather = {
|
||||
icon: 'http://www.zuimeitianqi.com/res/icon/' + zuimei.GetIconName(actual.wea, 'big'),
|
||||
name: zuimei.GetWeatherName(actual.wea),
|
||||
icon: `http://www.zuimeitianqi.com/res/icon/${zuimei.getIconName(actual.wea, 'big')}`,
|
||||
name: zuimei.getWeatherName(actual.wea),
|
||||
temperature: actual.tmp,
|
||||
dateTime: new Date(actual.PTm).format('MM-dd hh:mm')
|
||||
dateTime: new Date(actual.PTm).format('MM-dd hh:mm'),
|
||||
}
|
||||
return weather
|
||||
},
|
||||
|
||||
GetIconName: function (wea, flg) {
|
||||
getIconName (wea, flg) {
|
||||
let myDate = new Date()
|
||||
let hour = myDate.getHours()
|
||||
let num = 0
|
||||
if (wea.indexOf('/') !== -1) {
|
||||
let weas = wea.split('/')
|
||||
if (hour < 12) {
|
||||
num = zuimei.ReplaceIcon(weas[0])
|
||||
num = zuimei.replaceIcon(weas[0])
|
||||
if (num < 6) {
|
||||
num = num + '_' + flg + '_night.png'
|
||||
num = `${num}_${flg}_night.png`
|
||||
} else {
|
||||
num = num + '_' + flg + '.png'
|
||||
num = `${num}_${flg}.png`
|
||||
}
|
||||
} else if (hour >= 12) {
|
||||
num = zuimei.ReplaceIcon(weas[1])
|
||||
num = zuimei.replaceIcon(weas[1])
|
||||
if (hour >= 18) {
|
||||
num = num + '_' + flg + '_night.png'
|
||||
num = `${num}_${flg}_night.png`
|
||||
} else {
|
||||
num = num + '_' + flg + '.png'
|
||||
num = `${num}_${flg}.png`
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ((hour >= 18 && hour <= 23) || (hour >= 0 && hour <= 6)) {
|
||||
num = num + '_' + flg + '_night.png'
|
||||
num = `${num}_${flg}_night.png`
|
||||
} else {
|
||||
num = num + '_' + flg + '.png'
|
||||
num = `${num}_${flg}.png`
|
||||
}
|
||||
}
|
||||
|
||||
return num
|
||||
},
|
||||
|
||||
ReplaceIcon: function (num) {
|
||||
replaceIcon (num) {
|
||||
if (num === 21) {
|
||||
num = 7
|
||||
} else if (num === 22) {
|
||||
@@ -67,19 +67,19 @@ let zuimei = {
|
||||
return num
|
||||
},
|
||||
|
||||
GetWeatherName: function (wea) {
|
||||
getWeatherName (wea) {
|
||||
let name = ''
|
||||
if (wea.indexOf('/') !== -1) {
|
||||
let weas = wea.split('/')
|
||||
name = zuimei.GetWeatherByCode(weas[0]) + '转' + zuimei.GetWeatherByCode(weas[1])
|
||||
name = `${zuimei.getWeatherByCode(weas[0])}转${zuimei.getWeatherByCode(weas[1])}`
|
||||
} else {
|
||||
name = zuimei.GetWeatherByCode(wea)
|
||||
name = zuimei.getWeatherByCode(wea)
|
||||
}
|
||||
|
||||
return name
|
||||
},
|
||||
|
||||
GetWeatherByCode: function (num) {
|
||||
getWeatherByCode (num) {
|
||||
let wea = ''
|
||||
if (num === 0) {
|
||||
wea = '晴'
|
||||
@@ -160,7 +160,7 @@ let zuimei = {
|
||||
}
|
||||
|
||||
return wea
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
export default {
|
||||
@@ -171,11 +171,11 @@ export default {
|
||||
temperature: '5',
|
||||
name: '晴',
|
||||
icon: 'http://www.zuimeitianqi.com/res/icon/0_big.png',
|
||||
dateTime: new Date().format('MM-dd hh:mm')
|
||||
dateTime: new Date().format('MM-dd hh:mm'),
|
||||
},
|
||||
sales: [],
|
||||
quote: {
|
||||
avatar: 'http://img.hb.aicdn.com/bc442cf0cc6f7940dcc567e465048d1a8d634493198c4-sPx5BR_fw236'
|
||||
avatar: 'http://img.hb.aicdn.com/bc442cf0cc6f7940dcc567e465048d1a8d634493198c4-sPx5BR_fw236',
|
||||
},
|
||||
numbers: [],
|
||||
recentSales: [],
|
||||
@@ -184,49 +184,49 @@ export default {
|
||||
browser: [],
|
||||
cpu: {},
|
||||
user: {
|
||||
avatar: 'http://img.hb.aicdn.com/bc442cf0cc6f7940dcc567e465048d1a8d634493198c4-sPx5BR_fw236'
|
||||
}
|
||||
avatar: 'http://img.hb.aicdn.com/bc442cf0cc6f7940dcc567e465048d1a8d634493198c4-sPx5BR_fw236',
|
||||
},
|
||||
},
|
||||
subscriptions: {
|
||||
setup ({dispatch}) {
|
||||
dispatch({type: 'queryWeather'})
|
||||
dispatch({type: 'query'})
|
||||
}
|
||||
setup ({ dispatch }) {
|
||||
dispatch({ type: 'queryWeather' })
|
||||
dispatch({ type: 'query' })
|
||||
},
|
||||
},
|
||||
effects: {
|
||||
*query ({
|
||||
payload
|
||||
}, {call, put}) {
|
||||
payload,
|
||||
}, { call, put }) {
|
||||
const data = yield call(query, parse(payload))
|
||||
yield put({type: 'queryWeather', payload: {...data}})
|
||||
yield put({ type: 'queryWeather', payload: { ...data } })
|
||||
},
|
||||
*queryWeather ({
|
||||
payload
|
||||
}, {call, put}) {
|
||||
const myCityResult = yield call(myCity, {flg: 0})
|
||||
payload,
|
||||
}, { call, put }) {
|
||||
const myCityResult = yield call(myCity, { flg: 0 })
|
||||
const myCityData = myCityResult.query.results.json
|
||||
const result = yield call(queryWeather, {cityCode: myCityData.selectCityCode})
|
||||
const result = yield call(queryWeather, { cityCode: myCityData.selectCityCode })
|
||||
const data = result.query.results.json
|
||||
const weather = zuimei.ParseActualData(data.data.actual)
|
||||
const weather = zuimei.parseActualData(data.data.actual)
|
||||
weather.city = myCityData.selectCityName
|
||||
|
||||
yield put({type: 'queryWeatherSuccess', payload: {
|
||||
weather
|
||||
}})
|
||||
}
|
||||
yield put({ type: 'queryWeatherSuccess', payload: {
|
||||
weather,
|
||||
} })
|
||||
},
|
||||
},
|
||||
reducers: {
|
||||
queryWeatherSuccess (state, action) {
|
||||
return {
|
||||
...state,
|
||||
...action.payload
|
||||
...action.payload,
|
||||
}
|
||||
},
|
||||
queryWeather (state, action) {
|
||||
return {
|
||||
...state,
|
||||
...action.payload
|
||||
...action.payload,
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
+24
-24
@@ -16,8 +16,8 @@ export default {
|
||||
showQuickJumper: true,
|
||||
showTotal: total => `共 ${total} 条`,
|
||||
current: 1,
|
||||
total: null
|
||||
}
|
||||
total: null,
|
||||
},
|
||||
},
|
||||
|
||||
subscriptions: {
|
||||
@@ -26,11 +26,11 @@ export default {
|
||||
if (location.pathname === '/users') {
|
||||
dispatch({
|
||||
type: 'query',
|
||||
payload: location.query
|
||||
payload: location.query,
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
effects: {
|
||||
@@ -41,8 +41,8 @@ export default {
|
||||
type: 'querySuccess',
|
||||
payload: {
|
||||
list: data.data,
|
||||
pagination: data.page
|
||||
}
|
||||
pagination: data.page,
|
||||
},
|
||||
})
|
||||
}
|
||||
},
|
||||
@@ -55,9 +55,9 @@ export default {
|
||||
list: data.data,
|
||||
pagination: {
|
||||
total: data.page.total,
|
||||
current: data.page.current
|
||||
}
|
||||
}
|
||||
current: data.page.current,
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
},
|
||||
@@ -71,9 +71,9 @@ export default {
|
||||
list: data.data,
|
||||
pagination: {
|
||||
total: data.page.total,
|
||||
current: data.page.current
|
||||
}
|
||||
}
|
||||
current: data.page.current,
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
},
|
||||
@@ -89,30 +89,30 @@ export default {
|
||||
list: data.data,
|
||||
pagination: {
|
||||
total: data.page.total,
|
||||
current: data.page.current
|
||||
}
|
||||
}
|
||||
current: data.page.current,
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
},
|
||||
*switchIsMotion ({
|
||||
payload
|
||||
}, {put}) {
|
||||
payload,
|
||||
}, { put }) {
|
||||
yield put({
|
||||
type: 'handleSwitchIsMotion'
|
||||
type: 'handleSwitchIsMotion',
|
||||
})
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
reducers: {
|
||||
querySuccess (state, action) {
|
||||
const {list, pagination} = action.payload
|
||||
const { list, pagination } = action.payload
|
||||
return { ...state,
|
||||
list,
|
||||
pagination: {
|
||||
...state.pagination,
|
||||
...pagination
|
||||
}}
|
||||
...pagination,
|
||||
} }
|
||||
},
|
||||
showModal (state, action) {
|
||||
return { ...state, ...action.payload, modalVisible: true }
|
||||
@@ -123,7 +123,7 @@ export default {
|
||||
handleSwitchIsMotion (state) {
|
||||
localStorage.setItem('antdAdminUserIsMotion', !state.isMotion)
|
||||
return { ...state, isMotion: !state.isMotion }
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user