Browse Source

优化

pull/29/head
zyronon 2 years ago
parent
commit
d431af532d
  1. 14
      src/components/slide/SlideVerticalInfinite.vue
  2. 8
      src/components/slide/common.js
  3. 3
      src/pages/home/index.vue
  4. 7
      src/pages/home/slide/SlideList.vue
  5. 1
      src/utils/bus.js

14
src/components/slide/SlideVerticalInfinite.vue

@ -98,7 +98,9 @@ watch( @@ -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( @@ -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(() => { @@ -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) { @@ -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) {

8
src/components/slide/common.js

@ -1,7 +1,7 @@ @@ -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')

3
src/pages/home/index.vue

@ -169,6 +169,9 @@ function delayShowDialog(cb) { @@ -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)

7
src/pages/home/slide/SlideList.vue

@ -40,13 +40,6 @@ const props = defineProps({ @@ -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)

1
src/utils/bus.js

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

Loading…
Cancel
Save