index.js
1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import { Message } from 'element-ui'
export function debounce(func, wait = 200) {
let timeout
return function(event) {
clearTimeout(timeout)
timeout = setTimeout(() => {
func.call(this, event)
}, wait)
}
}
export function dateFormat(dateTime, format = 'YYYY-MM-DD HH:mm:ss') {
const date = new Date(dateTime)
const config = {
YYYY: date.getFullYear(),
MM: date.getMonth() + 1, //getMonth() 方法根据本地时间返回指定日期的月份(从 0 到 11)
DD: date.getDate(),
HH: date.getHours(),
mm: date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes(),
ss: date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds()
}
for (const key in config) {
format = format.replace(key, config[key])
}
return format
}
export function cloneText(message) {
let input = document.createElement('input')
input.value = message
document.body.appendChild(input)
input.select()
input.setSelectionRange(0, input.value.length), document.execCommand('Copy')
document.body.removeChild(input)
Message.success({ message: '复制成功', customClass: 'msgTips' })
}
export function openTab(url) {
const link = document.createElement('a')
link.href = url
link.target = '_blank'
link.rel = 'opener'
link.click()
}