|
1
|
<template>
|
vben
authored
|
2
|
<PageWrapper title="拖动校验示例">
|
|
3
4
|
<div class="flex justify-center p-4 items-center bg-gray-700">
<BasicDragVerify ref="el1" @success="handleSuccess" />
|
vben
authored
|
5
|
<a-button type="primary" class="ml-2" @click="handleBtnClick(el1)"> 还原 </a-button>
|
|
6
7
8
9
|
</div>
<div class="flex justify-center p-4 items-center bg-gray-700">
<BasicDragVerify ref="el2" @success="handleSuccess" circle />
|
vben
authored
|
10
|
<a-button type="primary" class="ml-2" @click="handleBtnClick(el2)"> 还原 </a-button>
|
|
11
12
13
14
15
16
17
18
19
|
</div>
<div class="flex justify-center p-4 items-center bg-gray-700">
<BasicDragVerify
ref="el3"
@success="handleSuccess"
text="拖动以进行校验"
successText="校验成功"
:barStyle="{
|
Vben
authored
|
20
|
backgroundColor: '#018ffb',
|
|
21
22
|
}"
/>
|
vben
authored
|
23
|
<a-button type="primary" class="ml-2" @click="handleBtnClick(el3)"> 还原 </a-button>
|
|
24
25
26
27
|
</div>
<div class="flex justify-center p-4 items-center bg-gray-700">
<BasicDragVerify ref="el4" @success="handleSuccess">
|
|
28
|
<template #actionIcon="isPassing">
|
|
29
30
31
32
|
<BugOutlined v-if="isPassing" />
<RightOutlined v-else />
</template>
</BasicDragVerify>
|
vben
authored
|
33
|
<a-button type="primary" class="ml-2" @click="handleBtnClick(el4)"> 还原 </a-button>
|
|
34
35
36
37
|
</div>
<div class="flex justify-center p-4 items-center bg-gray-700">
<BasicDragVerify ref="el5" @success="handleSuccess">
|
|
38
|
<template #text="isPassing">
|
|
39
40
41
42
43
44
45
46
47
48
|
<div v-if="isPassing">
<BugOutlined />
成功
</div>
<div v-else>
拖动
<RightOutlined />
</div>
</template>
</BasicDragVerify>
|
vben
authored
|
49
|
<a-button type="primary" class="ml-2" @click="handleBtnClick(el5)"> 还原 </a-button>
|
|
50
|
</div>
|
vben
authored
|
51
|
</PageWrapper>
|
|
52
53
54
55
56
57
|
</template>
<script lang="ts">
import { defineComponent, ref } from 'vue';
import { BasicDragVerify, DragVerifyActionType, PassingData } from '/@/components/Verify/index';
import { useMessage } from '/@/hooks/web/useMessage';
import { BugOutlined, RightOutlined } from '@ant-design/icons-vue';
|
vben
authored
|
58
59
|
import { PageWrapper } from '/@/components/Page';
|
|
60
|
export default defineComponent({
|
vben
authored
|
61
|
components: { BasicDragVerify, BugOutlined, RightOutlined, PageWrapper },
|
|
62
63
|
setup() {
const { createMessage } = useMessage();
|
vben
authored
|
64
65
66
67
68
|
const el1 = ref<Nullable<DragVerifyActionType>>(null);
const el2 = ref<Nullable<DragVerifyActionType>>(null);
const el3 = ref<Nullable<DragVerifyActionType>>(null);
const el4 = ref<Nullable<DragVerifyActionType>>(null);
const el5 = ref<Nullable<DragVerifyActionType>>(null);
|
|
69
70
71
72
73
74
|
function handleSuccess(data: PassingData) {
const { time } = data;
createMessage.success(`校验成功,耗时${time}秒`);
}
|
vben
authored
|
75
|
function handleBtnClick(elRef: Nullable<DragVerifyActionType>) {
|
|
76
77
78
|
if (!elRef) {
return;
}
|
vben
authored
|
79
|
elRef.resume();
|
|
80
81
82
83
84
85
86
87
88
89
90
91
92
|
}
return {
handleSuccess,
el1,
el2,
el3,
el4,
el5,
handleBtnClick,
};
},
});
</script>
|
nebv
authored
|
93
94
|
<style lang="less" scoped>
.bg-gray-700 {
|
Vben
authored
|
95
|
background-color: #4a5568;
|
nebv
authored
|
96
97
|
}
</style>
|