优化
This commit is contained in:
parent
f0778b4ba2
commit
d431af532d
@ -98,7 +98,9 @@ watch(
|
|||||||
watch(
|
watch(
|
||||||
() => props.index,
|
() => props.index,
|
||||||
(newVal, oldVal) => {
|
(newVal, oldVal) => {
|
||||||
// console.log('watch-index', newVal, oldVal,props.list, props.list[newVal].id)
|
if (!props.list.length) return
|
||||||
|
console.log('watch-index', newVal, oldVal)
|
||||||
|
bus.emit(EVENT_KEY.CURRENT_ITEM, props.list[newVal])
|
||||||
bus.emit(EVENT_KEY.SINGLE_CLICK_BROADCAST, {
|
bus.emit(EVENT_KEY.SINGLE_CLICK_BROADCAST, {
|
||||||
uniqueId: props.uniqueId,
|
uniqueId: props.uniqueId,
|
||||||
index: newVal,
|
index: newVal,
|
||||||
@ -111,15 +113,18 @@ watch(
|
|||||||
type: EVENT_KEY.ITEM_STOP
|
type: EVENT_KEY.ITEM_STOP
|
||||||
})
|
})
|
||||||
}, 200)
|
}, 200)
|
||||||
})
|
},)
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => props.active,
|
() => props.active,
|
||||||
(newVal, oldVal) => {
|
(newVal, oldVal) => {
|
||||||
// console.log('newVal', newVal, 'oldVal', oldVal)
|
|
||||||
if (newVal && !props.list.length) {
|
if (newVal && !props.list.length) {
|
||||||
return emit('refresh')
|
return emit('refresh')
|
||||||
}
|
}
|
||||||
|
console.log('active', 'newVal', newVal, 'oldVal', oldVal)
|
||||||
|
if (newVal) {
|
||||||
|
bus.emit(EVENT_KEY.CURRENT_ITEM, props.list[state.localIndex])
|
||||||
|
}
|
||||||
bus.emit(EVENT_KEY.SINGLE_CLICK_BROADCAST, {
|
bus.emit(EVENT_KEY.SINGLE_CLICK_BROADCAST, {
|
||||||
uniqueId: props.uniqueId,
|
uniqueId: props.uniqueId,
|
||||||
index: state.localIndex,
|
index: state.localIndex,
|
||||||
@ -133,6 +138,7 @@ onMounted(() => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
function insertContent(list = props.list) {
|
function insertContent(list = props.list) {
|
||||||
|
if (!list.length) return
|
||||||
$(wrapperEl.value).empty()
|
$(wrapperEl.value).empty()
|
||||||
let half = (props.virtualTotal - 1) / 2
|
let half = (props.virtualTotal - 1) / 2
|
||||||
let start = 0
|
let start = 0
|
||||||
@ -164,6 +170,8 @@ function insertContent(list = props.list) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
state.wrapper.childrenLength = wrapperEl.value.children.length
|
state.wrapper.childrenLength = wrapperEl.value.children.length
|
||||||
|
bus.emit(EVENT_KEY.CURRENT_ITEM, list[state.localIndex])
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function dislike(item) {
|
function dislike(item) {
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import bus from "../../utils/bus";
|
import bus from "@/utils/bus";
|
||||||
import Utils from '../../utils'
|
import Utils from '@/utils'
|
||||||
import {SlideType} from "../../utils/const_var";
|
import {SlideType} from "@/utils/const_var";
|
||||||
import GM from "../../utils";
|
import GM from "@/utils";
|
||||||
|
|
||||||
export function slideInit(el, state, type) {
|
export function slideInit(el, state, type) {
|
||||||
state.wrapper.width = GM.$getCss(el, 'width')
|
state.wrapper.width = GM.$getCss(el, 'width')
|
||||||
|
|||||||
@ -169,6 +169,9 @@ function delayShowDialog(cb) {
|
|||||||
}, 400)
|
}, 400)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bus.on(EVENT_KEY.CURRENT_ITEM, item => {
|
||||||
|
console.log('item', item)
|
||||||
|
})
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
bus.on(EVENT_KEY.ENTER_FULLSCREEN, (e) => state.fullScreen = true)
|
bus.on(EVENT_KEY.ENTER_FULLSCREEN, (e) => state.fullScreen = true)
|
||||||
bus.on(EVENT_KEY.EXIT_FULLSCREEN, (e) => state.fullScreen = false)
|
bus.on(EVENT_KEY.EXIT_FULLSCREEN, (e) => state.fullScreen = false)
|
||||||
|
|||||||
@ -40,13 +40,6 @@ const props = defineProps({
|
|||||||
default: void 0
|
default: void 0
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
const emit = defineEmits([
|
|
||||||
'update:item',
|
|
||||||
'goUserInfo',
|
|
||||||
'showComments',
|
|
||||||
'showShare',
|
|
||||||
'goMusic',
|
|
||||||
])
|
|
||||||
|
|
||||||
const store = useStore()
|
const store = useStore()
|
||||||
const loading = computed(() => store.state.loading)
|
const loading = computed(() => store.state.loading)
|
||||||
|
|||||||
@ -61,4 +61,5 @@ export const EVENT_KEY = {
|
|||||||
GO_USERINFO: 'GO_USERINFO',
|
GO_USERINFO: 'GO_USERINFO',
|
||||||
SHOW_SHARE: 'SHOW_SHARE',
|
SHOW_SHARE: 'SHOW_SHARE',
|
||||||
UPDATE_ITEM: 'UPDATE_ITEM',
|
UPDATE_ITEM: 'UPDATE_ITEM',
|
||||||
|
CURRENT_ITEM: 'CURRENT_ITEM',
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user