Commit 3b8a8b51 authored by 郑磊's avatar 郑磊

支持圆角设置

parent 6b7ab953
<script setup lang="ts"> <script setup lang="ts">
import { PropType, onMounted, ref, toRef } from 'vue' import { PropType, computed, onMounted, ref, toRef } from 'vue'
import ConcatCaptcha from './captcha-views/ConcatCaptcha.vue' import ConcatCaptcha from './captcha-views/ConcatCaptcha.vue'
import RotateCaptcha from './captcha-views/RotateCaptcha.vue' import RotateCaptcha from './captcha-views/RotateCaptcha.vue'
import SliderCaptcha from './captcha-views/SliderCaptcha.vue' import SliderCaptcha from './captcha-views/SliderCaptcha.vue'
...@@ -34,8 +34,7 @@ const props = defineProps({ ...@@ -34,8 +34,7 @@ const props = defineProps({
default: true, default: true,
}, },
radius: { radius: {
type: Boolean, type: Number,
default: true,
}, },
shadow: { shadow: {
type: Boolean, type: Boolean,
...@@ -50,6 +49,14 @@ const props = defineProps({ ...@@ -50,6 +49,14 @@ const props = defineProps({
}, },
}) })
const radiusStyle = computed(() =>
typeof props.radius === 'number' &&
!isNaN(props.radius) &&
props.radius >= 0
? { borderRadius: `${props.radius}px` }
: {},
)
const locale = toRef(props, 'locale') const locale = toRef(props, 'locale')
provideLocale(locale) provideLocale(locale)
...@@ -163,6 +170,7 @@ defineExpose({ ...@@ -163,6 +170,7 @@ defineExpose({
'captcha--container--radius': radius, 'captcha--container--radius': radius,
'captcha--container--shadow': shadow, 'captcha--container--shadow': shadow,
}" }"
:style="radiusStyle"
@touchmove.prevent @touchmove.prevent
@mousemove.prevent @mousemove.prevent
> >
......
...@@ -8,7 +8,13 @@ const validCaptchaUrl = import.meta.env.VITE_VALID_CAPTCHA_URL ...@@ -8,7 +8,13 @@ const validCaptchaUrl = import.meta.env.VITE_VALID_CAPTCHA_URL
//通过URL上的参数解析验证码组件的参数 //通过URL上的参数解析验证码组件的参数
const { radius, shadow, locale, callback, extra, style } = (() => { const { radius, shadow, locale, callback, extra, style } = (() => {
const url = new URL(location.href) const url = new URL(location.href)
const radius = url.searchParams.get('radius') === '1' const radius = (() => {
let value = url.searchParams.get('radius')
if (value === null) return undefined
const num = parseFloat(value)
if (isNaN(num) || num < 0) return undefined
return num
})()
const shadow = url.searchParams.get('shadow') === '1' const shadow = url.searchParams.get('shadow') === '1'
const locale = url.searchParams.get('lang') ?? undefined const locale = url.searchParams.get('lang') ?? undefined
const callback = url.searchParams.get('callback') const callback = url.searchParams.get('callback')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment