function debounce(fn, wait) {
let timerId = null
let flag = true
return function () {
clearTimeout(timerId)
if (flag) {
fn.apply(this, arguments)
flag = false
}
timerId = setTimeout(() => {
flag = true
}, wait)
}
}
const authError = debounce((message) => {
Message({
message,
type: 'warning'
})
}, 1000)
// 拦截器里这样调
authError(response.data.msg)