Waterfall #
Section列表组成Waterfall。 item列表组成Section。
瀑布流结构图 #

基础用法
<template>
<div class="es-sdk-root-css">
<qt-waterfall ref="waterfall" class="qt-waterfall-css" />
</div>
</template>
<script lang="ts">
import { ref } from 'vue'
import { defineComponent } from '@vue/runtime-core'
import { QTWaterfallSectionType } from '@quicktvui/quicktvui3'
import type {
QTIWaterfall,
QTPoster,
QTWaterfall,
QTWaterfallItem,
QTWaterfallSection,
} from '@quicktvui/quicktvui3'
export default defineComponent({
name: '基础用法',
setup() {
const waterfall = ref<QTIWaterfall>()
function onESCreate() {
//1.初始化瀑布流
const waterfallData: QTWaterfall = {
width: 1920,
height: 1080,
}
waterfall.value?.init(waterfallData)
//2.构造section数据
const sectionList: Array<QTWaterfallSection> = []
for (let i = 0; i < 2; i++) {
const section: QTWaterfallSection = {
_id: `${i}`,
type: QTWaterfallSectionType.QT_WATERFALL_SECTION_TYPE_FLEX,
title: `板块:${i}`,
titleStyle: {
width: 1920,
height: 60,
marginLeft: 90,
marginTop: 40,
marginBottom: 40,
fontSize: 80,
},
//3.构造section中item列表数据
itemList: buildPosterItemList(`${i}`),
style: {
width: 1920,
height: -1,
},
}
sectionList.push(section)
}
//4.给瀑布流设置板块列表数据
waterfall.value?.setSectionList(sectionList)
}
function buildPosterItemList(sectionId: string): Array<QTWaterfallItem> {
const data: Array<QTWaterfallItem> = []
const imgURL =
'https://img1.baidu.com/it/u=2666955302,2339578501&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=750'
for (let i = 0; i < 15; i++) {
const poster: QTPoster = {
_id: `${sectionId}_${i}`,
focus: {
enable: true,
scale: 1.1,
border: false,
},
type: 10001,
decoration: {
left: 90,
bottom: 90,
},
title: {
text: '主标题',
enable: true,
style: {
width: 260,
},
},
subTitle: {
text: '副标题',
enable: true,
style: {
width: 260,
},
},
floatTitle: {
text: '浮动标题',
enable: true,
style: {
width: 260,
},
background: { colors: ['#e5000000', '#00000000'], orientation: 4 },
},
shimmer: {
enable: true,
},
ripple: {
enable: true,
style: {
right: 0,
bottom: 0,
marginRight: -12,
},
},
image: {
src: imgURL,
enable: true,
style: {
width: 260,
height: 320,
},
},
corner: {
text: '角标',
enable: true,
style: {
width: 260,
height: 30,
},
background: {
colors: ['#FE3824', '#F0051E'],
cornerRadii4: [0, 8, 0, 8],
orientation: 2,
},
},
style: {
width: 260,
height: 400,
},
titleStyle: {
width: 260,
height: 120,
marginTop: 320 - 60,
},
titleFocusStyle: { width: 260, marginTop: 320 - 100 },
}
data.push(poster)
}
return data
}
return {
waterfall,
onESCreate,
}
},
})
</script>
<style>
.es-sdk-root-css {
width: 1920px;
height: 1080px;
background-color: #26292f;
}
.qt-waterfall-css {
width: 1920px;
height: 850px;
}
</style>
事件
<template>
<div class="es-sdk-root-css">
<qt-waterfall
ref="waterfall"
class="qt-waterfall-css"
@onScroll="onScroll"
@onItemClick="onItemClick"
@onItemFocused="onItemFocused"
@onItemBind="onItemBind"
@onScrollStateChanged="onScrollStateChanged"
@onItemAttached="onItemAttached"
>
<template #item>
<text-item :type="1" />
</template>
</qt-waterfall>
</div>
</template>
<script lang="ts">
import { ref } from 'vue'
import { defineComponent } from '@vue/runtime-core'
import { useESLog } from '@extscreen/es3-core'
import { QTWaterfallSectionType } from '@quicktvui/quicktvui3'
import textItem from './item/text-item.vue'
import type {
QTIWaterfall,
QTScrollState,
QTWaterfall,
QTWaterfallItem,
QTWaterfallSection,
} from '@quicktvui/quicktvui3'
const TAG = 'QTWaterfallEvent'
export default defineComponent({
name: '事件',
components: {
'text-item': textItem,
},
setup() {
const waterfall = ref<QTIWaterfall>()
const log = useESLog()
function onScroll(offsetX: number, scrollY: number) {
log.d(TAG, ` offsetX:${offsetX} scrollY:${scrollY}`)
}
function onItemClick(
sectionIndex: number,
position: number,
item: QTWaterfallItem
) {
log.d(
TAG,
` sectionIndex:${sectionIndex} position:${position} item:`,
item
)
}
function onItemFocused(
sectionIndex: number,
position: number,
isFocused: boolean,
item: QTWaterfallItem
) {
log.d(
TAG,
` sectionIndex:${sectionIndex} position:${position} isFocused:${isFocused} item:`,
item
)
}
function onItemBind(position: number) {
log.d(TAG, ` position:${position}`)
}
function onItemAttached(position: number) {
log.d(TAG, ` position:${position}`)
}
function onScrollStateChanged(
offsetX: number,
scrollY: number,
newState: QTScrollState
) {
log.d(TAG, ` offsetX:${offsetX} scrollY:${scrollY} newState:${newState}`)
}
function onESCreate() {
const waterfallData: QTWaterfall = {
width: 1920,
height: 1080,
}
waterfall.value?.init(waterfallData)
//
const sectionList: Array<QTWaterfallSection> = []
for (let i = 0; i < 2; i++) {
const itemList: Array<QTWaterfallItem> = []
for (let k = 0; k < 2; k++) {
const item: QTWaterfallItem = {
_id: `${i}_${k}`,
type: 1,
style: {
width: 500,
height: 200,
},
}
itemList.push(item)
}
const section: QTWaterfallSection = {
_id: `${i}`,
type: QTWaterfallSectionType.QT_WATERFALL_SECTION_TYPE_FLEX,
title: '板块',
itemList,
style: {
width: 1920,
height: 200,
},
}
sectionList.push(section)
}
waterfall.value?.setSectionList(sectionList)
}
return {
waterfall,
onESCreate,
onScroll,
onItemClick,
onItemFocused,
onItemBind,
onItemAttached,
onScrollStateChanged,
}
},
})
</script>
<style>
.es-sdk-root-css {
width: 1920px;
height: 1080px;
background-color: #26292f;
}
.qt-waterfall-css {
width: 1920px;
height: 1080px;
}
</style>
瀑布流板块 #
瀑布流板块类型 #
瀑布流内置如下类型板块:
- 加载板块:
QT_WATERFALL_SECTION_TYPE_LOADING
- 标题板块:
QT_WATERFALL_SECTION_TYPE_TITLE
- 弹性布局板块:
QT_WATERFALL_SECTION_TYPE_FLEX
- 横向列表板块:
QT_WATERFALL_SECTION_TYPE_LIST
- 标签板块:
QT_WATERFALL_SECTION_TYPE_TAB
- 标签列表板块:
QT_WATERFALL_SECTION_TYPE_TAB_LIST
- 卡片板块:
QT_WATERFALL_SECTION_TYPE_CARD
- 原生
Vue
板块:QT_WATERFALL_SECTION_TYPE_VUE
- 结束板块:
QT_WATERFALL_SECTION_TYPE_END
- 空板块:
QT_WATERFALL_SECTION_TYPE_BLANK
List Section #
使用内置列表板块,设置section类型为QT_WATERFALL_SECTION_TYPE_LIST
即可
<template>
<div class="es-sdk-root-css">
<qt-waterfall ref="waterfall" class="qt-waterfall-css" />
</div>
</template>
<script lang="ts">
import { ref } from 'vue'
import { defineComponent } from '@vue/runtime-core'
import { QTWaterfallSectionType } from '@quicktvui/quicktvui3'
import { buildPosterItemList } from '../__mocks__/poster'
import type { QTIWaterfall, QTWaterfallSection } from '@quicktvui/quicktvui3'
export default defineComponent({
name: 'ListSection',
setup() {
const waterfall = ref<QTIWaterfall>()
function onESCreate() {
waterfall.value?.init({
width: 1920,
height: 1080,
})
const section: QTWaterfallSection = {
itemList: buildPosterItemList('1'),
style: {
width: 1920,
height: 500,
spacing: 20,
},
type: QTWaterfallSectionType.QT_WATERFALL_SECTION_TYPE_LIST,
}
waterfall.value?.setSectionList([section])
}
return {
waterfall,
onESCreate,
}
},
})
</script>
<style>
.es-sdk-root-css {
width: 1920px;
height: 1080px;
background-color: #26292f;
}
.qt-waterfall-css {
width: 1920px;
height: 1080px;
}
</style>
End Section #
使用内置底部板块,设置section类型为QT_WATERFALL_SECTION_TYPE_END
即可
<template>
<div class="es-sdk-root-css">
<qt-waterfall ref="waterfall" class="qt-waterfall-css" />
</div>
</template>
<script lang="ts">
import { ref } from 'vue'
import { defineComponent } from '@vue/runtime-core'
import { QTWaterfallSectionType } from '@quicktvui/quicktvui3'
import { buildLinePosterItemList } from '../__mocks__/poster'
import type {
QTIWaterfall,
QTWaterfall,
QTWaterfallSection,
} from '@quicktvui/quicktvui3'
export default defineComponent({
name: 'EndSection',
setup() {
const waterfall = ref<QTIWaterfall>()
function onESCreate() {
const waterfallData: QTWaterfall = {
width: 1920,
height: 1080,
}
waterfall.value?.init(waterfallData)
//1.创建一个结束板块
const sectionList: Array<QTWaterfallSection> = []
const endSection: QTWaterfallSection = {
type: QTWaterfallSectionType.QT_WATERFALL_SECTION_TYPE_END,
title: '已经到底啦,按【返回键】回到顶部',
titleStyle: {
width: 1920,
height: 200,
marginLeft: 90,
marginTop: 40,
marginBottom: 40,
fontSize: 50,
},
itemList: [],
style: {
width: 1920,
height: 200,
},
}
sectionList.push(endSection)
//2.创建一个结束板块
const section: QTWaterfallSection = {
type: QTWaterfallSectionType.QT_WATERFALL_SECTION_TYPE_FLEX,
title: '底部板块',
titleStyle: {
width: 1920,
height: 60,
marginTop: 30,
marginBottom: 30,
marginLeft: 30,
},
itemList: buildLinePosterItemList(),
style: {
width: 1920,
height: -1,
},
}
sectionList.push(section)
waterfall.value?.setSectionList(sectionList)
}
return {
waterfall,
onESCreate,
}
},
})
</script>
<style>
.es-sdk-root-css {
width: 1920px;
height: 1080px;
background-color: #26292f;
}
.qt-waterfall-css {
width: 1920px;
height: 1080px;
}
</style>
Blank Section #
使用内置空板块,设置section类型为QT_WATERFALL_SECTION_TYPE_BLANK
即可
<template>
<div class="es-sdk-root-css">
<qt-waterfall ref="waterfall" class="qt-waterfall-css" />
</div>
</template>
<script lang="ts">
import { ref } from 'vue'
import { defineComponent } from '@vue/runtime-core'
import { QTWaterfallSectionType } from '@quicktvui/quicktvui3'
import type {
QTIWaterfall,
QTWaterfall,
QTWaterfallSection,
} from '@quicktvui/quicktvui3'
export default defineComponent({
name: 'BlankSection',
setup() {
const waterfall = ref<QTIWaterfall>()
function onESCreate() {
const waterfallData: QTWaterfall = {
width: 1920,
height: 1080,
}
waterfall.value?.init(waterfallData)
const sectionList: Array<QTWaterfallSection> = []
const sectionBlank: QTWaterfallSection = {
_id: '2',
type: QTWaterfallSectionType.QT_WATERFALL_SECTION_TYPE_BLANK,
itemList: [],
style: {
width: 1920,
height: 200,
},
}
sectionList.push(sectionBlank)
waterfall.value?.setSectionList(sectionList)
}
return {
waterfall,
onESCreate,
}
},
})
</script>
<style>
.es-sdk-root-css {
width: 1920px;
height: 1080px;
background-color: #26292f;
}
.qt-waterfall-css {
width: 1920px;
height: 1080px;
}
</style>
Tabs Section #
使用内置标签板块,设置section类型为QT_WATERFALL_ITEM_TYPE_TAB
即可
<template>
<div class="es-sdk-root-css">
<qt-waterfall
ref="waterfall"
class="qt-waterfall-css"
@onItemClick="onItemClick"
@onItemFocused="onItemFocused"
/>
</div>
</template>
<script lang="ts">
import { ref } from 'vue'
import { defineComponent } from '@vue/runtime-core'
import { ESLogLevel, useESLog } from '@extscreen/es3-core'
import {
QTWaterfallItemType,
QTWaterfallSectionType,
} from '@quicktvui/quicktvui3'
import type {
QTIWaterfall,
QTWaterfall,
QTWaterfallItem,
QTWaterfallSection,
QTWaterfallTabItem,
} from '@quicktvui/quicktvui3'
const TAG = 'TabSectionPage'
export default defineComponent({
name: 'TabSection',
setup() {
const log = useESLog()
const waterfall = ref<QTIWaterfall>()
function onESCreate() {
const waterfallData: QTWaterfall = {
width: 1920,
height: 1080,
}
waterfall.value?.init(waterfallData)
const tabItemList = []
for (let i = 0; i < 15; i++) {
const tabItem: QTWaterfallTabItem = {
_id: `${i}`,
style: {
width: 200,
height: 50,
paddingLeft: 40,
paddingRight: 40,
},
type: QTWaterfallItemType.QT_WATERFALL_ITEM_TYPE_TAB,
text: `Tab:${i}`,
}
tabItemList.push(tabItem)
}
const tabSection: QTWaterfallSection = {
_id: '1',
type: QTWaterfallSectionType.QT_WATERFALL_SECTION_TYPE_TAB,
title: 'Tab板块',
titleStyle: {
width: 1920,
height: 60,
marginLeft: 90,
marginTop: 40,
marginBottom: 40,
fontSize: 50,
},
style: {
width: 1920,
height: -1,
},
itemList: tabItemList,
}
const sectionList: Array<QTWaterfallSection> = [tabSection]
waterfall.value?.setSectionList(sectionList)
}
//-----------------------------------------------------
function onItemClick(
sectionIndex: number,
position: number,
item: QTWaterfallItem
) {
if (log.isLoggable(ESLogLevel.DEBUG)) {
log.d(
TAG,
item,
`sectionIndex:${sectionIndex} ` + `position:${position} ` + `item:`,
item
)
}
if (item.type === QTWaterfallItemType.QT_WATERFALL_ITEM_TYPE_TAB) {
if (log.isLoggable(ESLogLevel.DEBUG)) {
log.d(
TAG,
` sectionIndex:${sectionIndex} position:${position} item:`,
item
)
}
}
}
function onItemFocused(
sectionIndex: number,
position: number,
isFocused: boolean,
item: QTWaterfallItem
) {
if (log.isLoggable(ESLogLevel.DEBUG)) {
log.d(
TAG,
item,
`sectionIndex:${sectionIndex} ` +
`position:${position} ` +
`isFocused:${isFocused} `
)
}
if (item.type === QTWaterfallItemType.QT_WATERFALL_ITEM_TYPE_TAB) {
if (isFocused) {
//do sth
}
}
}
return {
waterfall,
onESCreate,
onItemFocused,
onItemClick,
}
},
})
</script>
<style>
.es-sdk-root-css {
width: 1920px;
height: 1080px;
background-color: #26292f;
}
.qt-waterfall-css {
width: 1920px;
height: 1080px;
}
</style>
Tabs List Section
<template>
<div class="es-sdk-root-css">
<qt-waterfall
ref="waterfall"
class="qt-waterfall-css"
@onItemFocused="onItemFocused"
/>
</div>
</template>
<script lang="ts">
import { ref } from 'vue'
import { defineComponent } from '@vue/runtime-core'
import { ESLogLevel, useESLog } from '@extscreen/es3-core'
import {
QTWaterfallItemType,
QTWaterfallSectionType,
} from '@quicktvui/quicktvui3'
import {
buildPosterItemList,
buildPosterTitleItemList,
} from '../__mocks__/poster'
import type {
QTIWaterfall,
QTWaterfall,
QTWaterfallItem,
QTWaterfallSection,
QTWaterfallTabItem,
} from '@quicktvui/quicktvui3'
const TAG = 'TabListSectionPage'
export default defineComponent({
name: 'TabListSection',
setup() {
const log = useESLog()
const waterfall = ref<QTIWaterfall>()
function onESCreate() {
const waterfallData: QTWaterfall = {
width: 1920,
height: 1080,
}
waterfall.value?.init(waterfallData)
const tabItemList = []
for (let i = 0; i < 15; i++) {
const tabItem: QTWaterfallTabItem = {
_id: `1_${i}`,
style: {
width: 100,
height: 50,
},
decoration: {
left: 90,
},
type: QTWaterfallItemType.QT_WATERFALL_ITEM_TYPE_TAB,
text: `Tab:${i}`,
}
tabItemList.push(tabItem)
}
const tabSection: QTWaterfallSection = {
_id: '1',
type: QTWaterfallSectionType.QT_WATERFALL_SECTION_TYPE_TAB,
title: 'Tab板块',
titleStyle: {
width: 1920,
height: 60,
marginLeft: 90,
marginTop: 40,
marginBottom: 40,
fontSize: 50,
},
style: {
width: 1920,
height: -1,
},
itemList: tabItemList,
}
const listSection: QTWaterfallSection = {
_id: '2',
type: QTWaterfallSectionType.QT_WATERFALL_SECTION_TYPE_LIST,
titleStyle: {
width: 0,
height: 0,
fontSize: 50,
},
style: {
width: 1920,
height: 400,
},
itemList: buildPosterItemList('2'),
}
const sectionList: Array<QTWaterfallSection> = [tabSection, listSection]
waterfall.value?.setSectionList(sectionList)
}
//-----------------------------------------------------
function onItemFocused(
sectionIndex: number,
position: number,
isFocused: boolean,
item: QTWaterfallItem
) {
if (log.isLoggable(ESLogLevel.DEBUG)) {
log.d(
TAG,
item,
`sectionIndex:${sectionIndex} ` +
`position:${position} ` +
`isFocused:${isFocused} `
)
}
if (item.type === QTWaterfallItemType.QT_WATERFALL_ITEM_TYPE_TAB) {
if (isFocused) {
const section = waterfall.value?.getSection(1)
if (section) {
section.itemList = buildPosterTitleItemList(`Tab:${position}`)
waterfall.value?.updateSection(1, section)
}
}
}
}
return {
waterfall,
onESCreate,
onItemFocused,
}
},
})
</script>
<style>
.es-sdk-root-css {
width: 1920px;
height: 1080px;
background-color: #26292f;
}
.qt-waterfall-css {
width: 1920px;
height: 1080px;
}
</style>
Vue Section #
<template>
<div class="es-sdk-root-css">
<qt-waterfall ref="waterfall" class="qt-waterfall-css">
<template #vue-section>
<time-section />
</template>
</qt-waterfall>
</div>
</template>
<script lang="ts">
import { ref } from 'vue'
import { defineComponent } from '@vue/runtime-core'
import { QTWaterfallSectionType } from '@quicktvui/quicktvui3'
import timeSection from './section/time-section.vue'
import type {
QTIWaterfall,
QTWaterfall,
QTWaterfallSection,
} from '@quicktvui/quicktvui3'
export default defineComponent({
name: 'VueSection',
components: {
'time-section': timeSection,
},
setup() {
const waterfall = ref<QTIWaterfall>()
function onESCreate() {
const waterfallData: QTWaterfall = {
width: 1920,
height: 1080,
}
waterfall.value?.init(waterfallData)
//
const sectionList: Array<QTWaterfallSection> = []
const section: QTWaterfallSection = {
_id: '1',
type: QTWaterfallSectionType.QT_WATERFALL_SECTION_TYPE_VUE,
title: 'VueSection',
titleStyle: {
width: 1920,
height: 200,
marginLeft: 90,
marginTop: 40,
marginBottom: 40,
fontSize: 50,
},
itemList: [],
style: {
width: 1920,
height: 400,
},
}
sectionList.push(section)
waterfall.value?.setSectionList(sectionList)
}
return {
waterfall,
onESCreate,
}
},
})
</script>
<style>
.es-sdk-root-css {
width: 1920px;
height: 1080px;
background-color: #26292f;
}
.qt-waterfall-css {
width: 1920px;
height: 1080px;
}
</style>
<template>
<div class="time-section-css">
<span class="time-section-text-css">18</span>
<span v-show="show" class="time-section-text-css">:</span>
<span class="time-section-text-css">24</span>
</div>
</template>
<script lang="ts">
import { ref } from 'vue'
import { defineComponent } from '@vue/runtime-core'
export default defineComponent({
name: 'TimeSection',
setup() {
const show = ref<boolean>(true)
setInterval(() => {
show.value = !show.value
}, 1000)
return {
show,
}
},
})
</script>
<style scoped>
.time-section-css {
width: 1920px;
height: 200px;
background-color: red;
flex-direction: row;
flex-wrap: wrap;
align-items: center;
justify-content: center;
}
.time-section-text-css {
color: white;
font-size: 40px;
width: 50px;
height: 50px;
text-align: center;
text-align-vertical: center;
}
</style>
Card Section
<template>
<div class="es-sdk-root-css">
<qt-waterfall ref="waterfall" class="qt-waterfall-css" />
</div>
</template>
<script lang="ts">
import { ref } from 'vue'
import { defineComponent } from '@vue/runtime-core'
import { QTWaterfallSectionType } from '@quicktvui/quicktvui3'
import type {
QTIWaterfall,
QTWaterfall,
QTWaterfallCardSection,
} from '@quicktvui/quicktvui3'
export default defineComponent({
name: 'CardSection',
setup() {
const waterfall = ref<QTIWaterfall>()
function onESCreate() {
const waterfallData: QTWaterfall = {
width: 1920,
height: 1080,
}
waterfall.value?.init(waterfallData)
//
const sectionList: Array<QTWaterfallCardSection> = []
for (let i = 0; i < 2; i++) {
const section: QTWaterfallCardSection = {
_id: `${i}`,
type: QTWaterfallSectionType.QT_WATERFALL_SECTION_TYPE_CARD,
title: 'Card板块',
titleStyle: {
width: 1920,
height: 60,
marginLeft: 90,
marginTop: 40,
marginBottom: 40,
fontSize: 50,
},
itemList: [],
cardId: '1717748409857474561',
cardStyle: {
width: 1920,
height: 400,
},
style: {
width: 1920,
height: 540,
},
decoration: {
top: 40,
bottom: 40,
},
}
sectionList.push(section)
}
waterfall.value?.setSectionList(sectionList)
}
return {
waterfall,
onESCreate,
}
},
})
</script>
<style>
.es-sdk-root-css {
width: 1920px;
height: 1080px;
background-color: #26292f;
}
.qt-waterfall-css {
width: 1920px;
height: 850px;
}
</style>
Card Section Placeholder
<template>
<div class="es-sdk-root-css">
<qt-waterfall ref="waterfall" class="qt-waterfall-css" />
</div>
</template>
<script lang="ts">
import { ref } from 'vue'
import { defineComponent } from '@vue/runtime-core'
import { QTWaterfallSectionType } from '@quicktvui/quicktvui3'
import type {
QTIWaterfall,
QTWaterfall,
QTWaterfallCardSection,
} from '@quicktvui/quicktvui3'
export default defineComponent({
name: 'CardSectionPlaceholder',
setup() {
const waterfall = ref<QTIWaterfall>()
function onESCreate() {
const waterfallData: QTWaterfall = {
width: 1920,
height: 1080,
}
waterfall.value?.init(waterfallData)
//
const sectionList: Array<QTWaterfallCardSection> = []
for (let i = 0; i < 2; i++) {
const section: QTWaterfallCardSection = {
_id: `${i}`,
type: QTWaterfallSectionType.QT_WATERFALL_SECTION_TYPE_CARD,
title: 'Card板块',
titleStyle: {
width: 1920,
height: 60,
marginLeft: 90,
marginTop: 40,
marginBottom: 40,
fontSize: 50,
},
itemList: [],
cardId: '1717748409857474561',
cardPlaceHolder: {
enable: true, //是否可用
radius: 100, //圆角
rect: [100, 0, 100, 0],
focusable: true,
focusScale: 1.2,
},
cardStyle: {
width: 1920,
height: 400,
},
style: {
width: 1920,
height: 540,
},
decoration: {
top: 40,
bottom: 40,
},
}
sectionList.push(section)
}
waterfall.value?.setSectionList(sectionList)
}
return {
waterfall,
onESCreate,
}
},
})
</script>
<style>
.es-sdk-root-css {
width: 1920px;
height: 1080px;
background-color: #26292f;
}
.qt-waterfall-css {
width: 1920px;
height: 850px;
}
</style>
瀑布流板块操作 #
添加板块
<template>
<div class="es-sdk-root-css">
<s-text-button text="添加板块" @onButtonClicked="onAddButtonClicked" />
<qt-waterfall ref="waterfall" class="qt-waterfall-op-css">
<template #item>
<app-list-item :type="1" />
</template>
</qt-waterfall>
</div>
</template>
<script lang="ts">
import { ref } from 'vue'
import { defineComponent } from '@vue/runtime-core'
import { generatorAppWaterfallSection } from '../__mocks__/app'
import appListItem from './item/app-list-item'
import type {
QTIWaterfall,
QTWaterfall,
QTWaterfallSection,
} from '@quicktvui/quicktvui3'
const TAG = 'WaterfallTAG'
export default defineComponent({
name: '添加Section',
components: {
'app-list-item': appListItem,
},
setup() {
const waterfall = ref<QTIWaterfall>()
function onAddButtonClicked() {
const sectionList: Array<QTWaterfallSection> = [
generatorAppWaterfallSection('0', `应用:${Date.now()}`),
]
waterfall.value?.addSectionList(sectionList)
}
function onESCreate() {
const waterfallData: QTWaterfall = {
width: 1920,
height: 1080,
}
waterfall.value?.init(waterfallData)
const sectionList: Array<QTWaterfallSection> = [
generatorAppWaterfallSection('0', `应用:${Date.now()}`),
]
waterfall.value?.setSectionList(sectionList)
}
return {
waterfall,
onESCreate,
onAddButtonClicked,
}
},
})
</script>
<style>
.es-sdk-root-css {
width: 1920px;
height: 1080px;
background-color: #26292f;
}
.qt-waterfall-op-css {
width: 1920px;
height: 800px;
}
</style>
查询板块
<template>
<div class="es-sdk-root-css">
<div class="es-sdk-content-row-css">
<s-text-button text="查询板块" @onButtonClicked="onGetButtonClicked" />
</div>
<qt-waterfall ref="waterfall" class="qt-waterfall-op-css">
<template #item>
<app-list-item :type="1" />
</template>
</qt-waterfall>
</div>
</template>
<script lang="ts">
import { ref } from 'vue'
import { defineComponent } from '@vue/runtime-core'
import { useESLog } from '@extscreen/es3-core'
import { generatorAppWaterfallSection } from '../__mocks__/app'
import appListItem from './item/app-list-item'
import type {
QTIWaterfall,
QTWaterfall,
QTWaterfallSection,
} from '@quicktvui/quicktvui3'
const TAG = 'WaterfallTAG'
export default defineComponent({
name: '查询Section',
components: {
'app-list-item': appListItem,
},
setup() {
const waterfall = ref<QTIWaterfall>()
const log = useESLog()
function onGetButtonClicked() {
const section = waterfall.value?.getSection(0)
log.d(TAG, 'section:', section)
}
function onESCreate() {
const waterfallData: QTWaterfall = {
width: 1920,
height: 1080,
}
waterfall.value?.init(waterfallData)
const sectionList: Array<QTWaterfallSection> = [
generatorAppWaterfallSection('0', `应用:${Date.now()}`),
]
waterfall.value?.addSectionList(sectionList)
}
return {
waterfall,
onESCreate,
onGetButtonClicked,
}
},
})
</script>
<style>
.es-sdk-root-css {
width: 1920px;
height: 1080px;
background-color: #26292f;
}
.qt-waterfall-op-css {
width: 1920px;
height: 800px;
}
</style>
删除板块
<template>
<div class="es-sdk-root-css">
<div class="es-sdk-content-row-css">
<s-text-button text="添加板块" @onButtonClicked="onAddButtonClicked" />
<s-text-button text="删除板块" @onButtonClicked="onDeleteButtonClicked" />
</div>
<qt-waterfall ref="waterfall" class="qt-waterfall-op-css">
<template #item>
<app-list-item :type="1" />
</template>
</qt-waterfall>
</div>
</template>
<script lang="ts">
import { ref } from 'vue'
import { defineComponent } from '@vue/runtime-core'
import { generatorAppWaterfallSection } from '../__mocks__/app'
import appListItem from './item/app-list-item'
import type {
QTIWaterfall,
QTWaterfall,
QTWaterfallSection,
} from '@quicktvui/quicktvui3'
const TAG = 'WaterfallTAG'
export default defineComponent({
name: '删除Section',
components: {
'app-list-item': appListItem,
},
setup() {
const waterfall = ref<QTIWaterfall>()
function onAddButtonClicked() {
const sectionList: Array<QTWaterfallSection> = [
generatorAppWaterfallSection('0', `应用:${Date.now()}`),
]
waterfall.value?.addSectionList(sectionList)
}
function onDeleteButtonClicked() {
waterfall.value?.deleteSection(0, 1)
}
//-------------------------------------------------------------
function onESCreate() {
const waterfallData: QTWaterfall = {
width: 1920,
height: 1080,
}
waterfall.value?.init(waterfallData)
//
const sectionList: Array<QTWaterfallSection> = [
generatorAppWaterfallSection('0', `应用:${Date.now()}`),
]
waterfall.value?.addSectionList(sectionList)
}
return {
waterfall,
onESCreate,
onAddButtonClicked,
onDeleteButtonClicked,
}
},
})
</script>
<style>
.qt-waterfall-op-css {
width: 1920px;
height: 800px;
}
</style>
更新板块
<template>
<div class="es-sdk-root-css">
<div class="es-sdk-content-row-css">
<s-text-button
text="更新单个板块"
@onButtonClicked="onUpdateButtonClicked"
/>
<s-text-button
text="更新高度变化板块"
@onButtonClicked="onUpdateHeightButtonClicked"
/>
<s-text-button
text="更新多个板块"
@onButtonClicked="onUpdateMultiButtonClicked"
/>
</div>
<qt-waterfall ref="waterfall" class="qt-waterfall-op-css">
<template #item>
<app-list-item :type="1" />
</template>
</qt-waterfall>
</div>
</template>
<script lang="ts">
import { ref } from 'vue'
import { defineComponent } from '@vue/runtime-core'
import {
generatorAppChildrenWaterfallItemList,
generatorAppQuestionWaterfallItemList,
generatorAppWaterfallSection,
} from '../__mocks__/app'
import appListItem from './item/app-list-item'
import type {
QTIWaterfall,
QTWaterfall,
QTWaterfallSection,
} from '@quicktvui/quicktvui3'
const TAG = 'WaterfallTAG'
export default defineComponent({
name: '更新Section',
components: {
'app-list-item': appListItem,
},
setup() {
const waterfall = ref<QTIWaterfall>()
function onUpdateButtonClicked() {
const section = waterfall.value?.getSection(0)
if (section) {
section.title = `新:${section.title}`
section.itemList = generatorAppChildrenWaterfallItemList(`${0}`, 5)
waterfall.value?.updateSection(0, section)
}
}
function onUpdateHeightButtonClicked() {
const section = waterfall.value?.getSection(0)
if (section) {
section.title = `新:${section.title}`
section.itemList = generatorAppChildrenWaterfallItemList(`${0}`, 9)
waterfall.value?.updateSection(0, section)
}
}
function onUpdateMultiButtonClicked() {
const sectionList: Array<QTWaterfallSection> = []
const sectionZero = waterfall.value?.getSection(0)
if (sectionZero) {
sectionZero.title = `新:${sectionZero.title}`
sectionZero.itemList = generatorAppChildrenWaterfallItemList(`${0}`, 5)
sectionList.push(sectionZero)
}
const sectionOne = waterfall.value?.getSection(1)
if (sectionOne) {
sectionOne.title = `新:${sectionOne.title}`
sectionOne.itemList = generatorAppQuestionWaterfallItemList(`${1}`, 6)
sectionList.push(sectionOne)
}
if (sectionList) {
waterfall.value?.updateSectionList(0, 2, sectionList)
}
}
function onESCreate() {
const waterfallData: QTWaterfall = {
width: 1920,
height: 1080,
}
waterfall.value?.init(waterfallData)
//
const sectionList: Array<QTWaterfallSection> = [
generatorAppWaterfallSection('0', `应用:${Date.now()}`),
generatorAppWaterfallSection('1', `应用:${Date.now()}`),
generatorAppWaterfallSection('2', `应用:${Date.now()}`),
]
waterfall.value?.addSectionList(sectionList)
}
return {
waterfall,
onESCreate,
onUpdateButtonClicked,
onUpdateMultiButtonClicked,
onUpdateHeightButtonClicked,
}
},
})
</script>
<style>
.qt-waterfall-op-css {
width: 1920px;
height: 800px;
}
</style>
自定义板块
<template>
<div class="es-sdk-root-css">
<qt-waterfall ref="waterfall" class="qt-waterfall-css">
<template #section>
<text-section :type="1" />
</template>
</qt-waterfall>
</div>
</template>
<script lang="ts">
import { ref } from 'vue'
import { defineComponent } from '@vue/runtime-core'
import textSection from './section/text-section'
import type {
QTIWaterfall,
QTWaterfall,
QTWaterfallSection,
} from '@quicktvui/quicktvui3'
export default defineComponent({
name: '自定义ection',
components: {
'text-section': textSection,
},
setup() {
const waterfall = ref<QTIWaterfall>()
function onESCreate() {
const waterfallData: QTWaterfall = {
width: 1920,
height: 1080,
}
waterfall.value?.init(waterfallData)
const section: QTWaterfallSection = {
_id: '1',
type: 1,
itemList: [],
style: {
width: 1920,
height: 320,
},
}
const sectionList: Array<QTWaterfallSection> = [section]
waterfall.value?.setSectionList(sectionList)
}
return {
waterfall,
onESCreate,
}
},
})
</script>
<style>
.es-sdk-root-css {
width: 1920px;
height: 1080px;
background-color: #26292f;
}
.qt-waterfall-css {
width: 1920px;
height: 1080px;
}
</style>
板块装饰信息
<template>
<div class="es-sdk-root-css">
<qt-waterfall ref="waterfall" class="qt-waterfall-css" />
</div>
</template>
<script lang="ts">
import { ref } from 'vue'
import { defineComponent } from '@vue/runtime-core'
import { QTWaterfallSectionType } from '@quicktvui/quicktvui3'
import { buildPosterDecorationItemList } from '../__mocks__/poster'
import type {
QTIWaterfall,
QTWaterfall,
QTWaterfallSection,
} from '@quicktvui/quicktvui3'
export default defineComponent({
name: 'SectionDecoration',
setup() {
const waterfall = ref<QTIWaterfall>()
function onESCreate() {
const waterfallData: QTWaterfall = {
width: 1920,
height: 1080,
}
waterfall.value?.init(waterfallData)
//
const sectionList: Array<QTWaterfallSection> = []
for (let i = 0; i < 2; i++) {
const section: QTWaterfallSection = {
_id: `${i}`,
type: QTWaterfallSectionType.QT_WATERFALL_SECTION_TYPE_FLEX,
itemList: buildPosterDecorationItemList(),
title: 'Section',
titleStyle: {
width: 1920,
height: 60,
marginLeft: 90,
marginTop: 40,
marginBottom: 40,
fontSize: 50,
},
style: {
width: 1920,
height: -1,
},
//
decoration: {
top: 10,
bottom: 300,
},
}
sectionList.push(section)
}
waterfall.value?.setSectionList(sectionList)
}
return {
waterfall,
onESCreate,
}
},
})
</script>
<style>
.es-sdk-root-css {
width: 1920px;
height: 1080px;
background-color: #26292f;
}
.qt-waterfall-css {
width: 1920px;
height: 1080px;
}
</style>
板块背景
<template>
<div class="es-sdk-root-css">
<qt-waterfall ref="waterfall" class="qt-waterfall-css" />
</div>
</template>
<script lang="ts">
import { ref } from 'vue'
import { defineComponent } from '@vue/runtime-core'
import { ESGradientShape, ESGradientType } from '@extscreen/es3-component'
import { QTWaterfallSectionType } from '@quicktvui/quicktvui3'
import { buildLinePosterItemList } from '../__mocks__/poster'
import type {
QTIWaterfall,
QTWaterfall,
QTWaterfallSection,
} from '@quicktvui/quicktvui3'
export default defineComponent({
name: 'SectionBackground',
setup() {
const waterfall = ref<QTIWaterfall>()
function onESCreate() {
const waterfallData: QTWaterfall = {
width: 1920,
height: 1080,
}
waterfall.value?.init(waterfallData)
const sectionList: Array<QTWaterfallSection> = []
const endSection: QTWaterfallSection = {
_id: '100',
type: QTWaterfallSectionType.QT_WATERFALL_SECTION_TYPE_END,
title: '已经到底啦,按【返回键】回到顶部',
titleStyle: {
width: 1920,
height: 200,
marginLeft: 90,
marginTop: 40,
marginBottom: 40,
fontSize: 50,
},
itemList: [],
style: {
width: 1920,
height: 200,
gradientBackground: {
type: ESGradientType.ES_GRADIENT_TYPE_LINEAR_GRADIENT,
shape: ESGradientShape.ES_GRADIENT_SHAPE_RECTANGLE,
colors: ['#40b883', '#4068b8'],
cornerRadii4: [0, 5, 20, 0],
},
},
}
sectionList.push(endSection)
for (let i = 0; i < 1; i++) {
const section: QTWaterfallSection = {
_id: `${i}`,
type: QTWaterfallSectionType.QT_WATERFALL_SECTION_TYPE_FLEX,
title: '板块',
titleStyle: {
width: 1920,
height: 60,
marginTop: 30,
marginBottom: 30,
marginLeft: 30,
fontSize: 50,
},
itemList: buildLinePosterItemList(),
style: {
width: 1920,
height: -1,
},
}
sectionList.push(section)
}
waterfall.value?.setSectionList(sectionList)
}
return {
waterfall,
onESCreate,
}
},
})
</script>
<style>
.qt-waterfall-css {
width: 1920px;
height: 1080px;
}
</style>
瀑布流条目 #
瀑布流条目类型 #
瀑布流内置如下类型条目:
- 海报条目:
QT_WATERFALL_ITEM_TYPE_POSTER
- 标签条目:
QT_WATERFALL_ITEM_TYPE_TAB
- 卡片条目:
QT_WATERFALL_ITEM_TYPE_CARD
- 空条目:
QT_WATERFALL_ITEM_TYPE_BLANK
Card Item #
<template>
<div class="es-sdk-root-css">
<qt-waterfall ref="waterfall" class="qt-waterfall-css" />
</div>
</template>
<script lang="ts">
import { ref } from 'vue'
import { defineComponent } from '@vue/runtime-core'
import { QTWaterfallSectionType } from '@quicktvui/quicktvui3'
import { buildCardItemList } from '../__mocks__/card'
import type {
QTIWaterfall,
QTWaterfall,
QTWaterfallSection,
} from '@quicktvui/quicktvui3'
export default defineComponent({
name: 'CardItem',
setup() {
const waterfall = ref<QTIWaterfall>()
function onESCreate() {
const waterfallData: QTWaterfall = {
width: 1920,
height: 1080,
}
waterfall.value?.init(waterfallData)
const sectionList: Array<QTWaterfallSection> = []
const section: QTWaterfallSection = {
_id: '1',
type: QTWaterfallSectionType.QT_WATERFALL_SECTION_TYPE_FLEX,
title: 'CardItem板块:',
titleStyle: {
width: 1920,
height: 60,
marginLeft: 90,
marginTop: 40,
marginBottom: 40,
fontSize: 50,
},
itemList: buildCardItemList(),
style: {
width: 1920,
height: -1,
},
}
sectionList.push(section)
waterfall.value?.setSectionList(sectionList)
}
return {
waterfall,
onESCreate,
}
},
})
</script>
<style>
.qt-waterfall-css {
width: 1920px;
height: 850px;
}
</style>
Card Item Placeholder #
<template>
<div class="es-sdk-root-css">
<qt-waterfall ref="waterfall" class="qt-waterfall-css" />
</div>
</template>
<script lang="ts">
import { ref } from 'vue'
import { defineComponent } from '@vue/runtime-core'
import { QTWaterfallSectionType } from '@quicktvui/quicktvui3'
import { buildCardItemPlaceHolderList } from '../__mocks__/card'
import type {
QTIWaterfall,
QTWaterfall,
QTWaterfallSection,
} from '@quicktvui/quicktvui3'
export default defineComponent({
name: 'CardItemPlaceHolder',
setup() {
const waterfall = ref<QTIWaterfall>()
function onESCreate() {
const waterfallData: QTWaterfall = {
width: 1920,
height: 1080,
}
waterfall.value?.init(waterfallData)
//
const sectionList: Array<QTWaterfallSection> = []
const section: QTWaterfallSection = {
_id: '1',
type: QTWaterfallSectionType.QT_WATERFALL_SECTION_TYPE_FLEX,
title: 'CardItem板块:',
titleStyle: {
width: 1920,
height: 60,
marginLeft: 90,
marginTop: 40,
marginBottom: 40,
fontSize: 50,
},
itemList: buildCardItemPlaceHolderList(),
style: {
width: 1920,
height: -1,
},
}
sectionList.push(section)
waterfall.value?.setSectionList(sectionList)
}
return {
waterfall,
onESCreate,
}
},
})
</script>
<style>
.qt-waterfall-css {
width: 1920px;
height: 850px;
}
</style>
瀑布流条目操作 #
添加条目 #
<template>
<div class="es-sdk-root-css">
<div class="es-sdk-content-row-css">
<s-text-button text="添加Item" @onButtonClicked="onAddButtonClicked" />
</div>
<qt-waterfall ref="waterfall" class="qt-waterfall-op-css">
<template #item>
<app-list-item :type="1" />
</template>
</qt-waterfall>
</div>
</template>
<script lang="ts">
import { ref } from 'vue'
import { defineComponent } from '@vue/runtime-core'
import {
generatorAppChildrenWaterfallItemList,
generatorAppQuestionWaterfallItemList,
generatorAppWaterfallItemList,
generatorWaterfallSection,
} from '../__mocks__/app'
import appListItem from './item/app-list-item'
import type {
QTIWaterfall,
QTWaterfall,
QTWaterfallSection,
} from '@quicktvui/quicktvui3'
const TAG = 'WaterfallTAG'
export default defineComponent({
name: '添加Item',
components: {
'app-list-item': appListItem,
},
setup() {
const waterfall = ref<QTIWaterfall>()
//
function onAddButtonClicked() {
const itemList = generatorAppWaterfallItemList('0', 1)
waterfall.value?.addItemList(0, itemList)
}
function onESCreate() {
const waterfallData: QTWaterfall = {
width: 1920,
height: 1080,
}
waterfall.value?.init(waterfallData)
//
const sectionList: Array<QTWaterfallSection> = [
generatorWaterfallSection(
'0',
`应用:${Date.now()}`,
generatorAppQuestionWaterfallItemList('1', 5)
),
generatorWaterfallSection(
'2',
`应用:${Date.now()}`,
generatorAppChildrenWaterfallItemList('3', 5)
),
]
waterfall.value?.addSectionList(sectionList)
}
return {
waterfall,
onESCreate,
onAddButtonClicked,
}
},
})
</script>
<style>
.qt-waterfall-op-css {
width: 1920px;
height: 800px;
}
</style>
查询条目 #
<template>
<div class="es-sdk-root-css">
<div class="es-sdk-content-row-css">
<s-text-button text="查询Item" @onButtonClicked="onGetButtonClicked" />
</div>
<qt-waterfall ref="waterfall" class="qt-waterfall-op-css">
<template #item>
<app-list-item :type="1" />
</template>
</qt-waterfall>
</div>
</template>
<script lang="ts">
import { ref } from 'vue'
import { defineComponent } from '@vue/runtime-core'
import { useESLog } from '@extscreen/es3-core'
import { generatorAppWaterfallSection } from '../__mocks__/app'
import appListItem from './item/app-list-item'
import type {
QTIWaterfall,
QTWaterfall,
QTWaterfallSection,
} from '@quicktvui/quicktvui3'
const TAG = 'WaterfallTAG'
export default defineComponent({
name: '查询Item',
components: {
'app-list-item': appListItem,
},
setup() {
const waterfall = ref<QTIWaterfall>()
const log = useESLog()
function onGetButtonClicked() {
const item = waterfall.value?.getItem(0, 2)
log.d(TAG, '-------获取item信息-------->>>>', item)
}
function onESCreate() {
const waterfallData: QTWaterfall = {
width: 1920,
height: 1080,
}
waterfall.value?.init(waterfallData)
const sectionList: Array<QTWaterfallSection> = [
generatorAppWaterfallSection('0', `应用:${Date.now()}`),
]
waterfall.value?.addSectionList(sectionList)
}
return {
waterfall,
onESCreate,
onGetButtonClicked,
}
},
})
</script>
<style>
.qt-waterfall-op-css {
width: 1920px;
height: 800px;
}
</style>
删除条目 #
<template>
<div class="es-sdk-root-css">
<div class="es-sdk-content-row-css">
<s-text-button
text="删除第一个板块Item"
@onButtonClicked="onDeleteButtonClicked"
/>
<s-text-button
text="删除第二个板块Item"
@onButtonClicked="onDeleteButton2Clicked"
/>
</div>
<qt-waterfall ref="waterfall" class="qt-waterfall-op-css">
<template #item>
<app-list-item :type="1" />
</template>
</qt-waterfall>
</div>
</template>
<script lang="ts">
import { ref } from 'vue'
import { defineComponent } from '@vue/runtime-core'
import {
generatorAppChildrenWaterfallItemList,
generatorAppQuestionWaterfallItemList,
generatorWaterfallSection,
} from '../__mocks__/app'
import appListItem from './item/app-list-item'
import type {
QTIWaterfall,
QTWaterfall,
QTWaterfallSection,
} from '@quicktvui/quicktvui3'
const TAG = 'WaterfallTAG'
export default defineComponent({
name: '删除Item',
components: {
'app-list-item': appListItem,
},
setup() {
const waterfall = ref<QTIWaterfall>()
function onDeleteButtonClicked() {
waterfall.value?.deleteItem(0, 0, 1)
}
function onDeleteButton2Clicked() {
waterfall.value?.deleteItem(1, 0, 2)
}
function onESCreate() {
const waterfallData: QTWaterfall = {
width: 1920,
height: 1080,
}
waterfall.value?.init(waterfallData)
const sectionList: Array<QTWaterfallSection> = [
generatorWaterfallSection(
'0',
`应用:${Date.now()}`,
generatorAppQuestionWaterfallItemList('1', 7)
),
generatorWaterfallSection(
'2',
`应用:${Date.now()}`,
generatorAppChildrenWaterfallItemList('3', 7)
),
]
waterfall.value?.addSectionList(sectionList)
}
return {
waterfall,
onESCreate,
onDeleteButton2Clicked,
onDeleteButtonClicked,
}
},
})
</script>
<style>
.qt-waterfall-op-css {
width: 1920px;
height: 800px;
}
</style>
更新条目 #
<template>
<div class="es-sdk-root-css">
<div class="es-sdk-content-row-css">
<s-text-button
text="更新单个Item"
@onButtonClicked="onUpdateButtonClicked"
/>
<s-text-button
text="更新多个Item"
@onButtonClicked="onUpdateMultiButtonClicked"
/>
</div>
<qt-waterfall ref="waterfall" class="qt-waterfall-op-css">
<template #item>
<app-list-item :type="1" />
</template>
</qt-waterfall>
</div>
</template>
<script lang="ts">
import { ref } from 'vue'
import { defineComponent } from '@vue/runtime-core'
import {
generatorAppChildrenWaterfallItem,
generatorAppChildrenWaterfallItemList,
generatorAppWaterfallSection,
} from '../__mocks__/app'
import appListItem from './item/app-list-item'
import type {
QTIWaterfall,
QTWaterfall,
QTWaterfallSection,
} from '@quicktvui/quicktvui3'
const TAG = 'WaterfallTAG'
export default defineComponent({
name: '更新Item',
components: {
'app-list-item': appListItem,
},
setup() {
const waterfall = ref<QTIWaterfall>()
function onUpdateButtonClicked() {
const item = generatorAppChildrenWaterfallItem('0', 2)
waterfall.value?.updateItem(0, 0, item)
}
function onUpdateMultiButtonClicked() {
const itemList = generatorAppChildrenWaterfallItemList('0', 2)
waterfall.value?.updateItemList(0, 0, 2, itemList)
}
function onESCreate() {
const waterfallData: QTWaterfall = {
width: 1920,
height: 1080,
}
waterfall.value?.init(waterfallData)
const sectionList: Array<QTWaterfallSection> = [
generatorAppWaterfallSection('0', `应用:${Date.now()}`),
generatorAppWaterfallSection('1', `应用:${Date.now()}`),
generatorAppWaterfallSection('2', `应用:${Date.now()}`),
]
waterfall.value?.addSectionList(sectionList)
}
return {
waterfall,
onESCreate,
onUpdateButtonClicked,
onUpdateMultiButtonClicked,
}
},
})
</script>
<style>
.qt-waterfall-op-css {
width: 1920px;
height: 800px;
}
</style>
条目装饰信息 #
<template>
<div class="es-sdk-root-css">
<qt-waterfall ref="waterfall" class="qt-waterfall-css" />
</div>
</template>
<script lang="ts">
import { ref } from 'vue'
import { defineComponent } from '@vue/runtime-core'
import { QTWaterfallSectionType } from '@quicktvui/quicktvui3'
import { buildPosterDecorationItemList } from '../__mocks__/poster'
import type {
QTIWaterfall,
QTWaterfall,
QTWaterfallSection,
} from '@quicktvui/quicktvui3'
export default defineComponent({
name: 'ItemDecoration',
setup() {
const waterfall = ref<QTIWaterfall>()
function onESCreate() {
const waterfallData: QTWaterfall = {
width: 1920,
height: 1080,
}
waterfall.value?.init(waterfallData)
const sectionList: Array<QTWaterfallSection> = []
for (let i = 0; i < 1; i++) {
const section: QTWaterfallSection = {
_id: `${i}`,
type: QTWaterfallSectionType.QT_WATERFALL_SECTION_TYPE_FLEX,
itemList: buildPosterDecorationItemList(),
titleStyle: {
width: 0,
height: 0,
fontSize: 50,
},
style: {
width: 1920,
height: 400 + 60 + 36,
},
}
sectionList.push(section)
}
waterfall.value?.setSectionList(sectionList)
}
return {
waterfall,
onESCreate,
}
},
})
</script>
<style>
.qt-waterfall-css {
width: 1920px;
height: 1080px;
}
</style>
自定义条目 #
<template>
<div class="es-sdk-root-css">
<qt-waterfall ref="waterfall" class="qt-waterfall-css">
<template #item>
<text-item :type="1" />
</template>
</qt-waterfall>
</div>
</template>
<script lang="ts">
import { ref } from 'vue'
import { defineComponent } from '@vue/runtime-core'
import { QTWaterfallSectionType } from '@quicktvui/quicktvui3'
import textItem from './item/text-item.vue'
import type {
QTIWaterfall,
QTWaterfall,
QTWaterfallItem,
QTWaterfallSection,
} from '@quicktvui/quicktvui3'
export default defineComponent({
name: '自定义Item',
components: {
'text-item': textItem,
},
setup() {
const waterfall = ref<QTIWaterfall>()
function onESCreate() {
const waterfallData: QTWaterfall = {
width: 1920,
height: 1080,
}
waterfall.value?.init(waterfallData)
const itemList: Array<QTWaterfallItem> = []
for (let i = 0; i < 2; i++) {
const item: QTWaterfallItem = {
_id: `${i}`,
type: 1,
style: {
width: 500,
height: 200,
},
}
itemList.push(item)
}
const section: QTWaterfallSection = {
_id: '1',
type: QTWaterfallSectionType.QT_WATERFALL_SECTION_TYPE_FLEX,
title: '板块',
itemList,
style: {
width: 1920,
height: 200,
spacing: 20,
},
}
const sectionList: Array<QTWaterfallSection> = [section, section, section]
waterfall.value?.setSectionList(sectionList)
}
return {
waterfall,
onESCreate,
}
},
})
</script>
<style>
.qt-waterfall-css {
width: 1920px;
height: 1080px;
}
</style>
数据双向绑定用法 #
基础用法
<template>
<qt-waterfall :listData="waterfallDatas" class="qt-waterfall-ref-css" />
</template>
<script lang="ts" setup>
import { QTWaterfallSectionType, qtRef } from '@quicktvui/quicktvui3'
import type { QTPoster, QTWaterfallItem } from '@quicktvui/quicktvui3'
const waterfallDatas = qtRef()
defineExpose({
onESCreate() {
waterfallDatas.value = mockData('initFn')
},
})
// 模拟数据
function mockPosterItemList(
sectionId: string,
size = 15
): Array<QTWaterfallItem> {
const data: Array<QTWaterfallItem> = []
const imgURL =
'https://img1.baidu.com/it/u=2666955302,2339578501&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=750'
for (let i = 0; i < size; i++) {
const poster: QTPoster = {
_id: `${sectionId}_${i}`,
focus: {
enable: true,
scale: 1.1,
border: false,
},
type: 10001,
decoration: {
left: 60,
bottom: 20,
},
title: {
text: `主标题${i}`,
enable: true,
style: {
width: 260,
},
},
subTitle: {
text: '副标题',
enable: true,
style: {
width: 260,
},
},
floatTitle: {
text: '浮动标题',
enable: true,
style: {
width: 260,
},
background: { colors: ['#e5000000', '#00000000'], orientation: 4 },
},
shimmer: {
enable: true,
},
ripple: {
enable: true,
style: {
right: 0,
bottom: 0,
marginRight: -12,
},
},
image: {
src: imgURL,
enable: true,
style: {
width: 260,
height: 320,
},
},
corner: {
text: '角标',
enable: true,
style: {
width: 260,
height: 30,
},
background: {
colors: ['#FE3824', '#F0051E'],
cornerRadii4: [0, 8, 0, 8],
orientation: 2,
},
},
style: {
width: 260,
height: 400,
},
titleStyle: {
width: 260,
height: 120,
marginTop: 320 - 60,
},
titleFocusStyle: { width: 260, marginTop: 320 - 100 },
}
data.push(poster)
}
return data
}
// 模拟数据
const mockData = (flag = '') => {
return new Array(5).fill(1).map((item, i) => {
return {
_id: `${i}`,
type: QTWaterfallSectionType.QT_WATERFALL_SECTION_TYPE_FLEX,
title: `板块标题${i}${flag}`,
titleStyle: {
width: 1000,
height: 50,
marginTop: 10,
marginBottom: 10,
fontSize: 50,
},
itemList: mockPosterItemList(i + flag, 5),
style: {
width: 1620,
height: -1,
},
decoration: {
left: 1,
right: 1,
top: 10,
},
}
})
}
</script>
<style scoped>
.qt-waterfall-ref-css {
width: 1620px;
height: 1080px;
background-color: transparent;
}
</style>
增删改查操作示例
<template>
<qt-waterfall :listData="waterfallDatas" class="qt-waterfall-ref-css" />
</template>
<script lang="ts" setup>
import { onMounted } from 'vue'
import { QTWaterfallSectionType, qtRef } from '@quicktvui/quicktvui3'
import type { QTWaterfallItem, QTWaterfallSection } from '@quicktvui/quicktvui3'
const waterfallDatas = qtRef<QTWaterfallSection[]>()
// 新增板块数据
const addFn = () => {
waterfallDatas.value.push(mockSectionData(7, 'addFn'))
}
// 插入板块数据
const insertFn = () => {
waterfallDatas.value.splice(0, 0, mockSectionData(6, 'insertFn'))
}
// 更新板块数据
const updateFn = () => {
waterfallDatas.value[0].title = `${Math.random()}-update`
}
// 删除板块数据
const deleteFn = () => {
waterfallDatas.value.splice(1, 1)
}
// 新增板块格子数据
const addItemFn = () => {
waterfallDatas.value[0].itemList.push(
mockPosterData(`addItemFn${Math.random()}`, 1)
)
}
// 更新板块格子数据
const updateItemFn = () => {
waterfallDatas.value[0].itemList[0].title.text = `${Math.random()}updateItemFn`
}
// 重置板块格子数据
const resetItemAllFn = () => {
waterfallDatas.value[0].itemList = mockPosterItemList('resetItemAllFn', 5)
}
// 删除板块格子数据
const deleteItemFn = () => {
waterfallDatas.value[0].itemList.splice(0, 1)
}
// 插入板块格子数据
const insertItemFn = () => {
waterfallDatas.value[0].itemList.splice(0, 0, mockPosterData('addItemFn', 1))
}
// 清空所有数据
const clearFn = () => {
waterfallDatas.value = []
}
onMounted(() => {
waterfallDatas.value = mockList()
})
const imgURL =
'https://img1.baidu.com/it/u=2666955302,2339578501&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=750'
// 模拟格子数据
const mockPosterData = (sectionId, i) => {
return {
_id: `${sectionId}_${i}${Math.random()}`,
focus: {
enable: true,
scale: 1.1,
border: false,
},
type: 10001,
decoration: {
left: 60,
bottom: 20,
},
title: {
text: `主标题${i}`,
enable: true,
style: {
width: 260,
},
},
subTitle: {
text: '副标题',
enable: true,
style: {
width: 260,
},
},
floatTitle: {
text: '浮动标题',
enable: true,
style: {
width: 260,
},
background: { colors: ['#e5000000', '#00000000'], orientation: 4 },
},
shimmer: {
enable: true,
},
ripple: {
enable: true,
style: {
right: 0,
bottom: 0,
marginRight: -12,
},
},
image: {
src: imgURL,
enable: true,
style: {
width: 260,
height: 320,
},
},
corner: {
text: '角标',
enable: true,
style: {
width: 260,
height: 30,
},
background: {
colors: ['#FE3824', '#F0051E'],
cornerRadii4: [0, 8, 0, 8],
orientation: 2,
},
},
style: {
width: 260,
height: 400,
},
titleStyle: {
width: 260,
height: 120,
marginTop: 320 - 60,
},
titleFocusStyle: { width: 260, marginTop: 320 - 100 },
}
}
// 模拟格子列表
function mockPosterItemList(
sectionId: string,
size = 15
): Array<QTWaterfallItem> {
return new Array(size).fill(1).map((item, i) => {
return mockPosterData(sectionId, i)
})
}
// 模拟板块数据
const mockSectionData = (i, flag) => {
return {
_id: `${i}${Math.random()}`,
type: QTWaterfallSectionType.QT_WATERFALL_SECTION_TYPE_FLEX,
title: `板块标题:${i}${flag}`,
titleStyle: {
width: 1000,
height: 50,
marginTop: 10,
marginBottom: 10,
fontSize: 50,
},
itemList: mockPosterItemList(i + flag, 5),
style: {
width: 1620,
// height: -1,
},
decoration: {
left: 1,
right: 1,
top: 10,
},
}
}
// 模拟数据集
const mockList = (flag = '', num = 5) => {
return new Array(num).fill(1).map((item, i) => {
return mockSectionData(i, flag)
})
}
</script>
<style>
.qt-waterfall-ref-css {
width: 1620px;
height: 1080px;
background-color: transparent;
}
</style>
API #
DataStructure #
QTWaterfall #
用来描述瀑布流信息
Name | Description | Type | Default |
---|---|---|---|
width | 瀑布流的宽度 | number | - |
height | 瀑布流的高度 | number | - |
visibleType | 瀑布流显示的类型 | QTWaterfallVisibleType | - |
QTWaterfallItem #
用来描述瀑布流Item
信息
Name | Description | Type | Default |
---|---|---|---|
_id | 瀑布流item的id | string | - |
type | 瀑布流item的类型 | number | - |
decoration | 瀑布流item的装饰尺寸 | QTListViewItemDecoration | - |
style | 瀑布流item视图的样式 | QTWaterfallFlexStyle | - |
QTWaterfallSection #
用来描述瀑布流Section
信息
Name | Description | Type | Default |
---|---|---|---|
_id | 瀑布流section的id | string | - |
type | 瀑布流section的类型 | number | - |
decoration | 瀑布流section的装饰尺寸 | QTListViewItemDecoration | - |
style | 瀑布流section视图的样式 | QTWaterfallFlexStyle | - |
title | 瀑布流section的标题 | string | - |
titleStyle | 瀑布流section的标题样式 | QTWaterfallFlexStyle & QTFlexStyleText | - |
itemList | 瀑布流section中的item列表 | Array<QTWaterfallItem> | - |
placeholder | 瀑布流section中的占位 | QTWaterfallPlaceholder | - |
Attributes #
Name | Description | Type | Default |
---|---|---|---|
enablePlaceholder | 是否启用占位图 | boolean | false |
blockFocusDirections | 拦截焦点的方向 | object | ['left', 'right'] |
scrollYLesserReferenceValue | Y轴滚动减少的阈值 | number | 0 |
scrollYGreaterReferenceValue | Y轴滚动增加的阈值 | number | 0 |
focusable | 是否可以获得焦点 | boolean | false |
clipChildren | 裁剪子布局 | boolean | false |
clipPadding | 从padding区域向外裁剪 | boolean | false |
nextFocusDownSID 2.7 | 向下时指定下一个焦点sid | string | - |
nextFocusUpSID 2.7 | 向上时指定下一个焦点sid | string | - |
nextFocusLeftSID 2.7 | 向左时指定下一个焦点sid | string | - |
nextFocusRightSID 2.7 | 向右时指定下一个焦点sid | string | - |
nextFocusSID 2.7 | 指定各方向下一个焦点sid | object | - |
sid 2.7 | 给一个元素标记一个string id ,可随意赋值,需确保唯一 | string | - |
fadingEdgeLength 2.5 | 淡出效果长度 | number | 0 |
horizontalFadingEdgeEnabled 2.5 | 开启横向淡出效果 | boolean | false |
verticalFadingEdgeEnabled 2.5 | 开启纵向淡出效果 | boolean | false |
autofocus 2.7 | 组件内根据状态(初始化、可见性改变、尺寸改变 )变化自动获焦,focusable为true时自己获焦 | boolean | false |
renderToHardwareTextureAndroid | 设置layerType 为LAYER_TYPE_HARDWARE | boolean | false |
viewLayerType | 设置layerType | enum | - |
clipBounds | 设置裁剪区域 | object | - |
descendantFocusability | 设置子孙组件的可聚焦性策略 | enum | - |
name | 指定元素的name | string | - |
nextFocusName | 指定各方向下一个焦点元素的name | object | - |
visible | 是否可见 | boolean | false |
visibility | 可见性 | enum | visible |
size | 设置元素大小 | array | - |
layout | 设置元素位置及大小 | array | - |
selectChildPosition | 设置选中子元素位置 | number | -1 |
enableSelectOnFocus | 开启当焦点时自动设置选中子元素位置 | number | -1 |
focusMemory | 开启子元素焦点记忆 | boolean | false |
useDiff | 开启时更新diff算法,提高性能,解决多次刷新问题 beta | boolean | false |
initPosition | 列表初始化时一些滚动位置、初始化焦点等设置 deprecated 使用autofocus、autoscroll替代 | object | - |
listenBoundEvent | 开启监听item-focused 等事件 | boolean | false |
enableItemAnimator | 开启item加载动画 | boolean | false |
disableScrollOnFirstScreen | 首屏时焦点切换不滚动 beta | boolean | false |
skipFocusOnPause | pause 状态时不可获焦 | boolean | false |
taskPaused | 将组件活动 (如创建item等,postDelay 的组件)暂停 | boolean | false |
pauseTaskOnHide | 组件不可见时pause | boolean | false |
resetOnDetach | 开启时自动在离开屏幕时重置状态、滚动到头部 | boolean | false |
touchScrollEnabled | 开启触屏时滚动 | boolean | true |
firstFocusChild 2.87 | 指定从各方向获焦时,首个获焦对象,由child 的position 或sid 指定 | object | - |
enableFirstFocusAtStart 2.87 | 开启首个获焦对象为头部child | boolean | false |
enablePlaceholder 2.5 | 加载时是否先展示placeholder | boolean | false |
checkScrollOffsetOnStateChanged | 是否在滚动事件时触发事件监听 | boolean | false |
onScrollEnable | 开启scroll 事件监听 | boolean | true |
makeChildVisibleType | 列表随焦点变化滚动方式 | enum | center |
makeChildVisibleClampBackward | 列表向后滚动时的留白beta | number | 0 |
makeChildVisibleClampForward | 列表向后滚动时的留白beta | number | 0 |
scrollThresholdHorizontal | 横向焦点触发滚动的阈值 | number | 0 |
scrollThresholdVertical | 纵向焦点触发滚动的阈值 | number | 0 |
cachePool | item 缓存池,可以设置缓存池name ,指定不同type 类型item 的数量,以优化性能 | object | - |
cachePoolName | cachePool 简化版,只可指定缓存池name ,不同实例,相同name 使用同一缓存池 | string | - |
selectChildPosition | 选中子item位置 | number | -1 |
shakePreCheckNumber | 到底抖动提示提前位置 | number | 2 |
placeholderFocusScale 2.7 | placeholder 焦点放大倍数 | number | 1.1 |
placeholderColorString 2.7 | placeholder 背景颜色(#RRGGBBAA ) | string | #FFFFFF1A |
placeholderColor 2.7 | placeholder 背景颜色 | number | (255,255,255,0.1) |
placeholderBorderRadius 2.7 | placeholder 圆角 | number | 8 |
endShakeEnabled | 到底反馈 | boolean | true |
listenFocusSearchOnFail | 监听内部寻焦失败 | boolean | false |
enableStatesOnFocus | 子item获焦时自动改变自定义 名称的状态 | array | false |
placeholderPostDelay 2.5 | placeholder 变为真实内容的delay时间 | number | 100ms |
enableKeepFocus | 保持焦点在内部 | boolean | false |
scrollFactor | 滚动速度参数 | number | 1 |
autofocusPosition 2.7 | 自动焦点位置 | number | -1 |
autofocusSID 2.8 | 自动焦点位置 | string | |
autoscroll 2.7 | 自动滚动参数[position,offset] | array | - |
autoSelectPosition 2.7 | 自动选择位置beta | number | -1 |
infiniteMode 2.87 | 循环模式 | boolean | false |
infiniteParams 2.87 | 循环模式参数:{autoscroll:array,scrollOffset:number, itemSize : number,selectPosition:number,minChildScale:number} | object | - |
listData beta | 双向绑定数据集 | Array | [] |
Events #
Name | Description | Type |
---|---|---|
onScroll | 页面滚动 | Function |
onScrollStateChanged | 页面滚动状态变化 | Function |
onItemClick | 条目点击事件 | Function |
onItemFocused | 条目焦点变化 | Function |
onSectionBind | 板块绑定 | Function |
onSectionAttached | 板块Attached | Function |
onSectionDetached | 板块Detached | Function |
onScrollYGreaterReference | Y轴滚动增加事件 | Function |
onScrollYLesserReference | Y轴滚动减少事件 | Function |
onPluginLoadSuccess | 插件加载成功 | Function |
onPluginLoadError | 插件加载失败 | Function |
Slots #
Name | Description |
---|---|
item | flex section中自定义item. |
list-item | list section 中自定义item. |
vue-section | vue section 中内容. |
section | 自定义section. |
Exposes #
Name | Description | Type |
---|---|---|
init | 该方法根据初始化瀑布流 | Function |
getSectionList | 该方法获取瀑布流包含的板块列表数据 | Function |
setSectionList | 该方法设置瀑布流板块列表数据 | Function |
addSectionList | 该方法给瀑布流添加板块 | Function |
deleteSection | 该方法删除指定的板块 | Function |
updateSection | 该方法更新指定index的瀑布流板块 | Function |
updateSectionList | 该方法更新瀑布流板块列表 | Function |
getSection | 该方法获取指定索引的瀑布流板块 | Function |
addItemList | 该方法向指定索引的板块中添加条目 | Function |
deleteItem | 该方法删除指定索引板块中的条目 | Function |
updateItem | 该方法更新指定索引板块中的条目 | Function |
updateItemList | 该方法更新指定索引板块中的条目列表 | Function |
getItem | 该方法获取指定索引板块中的条目 | Function |
scrollToIndex | 滚动到指定位置 | Function |
startScroll | 开始滚动 | Function |
setSelectChildPosition | 选中指定位置的条目 | Function |
scrollToPositionWithOffset | 滚动到指定的位置 | Function |
scrollToPositionWithOffsetInfiniteMode | 滚动到指定的位置 | Function |
scrollToPosition | 滚动到指定的位置 | Function |
refreshListData | 刷新列表数据 | Function |
updateItemTraverse | 更新条目 | Function |
requestItemLayout | 条目刷新布局 | Function |
updateItemRange | 更新条目 | Function |
insertItemRange | 插入条目 | Function |
updateItemMatched | 更新条目 | Function |
updateItemMatchedByKey | 更新条目 | Function |
deleteItemRange | 删除条目 | Function |
setListData | 设置列表数据 | Function |
setListDataWithParams | 设置列表数据 | Function |
addListData | 添加数据 | Function |
addListDataWithParams | 添加数据 | Function |
destroy | 销毁 | Function |
recycle | 回收 | Function |
scrollToTop | 滚动到顶部 | Function |
scrollToFocus | 滚动到焦点 | Function |
prepareForRecycle | 准备回收 | Function |
setDisplay | 是否显示 | Function |
changeDisplayState | 改变显示状态 | Function |
notifySaveInstance | 请求保存状态 | Function |
updateItemProps | 更新条目属性 | Function |
dispatchItemFunction | 执行条目方法 | Function |
clearPostTask | 清空任务 | Function |
clearPostTaskByCate | 清空任务 | Function |
clearData | 清空数据 | Function |
pausePostTask | 暂停任务 | Function |
resumePostTask | 恢复任务 | Function |
requestLayoutManual | 手动刷新布局 | Function |
setSpanCount | 设置格子数量 | Function |
searchReplaceItem | 请求替换条目 | Function |
setCustomStateEnableOnFocus | 设置自定义状态在焦点时是否可用 | Function |
setItemCustomState | 设置条目自定义状态 | Function |
dispatchItemFunctionWithPromise | 执行条目的方法 | Function |
getScrollOffset | 获取滚动的偏移量 | Function |