mirror of
https://github.com/continew-org/continew-admin-ui.git
synced 2025-11-05 08:57:10 +08:00
feat: 新增行为验证码
This commit is contained in:
@@ -2,6 +2,7 @@ import Base64 from 'crypto-js/enc-base64'
|
||||
import UTF8 from 'crypto-js/enc-utf8'
|
||||
import { JSEncrypt } from 'jsencrypt'
|
||||
import md5 from 'crypto-js/md5'
|
||||
import CryptoJS from 'crypto-js'
|
||||
|
||||
export function encodeByBase64(txt: string) {
|
||||
return UTF8.parse(txt).toString(Base64)
|
||||
@@ -24,3 +25,15 @@ export function encryptByRsa(txt: string) {
|
||||
encryptor.setPublicKey(publicKey) // 设置公钥
|
||||
return encryptor.encrypt(txt) // 对数据进行加密
|
||||
}
|
||||
|
||||
const defaultKeyWork = 'XwKsGlMcdPMEhR1B'
|
||||
|
||||
export function aesEncrypt(word, keyWord = defaultKeyWork) {
|
||||
const key = CryptoJS.enc.Utf8.parse(keyWord)
|
||||
const arcs = CryptoJS.enc.Utf8.parse(word)
|
||||
const encrypted = CryptoJS.AES.encrypt(arcs, key, {
|
||||
mode: CryptoJS.mode.ECB,
|
||||
padding: CryptoJS.pad.Pkcs7
|
||||
})
|
||||
return encrypted.toString()
|
||||
}
|
||||
|
||||
39
src/utils/verify.ts
Normal file
39
src/utils/verify.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
export function resetSize(vm) {
|
||||
let img_width
|
||||
let img_height
|
||||
let bar_width
|
||||
let bar_height // 图片的宽度、高度,移动条的宽度、高度
|
||||
|
||||
const parentWidth = vm.$el.parentNode.offsetWidth || window.innerWidth
|
||||
const parentHeight = vm.$el.parentNode.offsetHeight || window.innerHeight
|
||||
if (vm.imgSize.width.includes('%')) {
|
||||
img_width = `${(Number.parseInt(vm.imgSize.width, 10) / 100) * parentWidth}px`
|
||||
} else {
|
||||
img_width = vm.imgSize.width
|
||||
}
|
||||
|
||||
if (vm.imgSize.height.includes('%')) {
|
||||
img_height = `${(Number.parseInt(vm.imgSize.height, 10) / 100) * parentHeight}px`
|
||||
} else {
|
||||
img_height = vm.imgSize.height
|
||||
}
|
||||
|
||||
if (vm.barSize.width.includes('%')) {
|
||||
bar_width = `${(Number.parseInt(vm.barSize.width, 10) / 100) * parentWidth}px`
|
||||
} else {
|
||||
bar_width = vm.barSize.width
|
||||
}
|
||||
|
||||
if (vm.barSize.height.includes('%')) {
|
||||
bar_height = `${(Number.parseInt(vm.barSize.height, 10) / 100) * parentHeight}px`
|
||||
} else {
|
||||
bar_height = vm.barSize.height
|
||||
}
|
||||
|
||||
return {
|
||||
imgWidth: img_width,
|
||||
imgHeight: img_height,
|
||||
barWidth: bar_width,
|
||||
barHeight: bar_height
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user