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

View File

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

View File

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