优化右击菜单逻辑
parent
fbd2a57a35
commit
c9d0aafbfa
|
@ -37,7 +37,7 @@ export default {
|
||||||
},
|
},
|
||||||
location: {
|
location: {
|
||||||
handler(n) {
|
handler(n) {
|
||||||
this.listStyles.left = n.x + 'px'
|
this.listStyles.left = n.x + 2 + 'px'
|
||||||
this.listStyles.top = n.y + 'px'
|
this.listStyles.top = n.y + 'px'
|
||||||
if (this.show) {
|
if (this.show) {
|
||||||
if (this.listStyles.transitionProperty != this.transition2) this.listStyles.transitionProperty = this.transition2
|
if (this.listStyles.transitionProperty != this.transition2) this.listStyles.transitionProperty = this.transition2
|
||||||
|
@ -89,10 +89,10 @@ export default {
|
||||||
const offsetHeight = containerHeight - top - listHeight
|
const offsetHeight = containerHeight - top - listHeight
|
||||||
let x = 0
|
let x = 0
|
||||||
let y = 0
|
let y = 0
|
||||||
if (containerWidth > listWidth && offsetWidth < 0) {
|
if (containerWidth > listWidth && offsetWidth < 17) {
|
||||||
x = offsetWidth - 15
|
x = offsetWidth - 17
|
||||||
}
|
}
|
||||||
if (containerHeight > listHeight && offsetHeight < 0) {
|
if (containerHeight > listHeight && offsetHeight < 5) {
|
||||||
y = offsetHeight - 5
|
y = offsetHeight - 5
|
||||||
}
|
}
|
||||||
return `${x}px, ${y}px`
|
return `${x}px, ${y}px`
|
||||||
|
|
|
@ -48,7 +48,7 @@ div(:class="$style.songList")
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { mapGetters } from 'vuex'
|
import { mapGetters } from 'vuex'
|
||||||
import { scrollTo, clipboardWriteText, assertApiSupport, findParentNode } from '../../utils'
|
import { scrollTo, clipboardWriteText, assertApiSupport } from '../../utils'
|
||||||
import musicSdk from '../../utils/music'
|
import musicSdk from '../../utils/music'
|
||||||
export default {
|
export default {
|
||||||
name: 'MaterialSongList',
|
name: 'MaterialSongList',
|
||||||
|
@ -340,7 +340,7 @@ export default {
|
||||||
let dom_selected = this.$refs.dom_tbody.querySelector('tr.selected')
|
let dom_selected = this.$refs.dom_tbody.querySelector('tr.selected')
|
||||||
if (dom_selected) dom_selected.classList.remove('selected')
|
if (dom_selected) dom_selected.classList.remove('selected')
|
||||||
this.$refs.dom_tbody.querySelectorAll('tr')[index].classList.add('selected')
|
this.$refs.dom_tbody.querySelectorAll('tr')[index].classList.add('selected')
|
||||||
let dom_td = findParentNode(event.target, 'TD')
|
let dom_td = event.target.closest('td')
|
||||||
this.listMenu.rightClickItemIndex = index
|
this.listMenu.rightClickItemIndex = index
|
||||||
this.listMenu.menuLocation.x = dom_td.offsetLeft + event.offsetX
|
this.listMenu.menuLocation.x = dom_td.offsetLeft + event.offsetX
|
||||||
this.listMenu.menuLocation.y = dom_td.offsetParent.offsetTop + dom_td.offsetTop + event.offsetY - this.$refs.dom_scrollContent.scrollTop
|
this.listMenu.menuLocation.y = dom_td.offsetParent.offsetTop + dom_td.offsetTop + event.offsetY - this.$refs.dom_scrollContent.scrollTop
|
||||||
|
|
|
@ -321,9 +321,6 @@ export const asyncSetArray = (from, to, num = 100) => new Promise(resolve => {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
export const findParentNode = (target, tagName) => target.tagName == tagName ? target : target === document ? null : findParentNode(target.parentNode, tagName)
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取缓存大小
|
* 获取缓存大小
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -36,7 +36,7 @@ div(:class="$style.download")
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { mapGetters, mapActions, mapMutations } from 'vuex'
|
import { mapGetters, mapActions, mapMutations } from 'vuex'
|
||||||
import { checkPath, openDirInExplorer, findParentNode, openUrl } from '../utils'
|
import { checkPath, openDirInExplorer, openUrl } from '../utils'
|
||||||
import musicSdk from '../utils/music'
|
import musicSdk from '../utils/music'
|
||||||
import path from 'path'
|
import path from 'path'
|
||||||
|
|
||||||
|
@ -370,7 +370,7 @@ export default {
|
||||||
let dom_selected = this.$refs.dom_tbody.querySelector('tr.selected')
|
let dom_selected = this.$refs.dom_tbody.querySelector('tr.selected')
|
||||||
if (dom_selected) dom_selected.classList.remove('selected')
|
if (dom_selected) dom_selected.classList.remove('selected')
|
||||||
this.$refs.dom_tbody.querySelectorAll('tr')[index].classList.add('selected')
|
this.$refs.dom_tbody.querySelectorAll('tr')[index].classList.add('selected')
|
||||||
let dom_td = findParentNode(event.target, 'TD')
|
let dom_td = event.target.closest('td')
|
||||||
this.listMenu.rightClickItemIndex = index
|
this.listMenu.rightClickItemIndex = index
|
||||||
this.listMenu.menuLocation.x = dom_td.offsetLeft + event.offsetX
|
this.listMenu.menuLocation.x = dom_td.offsetLeft + event.offsetX
|
||||||
this.listMenu.menuLocation.y = dom_td.offsetTop + event.offsetY - this.$refs.dom_scrollContent.scrollTop
|
this.listMenu.menuLocation.y = dom_td.offsetTop + event.offsetY - this.$refs.dom_scrollContent.scrollTop
|
||||||
|
|
|
@ -70,7 +70,7 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { mapMutations, mapGetters, mapActions } from 'vuex'
|
import { mapMutations, mapGetters, mapActions } from 'vuex'
|
||||||
import { throttle, scrollTo, clipboardWriteText, assertApiSupport, findParentNode, openUrl } from '../utils'
|
import { throttle, scrollTo, clipboardWriteText, assertApiSupport, openUrl } from '../utils'
|
||||||
import musicSdk from '../utils/music'
|
import musicSdk from '../utils/music'
|
||||||
export default {
|
export default {
|
||||||
name: 'List',
|
name: 'List',
|
||||||
|
@ -687,7 +687,7 @@ export default {
|
||||||
let dom_selected = this.$refs.dom_tbody.querySelector('tr.selected')
|
let dom_selected = this.$refs.dom_tbody.querySelector('tr.selected')
|
||||||
if (dom_selected) dom_selected.classList.remove('selected')
|
if (dom_selected) dom_selected.classList.remove('selected')
|
||||||
this.$refs.dom_tbody.querySelectorAll('tr')[index].classList.add('selected')
|
this.$refs.dom_tbody.querySelectorAll('tr')[index].classList.add('selected')
|
||||||
let dom_td = findParentNode(event.target, 'TD')
|
let dom_td = event.target.closest('td')
|
||||||
|
|
||||||
this.listMenu.rightClickItemIndex = index
|
this.listMenu.rightClickItemIndex = index
|
||||||
this.listMenu.menuLocation.x = dom_td.offsetLeft + event.offsetX
|
this.listMenu.menuLocation.x = dom_td.offsetLeft + event.offsetX
|
||||||
|
|
|
@ -61,7 +61,7 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { mapGetters, mapActions, mapMutations } from 'vuex'
|
import { mapGetters, mapActions, mapMutations } from 'vuex'
|
||||||
import { scrollTo, clipboardWriteText, assertApiSupport, findParentNode, openUrl } from '../utils'
|
import { scrollTo, clipboardWriteText, assertApiSupport, openUrl } from '../utils'
|
||||||
import musicSdk from '../utils/music'
|
import musicSdk from '../utils/music'
|
||||||
export default {
|
export default {
|
||||||
name: 'Search',
|
name: 'Search',
|
||||||
|
@ -427,7 +427,7 @@ export default {
|
||||||
let dom_selected = this.$refs.dom_tbody.querySelector('tr.selected')
|
let dom_selected = this.$refs.dom_tbody.querySelector('tr.selected')
|
||||||
if (dom_selected) dom_selected.classList.remove('selected')
|
if (dom_selected) dom_selected.classList.remove('selected')
|
||||||
this.$refs.dom_tbody.querySelectorAll('tr')[index].classList.add('selected')
|
this.$refs.dom_tbody.querySelectorAll('tr')[index].classList.add('selected')
|
||||||
let dom_td = findParentNode(event.target, 'TD')
|
let dom_td = event.target.closest('td')
|
||||||
this.listMenu.rightClickItemIndex = index
|
this.listMenu.rightClickItemIndex = index
|
||||||
this.listMenu.menuLocation.x = dom_td.offsetLeft + event.offsetX
|
this.listMenu.menuLocation.x = dom_td.offsetLeft + event.offsetX
|
||||||
this.listMenu.menuLocation.y = dom_td.offsetTop + event.offsetY - this.$refs.dom_scrollContent.scrollTop
|
this.listMenu.menuLocation.y = dom_td.offsetTop + event.offsetY - this.$refs.dom_scrollContent.scrollTop
|
||||||
|
|
Loading…
Reference in New Issue