refactor: 调整悬浮按钮代码实现

This commit is contained in:
ZiuChen 2022-09-08 18:45:15 +08:00
parent 1c4fed4f01
commit 4576b44c29
3 changed files with 23 additions and 12 deletions

View File

@ -1,18 +1,16 @@
<template> <template>
<div class="clip-float-btn"> <div class="clip-float-btn" @click="handleBtnClick">
<div @click="restoreDataBase">🧭</div> <div>{{ props.icon }}</div>
</div> </div>
</template> </template>
<script setup> <script setup>
// const emit = defineEmits(['onBtnClick']) const emit = defineEmits(['onBtnClick'])
// const handleBtnClick = () => emit('onBtnClick') const handleBtnClick = () => emit('onBtnClick')
const restoreDataBase = () => { const props = defineProps({
// icon: {
const flag = window.confirm('确定要清空剪贴板记录吗?') type: String,
if (flag) { default: '🌎'
window.db.emptyDataBase()
updateShowList('all')
} }
} })
</script> </script>

View File

@ -19,4 +19,7 @@
background-color: @primary-color; background-color: @primary-color;
transition: all 0.15s; transition: all 0.15s;
} }
div {
margin-bottom: 5px;
}
} }

View File

@ -1,6 +1,6 @@
<template> <template>
<div class="main"> <div class="main">
<ClipFloatBtn></ClipFloatBtn> <ClipFloatBtn :icon="'🧭'" @onBtnClick="restoreDataBase"></ClipFloatBtn>
<ClipFullData <ClipFullData
:isShow="fullDataShow" :isShow="fullDataShow"
:fullData="fullData" :fullData="fullData"
@ -67,6 +67,15 @@ const updateShowList = (type) => {
window.toTop() window.toTop()
} }
const restoreDataBase = () => {
//
const flag = window.confirm('确定要清空剪贴板记录吗?')
if (flag) {
window.db.emptyDataBase()
updateShowList('all')
}
}
const handleNavClick = (type) => { const handleNavClick = (type) => {
updateShowList(type) updateShowList(type)
offset.value = 0 // offset.value = 0 //
@ -160,6 +169,7 @@ onMounted(() => {
} }
} else if (ctrlKey || metaKey || isArrow || isEnter) { } else if (ctrlKey || metaKey || isArrow || isEnter) {
// Ctrl (utools) // Ctrl (utools)
e.preventDefault()
} else { } else {
window.focus() // window.focus() //
} }