|
|
@ -287,7 +287,7 @@ export default { |
|
|
this.$root.$emit('video-layout-updated', this.layout) |
|
|
this.$root.$emit('video-layout-updated', this.layout) |
|
|
if (this.channels.length) { |
|
|
if (this.channels.length) { |
|
|
this.streamsInitialized = true |
|
|
this.streamsInitialized = true |
|
|
this.populateRandomLayout() |
|
|
|
|
|
|
|
|
this.populateDefaultLayout() |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
deactivated() { |
|
|
deactivated() { |
|
|
@ -382,7 +382,7 @@ export default { |
|
|
}) |
|
|
}) |
|
|
if (initializeStreams && this.pageActive && !this.streamsInitialized && this.channels.length) { |
|
|
if (initializeStreams && this.pageActive && !this.streamsInitialized && this.channels.length) { |
|
|
this.streamsInitialized = true |
|
|
this.streamsInitialized = true |
|
|
this.populateRandomLayout() |
|
|
|
|
|
|
|
|
this.populateDefaultLayout() |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
isCameraCodeName(name) { |
|
|
isCameraCodeName(name) { |
|
|
@ -399,19 +399,10 @@ export default { |
|
|
if (treeCodes.size) this.channels = this.channels.filter(item => treeCodes.has(item.cameraCode)) |
|
|
if (treeCodes.size) this.channels = this.channels.filter(item => treeCodes.has(item.cameraCode)) |
|
|
this.setAvailableChannels(channels, true) |
|
|
this.setAvailableChannels(channels, true) |
|
|
}, |
|
|
}, |
|
|
shuffleChannels() { |
|
|
|
|
|
const channels = this.channels.slice() |
|
|
|
|
|
for (let index = channels.length - 1; index > 0; index -= 1) { |
|
|
|
|
|
const randomIndex = Math.floor(Math.random() * (index + 1)) |
|
|
|
|
|
const current = channels[index] |
|
|
|
|
|
channels[index] = channels[randomIndex] |
|
|
|
|
|
channels[randomIndex] = current |
|
|
|
|
|
} |
|
|
|
|
|
return channels |
|
|
|
|
|
}, |
|
|
|
|
|
async populateRandomLayout() { |
|
|
|
|
|
|
|
|
async populateDefaultLayout() { |
|
|
if (!this.pageActive) return |
|
|
if (!this.pageActive) return |
|
|
const channels = this.shuffleChannels().slice(0, this.capacity) |
|
|
|
|
|
|
|
|
// 几宫格就按频道列表顺序默认播放前几个,不做随机洗牌 |
|
|
|
|
|
const channels = this.channels.slice(0, this.capacity) |
|
|
if (!channels.length) return |
|
|
if (!channels.length) return |
|
|
await Promise.all(this.slots.map((slot, index) => slot ? this.closeSlot(index, false) : null)) |
|
|
await Promise.all(this.slots.map((slot, index) => slot ? this.closeSlot(index, false) : null)) |
|
|
if (!this.pageActive) return |
|
|
if (!this.pageActive) return |
|
|
@ -535,7 +526,7 @@ export default { |
|
|
if (layout === this.layout) return |
|
|
if (layout === this.layout) return |
|
|
this.layout = layout |
|
|
this.layout = layout |
|
|
this.$root.$emit('video-layout-updated', layout) |
|
|
this.$root.$emit('video-layout-updated', layout) |
|
|
this.populateRandomLayout() |
|
|
|
|
|
|
|
|
this.populateDefaultLayout() |
|
|
}, |
|
|
}, |
|
|
changeControlPanel(expanded) { |
|
|
changeControlPanel(expanded) { |
|
|
this.controlPanelExpanded = Boolean(expanded) |
|
|
this.controlPanelExpanded = Boolean(expanded) |
|
|
|