mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-23 07:41:53 +08:00
feat: vue3 add captcha support i18n
This commit is contained in:
parent
40f730033f
commit
cff736f656
@ -5,7 +5,7 @@
|
|||||||
:style="{ 'max-width': parseInt(imgSize.width) + 30 + 'px' }"
|
:style="{ 'max-width': parseInt(imgSize.width) + 30 + 'px' }"
|
||||||
>
|
>
|
||||||
<div class="verifybox-top" v-if="mode == 'pop'">
|
<div class="verifybox-top" v-if="mode == 'pop'">
|
||||||
请完成安全验证
|
{{ t('captcha.verification') }}
|
||||||
<span class="verifybox-close" @click="closeBox">
|
<span class="verifybox-close" @click="closeBox">
|
||||||
<i class="iconfont icon-close"></i>
|
<i class="iconfont icon-close"></i>
|
||||||
</span>
|
</span>
|
||||||
@ -38,6 +38,7 @@
|
|||||||
* */
|
* */
|
||||||
import { VerifySlide, VerifyPoints } from './Verify'
|
import { VerifySlide, VerifyPoints } from './Verify'
|
||||||
import { computed, ref, toRefs, watchEffect } from 'vue'
|
import { computed, ref, toRefs, watchEffect } from 'vue'
|
||||||
|
import { useI18n } from '@/hooks/web/useI18n'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'Vue3Verify',
|
name: 'Vue3Verify',
|
||||||
@ -83,6 +84,7 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
setup(props) {
|
setup(props) {
|
||||||
|
const { t } = useI18n()
|
||||||
const { captchaType, mode } = toRefs(props)
|
const { captchaType, mode } = toRefs(props)
|
||||||
const clickShow = ref(false)
|
const clickShow = ref(false)
|
||||||
const verifyType = ref(undefined)
|
const verifyType = ref(undefined)
|
||||||
@ -129,6 +131,7 @@ export default {
|
|||||||
})
|
})
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
t,
|
||||||
clickShow,
|
clickShow,
|
||||||
verifyType,
|
verifyType,
|
||||||
componentType,
|
componentType,
|
||||||
|
@ -66,6 +66,7 @@ import { resetSize } from './../utils/util'
|
|||||||
import { aesEncrypt } from './../utils/ase'
|
import { aesEncrypt } from './../utils/ase'
|
||||||
import { reqGet, reqCheck } from './../api/index'
|
import { reqGet, reqCheck } from './../api/index'
|
||||||
import { onMounted, reactive, ref, nextTick, toRefs, getCurrentInstance } from 'vue'
|
import { onMounted, reactive, ref, nextTick, toRefs, getCurrentInstance } from 'vue'
|
||||||
|
import { useI18n } from '@/hooks/web/useI18n'
|
||||||
export default {
|
export default {
|
||||||
name: 'VerifyPoints',
|
name: 'VerifyPoints',
|
||||||
props: {
|
props: {
|
||||||
@ -102,6 +103,7 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
setup(props) {
|
setup(props) {
|
||||||
|
const { t } = useI18n()
|
||||||
const { mode, captchaType } = toRefs(props)
|
const { mode, captchaType } = toRefs(props)
|
||||||
const { proxy } = getCurrentInstance()
|
const { proxy } = getCurrentInstance()
|
||||||
let secretKey = ref(''), //后端返回的ase加密秘钥
|
let secretKey = ref(''), //后端返回的ase加密秘钥
|
||||||
@ -174,7 +176,7 @@ export default {
|
|||||||
if (res.repCode == '0000') {
|
if (res.repCode == '0000') {
|
||||||
barAreaColor.value = '#4cae4c'
|
barAreaColor.value = '#4cae4c'
|
||||||
barAreaBorderColor.value = '#5cb85c'
|
barAreaBorderColor.value = '#5cb85c'
|
||||||
text.value = '验证成功'
|
text.value = t('captcha.success')
|
||||||
bindingClick.value = false
|
bindingClick.value = false
|
||||||
if (mode.value == 'pop') {
|
if (mode.value == 'pop') {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
@ -187,7 +189,7 @@ export default {
|
|||||||
proxy.$parent.$emit('error', proxy)
|
proxy.$parent.$emit('error', proxy)
|
||||||
barAreaColor.value = '#d9534f'
|
barAreaColor.value = '#d9534f'
|
||||||
barAreaBorderColor.value = '#d9534f'
|
barAreaBorderColor.value = '#d9534f'
|
||||||
text.value = '验证失败'
|
text.value = t('captcha.fail')
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
refresh()
|
refresh()
|
||||||
}, 700)
|
}, 700)
|
||||||
@ -219,7 +221,7 @@ export default {
|
|||||||
checkPosArr.splice(0, checkPosArr.length)
|
checkPosArr.splice(0, checkPosArr.length)
|
||||||
num.value = 1
|
num.value = 1
|
||||||
getPictrue()
|
getPictrue()
|
||||||
text.value = '验证失败'
|
text.value = t('captcha.fail')
|
||||||
showRefresh.value = true
|
showRefresh.value = true
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -234,7 +236,7 @@ export default {
|
|||||||
backToken.value = res.repData.token
|
backToken.value = res.repData.token
|
||||||
secretKey.value = res.repData.secretKey
|
secretKey.value = res.repData.secretKey
|
||||||
poinTextList.value = res.repData.wordList
|
poinTextList.value = res.repData.wordList
|
||||||
text.value = '请依次点击【' + poinTextList.value.join(',') + '】'
|
text.value = t('captcha.point') + '【' + poinTextList.value.join(',') + '】'
|
||||||
} else {
|
} else {
|
||||||
text.value = res.repMsg
|
text.value = res.repMsg
|
||||||
}
|
}
|
||||||
|
@ -79,6 +79,7 @@
|
|||||||
import { aesEncrypt } from './../utils/ase'
|
import { aesEncrypt } from './../utils/ase'
|
||||||
import { resetSize } from './../utils/util'
|
import { resetSize } from './../utils/util'
|
||||||
import { reqGet, reqCheck } from './../api/index'
|
import { reqGet, reqCheck } from './../api/index'
|
||||||
|
import { useI18n } from '@/hooks/web/useI18n'
|
||||||
import {
|
import {
|
||||||
computed,
|
computed,
|
||||||
onMounted,
|
onMounted,
|
||||||
@ -111,7 +112,7 @@ export default {
|
|||||||
},
|
},
|
||||||
explain: {
|
explain: {
|
||||||
type: String,
|
type: String,
|
||||||
default: '向右滑动完成验证'
|
default: ''
|
||||||
},
|
},
|
||||||
imgSize: {
|
imgSize: {
|
||||||
type: Object,
|
type: Object,
|
||||||
@ -142,6 +143,7 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
setup(props) {
|
setup(props) {
|
||||||
|
const { t } = useI18n()
|
||||||
const { mode, captchaType, type, blockSize, explain } = toRefs(props)
|
const { mode, captchaType, type, blockSize, explain } = toRefs(props)
|
||||||
const { proxy } = getCurrentInstance()
|
const { proxy } = getCurrentInstance()
|
||||||
let secretKey = ref(''), //后端返回的ase加密秘钥
|
let secretKey = ref(''), //后端返回的ase加密秘钥
|
||||||
@ -181,7 +183,11 @@ export default {
|
|||||||
return proxy.$el.querySelector('.verify-bar-area')
|
return proxy.$el.querySelector('.verify-bar-area')
|
||||||
})
|
})
|
||||||
function init() {
|
function init() {
|
||||||
text.value = explain.value
|
if (explain.value === '') {
|
||||||
|
text.value = t('captcha.slide')
|
||||||
|
} else {
|
||||||
|
text.value = explain.value
|
||||||
|
}
|
||||||
getPictrue()
|
getPictrue()
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
let { imgHeight, imgWidth, barHeight, barWidth } = resetSize(proxy)
|
let { imgHeight, imgWidth, barHeight, barWidth } = resetSize(proxy)
|
||||||
@ -311,9 +317,8 @@ export default {
|
|||||||
}, 1500)
|
}, 1500)
|
||||||
}
|
}
|
||||||
passFlag.value = true
|
passFlag.value = true
|
||||||
tipWords.value = `${((endMovetime.value - startMoveTime.value) / 1000).toFixed(
|
tipWords.value = `${((endMovetime.value - startMoveTime.value) / 1000).toFixed(2)}s
|
||||||
2
|
${t('captcha.success')}`
|
||||||
)}s验证成功`
|
|
||||||
var captchaVerification = secretKey.value
|
var captchaVerification = secretKey.value
|
||||||
? aesEncrypt(
|
? aesEncrypt(
|
||||||
backToken.value + '---' + JSON.stringify({ x: moveLeftDistance, y: 5.0 }),
|
backToken.value + '---' + JSON.stringify({ x: moveLeftDistance, y: 5.0 }),
|
||||||
@ -335,7 +340,7 @@ export default {
|
|||||||
refresh()
|
refresh()
|
||||||
}, 1000)
|
}, 1000)
|
||||||
proxy.$parent.$emit('error', proxy)
|
proxy.$parent.$emit('error', proxy)
|
||||||
tipWords.value = '验证失败'
|
tipWords.value = t('captcha.fail')
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
tipWords.value = ''
|
tipWords.value = ''
|
||||||
}, 1000)
|
}, 1000)
|
||||||
|
@ -128,6 +128,13 @@ export default {
|
|||||||
btnRegister: 'Sign up',
|
btnRegister: 'Sign up',
|
||||||
SmsSendMsg: 'code has been sent'
|
SmsSendMsg: 'code has been sent'
|
||||||
},
|
},
|
||||||
|
captcha: {
|
||||||
|
verification: 'Please complete security verification',
|
||||||
|
slide: 'Swipe right to complete verification',
|
||||||
|
point: 'Please click',
|
||||||
|
success: 'Verification succeeded',
|
||||||
|
fail: 'verification failed'
|
||||||
|
},
|
||||||
router: {
|
router: {
|
||||||
login: 'Login',
|
login: 'Login',
|
||||||
home: 'Home',
|
home: 'Home',
|
||||||
@ -191,7 +198,6 @@ export default {
|
|||||||
yield: 'Yield',
|
yield: 'Yield',
|
||||||
dynamic: 'Dynamic',
|
dynamic: 'Dynamic',
|
||||||
push: 'push',
|
push: 'push',
|
||||||
pushCode: 'push code to Github',
|
|
||||||
follow: 'Follow'
|
follow: 'Follow'
|
||||||
},
|
},
|
||||||
form: {
|
form: {
|
||||||
|
@ -128,6 +128,13 @@ export default {
|
|||||||
btnRegister: '注册',
|
btnRegister: '注册',
|
||||||
SmsSendMsg: '验证码已发送'
|
SmsSendMsg: '验证码已发送'
|
||||||
},
|
},
|
||||||
|
captcha: {
|
||||||
|
verification: '请完成安全验证',
|
||||||
|
slide: '向右滑动完成验证',
|
||||||
|
point: '请依次点击',
|
||||||
|
success: '验证成功',
|
||||||
|
fail: '验证失败'
|
||||||
|
},
|
||||||
router: {
|
router: {
|
||||||
login: '登录',
|
login: '登录',
|
||||||
home: '首页',
|
home: '首页',
|
||||||
@ -191,7 +198,6 @@ export default {
|
|||||||
yield: '产量',
|
yield: '产量',
|
||||||
dynamic: '动态',
|
dynamic: '动态',
|
||||||
push: '推送',
|
push: '推送',
|
||||||
pushCode: '推送 代码到 Github',
|
|
||||||
follow: '关注'
|
follow: '关注'
|
||||||
},
|
},
|
||||||
form: {
|
form: {
|
||||||
|
Loading…
Reference in New Issue
Block a user