@shijiu/jsview-vue 0.9.602 → 0.9.684
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/dom/bin/jsview-browser-debug-dom.min.js +1 -1
- package/dom/bin/jsview-dom.min.js +1 -1
- package/dom/bin/jsview-engine-js-browser.min.js +1 -0
- package/dom/target_core_revision.js +4 -4
- package/package.json +1 -1
- package/samples/Basic/components/text/TextOverflow.vue +10 -5
- package/samples/Collision/App.vue +452 -0
- package/samples/DemoHomepage/components/BodyFrame.vue +2 -0
- package/samples/DemoHomepage/router.js +25 -0
- package/samples/DemoHomepage/views/Homepage.vue +3 -10
- package/samples/ImpactStop/App.vue +435 -0
- package/samples/Input/App.vue +8 -17
- package/samples/Input/InputPanel.vue +18 -11
- package/samples/Marquee/App.vue +176 -40
- package/samples/Marquee/longText.js +14 -0
- package/samples/MetroWidgetDemos/Advanced/App.vue +5 -6
- package/samples/MetroWidgetDemos/Advanced/ButtonItem.vue +1 -1
- package/samples/MetroWidgetDemos/Advanced/Buttons.vue +5 -5
- package/samples/MetroWidgetDemos/Advanced/Mixed.vue +4 -4
- package/samples/MetroWidgetDemos/Advanced/widgets/Item.vue +83 -0
- package/samples/MetroWidgetDemos/Advanced/widgets/WidgetItem.vue +89 -0
- package/samples/MetroWidgetDemos/Advanced/{Widgets.vue → widgets/Widgets.vue} +56 -11
- package/samples/MetroWidgetDemos/Advanced/widgets/focus1.png +0 -0
- package/samples/MetroWidgetDemos/Item.vue +20 -2
- package/samples/MetroWidgetDemos/PingPong/App.vue +3 -3
- package/samples/MetroWidgetDemos/PingPong/AppPage.vue +17 -2
- package/samples/MetroWidgetDemos/PingPong/AppTab.vue +3 -10
- package/samples/MetroWidgetDemos/PingPong/{Item.vue → TabItem.vue} +2 -10
- package/samples/MetroWidgetDemos/PingPong/ViewSwiper.vue +2 -2
- package/samples/MetroWidgetDemos/Simple/AbsoluteTemplate.vue +2 -2
- package/samples/MetroWidgetDemos/Simple/App.vue +2 -2
- package/samples/MetroWidgetDemos/Simple/RelativeTemplate.vue +4 -4
- package/samples/MetroWidgetDemos/data.js +2 -1
- package/samples/Preload/App.vue +16 -11
- package/samples/ScaleDownNeon/App.vue +107 -0
- package/samples/TextBox/App.vue +7 -81
- package/samples/TextBox/RenderCenter.vue +40 -16
- package/samples/TextBox/RenderLeft.vue +48 -19
- package/samples/TextBox/RenderOneLine.vue +30 -49
- package/samples/TextBox/RenderRight.vue +40 -16
- package/samples/TextShadowDemo/App.vue +11 -17
- package/samples/TextureAnimation/App2.vue +111 -0
- package/samples/TextureAnimation/assets/blackWhiteGrid.png +0 -0
- package/samples/TextureAnimation/assets/light.png +0 -0
- package/samples/TextureAnimation/assets/light2.png +0 -0
- package/samples/TextureAnimation/assets/mask.png +0 -0
- package/samples/TextureSize/App.vue +3 -3
- package/samples/VisibleSensorDemo/App.vue +92 -25
- package/utils/JsViewEngineWidget/MetroWidget/Const.js +11 -0
- package/utils/JsViewEngineWidget/MetroWidget/MetroWidget.vue +188 -80
- package/utils/JsViewEngineWidget/TemplateParser.js +89 -32
- package/utils/JsViewEngineWidget/WidgetCommon.js +3 -4
- package/utils/JsViewEngineWidget/index.js +3 -2
- package/utils/JsViewPlugin/JsvPlayer/JsvMedia.js +95 -12
- package/utils/JsViewPlugin/JsvPlayer/JsvPlayer.vue +25 -3
- package/utils/JsViewPlugin/JsvPlayer/index.js +22 -1
- package/utils/JsViewPlugin/JsvPlayer/version.js +4 -4
- package/utils/JsViewVueTools/JsvImpactTracer.js +113 -0
- package/utils/JsViewVueTools/index.js +2 -1
- package/utils/JsViewVueWidget/BrowserDebugWidget/BrowserPreload.vue +11 -1
- package/utils/JsViewVueWidget/BrowserDebugWidget/BrowserTextureAnim.vue +203 -14
- package/utils/JsViewVueWidget/JsvActorMove/JsvActorMove.vue +2 -2
- package/utils/JsViewVueWidget/JsvInput/Cursor.vue +4 -2
- package/utils/JsViewVueWidget/JsvInput/JsvInput.vue +13 -12
- package/utils/JsViewVueWidget/JsvMarquee.vue +178 -205
- package/utils/JsViewVueWidget/JsvNativeSharedDiv.vue +35 -27
- package/utils/JsViewVueWidget/JsvNinePatch.vue +1 -2
- package/utils/JsViewVueWidget/JsvPreload/JsvPreload.vue +37 -41
- package/utils/JsViewVueWidget/JsvSpriteAnim/JsvSpriteAnim.vue +282 -285
- package/utils/JsViewVueWidget/JsvSwiper/JsvSwiper.vue +18 -2
- package/utils/JsViewVueWidget/JsvSwiper3D/JsvSwiper.vue +22 -2
- package/utils/JsViewVueWidget/JsvTextBox.vue +35 -72
- package/utils/JsViewVueWidget/JsvTextureAnim/JsvTextureAnim.vue +123 -46
- package/utils/JsViewVueWidget/JsvTextureAnim/index.js +9 -5
- package/utils/JsViewVueWidget/JsvTouchContainer.vue +3 -4
- package/utils/JsViewVueWidget/JsvVideo.vue +9 -12
- package/utils/JsViewVueWidget/index.js +2 -2
- package/utils/JsViewVueWidget/utils/index.js +8 -0
- package/utils/JsViewVueWidget/utils/text.js +19 -0
- package/utils/JsViewEngineWidget/MetroPage.js +0 -2128
- package/utils/JsViewEngineWidget/SimpleWidget/ContentView.vue +0 -51
- package/utils/JsViewEngineWidget/SimpleWidget/Dispatcher.js +0 -19
- package/utils/JsViewEngineWidget/SimpleWidget/DivWrapper.vue +0 -53
- package/utils/JsViewEngineWidget/SimpleWidget/ItemView.vue +0 -142
- package/utils/JsViewEngineWidget/SimpleWidget/RootView.vue +0 -140
- package/utils/JsViewEngineWidget/SimpleWidget/SimpleWidget.vue +0 -1629
|
@@ -3,236 +3,209 @@
|
|
|
3
3
|
* JsvMarquee:Vue高阶组件,文字跑马灯
|
|
4
4
|
* props说明:
|
|
5
5
|
* text {String} 文字内容
|
|
6
|
-
*
|
|
7
|
-
* fontStyles {Array|Object} 文字样式
|
|
6
|
+
* style {Object} 样式
|
|
8
7
|
* slideSpeed {int} 滚动速度 px/s, 默认60
|
|
9
8
|
* forceSlide {boolean} 短文字是否滚动,默认false
|
|
10
9
|
-->
|
|
11
10
|
|
|
12
|
-
<script>
|
|
11
|
+
<script setup>
|
|
13
12
|
import { Forge } from "../../dom/jsv-forge-define";
|
|
14
|
-
import {
|
|
15
|
-
|
|
16
|
-
JsvTextStyleClass,
|
|
17
|
-
combinedStyles,
|
|
18
|
-
} from "../JsViewVueTools/JsvStyleClass";
|
|
13
|
+
import { getTextWidth } from "./utils";
|
|
14
|
+
import { ref, computed, toRaw, onMounted, onBeforeUnmount } from "vue";
|
|
19
15
|
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
// 60px per second
|
|
51
|
-
type: Number,
|
|
52
|
-
default: 60,
|
|
53
|
-
},
|
|
54
|
-
forceSlide: {
|
|
55
|
-
type: Boolean,
|
|
56
|
-
default: false,
|
|
57
|
-
},
|
|
58
|
-
className: {
|
|
59
|
-
type: String,
|
|
16
|
+
const defaultFontStyle = () => {
|
|
17
|
+
return {
|
|
18
|
+
color: "rgba(255,255,255,1.0)",
|
|
19
|
+
fontSize: 10,
|
|
20
|
+
textAlign: "start",
|
|
21
|
+
lineHeight: "20px",
|
|
22
|
+
whiteSpace: "nowrap",
|
|
23
|
+
direction: 'ltr'
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
const props = defineProps({
|
|
27
|
+
text: {
|
|
28
|
+
type: String,
|
|
29
|
+
default: "",
|
|
30
|
+
},
|
|
31
|
+
style: {
|
|
32
|
+
type: Object,
|
|
33
|
+
default() {
|
|
34
|
+
return {
|
|
35
|
+
left: 0,
|
|
36
|
+
top: 0,
|
|
37
|
+
width: 0,
|
|
38
|
+
height: 20,
|
|
39
|
+
color: "rgba(255,255,255,1.0)",
|
|
40
|
+
fontSize: 10,
|
|
41
|
+
textAlign: "start",
|
|
42
|
+
lineHeight: "20px",
|
|
43
|
+
whiteSpace: "nowrap",
|
|
44
|
+
direction: 'ltr,'
|
|
45
|
+
};
|
|
60
46
|
},
|
|
61
47
|
},
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
rollTimeId: -1,
|
|
66
|
-
animationCount: 0,
|
|
67
|
-
LayoutStyle: null,
|
|
68
|
-
FontStyle: null,
|
|
69
|
-
FontStyleClass: null,
|
|
70
|
-
TokenProcessed: null,
|
|
71
|
-
};
|
|
48
|
+
slideSpeed: {
|
|
49
|
+
type: Number,
|
|
50
|
+
default: 60,
|
|
72
51
|
},
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
return this.FontStyleClass ? this.FontStyleClass : this.className;
|
|
77
|
-
},
|
|
52
|
+
forceSlide: {
|
|
53
|
+
type: Boolean,
|
|
54
|
+
default: false,
|
|
78
55
|
},
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
56
|
+
});
|
|
57
|
+
const slideDiv = ref(null);
|
|
58
|
+
const textDiv = ref(null);
|
|
59
|
+
let animState = 0;
|
|
60
|
+
let animIdleHandler = -1;
|
|
61
|
+
let asyncStartHandler = -1;
|
|
62
|
+
const fontStyle = computed(() => {
|
|
63
|
+
let { left, top, width, height, ...rest } = props.style;
|
|
64
|
+
let r = defaultFontStyle();
|
|
65
|
+
Object.assign(r, rest);
|
|
66
|
+
if (props.forceSlide) {
|
|
67
|
+
//滚送时必需start对齐
|
|
68
|
+
r.textAlign = "start";
|
|
69
|
+
}
|
|
70
|
+
return r;
|
|
71
|
+
});
|
|
72
|
+
//rtl文字需要先获得文字宽度
|
|
73
|
+
let textWidth =
|
|
74
|
+
fontStyle.value.direction == "rtl" ? getTextWidth(props.text, fontStyle.value) : 0;
|
|
75
|
+
const slideDivLeft = computed(() =>
|
|
76
|
+
fontStyle.value.direction == "rtl" && props.style.width < textWidth
|
|
77
|
+
? props.style.width - textWidth
|
|
78
|
+
: 0
|
|
79
|
+
);
|
|
83
80
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
const text_width = this.$refs.textRef.clientWidth;
|
|
107
|
-
if (this.animationCount % 2 === 0) {
|
|
108
|
-
// 文字从原始位置,向左移动出屏幕(每次完整移动,停顿1秒)
|
|
109
|
-
this.rollTimeId = setTimeout(() => {
|
|
110
|
-
this.rollTimeId = -1;
|
|
111
|
-
const anim = new Forge.TranslateFrameAnimation(
|
|
112
|
-
0,
|
|
113
|
-
-text_width,
|
|
114
|
-
this.$props.slideSpeed,
|
|
115
|
-
true,
|
|
116
|
-
0,
|
|
117
|
-
0
|
|
118
|
-
);
|
|
119
|
-
anim.SetAnimationListener(
|
|
120
|
-
new Forge.AnimationListener(
|
|
121
|
-
null,
|
|
122
|
-
(ended) => {
|
|
123
|
-
if (ended) {
|
|
124
|
-
// 正常结束,非Cancel时,进行下一个动作
|
|
125
|
-
this._slideNextStep();
|
|
126
|
-
}
|
|
127
|
-
},
|
|
128
|
-
null
|
|
129
|
-
)
|
|
130
|
-
);
|
|
131
|
-
anim.Enable(Forge.AnimationEnable.ReleaseAfterEndCallback);
|
|
132
|
-
this.$refs.sliderRef.jsvMaskView.StartAnimation(anim);
|
|
133
|
-
this.animationCount += 1;
|
|
134
|
-
}, 1000);
|
|
135
|
-
} else {
|
|
136
|
-
// 文字从右边屏幕外部,移动回屏幕中的文字原始位置
|
|
137
|
-
const anim = new Forge.TranslateFrameAnimation(
|
|
138
|
-
this.LayoutStyle.width,
|
|
139
|
-
0,
|
|
140
|
-
this.$props.slideSpeed,
|
|
141
|
-
true,
|
|
142
|
-
this.LayoutStyle.width,
|
|
143
|
-
0
|
|
144
|
-
);
|
|
145
|
-
anim.SetAnimationListener(
|
|
146
|
-
new Forge.AnimationListener(
|
|
147
|
-
null,
|
|
148
|
-
(ended) => {
|
|
149
|
-
if (ended) {
|
|
150
|
-
// 正常结束,非Cancel时,进行下一个动作
|
|
151
|
-
this._slideNextStep();
|
|
152
|
-
}
|
|
153
|
-
},
|
|
154
|
-
null
|
|
155
|
-
)
|
|
156
|
-
);
|
|
157
|
-
this.$refs.sliderRef.jsvMaskView.StartAnimation(anim);
|
|
158
|
-
this.animationCount += 1;
|
|
159
|
-
}
|
|
160
|
-
},
|
|
161
|
-
_AnalyzeStyleChange() {
|
|
162
|
-
if (this.$props.styleToken !== this.TokenProcessed) {
|
|
163
|
-
// Token变化时,重新解析style array
|
|
164
|
-
let style_list;
|
|
165
|
-
if (this.layoutStyles instanceof Array) {
|
|
166
|
-
style_list = this.layoutStyles;
|
|
167
|
-
} else {
|
|
168
|
-
style_list = [this.layoutStyles];
|
|
169
|
-
}
|
|
170
|
-
const layout_set = combinedStyles(style_list, true);
|
|
171
|
-
this.LayoutStyle = layout_set.combinedStyle;
|
|
172
|
-
if (this.fontStyles) {
|
|
173
|
-
if (this.fontStyles instanceof Array) {
|
|
174
|
-
if (this.fontStyles[0] instanceof JsvStyleClass) {
|
|
175
|
-
style_list = [...this.fontStyles, sCommonFontStyle];
|
|
176
|
-
} else {
|
|
177
|
-
style_list = this.fontStyles.map(
|
|
178
|
-
(item) => new JsvStyleClass(item)
|
|
179
|
-
);
|
|
180
|
-
style_list.push(sCommonFontStyle);
|
|
81
|
+
const slideStep = () => {
|
|
82
|
+
if (animState == 0) {
|
|
83
|
+
// 文字从原始位置,移动出屏幕(每次完整移动,停顿1秒)
|
|
84
|
+
let start = 0,
|
|
85
|
+
end = fontStyle.value.direction == "rtl" ? textWidth : -textWidth;
|
|
86
|
+
animIdleHandler = setTimeout(() => {
|
|
87
|
+
animIdleHandler = -1;
|
|
88
|
+
const anim = new Forge.TranslateFrameAnimation(
|
|
89
|
+
start,
|
|
90
|
+
end,
|
|
91
|
+
props.slideSpeed,
|
|
92
|
+
true,
|
|
93
|
+
0,
|
|
94
|
+
0
|
|
95
|
+
);
|
|
96
|
+
anim.SetAnimationListener(
|
|
97
|
+
new Forge.AnimationListener(
|
|
98
|
+
null,
|
|
99
|
+
(ended) => {
|
|
100
|
+
if (ended) {
|
|
101
|
+
// 正常结束,非Cancel时,进行下一个动作
|
|
102
|
+
slideStep();
|
|
181
103
|
}
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
104
|
+
},
|
|
105
|
+
null
|
|
106
|
+
)
|
|
107
|
+
);
|
|
108
|
+
anim.Enable(Forge.AnimationEnable.ReleaseAfterEndCallback);
|
|
109
|
+
toRaw(slideDiv.value.jsvMaskView).StartAnimation(anim);
|
|
110
|
+
animState = 1;
|
|
111
|
+
}, 1000);
|
|
112
|
+
} else {
|
|
113
|
+
// 文字从屏幕外部,移动回屏幕中的文字原始位置
|
|
114
|
+
let start =
|
|
115
|
+
fontStyle.value.direction == "rtl" ? -props.style.width : props.style.width,
|
|
116
|
+
end = 0;
|
|
117
|
+
const anim = new Forge.TranslateFrameAnimation(
|
|
118
|
+
start,
|
|
119
|
+
end,
|
|
120
|
+
props.slideSpeed,
|
|
121
|
+
true,
|
|
122
|
+
props.style.width,
|
|
123
|
+
0
|
|
124
|
+
);
|
|
125
|
+
anim.SetAnimationListener(
|
|
126
|
+
new Forge.AnimationListener(
|
|
127
|
+
null,
|
|
128
|
+
(ended) => {
|
|
129
|
+
if (ended) {
|
|
130
|
+
// 正常结束,非Cancel时,进行下一个动作
|
|
131
|
+
slideStep();
|
|
189
132
|
}
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
133
|
+
},
|
|
134
|
+
null
|
|
135
|
+
)
|
|
136
|
+
);
|
|
137
|
+
toRaw(slideDiv.value.jsvMaskView).StartAnimation(anim);
|
|
138
|
+
animState = 0;
|
|
139
|
+
}
|
|
140
|
+
};
|
|
194
141
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
142
|
+
const stopSlide = () => {
|
|
143
|
+
if (animIdleHandler > 0) {
|
|
144
|
+
clearTimeout(animIdleHandler);
|
|
145
|
+
animIdleHandler = -1;
|
|
146
|
+
}
|
|
147
|
+
animState = 0;
|
|
148
|
+
toRaw(slideDiv.value?.jsvMaskView)?.StopAnimation();
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
const asyncStartAnim = () => {
|
|
152
|
+
stopSlide();
|
|
153
|
+
// 稍进行延迟,以等待JsView的native端描绘文字并回传文字宽度
|
|
154
|
+
if (asyncStartHandler > 0) {
|
|
155
|
+
clearTimeout(asyncStartHandler);
|
|
156
|
+
}
|
|
157
|
+
asyncStartHandler = setTimeout(() => {
|
|
158
|
+
if (textWidth <= 0) {
|
|
159
|
+
textWidth = textDiv.value.clientWidth;
|
|
213
160
|
}
|
|
214
|
-
|
|
215
|
-
|
|
161
|
+
if (props.forceSlide || textWidth > props.style.width) {
|
|
162
|
+
slideStep();
|
|
163
|
+
}
|
|
164
|
+
asyncStartHandler = -1;
|
|
165
|
+
}, 500);
|
|
216
166
|
};
|
|
167
|
+
|
|
168
|
+
onMounted(() => {
|
|
169
|
+
if (fontStyle.value.direction == "ltr") {
|
|
170
|
+
//普通的ltr文字异步通过clientWidth获取文字宽度
|
|
171
|
+
asyncStartAnim();
|
|
172
|
+
} else {
|
|
173
|
+
if (props.forceSlide || textWidth > props.style.width) {
|
|
174
|
+
slideStep();
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
onBeforeUnmount(() => {
|
|
180
|
+
clearTimeout(asyncStartHandler);
|
|
181
|
+
asyncStartHandler = -1;
|
|
182
|
+
stopSlide();
|
|
183
|
+
});
|
|
217
184
|
</script>
|
|
218
185
|
|
|
219
186
|
<template>
|
|
220
|
-
<div
|
|
187
|
+
<div
|
|
188
|
+
:style="{
|
|
189
|
+
left: style.left,
|
|
190
|
+
top: style.top,
|
|
191
|
+
width: style.width,
|
|
192
|
+
height: style.height,
|
|
193
|
+
overflow: 'hidden',
|
|
194
|
+
}"
|
|
195
|
+
>
|
|
221
196
|
<div
|
|
222
|
-
ref="
|
|
197
|
+
ref="slideDiv"
|
|
223
198
|
:style="{
|
|
224
|
-
left:
|
|
199
|
+
left: slideDivLeft,
|
|
225
200
|
top: 0,
|
|
226
|
-
width:
|
|
227
|
-
height:
|
|
201
|
+
width: style.width,
|
|
202
|
+
height: style.height,
|
|
228
203
|
}"
|
|
229
204
|
>
|
|
230
205
|
<div
|
|
231
|
-
ref="
|
|
232
|
-
:
|
|
233
|
-
:
|
|
234
|
-
:jsv_text_align_minwidth="LayoutStyle.width"
|
|
235
|
-
jsv-inherit-class="2"
|
|
206
|
+
ref="textDiv"
|
|
207
|
+
:style="{ ...fontStyle, height: style.height }"
|
|
208
|
+
:jsv_text_align_minwidth="style.width"
|
|
236
209
|
>
|
|
237
210
|
{{ text }}
|
|
238
211
|
</div>
|
|
@@ -7,42 +7,51 @@
|
|
|
7
7
|
* 例如`${window.JsView?.getJsContextId()}_${you_name}`
|
|
8
8
|
-->
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
<script>
|
|
11
11
|
import { Forge, ForgeExtension } from "../../dom/jsv-forge-define";
|
|
12
12
|
|
|
13
13
|
export default {
|
|
14
14
|
props: {
|
|
15
15
|
style: {
|
|
16
16
|
type: Object,
|
|
17
|
-
default: () => {
|
|
17
|
+
default: () => {
|
|
18
|
+
return {};
|
|
19
|
+
},
|
|
18
20
|
},
|
|
19
21
|
getId: Function,
|
|
20
22
|
setId: String,
|
|
23
|
+
seeThrough: {
|
|
24
|
+
type: Boolean,
|
|
25
|
+
default: true,
|
|
26
|
+
},
|
|
21
27
|
},
|
|
22
28
|
setup() {
|
|
23
29
|
return {
|
|
24
30
|
isBrowserDebug: window.jsvIsBrowserDebug,
|
|
25
31
|
jsvMainView: undefined,
|
|
26
32
|
innerViewId: undefined,
|
|
27
|
-
}
|
|
33
|
+
};
|
|
28
34
|
},
|
|
29
35
|
beforeMount() {
|
|
30
|
-
if(this.isBrowserDebug) {
|
|
36
|
+
if (this.isBrowserDebug) {
|
|
31
37
|
return;
|
|
32
38
|
}
|
|
33
39
|
|
|
34
40
|
// 初始化View
|
|
35
41
|
|
|
36
42
|
// 创建JsView图层穿透的texture,抠洞处理
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
)
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
// 默认为扣洞,有的场景不需要扣洞
|
|
44
|
+
let textureSetting = null;
|
|
45
|
+
if (this.seeThrough) {
|
|
46
|
+
const seeThroughTexture =
|
|
47
|
+
ForgeExtension.TextureManager.GetColorTexture("rgba(0,0,0,0)");
|
|
48
|
+
textureSetting = new Forge.TextureSetting(
|
|
49
|
+
seeThroughTexture,
|
|
50
|
+
null,
|
|
51
|
+
null,
|
|
52
|
+
false
|
|
53
|
+
);
|
|
54
|
+
}
|
|
46
55
|
|
|
47
56
|
// 通过内置函数构造定制的NativeSharedView
|
|
48
57
|
this.jsvMainView = new Forge.NativeSharedView(textureSetting);
|
|
@@ -51,7 +60,7 @@ export default {
|
|
|
51
60
|
);
|
|
52
61
|
|
|
53
62
|
// 更新宽高
|
|
54
|
-
if(typeof this.jsvMainView!="undefined" && this.jsvMainView){
|
|
63
|
+
if (typeof this.jsvMainView != "undefined" && this.jsvMainView) {
|
|
55
64
|
if (this.setId) {
|
|
56
65
|
// 使用设置进来的track id,而非自动生成
|
|
57
66
|
this.jsvMainView.SetTrackId(this.setId);
|
|
@@ -61,7 +70,7 @@ export default {
|
|
|
61
70
|
}
|
|
62
71
|
},
|
|
63
72
|
beforeUnmount() {
|
|
64
|
-
if(this.isBrowserDebug) {
|
|
73
|
+
if (this.isBrowserDebug) {
|
|
65
74
|
return;
|
|
66
75
|
}
|
|
67
76
|
|
|
@@ -75,21 +84,20 @@ export default {
|
|
|
75
84
|
};
|
|
76
85
|
</script>
|
|
77
86
|
|
|
78
|
-
|
|
79
|
-
<div
|
|
87
|
+
<template>
|
|
88
|
+
<div
|
|
89
|
+
v-if="!isBrowserDebug"
|
|
80
90
|
:style="{
|
|
81
|
-
left: style.left,
|
|
91
|
+
left: style.left,
|
|
82
92
|
top: style.top,
|
|
83
93
|
width: style.width,
|
|
84
|
-
height: style.height
|
|
85
|
-
|
|
94
|
+
height: style.height,
|
|
95
|
+
}"
|
|
86
96
|
:jsv_innerview="innerViewId"
|
|
87
97
|
>
|
|
88
|
-
<slot/>
|
|
89
|
-
</div> <div v-else
|
|
90
|
-
:style="{...style}"
|
|
91
|
-
>
|
|
92
|
-
<slot/>
|
|
98
|
+
<slot />
|
|
93
99
|
</div>
|
|
94
|
-
|
|
95
|
-
|
|
100
|
+
<div v-else :style="{ ...style }">
|
|
101
|
+
<slot />
|
|
102
|
+
</div>
|
|
103
|
+
</template>
|
|
@@ -44,7 +44,6 @@ export default {
|
|
|
44
44
|
if (!this.waitForInit) {
|
|
45
45
|
return true;
|
|
46
46
|
}
|
|
47
|
-
|
|
48
47
|
return this.style && this.style.width !== 0 && this.style.height !== 0;
|
|
49
48
|
},
|
|
50
49
|
getTransition() {
|
|
@@ -79,7 +78,7 @@ export default {
|
|
|
79
78
|
|
|
80
79
|
<template>
|
|
81
80
|
<div
|
|
82
|
-
v-if="isReady"
|
|
81
|
+
v-if="isReady()"
|
|
83
82
|
:style="{
|
|
84
83
|
...style,
|
|
85
84
|
transition: getTransition(),
|
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
* 列表的内容可以是图片,音频等任何网络资源,下载后缓存在本地,归入本地缓存管理(LRU清理策略)
|
|
8
8
|
* onPreloading {Function(float percent)}: 预加载中回调,返回预加载进度
|
|
9
9
|
* onPreloadDone {Function(sizeArray)}: 预加载完成回调,sizeArray(格式Object[]),每个的格式为{width, height}
|
|
10
|
-
* onDownloadDone {Function(pathesArray)}: 预下载完成回调,pathesArray(格式为String[])为下载好回调的地址,
|
|
11
|
-
* 其中pathesArray
|
|
10
|
+
* onDownloadDone {Function(pathesArray, extra)}: 预下载完成回调,pathesArray(格式为String[])为下载好回调的地址,
|
|
11
|
+
* 其中pathesArray为存储位置的路径列表, extra为额外信息(目前只有下载图片时的尺寸)
|
|
12
12
|
*
|
|
13
13
|
* 注意事项:
|
|
14
14
|
* 指定加载时的尺寸(0为不指定),与img标签中的 jsv_img_scaledown_tex 属性一起使用
|
|
@@ -54,10 +54,11 @@ const buildPreloadInfo = (
|
|
|
54
54
|
};
|
|
55
55
|
};
|
|
56
56
|
|
|
57
|
-
const buildDownloadInfo = (url, net_setting = null) => {
|
|
57
|
+
const buildDownloadInfo = (url, net_setting = null, get_image_size) => {
|
|
58
58
|
return {
|
|
59
59
|
url,
|
|
60
60
|
netSetting: net_setting,
|
|
61
|
+
getImageSize: get_image_size,
|
|
61
62
|
magicToken: CONST_FORMAT_TOKEN, // 用于格式校验
|
|
62
63
|
};
|
|
63
64
|
};
|
|
@@ -79,6 +80,7 @@ export default {
|
|
|
79
80
|
downloadViewList: [],
|
|
80
81
|
preloadStateList: [],
|
|
81
82
|
downloadStateList: [],
|
|
83
|
+
downloadResultMap: {},
|
|
82
84
|
preloadResultMap: {},
|
|
83
85
|
CONST_FORMAT_TOKEN: "_JsvP_",
|
|
84
86
|
preloadIsNullNum: 0, // 纪录传入的preload为null的数量,由于vue不支持在子组件修改props值,所有在删除值为null时,需要++,这样才能保证与传入数据的length相等从而触发回调
|
|
@@ -136,29 +138,6 @@ export default {
|
|
|
136
138
|
}
|
|
137
139
|
},
|
|
138
140
|
|
|
139
|
-
// shouldComponentUpdate(nextProps, nextState) {
|
|
140
|
-
// if (
|
|
141
|
-
// nextProps.preloadList.length === this.preloadList.length &&
|
|
142
|
-
// nextProps.downloadList.length === this.downloadList.length
|
|
143
|
-
// ) {
|
|
144
|
-
// let same = true;
|
|
145
|
-
// for (let i = 0; i < nextProps.preloadList.length; i++) {
|
|
146
|
-
// if (nextProps.preloadList[i].url !== this.preloadList[i].url) {
|
|
147
|
-
// same = false;
|
|
148
|
-
// break;
|
|
149
|
-
// }
|
|
150
|
-
// }
|
|
151
|
-
// for (let i = 0; i < nextProps.downloadList.length; i++) {
|
|
152
|
-
// if (nextProps.downloadList[i].url !== this.downloadList[i].url) {
|
|
153
|
-
// same = false;
|
|
154
|
-
// break;
|
|
155
|
-
// }
|
|
156
|
-
// }
|
|
157
|
-
// return !same;
|
|
158
|
-
// }
|
|
159
|
-
// return true;
|
|
160
|
-
// },
|
|
161
|
-
|
|
162
141
|
_checkPreload() {
|
|
163
142
|
let loadedNum = 0;
|
|
164
143
|
this.preloadStateList.forEach((state) => {
|
|
@@ -261,7 +240,10 @@ export default {
|
|
|
261
240
|
if (!state) return;
|
|
262
241
|
}
|
|
263
242
|
if (this.$props.onDownloadDone) {
|
|
264
|
-
this.$props.onDownloadDone(
|
|
243
|
+
this.$props.onDownloadDone(
|
|
244
|
+
this.downloadStateList,
|
|
245
|
+
this.downloadResultMap
|
|
246
|
+
);
|
|
265
247
|
}
|
|
266
248
|
},
|
|
267
249
|
|
|
@@ -269,7 +251,6 @@ export default {
|
|
|
269
251
|
if (!this.downloadList) {
|
|
270
252
|
return;
|
|
271
253
|
}
|
|
272
|
-
this.downloadStateList = new Array(this.downloadList.length).fill(null);
|
|
273
254
|
// 直接在map前将url为null的值清除掉
|
|
274
255
|
let downloadListData = this.downloadList;
|
|
275
256
|
for (let i = 0; i < downloadListData.length; i++) {
|
|
@@ -277,13 +258,14 @@ export default {
|
|
|
277
258
|
downloadListData.splice(i, 1);
|
|
278
259
|
}
|
|
279
260
|
}
|
|
261
|
+
this.downloadStateList = new Array(downloadListData.length).fill(null);
|
|
280
262
|
this.downloadViewList = downloadListData.map((item, index) => {
|
|
281
263
|
if (item.magicToken !== this.CONST_FORMAT_TOKEN) {
|
|
282
264
|
console.error(
|
|
283
265
|
"Error:format mismatch, data should comes from function buildDownloadInfo()"
|
|
284
266
|
);
|
|
285
267
|
}
|
|
286
|
-
console.log(`OnDownload get${index} url=${item.url}`)
|
|
268
|
+
console.log(`OnDownload get${index} url=${item.url}`);
|
|
287
269
|
const base_url = item.url;
|
|
288
270
|
let image_url = base_url;
|
|
289
271
|
if (base_url && base_url.indexOf("http") < 0) {
|
|
@@ -292,19 +274,33 @@ export default {
|
|
|
292
274
|
image_url = new window.JsView.Dom.UrlRef(base_url).href;
|
|
293
275
|
}
|
|
294
276
|
}
|
|
295
|
-
const texture =
|
|
296
|
-
|
|
277
|
+
const texture = ForgeExtension.TextureManager.GetDownloadTexture(
|
|
278
|
+
image_url,
|
|
279
|
+
null,
|
|
280
|
+
item.getImageSize
|
|
281
|
+
);
|
|
297
282
|
if (!texture) {
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
283
|
+
console.error(
|
|
284
|
+
"Error: Down view build texture failed for " + image_url
|
|
285
|
+
);
|
|
286
|
+
// 无法创建texture的图片先认为加载完成
|
|
287
|
+
this.downloadStateList[index] = "invalid";
|
|
288
|
+
return;
|
|
289
|
+
}
|
|
290
|
+
const callback_token = texture.RegisterLoadImageCallback(
|
|
291
|
+
null,
|
|
292
|
+
(texture_info) => {
|
|
293
|
+
console.log(`OnDownload done index${index}`);
|
|
294
|
+
this.downloadStateList[index] = texture_info.extra.absolutePath;
|
|
295
|
+
if (item.getImageSize && texture_info.extra.width && texture_info.extra.height) {
|
|
296
|
+
this.downloadResultMap[texture_info.extra.absolutePath] = {
|
|
297
|
+
width: texture_info.extra.width,
|
|
298
|
+
height: texture_info.extra.height,
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
this._checkDownload();
|
|
302
|
+
}
|
|
303
|
+
);
|
|
308
304
|
if (texture.EnableBackgroundLoad) {
|
|
309
305
|
texture.EnableBackgroundLoad(this);
|
|
310
306
|
}
|