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