mirror of
https://github.com/tusen-ai/naive-ui.git
synced 2024-12-21 04:50:14 +08:00
refactor(table): clean code
This commit is contained in:
parent
a715dfd545
commit
29577a22d2
@ -290,10 +290,12 @@ export default defineComponent({
|
|||||||
onKeydown={handleKeyDown}
|
onKeydown={handleKeyDown}
|
||||||
onClick={handleClick}
|
onClick={handleClick}
|
||||||
onMousedown={() => {
|
onMousedown={() => {
|
||||||
const userCallBack = window.onselectstart
|
const preventDefault = (e: Event): void => {
|
||||||
window.onselectstart = () => false
|
e.preventDefault()
|
||||||
|
}
|
||||||
|
window.addEventListener('selectstart', preventDefault)
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
window.onselectstart = userCallBack
|
window.removeEventListener('selectstart', preventDefault)
|
||||||
}, 0)
|
}, 0)
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
@ -143,12 +143,9 @@ export default defineComponent({
|
|||||||
checked: boolean,
|
checked: boolean,
|
||||||
shiftKey: boolean
|
shiftKey: boolean
|
||||||
): void {
|
): void {
|
||||||
const lastKey = lastSelectedKey
|
|
||||||
lastSelectedKey = tmNode.key
|
|
||||||
|
|
||||||
if (shiftKey) {
|
if (shiftKey) {
|
||||||
const lastIndex = paginatedDataRef.value.findIndex(
|
const lastIndex = paginatedDataRef.value.findIndex(
|
||||||
(item) => item.key === lastKey
|
(item) => item.key === lastSelectedKey
|
||||||
)
|
)
|
||||||
if (lastIndex !== -1) {
|
if (lastIndex !== -1) {
|
||||||
const currentIndex = paginatedDataRef.value.findIndex(
|
const currentIndex = paginatedDataRef.value.findIndex(
|
||||||
@ -167,6 +164,8 @@ export default defineComponent({
|
|||||||
} else {
|
} else {
|
||||||
doUncheck(rowKeysToCheck)
|
doUncheck(rowKeysToCheck)
|
||||||
}
|
}
|
||||||
|
lastSelectedKey = tmNode.key
|
||||||
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -175,6 +174,7 @@ export default defineComponent({
|
|||||||
} else {
|
} else {
|
||||||
doUncheck(tmNode.key)
|
doUncheck(tmNode.key)
|
||||||
}
|
}
|
||||||
|
lastSelectedKey = tmNode.key
|
||||||
}
|
}
|
||||||
function getScrollContainer (): HTMLElement | null {
|
function getScrollContainer (): HTMLElement | null {
|
||||||
if (virtualScrollRef.value) {
|
if (virtualScrollRef.value) {
|
||||||
|
Loading…
Reference in New Issue
Block a user