mirror of
https://github.com/ZiuChen/ClipboardManager.git
synced 2025-06-08 14:24:03 +08:00
refactor: 调整导航SidePanel插槽内结构 多选按钮初始化
This commit is contained in:
parent
6f02943cb6
commit
eaa0e762c0
@ -192,9 +192,11 @@ db.init()
|
|||||||
const remove = (item) => db.removeItemViaId(item.id)
|
const remove = (item) => db.removeItemViaId(item.id)
|
||||||
|
|
||||||
const select = () => document.querySelector('.clip-search input').select()
|
const select = () => document.querySelector('.clip-search input').select()
|
||||||
const focus = () => {
|
const focus = (isBlur = false) => {
|
||||||
document.querySelector('.clip-search-input').style.display !== 'none'
|
return document.querySelector('.clip-search').style.display !== 'none'
|
||||||
? document.querySelector('.clip-search-input')?.focus()
|
? isBlur
|
||||||
|
? document.querySelector('.clip-search-input')?.blur()
|
||||||
|
: document.querySelector('.clip-search-input')?.focus()
|
||||||
: (document.querySelector('.clip-search-btn')?.click(),
|
: (document.querySelector('.clip-search-btn')?.click(),
|
||||||
document.querySelector('.clip-search-input')?.focus())
|
document.querySelector('.clip-search-input')?.focus())
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,8 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="clip-search">
|
<div class="clip-search">
|
||||||
<span class="clip-search-btn" v-show="!filterText && !isFocus" @click="toggleFocusStatus(true)"
|
|
||||||
>🔍</span
|
|
||||||
>
|
|
||||||
<input
|
<input
|
||||||
class="clip-search-input"
|
class="clip-search-input"
|
||||||
@focusout="toggleFocusStatus(false)"
|
@focusout="handleFocusOut"
|
||||||
v-show="filterText || isFocus"
|
|
||||||
v-model="filterText"
|
v-model="filterText"
|
||||||
type="text"
|
type="text"
|
||||||
:placeholder="itemCount ? `🔍 在${itemCount}条历史中检索...` : '🔍 检索剪贴板历史...'"
|
:placeholder="itemCount ? `🔍 在${itemCount}条历史中检索...` : '🔍 检索剪贴板历史...'"
|
||||||
@ -27,22 +23,27 @@ const props = defineProps({
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const isFocus = ref(true)
|
|
||||||
const toggleFocusStatus = (status) =>
|
|
||||||
status ? ((isFocus.value = status), nextTick(() => window.focus())) : (isFocus.value = status)
|
|
||||||
|
|
||||||
const filterText = ref('')
|
const filterText = ref('')
|
||||||
const emit = defineEmits(['update:modelValue'])
|
const emit = defineEmits(['update:modelValue', 'onPanelHide'])
|
||||||
// filterText变了 通知父组件修改 modelValue的值
|
// filterText变了 通知父组件修改 modelValue的值
|
||||||
watch(filterText, (val) => emit('update:modelValue', val))
|
watch(filterText, (val) => emit('update:modelValue', val))
|
||||||
|
|
||||||
|
const handleFocusOut = () => {
|
||||||
|
if (!filterText.value) {
|
||||||
|
emit('onPanelHide')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// modelValue变了 更新 filterText的值
|
// modelValue变了 更新 filterText的值
|
||||||
watch(
|
watch(
|
||||||
() => props.modelValue,
|
() => props.modelValue,
|
||||||
(val) => (filterText.value = val)
|
(val) => (filterText.value = val)
|
||||||
)
|
)
|
||||||
|
|
||||||
const clear = () => emit('update:modelValue', '')
|
const clear = () => {
|
||||||
|
emit('update:modelValue', '')
|
||||||
|
nextTick(() => window.focus())
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="less" scoped>
|
<style lang="less" scoped>
|
||||||
|
@ -4,12 +4,6 @@
|
|||||||
justify-content: flex-end;
|
justify-content: flex-end;
|
||||||
min-width: 300px;
|
min-width: 300px;
|
||||||
margin-right: 10px;
|
margin-right: 10px;
|
||||||
.clip-search-btn {
|
|
||||||
width: 25px;
|
|
||||||
height: 25px;
|
|
||||||
padding: 10px;
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
.clip-search-input {
|
.clip-search-input {
|
||||||
width: 90%;
|
width: 90%;
|
||||||
/* normalize */
|
/* normalize */
|
||||||
|
@ -34,4 +34,10 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.clip-switch-btn {
|
||||||
|
width: 25px;
|
||||||
|
height: 25px;
|
||||||
|
padding: 10px;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,16 @@
|
|||||||
></ClipFullData>
|
></ClipFullData>
|
||||||
<ClipSwitch ref="ClipSwitchRef" @onNavClick="handleNavClick">
|
<ClipSwitch ref="ClipSwitchRef" @onNavClick="handleNavClick">
|
||||||
<template #SidePanel>
|
<template #SidePanel>
|
||||||
<ClipSearch v-model="filterText" :itemCount="list.length"></ClipSearch>
|
<div v-show="!isSearchPanelExpand">
|
||||||
|
<span class="clip-switch-btn"> 👆 </span>
|
||||||
|
<span class="clip-switch-btn clip-search-btn" @click="handleSearchBtnClick"> 🔍 </span>
|
||||||
|
</div>
|
||||||
|
<ClipSearch
|
||||||
|
v-show="isSearchPanelExpand"
|
||||||
|
@onPanelHide="isSearchPanelExpand = false"
|
||||||
|
v-model="filterText"
|
||||||
|
:itemCount="list.length"
|
||||||
|
></ClipSearch>
|
||||||
</template>
|
</template>
|
||||||
</ClipSwitch>
|
</ClipSwitch>
|
||||||
<div class="clip-break"></div>
|
<div class="clip-break"></div>
|
||||||
@ -24,13 +33,22 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, watch, onMounted, computed } from 'vue'
|
import { ref, watch, onMounted, computed, nextTick } from 'vue'
|
||||||
import ClipItemList from '../cpns/ClipItemList.vue'
|
import ClipItemList from '../cpns/ClipItemList.vue'
|
||||||
import ClipFullData from '../cpns/ClipFullData.vue'
|
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'
|
||||||
import ClipFloatBtn from '../cpns/ClipFloatBtn.vue'
|
import ClipFloatBtn from '../cpns/ClipFloatBtn.vue'
|
||||||
|
|
||||||
|
const isMultiple = ref(false)
|
||||||
|
|
||||||
|
const isSearchPanelExpand = ref(false)
|
||||||
|
|
||||||
|
const handleSearchBtnClick = () => {
|
||||||
|
isSearchPanelExpand.value = true
|
||||||
|
nextTick(() => window.focus())
|
||||||
|
}
|
||||||
|
|
||||||
const GAP = 15 // 懒加载 每次添加的条数
|
const GAP = 15 // 懒加载 每次添加的条数
|
||||||
const offset = ref(0) // 懒加载 偏移量
|
const offset = ref(0) // 懒加载 偏移量
|
||||||
const filterText = ref('') // 搜索框绑定值
|
const filterText = ref('') // 搜索框绑定值
|
||||||
@ -164,9 +182,13 @@ onMounted(() => {
|
|||||||
window.focus()
|
window.focus()
|
||||||
} else if (isExit) {
|
} else if (isExit) {
|
||||||
if (filterText.value) {
|
if (filterText.value) {
|
||||||
|
// 有筛选词 先清空筛选词
|
||||||
filterText.value = ''
|
filterText.value = ''
|
||||||
e.stopPropagation()
|
} else {
|
||||||
|
// 无筛选词 隐藏搜索框
|
||||||
|
window.focus(true)
|
||||||
}
|
}
|
||||||
|
e.stopPropagation()
|
||||||
} else if (ctrlKey || metaKey || isArrow || isEnter) {
|
} else if (ctrlKey || metaKey || isArrow || isEnter) {
|
||||||
// 仅有 Ctrl时 什么也不执行 (utools模拟执行粘贴时触发)
|
// 仅有 Ctrl时 什么也不执行 (utools模拟执行粘贴时触发)
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user