eslint apply all

This commit is contained in:
zuiidea
2017-03-14 20:03:21 +08:00
parent 23540e4394
commit 47e7d580bb
52 changed files with 692 additions and 601 deletions
+1 -1
View File
@@ -4,5 +4,5 @@ module.exports = {
footerText: 'Ant Design Admin 版权所有 © 2016 由 zuiidea 支持',
logoSrc: 'https://t.alipayobjects.com/images/rmsweb/T1B9hfXcdvXXXXXXXX.svg',
logoText: 'Antd Admin',
needLogin: true
needLogin: true,
}
+12 -12
View File
@@ -2,13 +2,13 @@ import config from './config'
import menu from './menu'
import request from './request'
import classnames from 'classnames'
import {color} from './theme'
import { color } from './theme'
require('./mock.js')
// 连字符转驼峰
String.prototype.hyphenToHump = function () {
return this.replace(/-(\w)/g, function () {
return arguments[1].toUpperCase()
return this.replace(/-(\w)/g, (...args) => {
return args[1].toUpperCase()
})
}
@@ -19,7 +19,7 @@ String.prototype.humpToHyphen = function () {
// 日期格式化
Date.prototype.format = function (format) {
var o = {
const o = {
'M+': this.getMonth() + 1,
'd+': this.getDate(),
'h+': this.getHours(),
@@ -27,14 +27,14 @@ Date.prototype.format = function (format) {
'm+': this.getMinutes(),
's+': this.getSeconds(),
'q+': Math.floor((this.getMonth() + 3) / 3),
'S': this.getMilliseconds()
S: this.getMilliseconds(),
}
if (/(y+)/.test(format)) { format = format.replace(RegExp.$1, (this.getFullYear() + '').substr(4 - RegExp.$1.length)) }
for (var k in o) {
if (new RegExp('(' + k + ')').test(format)) {
format = format.replace(RegExp.$1, RegExp.$1.length === 1
? o[k]
: ('00' + o[k]).substr(('' + o[k]).length))
if (/(y+)/.test(format)) {
format = format.replace(RegExp.$1, `${this.getFullYear()}`.substr(4 - RegExp.$1.length))
}
for (let k in o) {
if (new RegExp(`(${k})`).test(format)) {
format = format.replace(RegExp.$1, RegExp.$1.length === 1 ? o[k] : (`00${o[k]}`).substr(`${o[k]}`.length))
}
}
return format
@@ -45,5 +45,5 @@ module.exports = {
menu,
request,
color,
classnames
classnames,
}
+16 -16
View File
@@ -2,12 +2,12 @@ module.exports = [
{
key: 'dashboard',
name: '仪表盘',
icon: 'laptop'
icon: 'laptop',
},
{
key: 'users',
name: '用户管理',
icon: 'user'
icon: 'user',
},
{
key: 'ui',
@@ -17,21 +17,21 @@ module.exports = [
child: [
{
key: 'ico',
name: 'Ico 图标'
name: 'Ico 图标',
},
{
key: 'search',
name: 'Search 搜索'
name: 'Search 搜索',
},
{
key: 'dropOption',
name: 'DropOption 下拉操作'
name: 'DropOption 下拉操作',
},
{
key: 'layer',
name: 'Layer 弹层'
}
]
name: 'Layer 弹层',
},
],
},
{
key: 'navigation',
@@ -40,7 +40,7 @@ module.exports = [
child: [
{
key: 'navigation1',
name: '二级导航1'
name: '二级导航1',
},
{
key: 'navigation2',
@@ -48,14 +48,14 @@ module.exports = [
child: [
{
key: 'navigation21',
name: '三级导航1'
name: '三级导航1',
},
{
key: 'navigation22',
name: '三级导航2'
}
]
}
]
}
name: '三级导航2',
},
],
},
],
},
]
+28 -19
View File
@@ -1,34 +1,43 @@
const Mock = require('mockjs')
const mockData = [require('../../mock/users'), require('../../mock/app'), require('../../mock/dashboard')]
const users = require('../../mock/users')
const app = require('../../mock/app')
const dashboard = require('../../mock/dashboard')
const mockData = [users, app, dashboard]
function serialize (str) {
let paramArray = str.split('&')
let query = {}
for (let i in paramArray) {
query[paramArray[i].split('=')[0]] = paramArray[i].split('=')[1]
if (Object.prototype.hasOwnProperty.call(paramArray, i)) {
query[paramArray[i].split('=')[0]] = paramArray[i].split('=')[1]
}
}
return query
}
for (let i in mockData) {
for (let key in mockData[i]) {
Mock.mock(eval('/' + key.split(' ')[1].replace(/\//g, '\\\/') + '/'), key.split(' ')[0].toLowerCase(), function (options) {
if (key.split(' ')[0].toLowerCase() == 'get') {
options.query = options.url.split('?')[1]
? serialize(options.url.split('?')[1])
: (options.body
? serialize(options.body)
: {})
if (Object.prototype.hasOwnProperty.call(mockData, i)) {
for (let key in mockData[i]) {
if (Object.prototype.hasOwnProperty.call(mockData[i], key)) {
Mock.mock(eval(`/${key.split(' ')[1].replace(/\//g, '\\/')}/`), key.split(' ')[0].toLowerCase(), (options) => {
if (key.split(' ')[0].toLowerCase() === 'get') {
if (options.url.split('?')[1]) {
options.query = serialize(options.url.split('?')[1])
} else {
options.query = options.body ? serialize(options.body) : {}
}
}
let res = {}
let result = {}
res.json = function (data) {
result = data
}
mockData[i][key](options, res)
return result
})
}
let res = {}
let result = {}
res.json = function (data) {
result = data
}
mockData[i][key](options, res)
return result
})
}
}
}
Mock.setup({timeout: '200-600'})
Mock.setup({ timeout: '200-600' })
+1 -1
View File
@@ -7,7 +7,7 @@ export default function mockStorge (name, defaultValue) {
? JSON.parse(localStorage.getItem(key))
: defaultValue
!localStorage.getItem(key) && localStorage.setItem(key, JSON.stringify(global[key]))
Watch.watch(global[key], function () {
Watch.watch(global[key], () => {
localStorage.setItem(key, JSON.stringify(global[key]))
})
return key
+11 -12
View File
@@ -3,18 +3,17 @@ import Ajax from 'robe-ajax'
export default function request (url, options) {
if (options.cross) {
return Ajax.getJSON('http://query.yahooapis.com/v1/public/yql', {
q: "select * from json where url='" + url + '?' + Ajax.param(options.data) + "'",
format: 'json'
})
} else {
return Ajax.ajax({
url: url,
method: options.method || 'get',
data: options.data || {},
processData: options.method === 'get',
dataType: 'JSON'
}).done((data) => {
return data
q: `select * from json where url='${url}?${Ajax.param(options.data)}'`,
format: 'json',
})
}
return Ajax.ajax({
url,
method: options.method || 'get',
data: options.data || {},
processData: options.method === 'get',
dataType: 'JSON',
}).done((data) => {
return data
})
}
+2 -2
View File
@@ -9,6 +9,6 @@ module.exports = {
borderBase: '#e5e5e5',
borderSplit: '#f4f4f4',
grass: '#d6fbb5',
sky: '#c1e0fc'
}
sky: '#c1e0fc',
},
}