init project
This commit is contained in:
46
src/components/captcha/index.vue
Normal file
46
src/components/captcha/index.vue
Normal file
@@ -0,0 +1,46 @@
|
||||
<template>
|
||||
<img
|
||||
class="tui-captcha ir-pixelated"
|
||||
v-if="src"
|
||||
:width="width"
|
||||
:height="height"
|
||||
:src="src"
|
||||
alt="验证码"
|
||||
@click="update()"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import Toolkit from "~/utils/Toolkit";
|
||||
|
||||
defineOptions({
|
||||
name: "Captcha"
|
||||
});
|
||||
|
||||
const props = withDefaults(defineProps<{
|
||||
width: number,
|
||||
height: number,
|
||||
from: string,
|
||||
api: string,
|
||||
}>(), {});
|
||||
const { width, height, from, api } = toRefs(props);
|
||||
|
||||
const src = ref("");
|
||||
function update() {
|
||||
src.value = `${api.value}?from=${from.value}&width=${width.value}&height=${height.value}&r=${Toolkit.random(0, 999999)}`;
|
||||
}
|
||||
onMounted(update);
|
||||
|
||||
defineExpose({
|
||||
update
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.tui-captcha {
|
||||
cursor: var(--tui-cur-pointer);
|
||||
border: 1px solid gray;
|
||||
display: block;
|
||||
pointer-events: all;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user