lint:format code style

pull/285/head
Pan 7 years ago
parent 3666148ddc
commit 98d5f9a247

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

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

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

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

Loading…
Cancel
Save