1
0
mirror of https://github.com/zclzone/vue-naive-admin.git synced 2025-12-28 12:10:20 +08:00

style: lint

This commit is contained in:
zclzone
2024-06-06 18:05:36 +08:00
parent 98f9d5893a
commit a67510fe34
72 changed files with 542 additions and 389 deletions

View File

@@ -10,10 +10,10 @@
import dayjs from 'dayjs'
/**
* @desc 格式化时间
* @param {(Object|string|number)} time
* @param {(object | string | number)} time
* @param {string} format
* @returns {string | null}
* @returns {string | null} 格式化后的时间字符串
*
*/
export function formatDateTime(time = undefined, format = 'YYYY-MM-DD HH:mm:ss') {
return dayjs(time).format(format)
@@ -24,19 +24,19 @@ export function formatDate(date = undefined, format = 'YYYY-MM-DD') {
}
/**
* @desc 函数节流
* @param {Function} fn
* @param {Number} wait
* @returns {Function}
* @param {number} wait
* @returns {Function} 节流函数
*
*/
export function throttle(fn, wait) {
var context, args
var previous = 0
let context, args
let previous = 0
return function () {
var now = +new Date()
return function (...argArr) {
const now = +new Date()
context = this
args = arguments
args = argArr
if (now - previous > wait) {
fn.apply(context, args)
previous = now
@@ -45,16 +45,15 @@ export function throttle(fn, wait) {
}
/**
* @desc 函数防抖
* @param {Function} func
* @param {Function} method
* @param {number} wait
* @param {boolean} immediate
* @return {*}
* @return {*} 防抖函数
*/
export function debounce(method, wait, immediate) {
let timeout
return function (...args) {
let context = this
const context = this
if (timeout) {
clearTimeout(timeout)
}
@@ -64,14 +63,15 @@ export function debounce(method, wait, immediate) {
* 如果定时器不存在则立即执行并设置一个定时器wait毫秒后将定时器置为null
* 这样确保立即执行后wait毫秒内不会被再次触发
*/
let callNow = !timeout
const callNow = !timeout
timeout = setTimeout(() => {
timeout = null
}, wait)
if (callNow) {
method.apply(context, args)
}
} else {
}
else {
// 如果immediate为false则函数wait毫秒后执行
timeout = setTimeout(() => {
/**
@@ -85,12 +85,11 @@ export function debounce(method, wait, immediate) {
}
/**
* @desc 睡一会儿,让子弹暂停一下
* @param {number} time 毫秒数
* @returns
* @returns 睡一会儿,让子弹暂停一下
*/
export function sleep(time) {
return new Promise((resolve) => setTimeout(resolve, time))
return new Promise(resolve => setTimeout(resolve, time))
}
/**