fix bugs & add batchdelete peer & add peer to ab

This commit is contained in:
ljw
2024-09-29 11:50:23 +08:00
parent 8be855ff3e
commit 777510c7ec
14 changed files with 427 additions and 65 deletions
+28 -5
View File
@@ -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)
})
}
+2 -3
View File
@@ -1,17 +1,16 @@
import en from '@/utils/i18n/en.json'
import zhCN from '@/utils/i18n/zh_CN.json'
import { useAppStore } from '@/store/app'
import { pinia } from '@/store'
export function T (key, params, num = 0) {
const appStore = useAppStore(pinia)
const appStore = useAppStore()
const lang = appStore.setting.lang
const trans = lang === 'zh-CN' ? zhCN : en
const tran = trans[key]
if (!tran) {
return key
}
const msg = num > 0 ? (tran.Other ? tran.Other : tran.One) : tran.One
const msg = num > 1 ? (tran.Other ? tran.Other : tran.One) : tran.One
//msg 是这样 {name} is name
//params 是这样 {name: 'zhangsan'}
//替换
+50
View File
@@ -232,5 +232,55 @@
},
"LoginLog": {
"One": "Login Log"
},
"LastOnlineTime": {
"One": "Last Online Time"
},
"JustNow": {
"One": "Just Now"
},
"MinutesAgo": {
"One": "{param} Minute Ago",
"Other": "{param} Minutes Ago"
},
"HoursAgo": {
"One": "{param} Hour Ago",
"Other": "{param} Hours Ago"
},
"DaysAgo": {
"One": "{param} Day Ago",
"Other": "{param} Days Ago"
},
"MonthsAgo": {
"One": "{param} Month Ago",
"Other": "{param} Months Ago"
},
"YearsAgo": {
"One": "{param} Year Ago",
"Other": "{param} Years Ago"
},
"MinutesLess": {
"One": "Less than {param} minute",
"Other": "Less than {param} minutes"
},
"HoursLess": {
"One": "Less than {param} hour",
"Other": "Less than {param} hours"
},
"DaysLess": {
"One": "Less than {param} day",
"Other": "Less than {param} days"
},
"Export": {
"One": "Export"
},
"AddToAddressBook": {
"One": "Add To Address Book"
},
"BatchDelete": {
"One": "Batch Delete"
},
"PleaseSelectData": {
"One": "Please select data"
}
}
+42
View File
@@ -232,5 +232,47 @@
},
"LoginLog": {
"One": "登录日志"
},
"LastOnlineTime": {
"One": "最后在线时间"
},
"JustNow": {
"One": "刚刚"
},
"MinutesAgo": {
"One": "{param} 分钟前"
},
"HoursAgo": {
"One": "{param} 小时前"
},
"DaysAgo": {
"One": "{param} 天前"
},
"MonthsAgo": {
"One": "{param} 月前"
},
"YearsAgo": {
"One": "{param} 年前"
},
"MinutesLess": {
"One": "{param} 分钟内"
},
"HoursLess": {
"One": "{param} 小时内"
},
"DaysLess": {
"One": "{param} 天内"
},
"Export": {
"One": "导出"
},
"AddToAddressBook": {
"One": "添加到地址簿"
},
"BatchDelete": {
"One": "批量删除"
},
"PleaseSelectData": {
"One": "请选择数据"
}
}
+25
View File
@@ -0,0 +1,25 @@
import { T } from '@/utils/i18n'
export function timeAgo (time) {
let now = new Date().getTime()
let after = new Date(time).getTime()
let dis = now - after
if (dis < 60 * 1000) {
return T('JustNow')
} else if (dis < 60 * 60 * 1000) {
const num = Math.floor(dis / (60 * 1000))
return T('MinutesAgo', { param: num }, num)
} else if (dis < 24 * 60 * 60 * 1000) {
const num = Math.floor(dis / (60 * 60 * 1000))
return T('HoursAgo', { param: num }, num)
} else if (dis < 30 * 24 * 60 * 60 * 1000) {
const num = Math.floor(dis / (24 * 60 * 60 * 1000))
return T('DaysAgo', { param: num }, num)
} else if (dis < 12 * 30 * 24 * 60 * 60 * 1000) {
const num = Math.floor(dis / (30 * 24 * 60 * 60 * 1000))
return T('MonthsAgo', { param: num }, num)
} else {
const num = Math.floor(dis / (12 * 30 * 24 * 60 * 60 * 1000))
return T('YearsAgo', { param: num }, num)
}
}