diff --git a/src/components/slide/SlideVerticalInfinite.vue b/src/components/slide/SlideVerticalInfinite.vue index 89203a6..e0fb918 100644 --- a/src/components/slide/SlideVerticalInfinite.vue +++ b/src/components/slide/SlideVerticalInfinite.vue @@ -98,7 +98,9 @@ watch( watch( () => props.index, (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, { uniqueId: props.uniqueId, index: newVal, @@ -111,15 +113,18 @@ watch( type: EVENT_KEY.ITEM_STOP }) }, 200) - }) + },) watch( () => props.active, (newVal, oldVal) => { - // console.log('newVal', newVal, 'oldVal', oldVal) if (newVal && !props.list.length) { 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, { uniqueId: props.uniqueId, index: state.localIndex, @@ -133,6 +138,7 @@ onMounted(() => { }) function insertContent(list = props.list) { + if (!list.length) return $(wrapperEl.value).empty() let half = (props.virtualTotal - 1) / 2 let start = 0 @@ -164,6 +170,8 @@ function insertContent(list = props.list) { }) } state.wrapper.childrenLength = wrapperEl.value.children.length + bus.emit(EVENT_KEY.CURRENT_ITEM, list[state.localIndex]) + } function dislike(item) { diff --git a/src/components/slide/common.js b/src/components/slide/common.js index 8267367..32184c9 100644 --- a/src/components/slide/common.js +++ b/src/components/slide/common.js @@ -1,7 +1,7 @@ -import bus from "../../utils/bus"; -import Utils from '../../utils' -import {SlideType} from "../../utils/const_var"; -import GM from "../../utils"; +import bus from "@/utils/bus"; +import Utils from '@/utils' +import {SlideType} from "@/utils/const_var"; +import GM from "@/utils"; export function slideInit(el, state, type) { state.wrapper.width = GM.$getCss(el, 'width') diff --git a/src/pages/home/index.vue b/src/pages/home/index.vue index 1f5787b..4ca7095 100644 --- a/src/pages/home/index.vue +++ b/src/pages/home/index.vue @@ -169,6 +169,9 @@ function delayShowDialog(cb) { }, 400) } +bus.on(EVENT_KEY.CURRENT_ITEM, item => { + console.log('item', item) +}) onMounted(() => { bus.on(EVENT_KEY.ENTER_FULLSCREEN, (e) => state.fullScreen = true) bus.on(EVENT_KEY.EXIT_FULLSCREEN, (e) => state.fullScreen = false) diff --git a/src/pages/home/slide/SlideList.vue b/src/pages/home/slide/SlideList.vue index 9ccd76c..473ecd1 100644 --- a/src/pages/home/slide/SlideList.vue +++ b/src/pages/home/slide/SlideList.vue @@ -40,13 +40,6 @@ const props = defineProps({ default: void 0 }, }) -const emit = defineEmits([ - 'update:item', - 'goUserInfo', - 'showComments', - 'showShare', - 'goMusic', -]) const store = useStore() const loading = computed(() => store.state.loading) diff --git a/src/utils/bus.js b/src/utils/bus.js index 8c76444..f3ff97a 100644 --- a/src/utils/bus.js +++ b/src/utils/bus.js @@ -61,4 +61,5 @@ export const EVENT_KEY = { GO_USERINFO: 'GO_USERINFO', SHOW_SHARE: 'SHOW_SHARE', UPDATE_ITEM: 'UPDATE_ITEM', + CURRENT_ITEM: 'CURRENT_ITEM', }