This commit is contained in:
zyronon 2023-02-22 01:48:39 +08:00
parent f0778b4ba2
commit d431af532d
5 changed files with 19 additions and 14 deletions

View File

@ -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) {

View File

@ -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')

View File

@ -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)

View File

@ -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)

View File

@ -61,4 +61,5 @@ export const EVENT_KEY = {
GO_USERINFO: 'GO_USERINFO',
SHOW_SHARE: 'SHOW_SHARE',
UPDATE_ITEM: 'UPDATE_ITEM',
CURRENT_ITEM: 'CURRENT_ITEM',
}