lint:format code style

This commit is contained in:
Pan 2017-10-31 16:04:30 +08:00
parent 3666148ddc
commit 98d5f9a247
14 changed files with 341 additions and 342 deletions

View File

@ -52,7 +52,7 @@ module.exports = {
'no-class-assign': 2, 'no-class-assign': 2,
'no-cond-assign': 2, 'no-cond-assign': 2,
'no-const-assign': 2, 'no-const-assign': 2,
'no-control-regex': 2, 'no-control-regex': 0,
'no-delete-var': 2, 'no-delete-var': 2,
'no-dupe-args': 2, 'no-dupe-args': 2,
'no-dupe-class-members': 2, 'no-dupe-class-members': 2,

View File

@ -7,7 +7,7 @@
<script> <script>
import Dropzone from 'dropzone' import Dropzone from 'dropzone'
import 'dropzone/dist/dropzone.css' import 'dropzone/dist/dropzone.css'
// import { getToken } from 'api/qiniu'; // import { getToken } from 'api/qiniu';
Dropzone.autoDiscover = false Dropzone.autoDiscover = false

View File

@ -29,29 +29,29 @@ service.interceptors.response.use(
* 下面的注释为通过response自定义code来标示请求状态当code返回如下情况为权限有问题登出并返回到登录页 * 下面的注释为通过response自定义code来标示请求状态当code返回如下情况为权限有问题登出并返回到登录页
* 如通过xmlhttprequest 状态码标识 逻辑可写在下面error中 * 如通过xmlhttprequest 状态码标识 逻辑可写在下面error中
*/ */
// const res = response.data; // const res = response.data;
// if (res.code !== 20000) { // if (res.code !== 20000) {
// Message({ // Message({
// message: res.message, // message: res.message,
// type: 'error', // type: 'error',
// duration: 5 * 1000 // duration: 5 * 1000
// }); // });
// // 50008:非法的token; 50012:其他客户端登录了; 50014:Token 过期了; // // 50008:非法的token; 50012:其他客户端登录了; 50014:Token 过期了;
// if (res.code === 50008 || res.code === 50012 || res.code === 50014) { // if (res.code === 50008 || res.code === 50012 || res.code === 50014) {
// MessageBox.confirm('你已被登出,可以取消继续留在该页面,或者重新登录', '确定登出', { // MessageBox.confirm('你已被登出,可以取消继续留在该页面,或者重新登录', '确定登出', {
// confirmButtonText: '重新登录', // confirmButtonText: '重新登录',
// cancelButtonText: '取消', // cancelButtonText: '取消',
// type: 'warning' // type: 'warning'
// }).then(() => { // }).then(() => {
// store.dispatch('FedLogOut').then(() => { // store.dispatch('FedLogOut').then(() => {
// location.reload();// 为了重新实例化vue-router对象 避免bug // location.reload();// 为了重新实例化vue-router对象 避免bug
// }); // });
// }) // })
// } // }
// return Promise.reject('error'); // return Promise.reject('error');
// } else { // } else {
// return response.data; // return response.data;
// } // }
error => { error => {
console.log('err' + error)// for debug console.log('err' + error)// for debug
Message({ Message({
@ -60,7 +60,6 @@ service.interceptors.response.use(
duration: 5 * 1000 duration: 5 * 1000
}) })
return Promise.reject(error) return Promise.reject(error)
} })
)
export default service export default service

View File

@ -2,7 +2,7 @@
* Created by jiachenpan on 16/11/18. * Created by jiachenpan on 16/11/18.
*/ */
export function parseTime(time, cFormat) { export function parseTime(time, cFormat) {
if (arguments.length === 0) { if (arguments.length === 0) {
return null return null
} }
@ -32,9 +32,9 @@
return value || 0 return value || 0
}) })
return time_str return time_str
} }
export function formatTime(time, option) { export function formatTime(time, option) {
time = +time * 1000 time = +time * 1000
const d = new Date(time) const d = new Date(time)
const now = Date.now() const now = Date.now()
@ -55,10 +55,10 @@
} else { } else {
return d.getMonth() + 1 + '月' + d.getDate() + '日' + d.getHours() + '时' + d.getMinutes() + '分' return d.getMonth() + 1 + '月' + d.getDate() + '日' + d.getHours() + '时' + d.getMinutes() + '分'
} }
} }
// 格式化时间 // 格式化时间
export function getQueryObject(url) { export function getQueryObject(url) {
url = url == null ? window.location.href : url url = url == null ? window.location.href : url
const search = url.substring(url.lastIndexOf('?') + 1) const search = url.substring(url.lastIndexOf('?') + 1)
const obj = {} const obj = {}
@ -71,14 +71,14 @@
return rs return rs
}) })
return obj return obj
} }
/** /**
*get getByteLen *get getByteLen
* @param {Sting} val input value * @param {Sting} val input value
* @returns {number} output value * @returns {number} output value
*/ */
export function getByteLen(val) { export function getByteLen(val) {
let len = 0 let len = 0
for (let i = 0; i < val.length; i++) { for (let i = 0; i < val.length; i++) {
if (val[i].match(/[^\x00-\xff]/ig) != null) { if (val[i].match(/[^\x00-\xff]/ig) != null) {
@ -86,9 +86,9 @@
} else { len += 0.5 } } else { len += 0.5 }
} }
return Math.floor(len) return Math.floor(len)
} }
export function cleanArray(actual) { export function cleanArray(actual) {
const newArray = [] const newArray = []
for (let i = 0; i < actual.length; i++) { for (let i = 0; i < actual.length; i++) {
if (actual[i]) { if (actual[i]) {
@ -96,32 +96,32 @@
} }
} }
return newArray return newArray
} }
export function param(json) { export function param(json) {
if (!json) return '' if (!json) return ''
return cleanArray(Object.keys(json).map(key => { return cleanArray(Object.keys(json).map(key => {
if (json[key] === undefined) return '' if (json[key] === undefined) return ''
return encodeURIComponent(key) + '=' + return encodeURIComponent(key) + '=' +
encodeURIComponent(json[key]) encodeURIComponent(json[key])
})).join('&') })).join('&')
} }
export function param2Obj(url) { export function param2Obj(url) {
const search = url.split('?')[1] const search = url.split('?')[1]
if (!search) { if (!search) {
return {} return {}
} }
return JSON.parse('{"' + decodeURIComponent(search).replace(/"/g, '\\"').replace(/&/g, '","').replace(/=/g, '":"') + '"}') return JSON.parse('{"' + decodeURIComponent(search).replace(/"/g, '\\"').replace(/&/g, '","').replace(/=/g, '":"') + '"}')
} }
export function html2Text(val) { export function html2Text(val) {
const div = document.createElement('div') const div = document.createElement('div')
div.innerHTML = val div.innerHTML = val
return div.textContent || div.innerText return div.textContent || div.innerText
} }
export function objectMerge(target, source) { export function objectMerge(target, source) {
/* Merges two objects, /* Merges two objects,
giving the last one precedence */ giving the last one precedence */
@ -142,9 +142,9 @@
} }
} }
return target return target
} }
export function scrollTo(element, to, duration) { export function scrollTo(element, to, duration) {
if (duration <= 0) return if (duration <= 0) return
const difference = to - element.scrollTop const difference = to - element.scrollTop
const perTick = difference / duration * 10 const perTick = difference / duration * 10
@ -154,9 +154,9 @@
if (element.scrollTop === to) return if (element.scrollTop === to) return
scrollTo(element, to, duration - 10) scrollTo(element, to, duration - 10)
}, 10) }, 10)
} }
export function toggleClass(element, className) { export function toggleClass(element, className) {
if (!element || !className) { if (!element || !className) {
return return
} }
@ -168,9 +168,9 @@
classString = classString.substr(0, nameIndex) + classString.substr(nameIndex + className.length) classString = classString.substr(0, nameIndex) + classString.substr(nameIndex + className.length)
} }
element.className = classString element.className = classString
} }
export const pickerOptions = [ export const pickerOptions = [
{ {
text: '今天', text: '今天',
onClick(picker) { onClick(picker) {
@ -205,15 +205,15 @@
} }
}] }]
export function getTime(type) { export function getTime(type) {
if (type === 'start') { if (type === 'start') {
return new Date().getTime() - 3600 * 1000 * 24 * 90 return new Date().getTime() - 3600 * 1000 * 24 * 90
} else { } else {
return new Date(new Date().toDateString()) return new Date(new Date().toDateString())
} }
} }
export function debounce(func, wait, immediate) { export function debounce(func, wait, immediate) {
let timeout, args, context, timestamp, result let timeout, args, context, timestamp, result
const later = function() { const later = function() {
@ -246,9 +246,9 @@
return result return result
} }
} }
export function deepClone(source) { export function deepClone(source) {
if (!source && typeof source !== 'object') { if (!source && typeof source !== 'object') {
throw new Error('error arguments', 'shallowClone') throw new Error('error arguments', 'shallowClone')
} }
@ -264,4 +264,4 @@
} }
} }
return targetObj return targetObj
} }