refactor: 优化代码执行细节

This commit is contained in:
ZiuChen 2022-08-15 15:28:40 +08:00
parent 6b63c7a4f7
commit de5ac3476e

View File

@ -24,18 +24,14 @@ import ClipFullData from '../cpns/ClipFullData.vue'
import ClipSearch from '../cpns/ClipSearch.vue'
import ClipSwitch from '../cpns/ClipSwitch.vue'
const ClipSwitchRef = ref()
const GAP = 10 //
const offset = ref(0) //
const filterText = ref('') //
const list = ref([]) //
const showList = ref([]) //
const fullData = ref({ type: 'text', data: '' })
const fullDataShow = ref(false)
const filterText = ref('')
const GAP = 10
const list = ref([])
const showList = ref([])
const offset = ref(0)
const updateShowList = (type) => {
//
if (type === 'all') {
if (filterText.value) {
//
@ -63,9 +59,12 @@ const updateShowList = (type) => {
document.scrollingElement.scrollTop = 0
}
const fullData = ref({ type: 'text', data: '' })
const fullDataShow = ref(false)
const toggleFullData = (item) => {
// only text || file
// ()
const { type, data } = item
// type: 'text' | 'file'
if (type === 'text') {
fullData.value.type = 'text'
fullData.value.data = data
@ -77,6 +76,7 @@ const toggleFullData = (item) => {
}
const restoreDataBase = () => {
//
const flag = window.confirm('确定要清空剪贴板记录吗?')
if (flag) {
window.db.emptyDataBase()
@ -84,8 +84,9 @@ const restoreDataBase = () => {
}
}
const ClipSwitchRef = ref()
onMounted(() => {
// Ref
// Ref
const activeTab = computed(() => ClipSwitchRef.value.activeTab)
//
@ -107,11 +108,7 @@ onMounted(() => {
}, 500)
//
watch(filterText, (val) => {
console.log(val)
console.log(ClipSwitchRef)
updateShowList(activeTab.value)
})
watch(filterText, (val) => updateShowList(activeTab.value))
//
document.addEventListener('scroll', (e) => {
@ -175,7 +172,6 @@ onMounted(() => {
transition: all 0.15s;
}
}
.clip-break {
height: 55px;
}