mirror of
https://github.com/continew-org/continew-admin-ui.git
synced 2025-11-12 00:59:23 +08:00
refactor: 调整 eslint.config.js,优化代码格式
This commit is contained in:
@@ -2,8 +2,8 @@
|
||||
<div style="position: relative">
|
||||
<div class="verify-img-out">
|
||||
<div
|
||||
class="verify-img-panel"
|
||||
:style="{
|
||||
class="verify-img-panel"
|
||||
:style="{
|
||||
'width': setSize.imgWidth,
|
||||
'height': setSize.imgHeight,
|
||||
'background-size': `${setSize.imgWidth} ${setSize.imgHeight}`,
|
||||
@@ -11,26 +11,26 @@
|
||||
}"
|
||||
>
|
||||
<div
|
||||
v-show="showRefresh"
|
||||
class="verify-refresh"
|
||||
style="z-index: 3"
|
||||
@click="refresh"
|
||||
v-show="showRefresh"
|
||||
class="verify-refresh"
|
||||
style="z-index: 3"
|
||||
@click="refresh"
|
||||
>
|
||||
<i class="iconfont icon-refresh"></i>
|
||||
</div>
|
||||
<img
|
||||
ref="canvas"
|
||||
:src="`data:image/png;base64,${pointBackImgBase}`"
|
||||
alt=""
|
||||
style="width: 100%; height: 100%; display: block"
|
||||
@click="bindingClick ? canvasClick($event) : undefined"
|
||||
ref="canvas"
|
||||
:src="`data:image/png;base64,${pointBackImgBase}`"
|
||||
alt=""
|
||||
style="width: 100%; height: 100%; display: block"
|
||||
@click="bindingClick ? canvasClick($event) : undefined"
|
||||
/>
|
||||
|
||||
<div
|
||||
v-for="(tempPoint, index) in tempPoints"
|
||||
:key="index"
|
||||
class="point-area"
|
||||
:style="{
|
||||
v-for="(tempPoint, index) in tempPoints"
|
||||
:key="index"
|
||||
class="point-area"
|
||||
:style="{
|
||||
'background-color': '#1abd6c',
|
||||
'color': '#fff',
|
||||
'z-index': 9999,
|
||||
@@ -50,8 +50,8 @@
|
||||
</div>
|
||||
|
||||
<div
|
||||
class="verify-bar-area"
|
||||
:style="{
|
||||
class="verify-bar-area"
|
||||
:style="{
|
||||
'width': setSize.imgWidth,
|
||||
'color': barAreaColor,
|
||||
'border-color': barAreaBorderColor,
|
||||
@@ -70,11 +70,11 @@ import {
|
||||
onMounted,
|
||||
reactive,
|
||||
ref,
|
||||
toRefs
|
||||
toRefs,
|
||||
} from 'vue'
|
||||
import {
|
||||
checkBehaviorCaptcha,
|
||||
getBehaviorCaptcha
|
||||
getBehaviorCaptcha,
|
||||
} from '@/apis/common/captcha'
|
||||
import { resetSize } from '@/utils/verify'
|
||||
import { encryptByAes } from '@/utils/encrypt'
|
||||
@@ -85,34 +85,34 @@ export default {
|
||||
// 弹出式pop,固定fixed
|
||||
mode: {
|
||||
type: String,
|
||||
default: ''
|
||||
default: '',
|
||||
},
|
||||
captchaType: {
|
||||
type: String
|
||||
type: String,
|
||||
},
|
||||
// 间隔
|
||||
vSpace: {
|
||||
type: Number,
|
||||
default: 5
|
||||
default: 5,
|
||||
},
|
||||
imgSize: {
|
||||
type: Object,
|
||||
default() {
|
||||
return {
|
||||
width: '310px',
|
||||
height: '155px'
|
||||
height: '155px',
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
barSize: {
|
||||
type: Object,
|
||||
default() {
|
||||
return {
|
||||
width: '310px',
|
||||
height: '40px'
|
||||
height: '40px',
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
setup(props) {
|
||||
const { mode, captchaType } = toRefs(props)
|
||||
@@ -129,7 +129,7 @@ export default {
|
||||
imgHeight: 0,
|
||||
imgWidth: 0,
|
||||
barHeight: 0,
|
||||
barWidth: 0
|
||||
barWidth: 0,
|
||||
})
|
||||
const tempPoints = reactive([])
|
||||
const text = ref('')
|
||||
@@ -141,7 +141,7 @@ export default {
|
||||
// 请求背景图片和验证图片
|
||||
function getPicture() {
|
||||
const data = {
|
||||
captchaType: captchaType.value
|
||||
captchaType: captchaType.value,
|
||||
}
|
||||
getBehaviorCaptcha(data).then((res) => {
|
||||
pointBackImgBase.value = res.data.originalImageBase64
|
||||
@@ -226,7 +226,7 @@ export default {
|
||||
const captchaVerification = secretKey.value
|
||||
? encryptByAes(
|
||||
`${backToken.value}---${JSON.stringify(checkPosArr)}`,
|
||||
secretKey.value
|
||||
secretKey.value,
|
||||
)
|
||||
: `${backToken.value}---${JSON.stringify(checkPosArr)}`
|
||||
const data = {
|
||||
@@ -234,7 +234,7 @@ export default {
|
||||
pointJson: secretKey.value
|
||||
? encryptByAes(JSON.stringify(checkPosArr), secretKey.value)
|
||||
: JSON.stringify(checkPosArr),
|
||||
token: backToken.value
|
||||
token: backToken.value,
|
||||
}
|
||||
checkBehaviorCaptcha(data).then((res) => {
|
||||
if (res.success && res.data.repCode === '0000') {
|
||||
@@ -289,8 +289,8 @@ export default {
|
||||
createPoint,
|
||||
refresh,
|
||||
getPicture,
|
||||
pointTransform
|
||||
pointTransform,
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -1,38 +1,35 @@
|
||||
<template>
|
||||
<div style="position: relative">
|
||||
<div
|
||||
v-if="type === '2'"
|
||||
class="verify-img-out"
|
||||
:style="{ height: `${parseInt(setSize.imgHeight) + vSpace}px` }"
|
||||
v-if="type === '2'"
|
||||
class="verify-img-out"
|
||||
:style="{ height: `${parseInt(setSize.imgHeight) + vSpace}px` }"
|
||||
>
|
||||
<div
|
||||
class="verify-img-panel"
|
||||
:style="{ width: setSize.imgWidth, height: setSize.imgHeight }"
|
||||
class="verify-img-panel"
|
||||
:style="{ width: setSize.imgWidth, height: setSize.imgHeight }"
|
||||
>
|
||||
<img
|
||||
:src="`data:image/png;base64,${backImgBase}`"
|
||||
alt=""
|
||||
style="width: 100%; height: 100%; display: block"
|
||||
:src="`data:image/png;base64,${backImgBase}`"
|
||||
alt=""
|
||||
style="width: 100%; height: 100%; display: block"
|
||||
/>
|
||||
<div v-show="showRefresh" class="verify-refresh" @click="refresh"
|
||||
>
|
||||
<i class="iconfont icon-refresh"></i
|
||||
>
|
||||
</div>
|
||||
<div v-show="showRefresh" class="verify-refresh" @click="refresh">
|
||||
<i class="iconfont icon-refresh"></i>
|
||||
</div>
|
||||
<transition name="tips">
|
||||
<span
|
||||
v-if="tipWords"
|
||||
class="verify-tips"
|
||||
:class="passFlag ? 'suc-bg' : 'err-bg'"
|
||||
>{{ tipWords }}</span
|
||||
>
|
||||
v-if="tipWords"
|
||||
class="verify-tips"
|
||||
:class="passFlag ? 'suc-bg' : 'err-bg'"
|
||||
>{{ tipWords }}</span>
|
||||
</transition>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 公共部分 -->
|
||||
<div
|
||||
class="verify-bar-area"
|
||||
:style="{
|
||||
class="verify-bar-area"
|
||||
:style="{
|
||||
'width': setSize.imgWidth,
|
||||
'height': barSize.height,
|
||||
'line-height': barSize.height,
|
||||
@@ -40,8 +37,8 @@
|
||||
>
|
||||
<span class="verify-msg" v-text="text"></span>
|
||||
<div
|
||||
class="verify-left-bar"
|
||||
:style="{
|
||||
class="verify-left-bar"
|
||||
:style="{
|
||||
'width': leftBarWidth !== undefined ? leftBarWidth : barSize.height,
|
||||
'height': barSize.height,
|
||||
'border-color': leftBarBorderColor,
|
||||
@@ -50,25 +47,25 @@
|
||||
>
|
||||
<span class="verify-msg" v-text="finishText"></span>
|
||||
<div
|
||||
class="verify-move-block"
|
||||
:style="{
|
||||
class="verify-move-block"
|
||||
:style="{
|
||||
'width': barSize.height,
|
||||
'height': barSize.height,
|
||||
'background-color': moveBlockBackgroundColor,
|
||||
'left': moveBlockLeft,
|
||||
'transition': transitionLeft,
|
||||
}"
|
||||
@touchstart="start"
|
||||
@mousedown="start"
|
||||
@touchstart="start"
|
||||
@mousedown="start"
|
||||
>
|
||||
<i
|
||||
class="verify-icon iconfont" :class="[iconClass]"
|
||||
:style="{ color: iconColor }"
|
||||
class="verify-icon iconfont" :class="[iconClass]"
|
||||
:style="{ color: iconColor }"
|
||||
></i>
|
||||
<div
|
||||
v-if="type === '2'"
|
||||
class="verify-sub-block"
|
||||
:style="{
|
||||
v-if="type === '2'"
|
||||
class="verify-sub-block"
|
||||
:style="{
|
||||
'width':
|
||||
`${Math.floor((parseInt(setSize.imgWidth) * 47) / 310)}px`,
|
||||
'height': setSize.imgHeight,
|
||||
@@ -77,9 +74,9 @@
|
||||
}"
|
||||
>
|
||||
<img
|
||||
:src="`data:image/png;base64,${blockBackImgBase}`"
|
||||
alt=""
|
||||
style="
|
||||
:src="`data:image/png;base64,${blockBackImgBase}`"
|
||||
alt=""
|
||||
style="
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: block;
|
||||
@@ -102,11 +99,11 @@ import {
|
||||
reactive,
|
||||
ref,
|
||||
toRefs,
|
||||
watch
|
||||
watch,
|
||||
} from 'vue'
|
||||
import {
|
||||
checkBehaviorCaptcha,
|
||||
getBehaviorCaptcha
|
||||
getBehaviorCaptcha,
|
||||
} from '@/apis/common/captcha'
|
||||
import { encryptByAes } from '@/utils/encrypt'
|
||||
import { resetSize } from '@/utils/verify'
|
||||
@@ -115,52 +112,52 @@ export default {
|
||||
name: 'VerifySlide',
|
||||
props: {
|
||||
captchaType: {
|
||||
type: String
|
||||
type: String,
|
||||
},
|
||||
type: {
|
||||
type: String,
|
||||
default: '1'
|
||||
default: '1',
|
||||
},
|
||||
// 弹出式pop,固定fixed
|
||||
mode: {
|
||||
type: String,
|
||||
default: 'fixed'
|
||||
default: 'fixed',
|
||||
},
|
||||
vSpace: {
|
||||
type: Number,
|
||||
default: 5
|
||||
default: 5,
|
||||
},
|
||||
explain: {
|
||||
type: String,
|
||||
default: '向右滑动完成验证'
|
||||
default: '向右滑动完成验证',
|
||||
},
|
||||
imgSize: {
|
||||
type: Object,
|
||||
default() {
|
||||
return {
|
||||
width: '310px',
|
||||
height: '155px'
|
||||
height: '155px',
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
blockSize: {
|
||||
type: Object,
|
||||
default() {
|
||||
return {
|
||||
width: '50px',
|
||||
height: '50px'
|
||||
height: '50px',
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
barSize: {
|
||||
type: Object,
|
||||
default() {
|
||||
return {
|
||||
width: '310px',
|
||||
height: '40px'
|
||||
height: '40px',
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
setup(props) {
|
||||
const { mode, captchaType, type, blockSize, explain } = toRefs(props)
|
||||
@@ -180,7 +177,7 @@ export default {
|
||||
imgHeight: 0,
|
||||
imgWidth: 0,
|
||||
barHeight: 0,
|
||||
barWidth: 0
|
||||
barWidth: 0,
|
||||
})
|
||||
const top = ref(0)
|
||||
const left = ref(0)
|
||||
@@ -201,7 +198,7 @@ export default {
|
||||
// 请求背景图片和验证图片
|
||||
function getPicture() {
|
||||
const data = {
|
||||
captchaType: captchaType.value
|
||||
captchaType: captchaType.value,
|
||||
}
|
||||
getBehaviorCaptcha(data).then((res) => {
|
||||
backImgBase.value = res.data.originalImageBase64
|
||||
@@ -276,7 +273,7 @@ export default {
|
||||
if (status.value && isEnd.value === false) {
|
||||
let moveLeftDistance = Number.parseInt(
|
||||
(moveBlockLeft.value || '').replace('px', ''),
|
||||
10
|
||||
10,
|
||||
)
|
||||
moveLeftDistance
|
||||
= (moveLeftDistance * 310) / Number.parseInt(`${setSize.imgWidth}`, 10)
|
||||
@@ -285,10 +282,10 @@ export default {
|
||||
pointJson: secretKey.value
|
||||
? encryptByAes(
|
||||
JSON.stringify({ x: moveLeftDistance, y: 5.0 }),
|
||||
secretKey.value
|
||||
secretKey.value,
|
||||
)
|
||||
: JSON.stringify({ x: moveLeftDistance, y: 5.0 }),
|
||||
token: backToken.value
|
||||
token: backToken.value,
|
||||
}
|
||||
checkBehaviorCaptcha(data).then((res) => {
|
||||
if (res.success && res.data.repCode === '0000') {
|
||||
@@ -313,13 +310,13 @@ export default {
|
||||
? encryptByAes(
|
||||
`${backToken.value}---${JSON.stringify({
|
||||
x: moveLeftDistance,
|
||||
y: 5.0
|
||||
y: 5.0,
|
||||
})}`,
|
||||
secretKey.value
|
||||
secretKey.value,
|
||||
)
|
||||
: `${backToken.value}---${JSON.stringify({
|
||||
x: moveLeftDistance,
|
||||
y: 5.0
|
||||
y: 5.0,
|
||||
})}`
|
||||
setTimeout(() => {
|
||||
tipWords.value = ''
|
||||
@@ -410,7 +407,7 @@ export default {
|
||||
x = e.touches[0].pageX
|
||||
}
|
||||
startLeft.value = Math.floor(
|
||||
x - barArea.value.getBoundingClientRect().left
|
||||
x - barArea.value.getBoundingClientRect().left,
|
||||
)
|
||||
startMoveTime.value = +new Date() // 开始滑动的时间
|
||||
if (isEnd.value === false) {
|
||||
@@ -452,8 +449,8 @@ export default {
|
||||
transitionWidth,
|
||||
barArea,
|
||||
refresh,
|
||||
start
|
||||
start,
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<template>
|
||||
<div v-show="showBox" :class="mode === 'pop' ? 'mask' : ''">
|
||||
<div
|
||||
:class="mode === 'pop' ? 'verifybox' : ''"
|
||||
:style="{ 'max-width': `${parseInt(imgSize.width) + 30}px` }"
|
||||
:class="mode === 'pop' ? 'verifybox' : ''"
|
||||
:style="{ 'max-width': `${parseInt(imgSize.width) + 30}px` }"
|
||||
>
|
||||
<div v-if="mode === 'pop'" class="verifybox-top">
|
||||
请完成安全验证
|
||||
@@ -11,24 +11,25 @@
|
||||
</span>
|
||||
</div>
|
||||
<div
|
||||
class="verifybox-bottom"
|
||||
:style="{ padding: mode === 'pop' ? '15px' : '0' }"
|
||||
class="verifybox-bottom"
|
||||
:style="{ padding: mode === 'pop' ? '15px' : '0' }"
|
||||
>
|
||||
<!-- 验证码容器 -->
|
||||
<!-- eslint-disable-next-line vue/no-restricted-v-bind -->
|
||||
<component
|
||||
:is="componentType"
|
||||
v-if="componentType"
|
||||
ref="instance"
|
||||
:captcha-type="captchaType"
|
||||
:type="verifyType"
|
||||
:figure="figure"
|
||||
:arith="arith"
|
||||
:mode="mode"
|
||||
:v-space="vSpace"
|
||||
:explain="explain"
|
||||
:img-size="imgSize"
|
||||
:block-size="blockSize"
|
||||
:bar-size="barSize"
|
||||
:is="componentType"
|
||||
v-if="componentType"
|
||||
ref="instance"
|
||||
:space="space"
|
||||
:captcha-type="captchaType"
|
||||
:type="verifyType"
|
||||
:figure="figure"
|
||||
:arith="arith"
|
||||
:mode="mode"
|
||||
:explain="explain"
|
||||
:img-size="imgSize"
|
||||
:block-size="blockSize"
|
||||
:bar-size="barSize"
|
||||
></component>
|
||||
</div>
|
||||
</div>
|
||||
@@ -44,44 +45,44 @@ export default {
|
||||
name: 'Vue2Verify',
|
||||
components: {
|
||||
VerifySlide,
|
||||
VerifyPoints
|
||||
VerifyPoints,
|
||||
},
|
||||
props: {
|
||||
captchaType: {
|
||||
type: String,
|
||||
required: true
|
||||
required: true,
|
||||
},
|
||||
figure: {
|
||||
type: Number
|
||||
type: Number,
|
||||
},
|
||||
arith: {
|
||||
type: Number
|
||||
type: Number,
|
||||
},
|
||||
mode: {
|
||||
type: String,
|
||||
default: 'pop'
|
||||
default: 'pop',
|
||||
},
|
||||
vSpace: {
|
||||
type: Number
|
||||
space: {
|
||||
type: Number,
|
||||
},
|
||||
explain: {
|
||||
type: String
|
||||
type: String,
|
||||
},
|
||||
imgSize: {
|
||||
type: Object,
|
||||
default() {
|
||||
return {
|
||||
width: '310px',
|
||||
height: '155px'
|
||||
height: '155px',
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
blockSize: {
|
||||
type: Object
|
||||
type: Object,
|
||||
},
|
||||
barSize: {
|
||||
type: Object
|
||||
}
|
||||
type: Object,
|
||||
},
|
||||
},
|
||||
setup(props) {
|
||||
const { captchaType, mode } = toRefs(props)
|
||||
@@ -135,9 +136,9 @@ export default {
|
||||
instance,
|
||||
showBox,
|
||||
closeBox,
|
||||
show
|
||||
show,
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user