@quicktvui/web-renderer 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +24 -0
- package/src/adapters/es3-video-player.js +828 -0
- package/src/components/Modal.js +119 -0
- package/src/components/QtAnimationView.js +678 -0
- package/src/components/QtBaseComponent.js +165 -0
- package/src/components/QtFastListView.js +1920 -0
- package/src/components/QtFlexView.js +799 -0
- package/src/components/QtImage.js +203 -0
- package/src/components/QtItemFrame.js +239 -0
- package/src/components/QtItemStoreView.js +93 -0
- package/src/components/QtItemView.js +125 -0
- package/src/components/QtListView.js +331 -0
- package/src/components/QtLoadingView.js +55 -0
- package/src/components/QtPageRootView.js +19 -0
- package/src/components/QtPlayMark.js +168 -0
- package/src/components/QtProgressBar.js +199 -0
- package/src/components/QtQRCode.js +78 -0
- package/src/components/QtReplaceChild.js +149 -0
- package/src/components/QtRippleView.js +166 -0
- package/src/components/QtSeekBar.js +409 -0
- package/src/components/QtText.js +679 -0
- package/src/components/QtTransitionImage.js +170 -0
- package/src/components/QtView.js +706 -0
- package/src/components/QtWebView.js +613 -0
- package/src/components/TabsView.js +420 -0
- package/src/components/ViewPager.js +206 -0
- package/src/components/index.js +24 -0
- package/src/components/plugins/TextV2Component.js +70 -0
- package/src/components/plugins/index.js +7 -0
- package/src/core/SceneBuilder.js +58 -0
- package/src/core/TVFocusManager.js +2014 -0
- package/src/core/asyncLocalStorage.js +175 -0
- package/src/core/autoProxy.js +165 -0
- package/src/core/componentRegistry.js +84 -0
- package/src/core/constants.js +6 -0
- package/src/core/index.js +8 -0
- package/src/core/moduleUtils.js +36 -0
- package/src/core/patches.js +958 -0
- package/src/core/templateBinding.js +666 -0
- package/src/index.js +246 -0
- package/src/modules/AndroidDevelopModule.js +101 -0
- package/src/modules/AndroidDeviceModule.js +341 -0
- package/src/modules/AndroidNetworkModule.js +178 -0
- package/src/modules/AndroidSharedPreferencesModule.js +100 -0
- package/src/modules/ESDeviceInfoModule.js +450 -0
- package/src/modules/ESGroupDataModule.js +195 -0
- package/src/modules/ESIJKAudioPlayerModule.js +477 -0
- package/src/modules/ESLocalStorageModule.js +100 -0
- package/src/modules/ESLogModule.js +65 -0
- package/src/modules/ESModule.js +106 -0
- package/src/modules/ESNetworkSpeedModule.js +117 -0
- package/src/modules/ESToastModule.js +172 -0
- package/src/modules/EsNativeModule.js +117 -0
- package/src/modules/FastListModule.js +101 -0
- package/src/modules/FocusModule.js +145 -0
- package/src/modules/RuntimeDeviceModule.js +176 -0
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
// QtTransitionImage - 支持过渡效果的图片组件
|
|
2
|
+
import { QtBaseComponent } from './QtBaseComponent'
|
|
3
|
+
import { registerComponent } from '../core/componentRegistry'
|
|
4
|
+
|
|
5
|
+
export class QtTransitionImage extends QtBaseComponent {
|
|
6
|
+
constructor(context, id, pId) {
|
|
7
|
+
super(context, id, pId)
|
|
8
|
+
this.tagName = 'TransitionImageComponent'
|
|
9
|
+
this.dom = document.createElement('div')
|
|
10
|
+
|
|
11
|
+
// 容器样式
|
|
12
|
+
this.dom.style.cssText = `
|
|
13
|
+
display: block;
|
|
14
|
+
background-size: cover;
|
|
15
|
+
background-position: center;
|
|
16
|
+
background-repeat: no-repeat;
|
|
17
|
+
`
|
|
18
|
+
|
|
19
|
+
// 默认过渡时间 (ms)
|
|
20
|
+
this._transitionDuration = 300
|
|
21
|
+
this._currentSrc = ''
|
|
22
|
+
|
|
23
|
+
// 注册组件
|
|
24
|
+
registerComponent(id, this)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// 处理属性更新
|
|
28
|
+
updateProperty(key, value) {
|
|
29
|
+
switch (key) {
|
|
30
|
+
case 'src':
|
|
31
|
+
case 'source':
|
|
32
|
+
this._setSrc(value)
|
|
33
|
+
break
|
|
34
|
+
case 'transitionDuration':
|
|
35
|
+
case 'transition-duration':
|
|
36
|
+
this._transitionDuration = typeof value === 'number' ? value : parseInt(value) || 300
|
|
37
|
+
break
|
|
38
|
+
case 'resizeMode':
|
|
39
|
+
this._setResizeMode(value)
|
|
40
|
+
break
|
|
41
|
+
default:
|
|
42
|
+
super.updateProperty(key, value)
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// 设置图片源(带过渡效果)
|
|
47
|
+
_setSrc(value) {
|
|
48
|
+
if (!value) {
|
|
49
|
+
this.dom.style.backgroundImage = ''
|
|
50
|
+
this._currentSrc = ''
|
|
51
|
+
return
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
let srcValue = ''
|
|
55
|
+
if (typeof value === 'string') {
|
|
56
|
+
srcValue = value
|
|
57
|
+
} else if (typeof value === 'object' && value.uri) {
|
|
58
|
+
srcValue = value.uri
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// 如果是同一张图片,不做处理
|
|
62
|
+
if (srcValue === this._currentSrc) return
|
|
63
|
+
|
|
64
|
+
// 如果当前没有图片,直接显示
|
|
65
|
+
if (!this._currentSrc) {
|
|
66
|
+
this.dom.style.backgroundImage = `url(${srcValue})`
|
|
67
|
+
this._currentSrc = srcValue
|
|
68
|
+
return
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// 有当前图片,执行渐变过渡
|
|
72
|
+
this._transitionToImage(srcValue)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// 渐变过渡到新图片
|
|
76
|
+
_transitionToImage(newSrc) {
|
|
77
|
+
// 先加载新图片
|
|
78
|
+
const img = new Image()
|
|
79
|
+
img.onload = () => {
|
|
80
|
+
// 淡出当前图片
|
|
81
|
+
this.dom.style.transition = `opacity ${this._transitionDuration / 2}ms ease-out`
|
|
82
|
+
this.dom.style.opacity = '0'
|
|
83
|
+
|
|
84
|
+
// 淡出完成后,切换图片并淡入
|
|
85
|
+
setTimeout(() => {
|
|
86
|
+
this.dom.style.backgroundImage = `url(${newSrc})`
|
|
87
|
+
this._currentSrc = newSrc
|
|
88
|
+
|
|
89
|
+
// 淡入新图片
|
|
90
|
+
this.dom.style.transition = `opacity ${this._transitionDuration / 2}ms ease-in`
|
|
91
|
+
this.dom.style.opacity = '1'
|
|
92
|
+
|
|
93
|
+
// 过渡完成后清除 transition
|
|
94
|
+
setTimeout(() => {
|
|
95
|
+
this.dom.style.transition = ''
|
|
96
|
+
}, this._transitionDuration / 2)
|
|
97
|
+
}, this._transitionDuration / 2)
|
|
98
|
+
}
|
|
99
|
+
img.onerror = () => {
|
|
100
|
+
console.warn('[QtTransitionImage] Image load failed:', newSrc)
|
|
101
|
+
}
|
|
102
|
+
img.src = newSrc
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// 设置缩放模式
|
|
106
|
+
_setResizeMode(value) {
|
|
107
|
+
const backgroundSize =
|
|
108
|
+
{
|
|
109
|
+
contain: 'contain',
|
|
110
|
+
cover: 'cover',
|
|
111
|
+
fill: '100% 100%',
|
|
112
|
+
center: 'auto',
|
|
113
|
+
origin: 'auto',
|
|
114
|
+
}[value] || 'cover'
|
|
115
|
+
|
|
116
|
+
this.dom.style.backgroundSize = backgroundSize
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// 设置下一张图片(带过渡效果)
|
|
120
|
+
// params 是数组形式,由 patches.js 的 callUIFunction 调用
|
|
121
|
+
setNextImage(params) {
|
|
122
|
+
const url = Array.isArray(params) ? params[0] : params
|
|
123
|
+
if (url && url !== this._currentSrc) {
|
|
124
|
+
this._transitionToImage(url)
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// 设置下一个颜色(带过渡效果)
|
|
129
|
+
setNextColor(params) {
|
|
130
|
+
const color = Array.isArray(params) ? params[0] : params
|
|
131
|
+
const formattedColor = this._formatColor(color)
|
|
132
|
+
|
|
133
|
+
// 淡出
|
|
134
|
+
this.dom.style.transition = `opacity ${this._transitionDuration / 2}ms ease-out`
|
|
135
|
+
this.dom.style.opacity = '0'
|
|
136
|
+
|
|
137
|
+
setTimeout(() => {
|
|
138
|
+
this.dom.style.backgroundImage = ''
|
|
139
|
+
this.dom.style.backgroundColor = formattedColor
|
|
140
|
+
this._currentSrc = ''
|
|
141
|
+
|
|
142
|
+
// 淡入
|
|
143
|
+
this.dom.style.transition = `opacity ${this._transitionDuration / 2}ms ease-in`
|
|
144
|
+
this.dom.style.opacity = '1'
|
|
145
|
+
|
|
146
|
+
setTimeout(() => {
|
|
147
|
+
this.dom.style.transition = ''
|
|
148
|
+
}, this._transitionDuration / 2)
|
|
149
|
+
}, this._transitionDuration / 2)
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// 设置过渡时间
|
|
153
|
+
setTransitionTime(params) {
|
|
154
|
+
const duration = Array.isArray(params) ? params[0] : params
|
|
155
|
+
this._transitionDuration = typeof duration === 'number' ? duration : parseInt(duration) || 300
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// 格式化颜色值
|
|
159
|
+
_formatColor(color) {
|
|
160
|
+
if (typeof color === 'number') {
|
|
161
|
+
// ARGB 格式
|
|
162
|
+
const a = ((color >> 24) & 0xff) / 255
|
|
163
|
+
const r = (color >> 16) & 0xff
|
|
164
|
+
const g = (color >> 8) & 0xff
|
|
165
|
+
const b = color & 0xff
|
|
166
|
+
return `rgba(${r}, ${g}, ${b}, ${a})`
|
|
167
|
+
}
|
|
168
|
+
return color
|
|
169
|
+
}
|
|
170
|
+
}
|