fix bugs & add batchdelete peer & add peer to ab
Cette révision appartient à :
+28
-5
@@ -1,4 +1,4 @@
|
||||
export function get_suffix(filename) {
|
||||
export function get_suffix (filename) {
|
||||
var pos = filename.lastIndexOf('.')
|
||||
var suffix = ''
|
||||
if (pos !== -1) {
|
||||
@@ -7,7 +7,7 @@ export function get_suffix(filename) {
|
||||
return suffix
|
||||
}
|
||||
|
||||
export function random_string(len) {
|
||||
export function random_string (len) {
|
||||
len = len || 32
|
||||
var chars = 'ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678'
|
||||
var maxPos = chars.length
|
||||
@@ -18,17 +18,40 @@ export function random_string(len) {
|
||||
return pwd
|
||||
}
|
||||
|
||||
export function random_filename(filename) {
|
||||
export function random_filename (filename) {
|
||||
var suffix = get_suffix(filename)
|
||||
var time = new Date()
|
||||
var time2 = new Date('2020/01/01')
|
||||
return Math.ceil((time.getTime() - time2.getTime()) / 1000) + '_' + random_string(10) + suffix
|
||||
}
|
||||
|
||||
export function utf8_to_b64(str) {
|
||||
export function utf8_to_b64 (str) {
|
||||
return window.btoa(unescape(encodeURIComponent(str)))
|
||||
}
|
||||
|
||||
export function b64_to_utf8(str) {
|
||||
export function b64_to_utf8 (str) {
|
||||
return decodeURIComponent(escape(window.atob(str)))
|
||||
}
|
||||
|
||||
export function jsonToCsv (data) {
|
||||
let csv = ''
|
||||
let keys = Object.keys(data[0])
|
||||
csv += keys.join(',') + '\n'
|
||||
data.forEach(row => {
|
||||
csv += keys.map(key => `"${row[key]}"`).join(',') + '\n'
|
||||
})
|
||||
return new Blob([csv], { type: 'text/csv' })
|
||||
}
|
||||
|
||||
export function downBlob (blob, filename) {
|
||||
const url = window.URL.createObjectURL(blob)
|
||||
const a = document.createElement('a')
|
||||
a.href = url
|
||||
a.download = filename
|
||||
document.body.appendChild(a)
|
||||
a.click()
|
||||
setTimeout(() => {
|
||||
window.URL.revokeObjectURL(url)
|
||||
document.body.removeChild(a)
|
||||
})
|
||||
}
|
||||
|
||||
Référencer dans un nouveau ticket
Bloquer un utilisateur