@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
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
<script>
|
|
2
|
-
import {
|
|
1
|
+
<script setup>
|
|
2
|
+
import { computed, shallowRef, onActivated } from "vue";
|
|
3
|
+
import { jJsvRuntimeBridge, EdgeDirection, useFocusHub } from "jsview";
|
|
3
4
|
import TabFrame from "../components/TabFrame.vue";
|
|
4
5
|
import BodyFrame from "../components/BodyFrame.vue";
|
|
5
6
|
import Dialog from "../components/Dialog.vue";
|
|
@@ -9,6 +10,7 @@ const colorTemplete = ["#89BEB2", "#C9BA83", "#DED38C", "#DE9C53"];
|
|
|
9
10
|
|
|
10
11
|
const featureData = [];
|
|
11
12
|
const metroWidgetData = [];
|
|
13
|
+
const focusBlockData = [];
|
|
12
14
|
for (let item of routeList) {
|
|
13
15
|
let obj = {
|
|
14
16
|
name: item.name,
|
|
@@ -23,104 +25,95 @@ for (let item of routeList) {
|
|
|
23
25
|
} else if (item.path.indexOf("metroWidget") >= 0) {
|
|
24
26
|
obj.backgroundColor = colorTemplete[metroWidgetData.length % 4];
|
|
25
27
|
metroWidgetData.push(obj);
|
|
28
|
+
} else if (item.path.indexOf("focusBlock") >= 0) {
|
|
29
|
+
obj.backgroundColor = colorTemplete[focusBlockData.length % 4];
|
|
30
|
+
focusBlockData.push(obj);
|
|
26
31
|
}
|
|
27
32
|
}
|
|
28
|
-
const dataList = [featureData, metroWidgetData];
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
if (
|
|
62
|
-
ev.keyCode == 8 || // Backspace
|
|
63
|
-
ev.keyCode == 27 || // Escape
|
|
64
|
-
ev.keyCode == 10000 // 盒子返回键
|
|
65
|
-
) {
|
|
66
|
-
this.showExitDialog = !this.showExitDialog;
|
|
67
|
-
if (!this.showExitDialog) {
|
|
68
|
-
this.changeFocus(this.preFocusName);
|
|
69
|
-
} else {
|
|
70
|
-
this.preFocusName = this.curFocusName;
|
|
71
|
-
this.curFocusName = this.name + "/exitDialog";
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
return true;
|
|
75
|
-
},
|
|
76
|
-
changeFocus(name) {
|
|
77
|
-
this.preFocusName = this.curFocusName;
|
|
78
|
-
this.curFocusName = name;
|
|
79
|
-
this.$refs.rootNode.findBlockByName(name).requestFocus();
|
|
80
|
-
},
|
|
81
|
-
onTabEdge(edgeInfo) {
|
|
82
|
-
if (edgeInfo.direction === EdgeDirection.bottom) {
|
|
83
|
-
this.changeFocus(this.name + "/bodyFrame");
|
|
84
|
-
}
|
|
85
|
-
},
|
|
86
|
-
onContentEdge(edgeInfo) {
|
|
87
|
-
if (edgeInfo.direction === EdgeDirection.top) {
|
|
88
|
-
this.changeFocus(this.name + "/tabFrame");
|
|
89
|
-
}
|
|
90
|
-
},
|
|
91
|
-
tabItemFocus(data) {
|
|
92
|
-
if (data.id != this.tabId) {
|
|
93
|
-
this.tabId = data.id;
|
|
94
|
-
this.contentData = dataList[this.tabId];
|
|
95
|
-
}
|
|
96
|
-
},
|
|
97
|
-
onDialogAction(msg) {
|
|
98
|
-
this.showExitDialog = false;
|
|
99
|
-
this.changeFocus(this.preFocusName);
|
|
100
|
-
switch (msg) {
|
|
101
|
-
case "ok":
|
|
102
|
-
jJsvRuntimeBridge.closePage();
|
|
103
|
-
// if (!window.JsView) {
|
|
104
|
-
// // 浏览器调试
|
|
105
|
-
// window.location.href = "about:blank";
|
|
106
|
-
// }
|
|
107
|
-
break;
|
|
108
|
-
case "back":
|
|
109
|
-
case "cancel":
|
|
110
|
-
break;
|
|
111
|
-
}
|
|
112
|
-
},
|
|
113
|
-
},
|
|
114
|
-
created() {
|
|
115
|
-
if (typeof localStorage.curTab !== "undefined") {
|
|
116
|
-
this.tabId = parseInt(localStorage.curTab);
|
|
33
|
+
const dataList = [featureData, metroWidgetData, focusBlockData];
|
|
34
|
+
|
|
35
|
+
let showExitDialog = shallowRef(false);
|
|
36
|
+
let contentData = shallowRef(dataList[0]);
|
|
37
|
+
let tabId = shallowRef(0);
|
|
38
|
+
|
|
39
|
+
let preFocusName = "";
|
|
40
|
+
let curFocusName = "";
|
|
41
|
+
let name = "/home";
|
|
42
|
+
|
|
43
|
+
let focusHub = useFocusHub();
|
|
44
|
+
|
|
45
|
+
let address = computed(() => {
|
|
46
|
+
return window.localStorage.href;
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
let onFocus = () => {
|
|
50
|
+
changeFocus(name + "/bodyFrame");
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
let onKeyDown = (ev) => {
|
|
54
|
+
// 处理返回键
|
|
55
|
+
if (
|
|
56
|
+
ev.keyCode == 8 || // Backspace
|
|
57
|
+
ev.keyCode == 27 || // Escape
|
|
58
|
+
ev.keyCode == 10000 // 盒子返回键
|
|
59
|
+
) {
|
|
60
|
+
showExitDialog.value = !showExitDialog.value;
|
|
61
|
+
if (!showExitDialog.value) {
|
|
62
|
+
changeFocus(preFocusName);
|
|
63
|
+
} else {
|
|
64
|
+
preFocusName = curFocusName;
|
|
65
|
+
curFocusName = name + "/exitDialog";
|
|
117
66
|
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
67
|
+
}
|
|
68
|
+
return true;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
let changeFocus = (name) => {
|
|
72
|
+
preFocusName = curFocusName;
|
|
73
|
+
curFocusName = name;
|
|
74
|
+
focusHub.setFocus(name);
|
|
123
75
|
};
|
|
76
|
+
|
|
77
|
+
let onTabEdge = (edgeInfo) => {
|
|
78
|
+
if (edgeInfo.direction === EdgeDirection.bottom) {
|
|
79
|
+
changeFocus(name + "/bodyFrame");
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
let onContentEdge = (edgeInfo) => {
|
|
84
|
+
if (edgeInfo.direction === EdgeDirection.top) {
|
|
85
|
+
changeFocus(name + "/tabFrame");
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
let tabItemFocus = (data) => {
|
|
90
|
+
if (data.id != tabId.value) {
|
|
91
|
+
tabId.value = data.id;
|
|
92
|
+
contentData.value = dataList[data.id];
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
let onDialogAction = (msg) => {
|
|
97
|
+
showExitDialog.value = false;
|
|
98
|
+
changeFocus(preFocusName);
|
|
99
|
+
switch (msg) {
|
|
100
|
+
case "ok":
|
|
101
|
+
jJsvRuntimeBridge.closePage();
|
|
102
|
+
// if (!window.JsView) {
|
|
103
|
+
// // 浏览器调试
|
|
104
|
+
// window.location.href = "about:blank";
|
|
105
|
+
// }
|
|
106
|
+
break;
|
|
107
|
+
case "back":
|
|
108
|
+
case "cancel":
|
|
109
|
+
break;
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
// keep-alive后 router 返回本页面时要激活一下focus
|
|
114
|
+
onActivated(() => {
|
|
115
|
+
onFocus();
|
|
116
|
+
});
|
|
124
117
|
</script>
|
|
125
118
|
|
|
126
119
|
<template>
|
|
@@ -132,7 +125,6 @@ export default {
|
|
|
132
125
|
|
|
133
126
|
<jsv-focus-block
|
|
134
127
|
autoFocus
|
|
135
|
-
ref="rootNode"
|
|
136
128
|
:onAction="{
|
|
137
129
|
onKeyDown: onKeyDown,
|
|
138
130
|
onFocus: onFocus,
|
|
@@ -174,7 +166,6 @@ export default {
|
|
|
174
166
|
.rootSize {
|
|
175
167
|
width: 1920;
|
|
176
168
|
height: 1080;
|
|
177
|
-
background-color: #334c4c;
|
|
178
169
|
}
|
|
179
170
|
|
|
180
171
|
.address {
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* @Description: file content
|
|
7
7
|
-->
|
|
8
8
|
<script setup>
|
|
9
|
-
import { ref, reactive, onMounted } from "vue";
|
|
9
|
+
import { ref, shallowRef, reactive, onMounted } from "vue";
|
|
10
10
|
import { useRouter } from "vue-router";
|
|
11
11
|
import { jJsvRuntimeBridge, JsvFilterView } from "jsview";
|
|
12
12
|
import sample from "../assets/jpegDemo.jpeg";
|
package/samples/FlipCard/App.vue
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script setup>
|
|
2
2
|
import { useRouter } from "vue-router";
|
|
3
|
-
import { ref } from "vue";
|
|
3
|
+
import { ref, shallowRef } from "vue";
|
|
4
4
|
import { HORIZONTAL, MetroWidget } from "jsview";
|
|
5
5
|
import FlipCard from "./FlipCard.vue";
|
|
6
6
|
import { data } from "./data.js";
|
|
@@ -8,7 +8,7 @@ import redEgg from "./assets/red_egg.png";
|
|
|
8
8
|
import blueEgg from "./assets/blue_egg.png";
|
|
9
9
|
|
|
10
10
|
const name = "/flipCard";
|
|
11
|
-
const focusNode =
|
|
11
|
+
const focusNode = shallowRef(null);
|
|
12
12
|
const router = useRouter();
|
|
13
13
|
|
|
14
14
|
const onKeyDown = (ev) => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
-
import { ref } from "vue";
|
|
2
|
+
import { ref, shallowRef } from "vue";
|
|
3
3
|
const props = defineProps({
|
|
4
4
|
initFlipped: Boolean,
|
|
5
5
|
width: Number,
|
|
@@ -18,7 +18,7 @@ let flipAnim = ref("");
|
|
|
18
18
|
let flipped = ref(props.initFlipped);
|
|
19
19
|
let focused = ref(false);
|
|
20
20
|
let keyLocked = false;
|
|
21
|
-
let focusNode =
|
|
21
|
+
let focusNode = shallowRef(null);
|
|
22
22
|
|
|
23
23
|
const onFocus = () => {
|
|
24
24
|
focused.value = true;
|
|
@@ -65,7 +65,7 @@ props.onAction.register("onClick", onClick);
|
|
|
65
65
|
transformStyle: 'preserve-3d',
|
|
66
66
|
backgroundColor: '#FFFF00',
|
|
67
67
|
}"
|
|
68
|
-
|
|
68
|
+
@animationend="onFlipped"
|
|
69
69
|
>
|
|
70
70
|
<div
|
|
71
71
|
:style="{
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
* 【界面概述】
|
|
3
|
+
* JsvFocusBlock的autoFocus效果展示
|
|
4
|
+
* 主要用于Dialog弹出的场景,当Dialog内部的JsvFocusBlock设置autoFocus后,
|
|
5
|
+
* Dialog只要展示就会抢走焦点,同时,此样例也展示了,当Dialog退出后,只要App讲焦点
|
|
6
|
+
* 还给Dialog弹出前的焦点分支的根部,按照渐进式焦点处理写法,各级的onFocus触发后
|
|
7
|
+
* 后会再次将焦点传递给目标的子节点
|
|
8
|
+
*
|
|
9
|
+
-->
|
|
10
|
+
|
|
11
|
+
<template>
|
|
12
|
+
<plane-block :style="{left: 50, top: 50}"/>
|
|
13
|
+
<dialog-block v-if="showDialog"/>
|
|
14
|
+
</template>
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
<script setup>
|
|
18
|
+
import { shallowRef, watch, onMounted } from "vue"
|
|
19
|
+
import { useFocusHub, jJsvRuntimeBridge } from "jsview"
|
|
20
|
+
import PlaneBlock from "./PlaneBlock.vue"
|
|
21
|
+
import DialogBlock from "./DialogBlock.vue"
|
|
22
|
+
import { CreateDialogControl } from "./DialogContorls.js"
|
|
23
|
+
import FocusNames from "./FocusNamesDefine.js"
|
|
24
|
+
|
|
25
|
+
// 获取 FocusHub 操作句柄
|
|
26
|
+
let focusHub = useFocusHub();
|
|
27
|
+
|
|
28
|
+
// 创建 Dialog 控制节点,并讲showDialog这个reactive变量和控制节点关联上
|
|
29
|
+
let showDialog = shallowRef(false);
|
|
30
|
+
CreateDialogControl(showDialog);
|
|
31
|
+
|
|
32
|
+
watch(showDialog, ()=>{
|
|
33
|
+
if (showDialog.value == false) {
|
|
34
|
+
// Dialog消失后,将焦点设置给主区域,而主区域具体的focus对象则
|
|
35
|
+
// 按照渐进式焦点写法,触发了MainPlane的onFocus后,自动在一点点讲焦点给回原本的焦点子节点
|
|
36
|
+
focusHub.setFocus(FocusNames.MainPlane);
|
|
37
|
+
}
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
onMounted(()=>{
|
|
41
|
+
// 启动后先让主区域获得焦点
|
|
42
|
+
focusHub.setFocus(FocusNames.MainPlane);
|
|
43
|
+
|
|
44
|
+
// 通知小程序之家关闭启动图
|
|
45
|
+
jJsvRuntimeBridge.notifyPageLoaded();
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
</script>
|
|
49
|
+
|
|
50
|
+
<style scoped>
|
|
51
|
+
</style>
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { shallowRef } from "vue";
|
|
3
|
+
import { DefaultKeyCodeMap } from "jsview"
|
|
4
|
+
import { ShowDialog } from "./DialogContorls.js"
|
|
5
|
+
|
|
6
|
+
const props = defineProps({
|
|
7
|
+
name: String,
|
|
8
|
+
style: {
|
|
9
|
+
type: Object,
|
|
10
|
+
default: {},
|
|
11
|
+
},
|
|
12
|
+
onLeftRight: Function,
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
const hasFocused = shallowRef(false);
|
|
16
|
+
|
|
17
|
+
const onFocusFunc = () => {
|
|
18
|
+
console.log(`子节点 ${props.name} 获得焦点`);
|
|
19
|
+
hasFocused.value = true;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const onBlurFunc = () => {
|
|
23
|
+
console.log(`子节点 ${props.name} 失去焦点`);
|
|
24
|
+
hasFocused.value = false;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const onDispatchKeyDownFunc = (ev)=>{
|
|
28
|
+
console.log(`子节点 ${props.name} 收到下发按键 code=${ev.keyCode}`);
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const onKeyDownFunc = (ev)=>{
|
|
33
|
+
console.log(`子节点 ${props.name} 收到回流按键 code=${ev.keyCode}`);
|
|
34
|
+
|
|
35
|
+
// 将按键转化为left/right指令
|
|
36
|
+
let keyConsumed = true;
|
|
37
|
+
switch(ev.keyCode) {
|
|
38
|
+
case DefaultKeyCodeMap.Left:
|
|
39
|
+
props.onLeftRight?.("left");
|
|
40
|
+
break;
|
|
41
|
+
case DefaultKeyCodeMap.Right:
|
|
42
|
+
props.onLeftRight?.("right");
|
|
43
|
+
break;
|
|
44
|
+
case DefaultKeyCodeMap.Ok:
|
|
45
|
+
// 启动对话框,并让对话框显示自己的模块名
|
|
46
|
+
ShowDialog(`来自 ${props.name} 的信息`);
|
|
47
|
+
break;
|
|
48
|
+
default:
|
|
49
|
+
keyConsumed = false;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (keyConsumed) {
|
|
53
|
+
console.log(`子节点 ${props.name} 截断按键回流处理`)
|
|
54
|
+
}
|
|
55
|
+
return keyConsumed;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
</script>
|
|
59
|
+
|
|
60
|
+
<template>
|
|
61
|
+
<jsv-focus-block
|
|
62
|
+
:name="name"
|
|
63
|
+
:onAction="{
|
|
64
|
+
onDispatchKeyDown: onDispatchKeyDownFunc,
|
|
65
|
+
onKeyDown: onKeyDownFunc,
|
|
66
|
+
onFocus: onFocusFunc,
|
|
67
|
+
onBlur: onBlurFunc,
|
|
68
|
+
}"
|
|
69
|
+
>
|
|
70
|
+
<div
|
|
71
|
+
:style="{
|
|
72
|
+
...props.style,
|
|
73
|
+
width: 100,
|
|
74
|
+
height: 100,
|
|
75
|
+
fontSize: 35,
|
|
76
|
+
backgroundColor: hasFocused ? 'rgba(255,0,0,1)' : 'rgba(0,255,0,1)',
|
|
77
|
+
}"
|
|
78
|
+
>
|
|
79
|
+
{{ props.name }}
|
|
80
|
+
</div>
|
|
81
|
+
</jsv-focus-block>
|
|
82
|
+
</template>
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { onUnmounted } from "vue";
|
|
3
|
+
import { DefaultKeyCodeMap } from "jsview"
|
|
4
|
+
import { CloseDialog, GetDialogControl } from "./DialogContorls.js";
|
|
5
|
+
import FocusNames from "./FocusNamesDefine.js";
|
|
6
|
+
|
|
7
|
+
const dialogControlRef = GetDialogControl();
|
|
8
|
+
|
|
9
|
+
// 声明按键处理函数,只处理OK键
|
|
10
|
+
const onKeyDownFunc = (ev)=>{
|
|
11
|
+
console.log(`对话框收到回流按键 keyCode=${ev.keyCode}`);
|
|
12
|
+
if (ev.keyCode == DefaultKeyCodeMap.Ok) {
|
|
13
|
+
CloseDialog();
|
|
14
|
+
return true; // 阻断继续回流
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const onFocusFunc = ()=>{
|
|
21
|
+
console.log(`对话框获得焦点`);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const onBlurFunc = ()=>{
|
|
25
|
+
console.log(`对话框失去焦点`);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
onUnmounted(()=>{
|
|
29
|
+
console.log(`对话框被卸载`);
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
// 当此组件加载后,会通过autoFocus自动抢到焦点
|
|
33
|
+
|
|
34
|
+
</script>
|
|
35
|
+
|
|
36
|
+
<template>
|
|
37
|
+
<jsv-focus-block
|
|
38
|
+
:name="FocusNames.Dialog"
|
|
39
|
+
autoFocus
|
|
40
|
+
:onAction="{
|
|
41
|
+
onFocus: onFocusFunc,
|
|
42
|
+
onBlur: onBlurFunc,
|
|
43
|
+
onKeyDown: onKeyDownFunc,
|
|
44
|
+
}"
|
|
45
|
+
>
|
|
46
|
+
<div :style="{ top: 200, left: 465 }">
|
|
47
|
+
<div class="background"></div>
|
|
48
|
+
<div class="message">{{dialogControlRef.messageText}}</div>
|
|
49
|
+
<div :style="{ top: 120, left: 125 }">
|
|
50
|
+
<div class="focus"></div>
|
|
51
|
+
<div class="normal">确定</div>
|
|
52
|
+
</div>
|
|
53
|
+
</div>
|
|
54
|
+
</jsv-focus-block>
|
|
55
|
+
</template>
|
|
56
|
+
|
|
57
|
+
<style scoped>
|
|
58
|
+
.focus {
|
|
59
|
+
top: -5px;
|
|
60
|
+
left: -5px;
|
|
61
|
+
width: 100px;
|
|
62
|
+
height: 50px;
|
|
63
|
+
background-color: #0000ff;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.normal {
|
|
67
|
+
width: 90px;
|
|
68
|
+
height: 40px;
|
|
69
|
+
color: #ffffff;
|
|
70
|
+
text-align: center;
|
|
71
|
+
font-size: 30px;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.background {
|
|
75
|
+
left: 0px;
|
|
76
|
+
top: 0px;
|
|
77
|
+
width: 350px;
|
|
78
|
+
height: 200px;
|
|
79
|
+
background-color: rgba(0, 0, 0, 0.7);
|
|
80
|
+
}
|
|
81
|
+
.message {
|
|
82
|
+
top: 20px;
|
|
83
|
+
width: 350px;
|
|
84
|
+
height: 50px;
|
|
85
|
+
color: #ffffff;
|
|
86
|
+
font-size: 40px;
|
|
87
|
+
text-align: center;
|
|
88
|
+
}
|
|
89
|
+
</style>
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
let dialogConfigRef = null;
|
|
2
|
+
|
|
3
|
+
function CreateDialogControl(switcherRef) {
|
|
4
|
+
if (dialogConfigRef == null) {
|
|
5
|
+
dialogConfigRef = {
|
|
6
|
+
messageText: null,
|
|
7
|
+
switcher: switcherRef, // shallowRef对象
|
|
8
|
+
}
|
|
9
|
+
console.log("对话框控制对象创建完毕");
|
|
10
|
+
} else {
|
|
11
|
+
console.warn("对话框控制对象已经创建过");
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
return dialogConfigRef;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function ShowDialog(message) {
|
|
18
|
+
if (dialogConfigRef) {
|
|
19
|
+
console.log("通过showDialog开启对话框");
|
|
20
|
+
dialogConfigRef.messageText = message;
|
|
21
|
+
dialogConfigRef.switcher.value = true;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function CloseDialog() {
|
|
26
|
+
if (dialogConfigRef) {
|
|
27
|
+
console.log("通过closeDialog关闭对话框");
|
|
28
|
+
dialogConfigRef.messageText = null;
|
|
29
|
+
dialogConfigRef.switcher.value = false;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function GetDialogControl() {
|
|
34
|
+
return dialogConfigRef;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export {
|
|
38
|
+
CreateDialogControl,
|
|
39
|
+
ShowDialog,
|
|
40
|
+
CloseDialog,
|
|
41
|
+
GetDialogControl
|
|
42
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { useFocusHub } from "jsview"
|
|
3
|
+
import FocusNames from "./FocusNamesDefine";
|
|
4
|
+
import BaseBlock from "./BaseBlock.vue";
|
|
5
|
+
|
|
6
|
+
const props = defineProps({
|
|
7
|
+
style: {
|
|
8
|
+
type: Object,
|
|
9
|
+
default: {},
|
|
10
|
+
},
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
let focusHub = useFocusHub();
|
|
14
|
+
let ChildBlockNames = [FocusNames.BoxX, FocusNames.BoxY, FocusNames.BoxZ];
|
|
15
|
+
let lastIndex = 0;
|
|
16
|
+
let planeName = FocusNames.MainPlane;
|
|
17
|
+
|
|
18
|
+
const onFocusFunc = () => {
|
|
19
|
+
console.log(`父节点 ${planeName} 获得焦点`);
|
|
20
|
+
|
|
21
|
+
// 渐进式焦点设置方式,让子焦点获焦
|
|
22
|
+
focusHub.setFocus(ChildBlockNames[lastIndex]);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const onBlurFunc = () => {
|
|
26
|
+
console.log(`父节点 ${planeName} 失去焦点`);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const onDispatchKeyDownFunc = (ev)=>{
|
|
30
|
+
console.log(`父节点 ${planeName} 收到下发按键 code=${ev.keyCode}`);
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const onKeyDownFunc = (ev)=>{
|
|
35
|
+
console.log(`父节点 ${planeName} 收到回流按键 code=${ev.keyCode}`);
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const leftRightFunc = (action)=>{
|
|
40
|
+
if (action == "left") {
|
|
41
|
+
if (lastIndex >= 0) {
|
|
42
|
+
lastIndex--;
|
|
43
|
+
console.log(`父节点 ${planeName} 收到left指令 切换子节点到"${ChildBlockNames[lastIndex]}`);
|
|
44
|
+
focusHub.setFocus(ChildBlockNames[lastIndex]);
|
|
45
|
+
}
|
|
46
|
+
} else if (action = "right") {
|
|
47
|
+
if (lastIndex < ChildBlockNames.length - 1) {
|
|
48
|
+
lastIndex++;
|
|
49
|
+
console.log(`父节点 ${planeName} 收到left指令 切换子节点到"${ChildBlockNames[lastIndex]}"`);
|
|
50
|
+
focusHub.setFocus(ChildBlockNames[lastIndex]);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
</script>
|
|
55
|
+
|
|
56
|
+
<template>
|
|
57
|
+
<jsv-focus-block
|
|
58
|
+
:name="planeName"
|
|
59
|
+
:onAction="{
|
|
60
|
+
onDispatchKeyDown: onDispatchKeyDownFunc,
|
|
61
|
+
onKeyDown: onKeyDownFunc,
|
|
62
|
+
onFocus: onFocusFunc,
|
|
63
|
+
onBlur: onBlurFunc,
|
|
64
|
+
}"
|
|
65
|
+
:style="props.style"
|
|
66
|
+
>
|
|
67
|
+
<base-block :name="ChildBlockNames[0]" :style="{left:150 * 1}" :onLeftRight="leftRightFunc" />
|
|
68
|
+
<base-block :name="ChildBlockNames[1]" :style="{left:150 * 2}" :onLeftRight="leftRightFunc" />
|
|
69
|
+
<base-block :name="ChildBlockNames[2]" :style="{left:150 * 3}" :onLeftRight="leftRightFunc" />
|
|
70
|
+
</jsv-focus-block>
|
|
71
|
+
</template>
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
* 【界面概述】
|
|
3
|
+
* 渐进式焦点展示,整个界面分为上下两个部分,每个部分有3个方格,当方格获焦的时候会变更颜色。
|
|
4
|
+
* 所展示的效果是,上下两个部分只了解到兄弟节点focusBlock的名字,而并不知道其子节点的名字。
|
|
5
|
+
* 当从上部分的子焦点切换到下部分的子焦点过程,是首先指定父节点来进行setFocus,
|
|
6
|
+
* 然后通过onFocus事件处理再进一步setFocus到子焦点上
|
|
7
|
+
*
|
|
8
|
+
*
|
|
9
|
+
* 【技巧说明】
|
|
10
|
+
* Q: 如何进行按键响应?
|
|
11
|
+
* A: 重载函数onKeyDown/onKeyUp/onDispatchKeyDown/onDispatchKeyUp中任何一个关心
|
|
12
|
+
* 的按键事件响应函数,处理ev.keyCode判断按键值,通过返回值控制消息传递链是否中止
|
|
13
|
+
*
|
|
14
|
+
* Q: 如何进行焦点切换?
|
|
15
|
+
* A: 首先为子焦点设置name属性,当需要进行焦点切换的时候,通过 useFocusHub() 提供的hub
|
|
16
|
+
* 的 setFocus 函数处理
|
|
17
|
+
*
|
|
18
|
+
* Q: setFocus的第二个参数keepChildFocus的作用是什么?
|
|
19
|
+
* A: 使用场景举例:
|
|
20
|
+
* 针对有子节点的FocusBlock,当子节点已经获焦后,通过对自身进行setFocus并且设置
|
|
21
|
+
* keepChildFocus=false,可让自己的子焦点失焦
|
|
22
|
+
*
|
|
23
|
+
-->
|
|
24
|
+
|
|
25
|
+
<script setup>
|
|
26
|
+
import { onMounted, shallowRef, provide } from "vue"
|
|
27
|
+
import { useFocusHub } from "jsview"
|
|
28
|
+
import UpPlaneBlock from "./UpPlaneBlock.vue";
|
|
29
|
+
import DownPlaneBlock from "./DownPlaneBlock.vue";
|
|
30
|
+
import { DefaultKeyCodeMap } from "jsview"
|
|
31
|
+
|
|
32
|
+
let focusHub = useFocusHub();
|
|
33
|
+
|
|
34
|
+
let columnIndexData = {
|
|
35
|
+
index: 0
|
|
36
|
+
}; // Plane切换时的共享column数据
|
|
37
|
+
|
|
38
|
+
provide("globalColumn", columnIndexData);
|
|
39
|
+
|
|
40
|
+
const onKeyDownFunc = (ev)=>{
|
|
41
|
+
console.log(`App 根节点 收到回流按键 code=${ev.keyCode}`);
|
|
42
|
+
|
|
43
|
+
// 将按键转化为left/right指令
|
|
44
|
+
let keyConsumed = true;
|
|
45
|
+
switch(ev.keyCode) {
|
|
46
|
+
case DefaultKeyCodeMap.Up:
|
|
47
|
+
focusHub.setFocus("UpPlane");
|
|
48
|
+
break;
|
|
49
|
+
case DefaultKeyCodeMap.Down:
|
|
50
|
+
focusHub.setFocus("DownPlane");
|
|
51
|
+
break;
|
|
52
|
+
default:
|
|
53
|
+
keyConsumed = false;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return keyConsumed; // 若为true则会阻止按键下发到子节点
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
onMounted(()=>{
|
|
60
|
+
// 启动后先让上半区域获得焦点
|
|
61
|
+
focusHub.setFocus("UpPlane");
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
</script>
|
|
65
|
+
|
|
66
|
+
<template>
|
|
67
|
+
<jsv-focus-block
|
|
68
|
+
:onAction = "{
|
|
69
|
+
onKeyDown: onKeyDownFunc
|
|
70
|
+
}"
|
|
71
|
+
>
|
|
72
|
+
<up-plane-block :style="{top:100}" />
|
|
73
|
+
<down-plane-block :style="{top:220}"/>
|
|
74
|
+
</jsv-focus-block>
|
|
75
|
+
</template>
|
|
76
|
+
|
|
77
|
+
<style scoped>
|
|
78
|
+
</style>
|