@shijiu/jsview-vue 0.9.684 → 0.9.783
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 -1
- package/dom/bin/jsview-forge-define.min.js +1 -1
- package/dom/jsv-engine-js-browser.js +6 -0
- package/dom/target_core_revision.js +4 -4
- package/loader/loader.js +4 -0
- package/package.json +1 -1
- package/patches/node_modules/@vue/cli-service/lib/config/base.js +1 -1
- package/samples/AnimPicture/App.vue +5 -5
- package/samples/Basic/components/div/DivLayout.vue +1 -1
- package/samples/Basic/components/img/ImageGroup.vue +2 -2
- package/samples/Basic/components/img/ImgLayout.vue +79 -15
- package/samples/Basic/components/text/TextDirection.vue +104 -0
- package/samples/Basic/components/text/TextEmoji.vue +1 -1
- package/samples/Basic/components/text/TextGroup1.vue +1 -1
- package/samples/Basic/components/text/TextGroup2.vue +11 -1
- package/samples/BasicFocusControl/components/BaseBlock.vue +2 -2
- package/samples/Collision/App.vue +11 -11
- package/samples/DemoHomepage/App.vue +67 -8
- package/samples/DemoHomepage/components/TabFrame.vue +7 -0
- package/samples/DemoHomepage/router.js +27 -26
- package/samples/DemoHomepage/views/Homepage.vue +89 -98
- package/samples/FilterDemo/App.vue +1 -1
- package/samples/FlipCard/App.vue +2 -2
- package/samples/FlipCard/FlipCard.vue +3 -3
- package/samples/FocusBlockDemos/AutoFocus/App.vue +51 -0
- package/samples/FocusBlockDemos/AutoFocus/BaseBlock.vue +82 -0
- package/samples/FocusBlockDemos/AutoFocus/DialogBlock.vue +89 -0
- package/samples/FocusBlockDemos/AutoFocus/DialogContorls.js +42 -0
- package/samples/FocusBlockDemos/AutoFocus/FocusNamesDefine.js +9 -0
- package/samples/FocusBlockDemos/AutoFocus/PlaneBlock.vue +71 -0
- package/samples/FocusBlockDemos/ProgressiveFocusControl/App.vue +78 -0
- package/samples/FocusBlockDemos/ProgressiveFocusControl/BaseBlock.vue +77 -0
- package/samples/FocusBlockDemos/ProgressiveFocusControl/DownPlaneBlock.vue +83 -0
- package/samples/FocusBlockDemos/ProgressiveFocusControl/FocusNamesDefine.js +12 -0
- package/samples/FocusBlockDemos/ProgressiveFocusControl/UpPlaneBlock.vue +83 -0
- package/samples/GridDemo/App.vue +3 -3
- package/samples/GridDemo/ButtonBlock.vue +2 -2
- package/samples/GridDemo/FocusItem.vue +2 -2
- package/samples/GridDemo/Item.vue +1 -1
- package/samples/HashHistory/App.vue +10 -3
- package/samples/HashHistory/components/Item.vue +1 -1
- package/samples/ImpactStop/App.vue +15 -11
- package/samples/Input/InputPanel.vue +1 -1
- package/samples/LongImage/Button.vue +1 -1
- package/samples/LongImage/ButtonItem.vue +1 -1
- package/samples/LongImage/LongImageScroll.vue +2 -2
- package/samples/LongText/App.vue +1 -1
- package/samples/LongText/Button.vue +1 -1
- package/samples/LongText/ButtonItem.vue +1 -1
- package/samples/LongText/LongTextScroll.vue +3 -3
- package/samples/Marquee/App.vue +34 -3
- package/samples/Marquee/longText.js +2 -2
- package/samples/MetroWidgetDemos/PerformanceTest/App.vue +4 -4
- package/samples/MetroWidgetDemos/PerformanceTest/components/ContentItem.vue +1 -1
- package/samples/MetroWidgetDemos/PerformanceTest/components/MyTab.vue +3 -3
- package/samples/MetroWidgetDemos/PingPong/App.vue +22 -11
- package/samples/MetroWidgetDemos/PingPong/AppPage.vue +5 -5
- package/samples/MetroWidgetDemos/{Item.vue → PingPong/Item.vue} +3 -21
- package/samples/MetroWidgetDemos/PingPong/TabItem.vue +1 -1
- package/samples/MetroWidgetDemos/PingPong/ViewSwiper.vue +5 -5
- package/samples/MetroWidgetDemos/{WidgetItem.vue → PingPong/WidgetItem.vue} +8 -4
- package/samples/MetroWidgetDemos/basic/App.vue +162 -0
- package/samples/MetroWidgetDemos/basic/Item.vue +43 -0
- package/samples/MetroWidgetDemos/direction/App.vue +158 -0
- package/samples/MetroWidgetDemos/direction/Item.vue +45 -0
- package/samples/MetroWidgetDemos/focusableItemBasic/App.vue +67 -0
- package/samples/MetroWidgetDemos/{Advanced → focusableItemBasic}/ButtonItem.vue +17 -21
- package/samples/MetroWidgetDemos/focusableItemMetroWidget/App.vue +74 -0
- package/samples/MetroWidgetDemos/{Advanced/widgets → focusableItemMetroWidget}/Item.vue +13 -32
- package/samples/MetroWidgetDemos/{Advanced/widgets → focusableItemMetroWidget}/WidgetItem.vue +12 -12
- package/samples/MetroWidgetDemos/focusableItemMix/App.vue +88 -0
- package/samples/MetroWidgetDemos/focusableItemMix/ButtonItem.vue +86 -0
- package/samples/MetroWidgetDemos/focusableItemMix/Item.vue +43 -0
- package/samples/MetroWidgetDemos/index.js +6 -0
- package/samples/MetroWidgetDemos/layoutType/App.vue +180 -0
- package/samples/MetroWidgetDemos/layoutType/Item.vue +45 -0
- package/samples/MetroWidgetDemos/padding/App.vue +222 -0
- package/samples/MetroWidgetDemos/padding/Item.vue +64 -0
- package/samples/MetroWidgetDemos/routeList.js +64 -0
- package/samples/MetroWidgetDemos/slideSetting/App.vue +225 -0
- package/samples/MetroWidgetDemos/slideSetting/Item.vue +45 -0
- package/samples/NinePatchDemo/App.vue +78 -122
- package/samples/NinePatchDemo/Item.vue +29 -27
- package/samples/Preload/App.vue +1 -1
- package/samples/Preload/Item.vue +1 -1
- package/samples/QrcodeDemo/App.vue +1 -1
- package/samples/SoundPool/App.vue +3 -3
- package/samples/SpriteImage/App.vue +5 -0
- package/samples/Swiper/App.vue +148 -0
- package/samples/TextBox/App.vue +2 -1
- package/samples/TextureAnimation/App2.vue +1 -1
- package/samples/ThrowMoveDemo/LRParabolicDemo.vue +33 -47
- package/samples/TouchSample/MetroWidgetHorizontal.vue +1 -1
- package/samples/TouchSample/MetroWidgetVertical.vue +1 -1
- package/samples/TransitPage/App.vue +1 -1
- package/samples/VideoDemo/App.vue +8 -8
- package/samples/VideoDemo/components/Button.vue +1 -1
- package/samples/VideoDemo/components/Controllor.vue +1 -1
- package/samples/VisibleSensorDemo/App.vue +3 -3
- package/scripts/jsview-run-android.js +5 -4
- package/utils/JsViewEngineWidget/JsvFocusBlock.vue +4 -4
- package/utils/JsViewEngineWidget/MetroWidget/MetroWidget.vue +79 -50
- package/utils/JsViewEngineWidget/TemplateParser.js +144 -147
- package/utils/JsViewEngineWidget/WidgetCommon.js +12 -3
- package/utils/JsViewPlugin/BrowserPluginLoader.js +4 -2
- package/utils/JsViewPlugin/JsvAudio/AudioProxy.js +302 -0
- package/utils/JsViewPlugin/JsvAudio/CheckType.js +68 -0
- package/utils/JsViewPlugin/JsvAudio/Events.js +17 -0
- package/utils/JsViewPlugin/JsvAudio/JsvAudio.vue +176 -0
- package/utils/JsViewPlugin/JsvAudio/JsvAudioBridgeProxy.js +40 -0
- package/utils/JsViewPlugin/JsvAudio/JsvAudioBrowser.vue +46 -0
- package/utils/JsViewPlugin/JsvAudio/PluginLoader.js +140 -0
- package/utils/JsViewPlugin/JsvAudio/index.js +26 -0
- package/utils/JsViewPlugin/JsvAudio/version.js +24 -0
- package/utils/JsViewPlugin/JsvPlayer/index.js +1 -1
- package/utils/JsViewPlugin/JsvPlayer/version.js +5 -5
- package/utils/JsViewVueTools/JsvHashHistory.js +34 -8
- package/utils/JsViewVueTools/JsvImpactTracer.js +2 -2
- package/utils/JsViewVueTools/JsvRuntimeBridge.js +46 -8
- package/utils/JsViewVueTools/JsvStyleClass.js +9 -0
- package/utils/{JsViewVueWidget/utils/text.js → JsViewVueTools/JsvTextTools.js} +24 -4
- package/utils/JsViewVueTools/TypeCheckAndSet.js +3 -3
- package/utils/JsViewVueTools/index.js +2 -1
- package/utils/JsViewVueWidget/BrowserDebugWidget/BrowserTextureAnim.vue +5 -7
- package/utils/JsViewVueWidget/JsvActorMove/JsvActorMove.vue +20 -22
- package/utils/JsViewVueWidget/JsvApic/JsvApic.vue +4 -4
- package/utils/JsViewVueWidget/JsvGrid.vue +1 -9
- package/utils/JsViewVueWidget/JsvInput/Cursor.vue +1 -1
- package/utils/JsViewVueWidget/JsvMarquee.vue +91 -20
- package/utils/JsViewVueWidget/JsvMaskClipDiv.vue +1 -1
- package/utils/JsViewVueWidget/JsvNinePatch.vue +63 -53
- package/utils/JsViewVueWidget/JsvSpray/JsvSpray.vue +10 -5
- package/utils/JsViewVueWidget/JsvSpriteAnim/JsvSpriteAnim.vue +2 -2
- package/utils/JsViewVueWidget/JsvSwiper/JsvSwiper.vue +116 -80
- package/utils/JsViewVueWidget/JsvSwiper/index.js +3 -2
- package/utils/JsViewVueWidget/JsvSwiper3D/JsvSwiper.vue +1 -1
- package/utils/JsViewVueWidget/JsvTextBox.vue +11 -31
- package/utils/JsViewVueWidget/JsvTouchContainer.vue +2 -2
- package/utils/JsViewVueWidget/JsvTransparentDiv.vue +1 -1
- package/utils/JsViewVueWidget/JsvVisibleSensor/JsvVisibleSensor.vue +5 -5
- package/utils/JsViewVueWidget/index.js +8 -8
- package/samples/MetroWidgetDemos/Advanced/App.vue +0 -46
- package/samples/MetroWidgetDemos/Advanced/Buttons.vue +0 -70
- package/samples/MetroWidgetDemos/Advanced/Mixed.vue +0 -77
- package/samples/MetroWidgetDemos/Advanced/widgets/Widgets.vue +0 -116
- package/samples/MetroWidgetDemos/Advanced/widgets/focus1.png +0 -0
- package/samples/MetroWidgetDemos/Simple/AbsoluteTemplate.vue +0 -75
- package/samples/MetroWidgetDemos/Simple/App.vue +0 -45
- package/samples/MetroWidgetDemos/Simple/RelativeTemplate.vue +0 -111
- package/samples/MetroWidgetDemos/data.js +0 -205
- package/utils/JsViewVueWidget/JsvSwiper/Indicator.vue +0 -35
- package/utils/JsViewVueWidget/utils/index.js +0 -8
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
* @Author: ChenChanghua
|
|
3
|
+
* @Date: 2023-03-08 15:54:16
|
|
4
|
+
* @Description: file content
|
|
5
|
+
-->
|
|
6
|
+
<script setup>
|
|
7
|
+
import {
|
|
8
|
+
MetroWidget,
|
|
9
|
+
HORIZONTAL,
|
|
10
|
+
useFocusHub,
|
|
11
|
+
EdgeDirection,
|
|
12
|
+
SeamlessSlide,
|
|
13
|
+
WholePageSlide,
|
|
14
|
+
FixPositionSlide,
|
|
15
|
+
} from "jsview";
|
|
16
|
+
import Item from "./Item.vue";
|
|
17
|
+
import { onMounted } from "vue";
|
|
18
|
+
|
|
19
|
+
const TAG = "MetroWidgetDemo";
|
|
20
|
+
|
|
21
|
+
const focusHub = useFocusHub();
|
|
22
|
+
|
|
23
|
+
const randomColor = () => {
|
|
24
|
+
let randomColor = Math.round(Math.random() * 2 ** 24).toString(16);
|
|
25
|
+
return (
|
|
26
|
+
"#" + new Array(6 - randomColor.length).fill("0").join("") + randomColor
|
|
27
|
+
);
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const data = [];
|
|
31
|
+
for (let i = 0; i < 30; i++) {
|
|
32
|
+
data.push({
|
|
33
|
+
width: 90,
|
|
34
|
+
height: 90,
|
|
35
|
+
marginRight: 10,
|
|
36
|
+
marginBottom: 10,
|
|
37
|
+
color: randomColor(),
|
|
38
|
+
content: i,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const widget1 = {
|
|
43
|
+
provideData: () => {
|
|
44
|
+
return data;
|
|
45
|
+
},
|
|
46
|
+
measures: (data) => {
|
|
47
|
+
return {
|
|
48
|
+
width: data.width,
|
|
49
|
+
height: data.height,
|
|
50
|
+
marginRight: data.marginRight,
|
|
51
|
+
marginBottom: data.marginBottom,
|
|
52
|
+
};
|
|
53
|
+
},
|
|
54
|
+
onEdge: (edgeInfo) => {
|
|
55
|
+
if (edgeInfo.direction == EdgeDirection.bottom) {
|
|
56
|
+
focusHub.setFocus("widget2");
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
widgetLayout: {
|
|
60
|
+
left: 50,
|
|
61
|
+
top: 50,
|
|
62
|
+
width: 500,
|
|
63
|
+
height: 200,
|
|
64
|
+
},
|
|
65
|
+
slideSetting: new SeamlessSlide({
|
|
66
|
+
startPercent: 0.2,
|
|
67
|
+
endPercent: 0.8,
|
|
68
|
+
}),
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
const widget2 = {
|
|
72
|
+
provideData: () => {
|
|
73
|
+
return data;
|
|
74
|
+
},
|
|
75
|
+
measures: (data) => {
|
|
76
|
+
return {
|
|
77
|
+
width: data.width,
|
|
78
|
+
height: data.height,
|
|
79
|
+
marginRight: data.marginRight,
|
|
80
|
+
marginBottom: data.marginBottom,
|
|
81
|
+
};
|
|
82
|
+
},
|
|
83
|
+
onEdge: (edgeInfo) => {
|
|
84
|
+
if (edgeInfo.direction == EdgeDirection.top) {
|
|
85
|
+
focusHub.setFocus("widget1");
|
|
86
|
+
} else if (edgeInfo.direction == EdgeDirection.bottom) {
|
|
87
|
+
focusHub.setFocus("widget3");
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
widgetLayout: {
|
|
91
|
+
left: 50,
|
|
92
|
+
top: 300,
|
|
93
|
+
width: 500,
|
|
94
|
+
height: 220,
|
|
95
|
+
},
|
|
96
|
+
slideSetting: new WholePageSlide(),
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
const widget3 = {
|
|
100
|
+
provideData: () => {
|
|
101
|
+
return data;
|
|
102
|
+
},
|
|
103
|
+
measures: (data) => {
|
|
104
|
+
return {
|
|
105
|
+
width: data.width,
|
|
106
|
+
height: data.height,
|
|
107
|
+
marginRight: data.marginRight,
|
|
108
|
+
marginBottom: data.marginBottom,
|
|
109
|
+
};
|
|
110
|
+
},
|
|
111
|
+
onEdge: (edgeInfo) => {
|
|
112
|
+
if (edgeInfo.direction == EdgeDirection.top) {
|
|
113
|
+
focusHub.setFocus("widget2");
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
widgetLayout: {
|
|
117
|
+
left: 50,
|
|
118
|
+
top: 550,
|
|
119
|
+
width: 500,
|
|
120
|
+
height: 200,
|
|
121
|
+
},
|
|
122
|
+
slideSetting: new FixPositionSlide({ fixPercent: 0.5 }),
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
onMounted(() => {
|
|
126
|
+
//组件mount后设置焦点
|
|
127
|
+
focusHub.setFocus("widget1");
|
|
128
|
+
});
|
|
129
|
+
</script>
|
|
130
|
+
|
|
131
|
+
<template>
|
|
132
|
+
<div
|
|
133
|
+
:style="{
|
|
134
|
+
width: 1920,
|
|
135
|
+
height: 1080,
|
|
136
|
+
backgroundColor: '#007788',
|
|
137
|
+
}"
|
|
138
|
+
/>
|
|
139
|
+
<div
|
|
140
|
+
:style="{
|
|
141
|
+
left: widget1.widgetLayout.left,
|
|
142
|
+
top: widget1.widgetLayout.top - 50,
|
|
143
|
+
width: 1280,
|
|
144
|
+
height: 50,
|
|
145
|
+
fontSize: 20,
|
|
146
|
+
color: '#FFFFFF',
|
|
147
|
+
}"
|
|
148
|
+
>
|
|
149
|
+
{{ "无缝滚动" }}
|
|
150
|
+
</div>
|
|
151
|
+
<metro-widget
|
|
152
|
+
name="widget1"
|
|
153
|
+
:left="widget1.widgetLayout.left"
|
|
154
|
+
:top="widget1.widgetLayout.top"
|
|
155
|
+
:width="widget1.widgetLayout.width"
|
|
156
|
+
:height="widget1.widgetLayout.height"
|
|
157
|
+
:provideData="widget1.provideData"
|
|
158
|
+
:measures="widget1.measures"
|
|
159
|
+
:onEdge="widget1.onEdge"
|
|
160
|
+
:direction="HORIZONTAL"
|
|
161
|
+
:slideSetting="widget1.slideSetting"
|
|
162
|
+
>
|
|
163
|
+
<template #renderItem="{ data, onAction }">
|
|
164
|
+
<item :data="data" :onAction="onAction" />
|
|
165
|
+
</template>
|
|
166
|
+
</metro-widget>
|
|
167
|
+
|
|
168
|
+
<div
|
|
169
|
+
:style="{
|
|
170
|
+
left: widget2.widgetLayout.left,
|
|
171
|
+
top: widget2.widgetLayout.top - 50,
|
|
172
|
+
width: 1280,
|
|
173
|
+
height: 50,
|
|
174
|
+
fontSize: 20,
|
|
175
|
+
color: '#FFFFFF',
|
|
176
|
+
}"
|
|
177
|
+
>
|
|
178
|
+
{{ "翻页" }}
|
|
179
|
+
</div>
|
|
180
|
+
<metro-widget
|
|
181
|
+
name="widget2"
|
|
182
|
+
:left="widget2.widgetLayout.left"
|
|
183
|
+
:top="widget2.widgetLayout.top"
|
|
184
|
+
:width="widget2.widgetLayout.width"
|
|
185
|
+
:height="widget2.widgetLayout.height"
|
|
186
|
+
:provideData="widget2.provideData"
|
|
187
|
+
:measures="widget2.measures"
|
|
188
|
+
:onEdge="widget2.onEdge"
|
|
189
|
+
:direction="HORIZONTAL"
|
|
190
|
+
:slideSetting="widget2.slideSetting"
|
|
191
|
+
>
|
|
192
|
+
<template #renderItem="{ data, onAction }">
|
|
193
|
+
<item :data="data" :onAction="onAction" />
|
|
194
|
+
</template>
|
|
195
|
+
</metro-widget>
|
|
196
|
+
|
|
197
|
+
<div
|
|
198
|
+
:style="{
|
|
199
|
+
left: widget3.widgetLayout.left,
|
|
200
|
+
top: widget3.widgetLayout.top - 50,
|
|
201
|
+
width: 1280,
|
|
202
|
+
height: 50,
|
|
203
|
+
fontSize: 20,
|
|
204
|
+
color: '#FFFFFF',
|
|
205
|
+
}"
|
|
206
|
+
>
|
|
207
|
+
{{ "焦点固定位置" }}
|
|
208
|
+
</div>
|
|
209
|
+
<metro-widget
|
|
210
|
+
name="widget3"
|
|
211
|
+
:left="widget3.widgetLayout.left"
|
|
212
|
+
:top="widget3.widgetLayout.top"
|
|
213
|
+
:width="widget3.widgetLayout.width"
|
|
214
|
+
:height="widget3.widgetLayout.height"
|
|
215
|
+
:provideData="widget3.provideData"
|
|
216
|
+
:measures="widget3.measures"
|
|
217
|
+
:onEdge="widget3.onEdge"
|
|
218
|
+
:direction="HORIZONTAL"
|
|
219
|
+
:slideSetting="widget3.slideSetting"
|
|
220
|
+
>
|
|
221
|
+
<template #renderItem="{ data, onAction }">
|
|
222
|
+
<item :data="data" :onAction="onAction" />
|
|
223
|
+
</template>
|
|
224
|
+
</metro-widget>
|
|
225
|
+
</template>
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
* @Author: ChenChanghua
|
|
3
|
+
* @Date: 2023-03-08 14:52:17
|
|
4
|
+
* @Description: file content
|
|
5
|
+
-->
|
|
6
|
+
<script setup>
|
|
7
|
+
import { ref, shallowRef, inject } from "vue";
|
|
8
|
+
|
|
9
|
+
const props = defineProps({
|
|
10
|
+
data: Object,
|
|
11
|
+
onAction: Object,
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
const divRef = shallowRef(null);
|
|
15
|
+
const focused = ref(false);
|
|
16
|
+
|
|
17
|
+
// 注册回调
|
|
18
|
+
const onFocus = () => {
|
|
19
|
+
focused.value = true;
|
|
20
|
+
};
|
|
21
|
+
const onBlur = () => {
|
|
22
|
+
focused.value = false;
|
|
23
|
+
};
|
|
24
|
+
const onClick = () => {
|
|
25
|
+
console.log("item onclick ", props.data);
|
|
26
|
+
};
|
|
27
|
+
props.onAction.register("onFocus", onFocus);
|
|
28
|
+
props.onAction.register("onBlur", onBlur);
|
|
29
|
+
props.onAction.register("onClick", onClick);
|
|
30
|
+
</script>
|
|
31
|
+
|
|
32
|
+
<template>
|
|
33
|
+
<div
|
|
34
|
+
ref="divRef"
|
|
35
|
+
:style="{
|
|
36
|
+
width: data.width,
|
|
37
|
+
height: data.height,
|
|
38
|
+
fontSize: 30,
|
|
39
|
+
color: focused ? '#FF0000' : '#FFFFFF',
|
|
40
|
+
backgroundColor: data.color,
|
|
41
|
+
}"
|
|
42
|
+
>
|
|
43
|
+
{{ data.content }}
|
|
44
|
+
</div>
|
|
45
|
+
</template>
|
|
@@ -1,145 +1,101 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
-
import {
|
|
3
|
-
jJsvRuntimeBridge,
|
|
4
|
-
MetroWidget,
|
|
5
|
-
HORIZONTAL,
|
|
6
|
-
JsvNinePatch,
|
|
7
|
-
} from "jsview";
|
|
2
|
+
import { MetroWidget, HORIZONTAL, JsvNinePatch, useFocusHub } from "jsview";
|
|
8
3
|
import Item from "./Item.vue";
|
|
9
4
|
import borderImageUrl from "./assets/border.png";
|
|
10
|
-
import {
|
|
11
|
-
import { useRouter, useRoute } from "vue-router";
|
|
5
|
+
import { reactive, provide, onMounted } from "vue";
|
|
12
6
|
|
|
13
|
-
const
|
|
7
|
+
const focusHub = useFocusHub();
|
|
14
8
|
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
9
|
+
const focusSize = reactive({
|
|
10
|
+
width: 0,
|
|
11
|
+
height: 0,
|
|
12
|
+
left: 0,
|
|
13
|
+
top: 0,
|
|
14
|
+
});
|
|
15
|
+
provide("focusSize", focusSize);
|
|
16
|
+
|
|
17
|
+
const provideData = () => {
|
|
18
|
+
return [
|
|
19
|
+
{
|
|
20
|
+
width: 160,
|
|
21
|
+
height: 160,
|
|
22
|
+
color: "#FF9900",
|
|
23
|
+
content: 0,
|
|
20
24
|
},
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
w: 300,
|
|
27
|
-
h: 300,
|
|
25
|
+
{
|
|
26
|
+
width: 300,
|
|
27
|
+
height: 300,
|
|
28
|
+
color: "#0099FF",
|
|
29
|
+
content: 1,
|
|
28
30
|
},
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
w: 160,
|
|
35
|
-
h: 160,
|
|
31
|
+
{
|
|
32
|
+
width: 160,
|
|
33
|
+
height: 160,
|
|
34
|
+
color: "#FF9900",
|
|
35
|
+
content: 2,
|
|
36
36
|
},
|
|
37
|
-
|
|
38
|
-
content: 2,
|
|
39
|
-
},
|
|
40
|
-
];
|
|
41
|
-
|
|
42
|
-
const framePosition = ref({
|
|
43
|
-
x: 0,
|
|
44
|
-
y: 0,
|
|
45
|
-
width: 50,
|
|
46
|
-
height: 50,
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
const _onFramePositionChanged = (new_x, new_y, new_width, new_height) => {
|
|
50
|
-
console.log(
|
|
51
|
-
`new x=${new_x} y=${new_y} width=${new_width} height=${new_height}`
|
|
52
|
-
);
|
|
53
|
-
|
|
54
|
-
framePosition.value = {
|
|
55
|
-
x: new_x,
|
|
56
|
-
y: new_y,
|
|
57
|
-
width: new_width,
|
|
58
|
-
height: new_height,
|
|
59
|
-
};
|
|
37
|
+
];
|
|
60
38
|
};
|
|
61
39
|
|
|
62
|
-
const
|
|
40
|
+
const measures = (item) => {
|
|
63
41
|
return {
|
|
64
|
-
width: item.
|
|
65
|
-
height: item.
|
|
42
|
+
width: item.width,
|
|
43
|
+
height: item.height,
|
|
66
44
|
marginRight: 10,
|
|
67
|
-
marginTop: 10,
|
|
68
45
|
};
|
|
69
46
|
};
|
|
70
47
|
|
|
71
|
-
const _onKeyDown = (ev) => {
|
|
72
|
-
// 8:Backspace, 27:Escape, 10000:盒子返回键
|
|
73
|
-
if (ev.keyCode == 8 || ev.keyCode == 27 || ev.keyCode == 10000) {
|
|
74
|
-
router?.go(-1); // 有router时,是从DemoHomepage进入,回退
|
|
75
|
-
return true;
|
|
76
|
-
}
|
|
77
|
-
return false;
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
const myFocusWidget = ref(null);
|
|
81
|
-
|
|
82
48
|
onMounted(() => {
|
|
83
|
-
|
|
84
|
-
jJsvRuntimeBridge.notifyPageLoaded();
|
|
49
|
+
focusHub.setFocus("myWidget");
|
|
85
50
|
});
|
|
86
51
|
</script>
|
|
87
52
|
|
|
88
53
|
<template>
|
|
89
54
|
<div :style="{ width: 1280, height: 720, backgroundColor: '#FFFFFF' }">
|
|
90
|
-
<
|
|
91
|
-
|
|
92
|
-
:
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
>
|
|
117
|
-
<
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
:imageUrl="borderImageUrl"
|
|
136
|
-
:imageWidth="81"
|
|
137
|
-
:centerWidth="25"
|
|
138
|
-
:borderOutset="14"
|
|
139
|
-
:imageDspWidth="81"
|
|
140
|
-
:animTime="0.2"
|
|
141
|
-
></jsv-nine-patch>
|
|
142
|
-
</div>
|
|
143
|
-
</jsv-focus-block>
|
|
55
|
+
<div
|
|
56
|
+
:style="{
|
|
57
|
+
textAlign: 'center',
|
|
58
|
+
fontSize: 30,
|
|
59
|
+
lineHeight: 50,
|
|
60
|
+
color: '#ffffff',
|
|
61
|
+
left: 140,
|
|
62
|
+
top: 20,
|
|
63
|
+
width: 1000,
|
|
64
|
+
height: 50,
|
|
65
|
+
backgroundColor: 'rgba(27,38,151,0.8)',
|
|
66
|
+
}"
|
|
67
|
+
>
|
|
68
|
+
NinePatch展示,框的四个角的方形中心和项目的四个顶点严格对齐
|
|
69
|
+
</div>
|
|
70
|
+
<metro-widget
|
|
71
|
+
name="myWidget"
|
|
72
|
+
:top="100"
|
|
73
|
+
:left="250"
|
|
74
|
+
:width="1000"
|
|
75
|
+
:height="400"
|
|
76
|
+
:direction="HORIZONTAL"
|
|
77
|
+
:provideData="provideData"
|
|
78
|
+
:measures="measures"
|
|
79
|
+
:padding="{ left: 50, right: 50, top: 50, height: 50 }"
|
|
80
|
+
>
|
|
81
|
+
<template #renderItem="{ data, onAction }">
|
|
82
|
+
<item :data="data" :onAction="onAction" />
|
|
83
|
+
</template>
|
|
84
|
+
</metro-widget>
|
|
85
|
+
<jsv-nine-patch
|
|
86
|
+
:style="{
|
|
87
|
+
width: focusSize.width,
|
|
88
|
+
height: focusSize.height,
|
|
89
|
+
top: focusSize.top,
|
|
90
|
+
left: focusSize.left,
|
|
91
|
+
}"
|
|
92
|
+
:imageUrl="borderImageUrl"
|
|
93
|
+
:imageWidth="81"
|
|
94
|
+
:centerWidth="25"
|
|
95
|
+
:borderOutset="14"
|
|
96
|
+
:imageDspWidth="81"
|
|
97
|
+
:animTime="0.2"
|
|
98
|
+
:waitForInit="true"
|
|
99
|
+
></jsv-nine-patch>
|
|
144
100
|
</div>
|
|
145
101
|
</template>
|
|
@@ -1,37 +1,30 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
-
import { ref,
|
|
2
|
+
import { ref, inject } from "vue";
|
|
3
|
+
|
|
4
|
+
const focusSize = inject("focusSize");
|
|
3
5
|
|
|
4
6
|
const props = defineProps({
|
|
5
7
|
data: Object,
|
|
6
|
-
query: Object,
|
|
7
|
-
onEdge: Function,
|
|
8
8
|
onAction: Object,
|
|
9
|
-
frameChanged: Function,
|
|
10
9
|
});
|
|
11
10
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
let styleValue = computed(() => {
|
|
15
|
-
return {
|
|
16
|
-
width: props.data.blocks.w,
|
|
17
|
-
height: props.data.blocks.h,
|
|
18
|
-
color: "#FFFFFF",
|
|
19
|
-
backgroundColor: props.data.color,
|
|
20
|
-
};
|
|
21
|
-
});
|
|
11
|
+
const focused = ref(false);
|
|
12
|
+
const divRef = ref(null);
|
|
22
13
|
|
|
23
14
|
const onFocus = () => {
|
|
24
15
|
focused.value = true;
|
|
25
|
-
if (
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
16
|
+
if (focusSize) {
|
|
17
|
+
divRef.value?.getBoundingClientRect().then(
|
|
18
|
+
(data) => {
|
|
19
|
+
focusSize.width = data.width;
|
|
20
|
+
focusSize.height = data.height;
|
|
21
|
+
focusSize.left = data.left;
|
|
22
|
+
focusSize.top = data.top;
|
|
23
|
+
},
|
|
24
|
+
(error) => {
|
|
25
|
+
console.log("get absolute position failed", error);
|
|
26
|
+
}
|
|
27
|
+
);
|
|
35
28
|
}
|
|
36
29
|
};
|
|
37
30
|
|
|
@@ -40,7 +33,7 @@ const onBlur = () => {
|
|
|
40
33
|
};
|
|
41
34
|
|
|
42
35
|
const onClicked = () => {
|
|
43
|
-
|
|
36
|
+
console.log("item clicked", props.data);
|
|
44
37
|
};
|
|
45
38
|
|
|
46
39
|
props.onAction.register("onFocus", onFocus);
|
|
@@ -49,8 +42,17 @@ props.onAction.register("onClick", onClicked);
|
|
|
49
42
|
</script>
|
|
50
43
|
|
|
51
44
|
<template>
|
|
52
|
-
<div
|
|
53
|
-
|
|
45
|
+
<div
|
|
46
|
+
ref="divRef"
|
|
47
|
+
:class="focused ? 'focus' : 'blur'"
|
|
48
|
+
:style="{
|
|
49
|
+
width: data.width,
|
|
50
|
+
height: data.height,
|
|
51
|
+
color: '#FFFFFF',
|
|
52
|
+
backgroundColor: data.color,
|
|
53
|
+
}"
|
|
54
|
+
>
|
|
55
|
+
{{ data.content }}
|
|
54
56
|
</div>
|
|
55
57
|
</template>
|
|
56
58
|
|
package/samples/Preload/App.vue
CHANGED
|
@@ -11,7 +11,7 @@ import awesome from "./images/awesomeface.png";
|
|
|
11
11
|
import cat from "./images/cat.jpg";
|
|
12
12
|
import { data } from "./data.js";
|
|
13
13
|
import Item from "./Item.vue";
|
|
14
|
-
import { ref } from "vue";
|
|
14
|
+
import { ref, shallowRef } from "vue";
|
|
15
15
|
import { useRouter } from "vue-router";
|
|
16
16
|
|
|
17
17
|
const name = "/preload";
|
package/samples/Preload/Item.vue
CHANGED
|
@@ -10,7 +10,7 @@ import coin from "./coin.mp3";
|
|
|
10
10
|
import lose from "./lose.mp3";
|
|
11
11
|
import bgmusic from "./bgmusic.mp3";
|
|
12
12
|
import { JsvSoundPool, jJsvRuntimeBridge } from "jsview";
|
|
13
|
-
import { onMounted, onBeforeUnmount,
|
|
13
|
+
import { onMounted, onBeforeUnmount, shallowRef } from "vue";
|
|
14
14
|
import { useRouter } from "vue-router";
|
|
15
15
|
|
|
16
16
|
const router = useRouter();
|
|
@@ -19,7 +19,7 @@ let coinController1 = null;
|
|
|
19
19
|
let coinController2 = null;
|
|
20
20
|
let loseController1 = null;
|
|
21
21
|
let loseController2 = null;
|
|
22
|
-
let bgm =
|
|
22
|
+
let bgm = shallowRef(null);
|
|
23
23
|
const _onKeyDown = (ev) => {
|
|
24
24
|
if (ev.keyCode == 8 || ev.keyCode == 27 || ev.keyCode == 10000) {
|
|
25
25
|
router.go(-1); // 有router时,是从DemoHomepage进入,回退
|
|
@@ -128,7 +128,7 @@ onBeforeUnmount(() => {
|
|
|
128
128
|
`[确定]: 播放背景音乐\n[左]: 播放失败音乐1\n[右]: 播放失败音乐2\n[上]: 播放硬币音乐1\n[下]: 播放硬币音乐2`
|
|
129
129
|
}}
|
|
130
130
|
</div>
|
|
131
|
-
<audiotrack ref="bgm" :src="bgmusic" loop="loop" />
|
|
131
|
+
<jsv-audiotrack ref="bgm" :src="bgmusic" loop="loop" />
|
|
132
132
|
</div>
|
|
133
133
|
</jsv-focus-block>
|
|
134
134
|
</template>
|