@shijiu/jsview-vue-samples 1.9.747
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/AnimPicture/App.vue +207 -0
- package/AnimPicture/assets/animated_webp.webp +0 -0
- package/AnimPicture/assets/ball_3.webp +0 -0
- package/AnimPicture/assets/girl_run.gif +0 -0
- package/AnimPicture/assets/quan.webp +0 -0
- package/Basic/App.vue +134 -0
- package/Basic/assets/border.png +0 -0
- package/Basic/assets/border2.png +0 -0
- package/Basic/assets/icon.png +0 -0
- package/Basic/assets/test.jpg +0 -0
- package/Basic/components/ContentBlock.vue +38 -0
- package/Basic/components/FontStyle.css +16 -0
- package/Basic/components/anim/AnimGroup.vue +66 -0
- package/Basic/components/anim/AnimKeyframeBasic.vue +119 -0
- package/Basic/components/anim/AnimKeyframeComposite.vue +52 -0
- package/Basic/components/anim/AnimTransition.vue +157 -0
- package/Basic/components/div/DivBackground.vue +44 -0
- package/Basic/components/div/DivClip.vue +159 -0
- package/Basic/components/div/DivCssScoped.vue +20 -0
- package/Basic/components/div/DivCssVar.vue +53 -0
- package/Basic/components/div/DivGroup1.vue +47 -0
- package/Basic/components/div/DivGroup2.vue +65 -0
- package/Basic/components/div/DivLayout.vue +70 -0
- package/Basic/components/div/DivRadius.vue +65 -0
- package/Basic/components/div/DivTransform.vue +32 -0
- package/Basic/components/img/ImageGroup.vue +31 -0
- package/Basic/components/img/ImgLayout.vue +41 -0
- package/Basic/components/panel/Panel1.vue +55 -0
- package/Basic/components/panel/Panel2.vue +31 -0
- package/Basic/components/panel/TitleBar.vue +29 -0
- package/Basic/components/text/TextAlign.vue +66 -0
- package/Basic/components/text/TextEmoji.vue +26 -0
- package/Basic/components/text/TextFontStyle.vue +89 -0
- package/Basic/components/text/TextGroup1.vue +49 -0
- package/Basic/components/text/TextGroup2.vue +28 -0
- package/Basic/components/text/TextOverflow.vue +110 -0
- package/BasicFocusControl/App.vue +104 -0
- package/BasicFocusControl/components/BaseBlock.vue +50 -0
- package/BasicFocusControl/components/MainArea.vue +83 -0
- package/BasicFocusControl/components/MainAreaLeftBlock.vue +17 -0
- package/BasicFocusControl/components/MainAreaRightBlock.vue +27 -0
- package/BasicFocusControl/components/SideBar.vue +58 -0
- package/BasicFocusControl/components/SideBarBlock.vue +27 -0
- package/Collision/App.vue +452 -0
- package/ColorSpace/App.vue +126 -0
- package/ColorSpace/bmpDemo.bmp +0 -0
- package/ColorSpace/jpegDemo.jpeg +0 -0
- package/ColorSpace/pngDemo.png +0 -0
- package/ColorSpace/pngNoAlphaDemo.png +0 -0
- package/DemoHomepage/App.vue +27 -0
- package/DemoHomepage/components/BodyFrame.vue +95 -0
- package/DemoHomepage/components/Dialog.vue +94 -0
- package/DemoHomepage/components/Item.vue +77 -0
- package/DemoHomepage/components/TabFrame.vue +85 -0
- package/DemoHomepage/router.js +196 -0
- package/DemoHomepage/views/Homepage.vue +195 -0
- package/FilterDemo/AnimatePic.vue +58 -0
- package/FilterDemo/App.vue +159 -0
- package/FilterDemo/VideoLayer.vue +62 -0
- package/FilterDemo/jpegDemo.jpeg +0 -0
- package/FilterDemo/webpDemo.webp +0 -0
- package/FlipCard/App.vue +71 -0
- package/FlipCard/FlipCard.vue +118 -0
- package/FlipCard/assets/blue_egg.png +0 -0
- package/FlipCard/assets/red_egg.png +0 -0
- package/FlipCard/data.js +13 -0
- package/GridDemo/App.vue +215 -0
- package/GridDemo/ButtonBlock.vue +112 -0
- package/GridDemo/FocusItem.vue +37 -0
- package/GridDemo/Item.vue +93 -0
- package/HashHistory/App.vue +115 -0
- package/HashHistory/components/HorizontalButtonList.vue +91 -0
- package/HashHistory/components/Item.vue +60 -0
- package/HashHistory/router.js +41 -0
- package/HashHistory/views/MainPage.vue +57 -0
- package/HashHistory/views/SubPage.vue +66 -0
- package/ImpactStop/App.vue +435 -0
- package/Input/App.vue +164 -0
- package/Input/FullKeyboard.vue +87 -0
- package/Input/InputPanel.vue +131 -0
- package/Input/KeyboardItem.vue +58 -0
- package/LongImage/App.vue +80 -0
- package/LongImage/Button.vue +58 -0
- package/LongImage/ButtonItem.vue +44 -0
- package/LongImage/LongImageScroll.vue +92 -0
- package/LongImage/Scroll.vue +14 -0
- package/LongImage/assets/1280x7200.jpg +0 -0
- package/LongText/App.vue +96 -0
- package/LongText/Button.vue +51 -0
- package/LongText/ButtonItem.vue +44 -0
- package/LongText/LongTextScroll.vue +192 -0
- package/LongText/Scroll.vue +14 -0
- package/Marquee/App.vue +247 -0
- package/Marquee/longText.js +14 -0
- package/MaskClip/App.vue +122 -0
- package/MaskClip/images/mask-025/config.json +29 -0
- package/MaskClip/images/mask-025/res/1.png +0 -0
- package/MaskClip/images/mask-025/res/2.png +0 -0
- package/MaskClip/images/mask-025/res/3.png +0 -0
- package/MaskClip/images/mask-025/res/4.png +0 -0
- package/MaskClip/images/mask-025/res/icon.png +0 -0
- package/MaskClip/images/mask-025/res/stroke.png +0 -0
- package/MaskClip/images/php.jpg +0 -0
- package/MetroWidgetDemos/Advanced/App.vue +46 -0
- package/MetroWidgetDemos/Advanced/ButtonItem.vue +90 -0
- package/MetroWidgetDemos/Advanced/Buttons.vue +70 -0
- package/MetroWidgetDemos/Advanced/Mixed.vue +77 -0
- package/MetroWidgetDemos/Advanced/widgets/Item.vue +83 -0
- package/MetroWidgetDemos/Advanced/widgets/WidgetItem.vue +89 -0
- package/MetroWidgetDemos/Advanced/widgets/Widgets.vue +116 -0
- package/MetroWidgetDemos/Advanced/widgets/focus1.png +0 -0
- package/MetroWidgetDemos/Item.vue +85 -0
- package/MetroWidgetDemos/PerformanceTest/App.vue +210 -0
- package/MetroWidgetDemos/PerformanceTest/Item.vue +90 -0
- package/MetroWidgetDemos/PerformanceTest/assets/bg.jpg +0 -0
- package/MetroWidgetDemos/PerformanceTest/assets/coupon_content.png +0 -0
- package/MetroWidgetDemos/PerformanceTest/assets/coupon_left.png +0 -0
- package/MetroWidgetDemos/PerformanceTest/assets/coupon_mid.png +0 -0
- package/MetroWidgetDemos/PerformanceTest/assets/coupon_right.png +0 -0
- package/MetroWidgetDemos/PerformanceTest/assets/focus_border.png +0 -0
- package/MetroWidgetDemos/PerformanceTest/assets/holder_logo.png +0 -0
- package/MetroWidgetDemos/PerformanceTest/assets/jrbm.png +0 -0
- package/MetroWidgetDemos/PerformanceTest/assets/line_left.png +0 -0
- package/MetroWidgetDemos/PerformanceTest/assets/line_mid.png +0 -0
- package/MetroWidgetDemos/PerformanceTest/assets/line_right.png +0 -0
- package/MetroWidgetDemos/PerformanceTest/assets/loading.png +0 -0
- package/MetroWidgetDemos/PerformanceTest/assets/logo.png +0 -0
- package/MetroWidgetDemos/PerformanceTest/assets/mcjx.png +0 -0
- package/MetroWidgetDemos/PerformanceTest/assets/tao.png +0 -0
- package/MetroWidgetDemos/PerformanceTest/assets/tmall.png +0 -0
- package/MetroWidgetDemos/PerformanceTest/border.png +0 -0
- package/MetroWidgetDemos/PerformanceTest/components/ContentItem.vue +386 -0
- package/MetroWidgetDemos/PerformanceTest/components/MyTab.vue +129 -0
- package/MetroWidgetDemos/PerformanceTest/data.js +45 -0
- package/MetroWidgetDemos/PingPong/App.vue +135 -0
- package/MetroWidgetDemos/PingPong/AppPage.vue +73 -0
- package/MetroWidgetDemos/PingPong/AppTab.vue +62 -0
- package/MetroWidgetDemos/PingPong/TabItem.vue +84 -0
- package/MetroWidgetDemos/PingPong/ViewSwiper.vue +214 -0
- package/MetroWidgetDemos/Simple/AbsoluteTemplate.vue +75 -0
- package/MetroWidgetDemos/Simple/App.vue +45 -0
- package/MetroWidgetDemos/Simple/RelativeTemplate.vue +111 -0
- package/MetroWidgetDemos/WidgetItem.vue +89 -0
- package/MetroWidgetDemos/data.js +205 -0
- package/NinePatchDemo/App.vue +145 -0
- package/NinePatchDemo/Item.vue +69 -0
- package/NinePatchDemo/assets/border.png +0 -0
- package/Preload/App.vue +135 -0
- package/Preload/Item.vue +32 -0
- package/Preload/data.js +23 -0
- package/Preload/images/awesomeface.png +0 -0
- package/Preload/images/cat.jpg +0 -0
- package/Preload/images/rank.png +0 -0
- package/Preload/images/rank_focus.png +0 -0
- package/Preload/images/rule.png +0 -0
- package/Preload/images/rule_focus.png +0 -0
- package/Preload/images/start.png +0 -0
- package/Preload/images/start_focus.png +0 -0
- package/QrcodeDemo/App.vue +68 -0
- package/ScaleDownNeon/App.vue +107 -0
- package/SoundPool/App.vue +134 -0
- package/SoundPool/bgmusic.mp3 +0 -0
- package/SoundPool/coin.mp3 +0 -0
- package/SoundPool/jump.mp3 +0 -0
- package/SoundPool/lose.mp3 +0 -0
- package/SoundPool/run.mp3 +0 -0
- package/SprayView/App.vue +272 -0
- package/SprayView/assets/snow.png +0 -0
- package/SpriteImage/App.vue +173 -0
- package/SpriteImage/images/cat_run.png +0 -0
- package/SpriteImage/images/egg_break.json +116 -0
- package/SpriteImage/images/egg_break.png +0 -0
- package/SpriteImage/images/sprite.png +0 -0
- package/TextBox/App.vue +91 -0
- package/TextBox/RenderCenter.vue +133 -0
- package/TextBox/RenderLeft.vue +138 -0
- package/TextBox/RenderOneLine.vue +101 -0
- package/TextBox/RenderRight.vue +131 -0
- package/TextShadowDemo/App.vue +91 -0
- package/TextureAnimation/App.vue +336 -0
- package/TextureAnimation/App2.vue +111 -0
- package/TextureAnimation/assets/blackWhiteGrid.png +0 -0
- package/TextureAnimation/assets/light.png +0 -0
- package/TextureAnimation/assets/light2.png +0 -0
- package/TextureAnimation/assets/mask.png +0 -0
- package/TextureAnimation/assets/php.jpg +0 -0
- package/TextureAnimation/assets/php2.png +0 -0
- package/TextureAnimation/assets/swipLight.png +0 -0
- package/TextureSize/App.vue +132 -0
- package/TextureSize/bmpDemo.bmp +0 -0
- package/TextureSize/jpegDemo.jpeg +0 -0
- package/TextureSize/jpgDemo.jpg +0 -0
- package/TextureSize/pngDemo.png +0 -0
- package/TextureSize/pngNoAlphaDemo.png +0 -0
- package/ThrowMoveDemo/AccelerateDemo.vue +116 -0
- package/ThrowMoveDemo/App.vue +114 -0
- package/ThrowMoveDemo/LRParabolicDemo.vue +115 -0
- package/ThrowMoveDemo/TargetDemo.vue +116 -0
- package/ThrowMoveDemo/UDParabolicDemo.vue +121 -0
- package/TouchSample/App.vue +136 -0
- package/TouchSample/Item.vue +103 -0
- package/TouchSample/MetroWidgetHorizontal.vue +144 -0
- package/TouchSample/MetroWidgetVertical.vue +144 -0
- package/TouchSample/TouchContainerHorizontal.vue +160 -0
- package/TouchSample/TouchContainerVertical.vue +160 -0
- package/TouchSample/data.js +81 -0
- package/TransitPage/App.vue +29 -0
- package/VideoDemo/App.vue +121 -0
- package/VideoDemo/components/Button.vue +58 -0
- package/VideoDemo/components/Controllor.vue +197 -0
- package/VideoDemo/components/VideoFrame.vue +140 -0
- package/VisibleSensorDemo/App.vue +234 -0
- package/package.json +17 -0
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
* @Author: ChenChanghua
|
|
3
|
+
* @Date: 2022-05-10 15:21:24
|
|
4
|
+
* @LastEditors: ChenChanghua
|
|
5
|
+
* @LastEditTime: 2022-07-08 11:51:26
|
|
6
|
+
* @Description: file content
|
|
7
|
+
-->
|
|
8
|
+
<script setup>
|
|
9
|
+
import { ref, shallowRef } from "vue";
|
|
10
|
+
const props = defineProps({
|
|
11
|
+
userData: Object,
|
|
12
|
+
name: String,
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
let focusIndex = ref(0);
|
|
16
|
+
let focused = ref(false);
|
|
17
|
+
let divNumber = new Array(25);
|
|
18
|
+
let focusBlock = shallowRef(null);
|
|
19
|
+
|
|
20
|
+
const _onFocus = () => {
|
|
21
|
+
console.log("button onfocus", props.userData);
|
|
22
|
+
focused.value = true;
|
|
23
|
+
};
|
|
24
|
+
const _onBlur = () => {
|
|
25
|
+
focused.value = false;
|
|
26
|
+
focusIndex.value = 0;
|
|
27
|
+
};
|
|
28
|
+
const _onKeyDown = (ev) => {
|
|
29
|
+
console.log("button onkeydown");
|
|
30
|
+
if (ev.keyCode == 37 && focusIndex.value == 1) {
|
|
31
|
+
focusIndex.value = 0;
|
|
32
|
+
return true;
|
|
33
|
+
} else if (ev.keyCode == 39 && focusIndex.value == 0) {
|
|
34
|
+
focusIndex.value = 1;
|
|
35
|
+
return true;
|
|
36
|
+
} else if (ev.keyCode == 13) {
|
|
37
|
+
console.log("button click", props.userData);
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
return false;
|
|
41
|
+
};
|
|
42
|
+
const getFocusBlock = () => {
|
|
43
|
+
return focusBlock.value;
|
|
44
|
+
};
|
|
45
|
+
const _MapColor = (color_num) => {
|
|
46
|
+
return color_num < 10 || color_num >= 100
|
|
47
|
+
? "0" + (color_num % 10)
|
|
48
|
+
: "" + (color_num % 100);
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
defineExpose({
|
|
52
|
+
getFocusBlock,
|
|
53
|
+
});
|
|
54
|
+
</script>
|
|
55
|
+
|
|
56
|
+
<template>
|
|
57
|
+
<jsv-focus-block
|
|
58
|
+
ref="focusBlock"
|
|
59
|
+
:name="name"
|
|
60
|
+
:onAction="{
|
|
61
|
+
onFocus: _onFocus,
|
|
62
|
+
onBlur: _onBlur,
|
|
63
|
+
onKeyDown: _onKeyDown,
|
|
64
|
+
}"
|
|
65
|
+
>
|
|
66
|
+
<div
|
|
67
|
+
v-for="(item, index) in divNumber"
|
|
68
|
+
:key="index + '_l'"
|
|
69
|
+
:style="{
|
|
70
|
+
left: 2 * index,
|
|
71
|
+
width: 2,
|
|
72
|
+
height: 50,
|
|
73
|
+
backgroundColor: '#77' + _MapColor(index) + _MapColor(index),
|
|
74
|
+
}"
|
|
75
|
+
></div>
|
|
76
|
+
<div
|
|
77
|
+
:style="{
|
|
78
|
+
width: 50,
|
|
79
|
+
height: 50,
|
|
80
|
+
fontSize: 20,
|
|
81
|
+
color: '#FFFFFF',
|
|
82
|
+
}"
|
|
83
|
+
>
|
|
84
|
+
{{ userData.name }}
|
|
85
|
+
</div>
|
|
86
|
+
|
|
87
|
+
<div
|
|
88
|
+
v-for="(item, index) in divNumber"
|
|
89
|
+
:key="index + '_r'"
|
|
90
|
+
:style="{
|
|
91
|
+
left: 2 * index + 50,
|
|
92
|
+
width: 2,
|
|
93
|
+
height: 50,
|
|
94
|
+
backgroundColor:
|
|
95
|
+
'#' +
|
|
96
|
+
_MapColor(userData.baseColor) +
|
|
97
|
+
_MapColor(index) +
|
|
98
|
+
_MapColor(index),
|
|
99
|
+
}"
|
|
100
|
+
></div>
|
|
101
|
+
|
|
102
|
+
<div
|
|
103
|
+
:style="{
|
|
104
|
+
visibility: this.focused ? 'visible' : 'hidden',
|
|
105
|
+
left: 50 * focusIndex,
|
|
106
|
+
width: 10,
|
|
107
|
+
height: 10,
|
|
108
|
+
backgroundColor: '#FF0000',
|
|
109
|
+
}"
|
|
110
|
+
></div>
|
|
111
|
+
</jsv-focus-block>
|
|
112
|
+
</template>
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
* @Author: ChenChanghua
|
|
3
|
+
* @Date: 2022-05-10 15:21:24
|
|
4
|
+
* @LastEditors: ChenChanghua
|
|
5
|
+
* @LastEditTime: 2022-07-08 11:50:58
|
|
6
|
+
* @Description: file content
|
|
7
|
+
-->
|
|
8
|
+
<script setup>
|
|
9
|
+
import ButtonBlock from "./ButtonBlock.vue";
|
|
10
|
+
import { ref, shallowRef } from "vue";
|
|
11
|
+
|
|
12
|
+
const props = defineProps({
|
|
13
|
+
userData: Object,
|
|
14
|
+
widgetData: Object,
|
|
15
|
+
onAction: Object,
|
|
16
|
+
});
|
|
17
|
+
const focused = ref(false);
|
|
18
|
+
const divNumber = new Array(50);
|
|
19
|
+
const button = shallowRef(null);
|
|
20
|
+
const onFocus = () => {
|
|
21
|
+
button.value
|
|
22
|
+
.getFocusBlock()
|
|
23
|
+
.findBlockByName(props.widgetData.gridIndex + "_item")
|
|
24
|
+
.requestFocus();
|
|
25
|
+
};
|
|
26
|
+
const onBlur = () => {};
|
|
27
|
+
props.onAction.register("onFocus", onFocus);
|
|
28
|
+
props.onAction.register("onBlur", onBlur);
|
|
29
|
+
</script>
|
|
30
|
+
|
|
31
|
+
<template>
|
|
32
|
+
<button-block
|
|
33
|
+
ref="button"
|
|
34
|
+
:name="widgetData.gridIndex + '_item'"
|
|
35
|
+
:userData="userData"
|
|
36
|
+
></button-block>
|
|
37
|
+
</template>
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
* @Author: ChenChanghua
|
|
3
|
+
* @Date: 2022-05-10 15:21:24
|
|
4
|
+
* @LastEditors: ChenChanghua
|
|
5
|
+
* @LastEditTime: 2022-07-08 11:48:32
|
|
6
|
+
* @Description: file content
|
|
7
|
+
-->
|
|
8
|
+
<script setup>
|
|
9
|
+
import { ref, shallowRef, onUpdated, onMounted } from "vue";
|
|
10
|
+
|
|
11
|
+
const props = defineProps({
|
|
12
|
+
userData: Object,
|
|
13
|
+
widgetData: Object,
|
|
14
|
+
onAction: Object,
|
|
15
|
+
});
|
|
16
|
+
const randomColor = () => {
|
|
17
|
+
let randomColor = Math.round(Math.random() * 2 ** 24).toString(16);
|
|
18
|
+
return (
|
|
19
|
+
"#" + new Array(6 - randomColor.length).fill("0").join("") + randomColor
|
|
20
|
+
);
|
|
21
|
+
};
|
|
22
|
+
const focused = ref(false);
|
|
23
|
+
const divNumber = new Array(50);
|
|
24
|
+
const blurAction = false;
|
|
25
|
+
|
|
26
|
+
const onFocus = () => {
|
|
27
|
+
console.log("item onfocus", props.userData);
|
|
28
|
+
focused.value = true;
|
|
29
|
+
};
|
|
30
|
+
const onBlur = () => {
|
|
31
|
+
console.log(
|
|
32
|
+
"item onblur",
|
|
33
|
+
props.userData,
|
|
34
|
+
props.widgetData.getCurrentFocusId(),
|
|
35
|
+
props.widgetData.dataIndex
|
|
36
|
+
);
|
|
37
|
+
focused.value = false;
|
|
38
|
+
};
|
|
39
|
+
const onClick = () => {
|
|
40
|
+
console.log("item onclick ", props.userData);
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
props.onAction.register("onFocus", onFocus);
|
|
44
|
+
props.onAction.register("onBlur", onBlur);
|
|
45
|
+
props.onAction.register("onClick", onClick);
|
|
46
|
+
|
|
47
|
+
onUpdated(() => {
|
|
48
|
+
console.log("item updated", props.userData, props.widgetData);
|
|
49
|
+
});
|
|
50
|
+
onMounted(() => {
|
|
51
|
+
console.log("item mounted", props.userData, props.widgetData);
|
|
52
|
+
});
|
|
53
|
+
</script>
|
|
54
|
+
|
|
55
|
+
<template>
|
|
56
|
+
<div
|
|
57
|
+
v-for="(item, index) in divNumber"
|
|
58
|
+
:key="index"
|
|
59
|
+
:style="{
|
|
60
|
+
left: 2 * index,
|
|
61
|
+
width: 2,
|
|
62
|
+
height: 50,
|
|
63
|
+
backgroundColor: '#007788',
|
|
64
|
+
}"
|
|
65
|
+
></div>
|
|
66
|
+
<div
|
|
67
|
+
:style="{
|
|
68
|
+
width: 100,
|
|
69
|
+
height: 50,
|
|
70
|
+
fontSize: '30px',
|
|
71
|
+
color: '#FFFFFF',
|
|
72
|
+
}"
|
|
73
|
+
>
|
|
74
|
+
{{ userData.content }}
|
|
75
|
+
</div>
|
|
76
|
+
<div
|
|
77
|
+
:style="{
|
|
78
|
+
visibility: focused ? 'visible' : 'hidden',
|
|
79
|
+
width: 20,
|
|
80
|
+
height: 20,
|
|
81
|
+
backgroundColor: '#FF0000',
|
|
82
|
+
}"
|
|
83
|
+
></div>
|
|
84
|
+
<div
|
|
85
|
+
:style="{
|
|
86
|
+
visibility: !focused && widgetData.selected ? 'visible' : 'hidden',
|
|
87
|
+
left: 50,
|
|
88
|
+
width: 20,
|
|
89
|
+
height: 20,
|
|
90
|
+
backgroundColor: '#00FF00',
|
|
91
|
+
}"
|
|
92
|
+
></div>
|
|
93
|
+
</template>
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { router, routeList } from "./router.js";
|
|
3
|
+
export default {
|
|
4
|
+
Router: router,
|
|
5
|
+
};
|
|
6
|
+
</script>
|
|
7
|
+
|
|
8
|
+
<script setup>
|
|
9
|
+
import { jJsvRuntimeBridge } from "jsview";
|
|
10
|
+
import { router, routeList } from "./router.js";
|
|
11
|
+
import { useRouter, useRoute } from "vue-router";
|
|
12
|
+
import { onMounted, ref, shallowRef } from "vue";
|
|
13
|
+
|
|
14
|
+
const props = defineProps({
|
|
15
|
+
routePath: String,
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
const displayUrl = ref("");
|
|
19
|
+
let topRef = shallowRef(null);
|
|
20
|
+
let routePage = shallowRef(null);
|
|
21
|
+
let currentRouter;
|
|
22
|
+
if (props.routePath) {
|
|
23
|
+
const currentRoute = useRoute();
|
|
24
|
+
currentRouter = useRouter();
|
|
25
|
+
|
|
26
|
+
let redirectPath; // 自动跳转路径
|
|
27
|
+
for (const route of routeList) {
|
|
28
|
+
if (route.path === "/") {
|
|
29
|
+
// 不需要添加home
|
|
30
|
+
redirectPath = route.redirect;
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const subRoute = { ...route, path: route.path.substring(1) }; // 去掉字符'/'
|
|
35
|
+
currentRouter.addRoute(currentRoute.name, subRoute);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
currentRouter.replace(props.routePath + redirectPath); // 自动跳转到redirectPath
|
|
39
|
+
} else {
|
|
40
|
+
currentRouter = router;
|
|
41
|
+
}
|
|
42
|
+
currentRouter.afterEach(() => {
|
|
43
|
+
displayUrl.value = window.location.href;
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
const onRequestFocus = (branchName) => {
|
|
47
|
+
topRef.value.findBlockByname(branchName)?.requestFocus();
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const watchRouterChanged = (route) => {
|
|
51
|
+
route.afterEach(() => {
|
|
52
|
+
displayUrl.value = window.location.href;
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const onKeyDown = (event) => {
|
|
57
|
+
return routePage.value.onKeyDown(event);
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
onMounted(() => {
|
|
61
|
+
jJsvRuntimeBridge.notifyPageLoaded();
|
|
62
|
+
});
|
|
63
|
+
</script>
|
|
64
|
+
|
|
65
|
+
<template>
|
|
66
|
+
<div class="root">
|
|
67
|
+
<div class="address">当前URL: {{ displayUrl }}</div>
|
|
68
|
+
<div class="split"></div>
|
|
69
|
+
<jsv-focus-block ref="topRef">
|
|
70
|
+
<!-- 这种router-view的写法可以获取到component的ref,vue标准写法 -->
|
|
71
|
+
<router-view v-slot="{ Component }">
|
|
72
|
+
<component
|
|
73
|
+
:is="Component"
|
|
74
|
+
ref="routePage"
|
|
75
|
+
class="router"
|
|
76
|
+
@requestFocus="onRequestFocus"
|
|
77
|
+
/>
|
|
78
|
+
</router-view>
|
|
79
|
+
</jsv-focus-block>
|
|
80
|
+
</div>
|
|
81
|
+
</template>
|
|
82
|
+
|
|
83
|
+
<style scoped>
|
|
84
|
+
.root {
|
|
85
|
+
left: 0;
|
|
86
|
+
top: 0;
|
|
87
|
+
width: 1280;
|
|
88
|
+
height: 1080;
|
|
89
|
+
background-color: rgb(222, 211, 140);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.address {
|
|
93
|
+
left: 40;
|
|
94
|
+
top: 40;
|
|
95
|
+
width: 1200;
|
|
96
|
+
height: 200;
|
|
97
|
+
font-size: 20;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.split {
|
|
101
|
+
left: 40;
|
|
102
|
+
top: 150;
|
|
103
|
+
width: 1200;
|
|
104
|
+
height: 3;
|
|
105
|
+
background-color: #00f000;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.router {
|
|
109
|
+
left: 0;
|
|
110
|
+
top: 150;
|
|
111
|
+
width: 1920;
|
|
112
|
+
height: 930;
|
|
113
|
+
overflow: hidden;
|
|
114
|
+
}
|
|
115
|
+
</style>
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import Item from "./Item.vue";
|
|
3
|
+
|
|
4
|
+
const props = defineProps({
|
|
5
|
+
style: Object,
|
|
6
|
+
buttonConfig: Object,
|
|
7
|
+
onButtonClick: Function,
|
|
8
|
+
onBack: Function,
|
|
9
|
+
});
|
|
10
|
+
const maxWidth = 1280;
|
|
11
|
+
const listPadding = 10;
|
|
12
|
+
const buttonWidth = 400;
|
|
13
|
+
const buttonHeight = 80;
|
|
14
|
+
const buttonGap = 50;
|
|
15
|
+
let focusedItemIndex = 0;
|
|
16
|
+
|
|
17
|
+
let listLeft = 0;
|
|
18
|
+
const listWidth = (buttonWidth + buttonGap) * props.buttonConfig.length;
|
|
19
|
+
|
|
20
|
+
// 根据maxWidth,计算buttons的左边位置
|
|
21
|
+
const widthCenter = listWidth - buttonGap; // 减去最后一个元素的gap
|
|
22
|
+
if (widthCenter < maxWidth) {
|
|
23
|
+
listLeft = Math.floor((maxWidth - widthCenter) / 2);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const listSize = {
|
|
27
|
+
left: listLeft,
|
|
28
|
+
width: listWidth,
|
|
29
|
+
height: buttonHeight,
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const onKeyDown = (ev) => {
|
|
33
|
+
if (ev.keyCode === 13) {
|
|
34
|
+
// Enter
|
|
35
|
+
props.onButtonClick?.(focusedItemIndex);
|
|
36
|
+
return true;
|
|
37
|
+
} else if (ev.keyCode == 8 || ev.keyCode == 27 || ev.keyCode == 10000) {
|
|
38
|
+
// 8:Backspace, 27:Escape, 10000:盒子返回键
|
|
39
|
+
props.onBack?.();
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
let changeFocusTo = -1;
|
|
44
|
+
switch (ev.keyCode) {
|
|
45
|
+
case 37: // Left
|
|
46
|
+
changeFocusTo =
|
|
47
|
+
(focusedItemIndex - 1 + props.buttonConfig.length) %
|
|
48
|
+
props.buttonConfig.length;
|
|
49
|
+
break;
|
|
50
|
+
case 39: // Right
|
|
51
|
+
changeFocusTo = (focusedItemIndex + 1) % props.buttonConfig.length;
|
|
52
|
+
break;
|
|
53
|
+
default:
|
|
54
|
+
break;
|
|
55
|
+
}
|
|
56
|
+
if (changeFocusTo >= 0) {
|
|
57
|
+
ev.ownerNode.findBlockByName(changeFocusTo.toString()).requestFocus();
|
|
58
|
+
focusedItemIndex = changeFocusTo;
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return false;
|
|
63
|
+
};
|
|
64
|
+
</script>
|
|
65
|
+
|
|
66
|
+
<template>
|
|
67
|
+
<div :style="style">
|
|
68
|
+
<jsv-focus-block
|
|
69
|
+
:style="{
|
|
70
|
+
left: listSize.left,
|
|
71
|
+
width: listSize.width + listPadding * 2,
|
|
72
|
+
height: listSize.height + listPadding * 2,
|
|
73
|
+
}"
|
|
74
|
+
:onKeyDown="onKeyDown"
|
|
75
|
+
>
|
|
76
|
+
<Item
|
|
77
|
+
v-for="(item, index) in buttonConfig"
|
|
78
|
+
:key="index"
|
|
79
|
+
:style="{
|
|
80
|
+
left: (buttonWidth + 10) * index,
|
|
81
|
+
width: buttonWidth,
|
|
82
|
+
height: buttonHeight,
|
|
83
|
+
}"
|
|
84
|
+
:name="index.toString()"
|
|
85
|
+
:autoFocus="index === 0"
|
|
86
|
+
>
|
|
87
|
+
{{ item.name }}
|
|
88
|
+
</Item>
|
|
89
|
+
</jsv-focus-block>
|
|
90
|
+
</div>
|
|
91
|
+
</template>
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { ref, shallowRef } from "vue";
|
|
3
|
+
const props = defineProps({
|
|
4
|
+
style: Object,
|
|
5
|
+
name: String,
|
|
6
|
+
autoFocus: Boolean,
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
const hasFocused = ref(false);
|
|
10
|
+
const onFocus = () => {
|
|
11
|
+
hasFocused.value = true;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const onBlur = () => {
|
|
15
|
+
hasFocused.value = false;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const focusStyle = {
|
|
19
|
+
width: props.style.width + 10,
|
|
20
|
+
height: props.style.height + 10,
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const itemStyle = {
|
|
24
|
+
width: props.style.width,
|
|
25
|
+
height: props.style.height,
|
|
26
|
+
backgroundColor: "#0FF000",
|
|
27
|
+
lineHeight: props.style.height,
|
|
28
|
+
fontSize: `${Math.floor(props.style.height * 0.55)}px`,
|
|
29
|
+
};
|
|
30
|
+
</script>
|
|
31
|
+
|
|
32
|
+
<template>
|
|
33
|
+
<jsv-focus-block
|
|
34
|
+
:name="name"
|
|
35
|
+
:autoFocus="autoFocus ? '' : undefined"
|
|
36
|
+
:onFocus="onFocus"
|
|
37
|
+
:onBlur="onBlur"
|
|
38
|
+
>
|
|
39
|
+
<div :style="style">
|
|
40
|
+
<div class="focus" :style="focusStyle" v-if="hasFocused"></div>
|
|
41
|
+
<div class="item" :style="itemStyle">
|
|
42
|
+
<slot></slot>
|
|
43
|
+
</div>
|
|
44
|
+
</div>
|
|
45
|
+
</jsv-focus-block>
|
|
46
|
+
</template>
|
|
47
|
+
|
|
48
|
+
<style scoped>
|
|
49
|
+
.focus {
|
|
50
|
+
top: -5;
|
|
51
|
+
left: -5;
|
|
52
|
+
background-color: #0000ff;
|
|
53
|
+
}
|
|
54
|
+
.item {
|
|
55
|
+
text-align: center;
|
|
56
|
+
font-size: 30;
|
|
57
|
+
color: #000000;
|
|
58
|
+
white-space: nowrap;
|
|
59
|
+
}
|
|
60
|
+
</style>
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { createRouter } from "vue-router";
|
|
2
|
+
import { jsvCreateHashHistory } from "jsview";
|
|
3
|
+
|
|
4
|
+
const routeList = [
|
|
5
|
+
// 功能实例
|
|
6
|
+
{
|
|
7
|
+
name: "Home",
|
|
8
|
+
path: "/",
|
|
9
|
+
redirect: "/__MainJsvApp/MainPage",
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
name: "MainPage",
|
|
13
|
+
path: "/__MainJsvApp/MainPage",
|
|
14
|
+
component: () => import("./views/MainPage.vue"),
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
name: "SubPageFirst",
|
|
18
|
+
path: "/__MainJsvApp/SubPageFirst",
|
|
19
|
+
component: () => import("./views/SubPage.vue"),
|
|
20
|
+
props: {
|
|
21
|
+
name: "First",
|
|
22
|
+
jumpTo: "Second",
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
name: "SubPageSecond",
|
|
27
|
+
path: "/__MainJsvApp/SubPageSecond",
|
|
28
|
+
component: () => import("./views/SubPage.vue"),
|
|
29
|
+
props: {
|
|
30
|
+
name: "Second",
|
|
31
|
+
jumpTo: "First",
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
];
|
|
35
|
+
|
|
36
|
+
const router = createRouter({
|
|
37
|
+
history: jsvCreateHashHistory(),
|
|
38
|
+
routes: routeList,
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
export { router, routeList };
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { useRouter } from "vue-router";
|
|
3
|
+
import HorizontalButtonList from "../components/HorizontalButtonList.vue";
|
|
4
|
+
|
|
5
|
+
const branchName = "./MainPage.ButtonList";
|
|
6
|
+
const router = useRouter();
|
|
7
|
+
|
|
8
|
+
const buttonListConfig = [
|
|
9
|
+
{
|
|
10
|
+
name: "启动子界面-First",
|
|
11
|
+
route: {
|
|
12
|
+
path: "SubPageFirst",
|
|
13
|
+
query: { from: "main" },
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
name: "启动子界面-Second",
|
|
18
|
+
route: {
|
|
19
|
+
path: "SubPageSecond",
|
|
20
|
+
query: { from: "main" },
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
];
|
|
24
|
+
|
|
25
|
+
const onButtonClick = (idx) => {
|
|
26
|
+
const config = buttonListConfig[idx];
|
|
27
|
+
console.log("Jump page to: " + config.name);
|
|
28
|
+
router.push(config.route);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const onBack = () => {
|
|
32
|
+
router.go(-1);
|
|
33
|
+
};
|
|
34
|
+
</script>
|
|
35
|
+
|
|
36
|
+
<template>
|
|
37
|
+
<div>
|
|
38
|
+
<div class="title">这是主界面</div>
|
|
39
|
+
<HorizontalButtonList
|
|
40
|
+
:style="{ top: 330 }"
|
|
41
|
+
:buttonConfig="buttonListConfig"
|
|
42
|
+
:onButtonClick="onButtonClick"
|
|
43
|
+
:onBack="onBack"
|
|
44
|
+
/>
|
|
45
|
+
</div>
|
|
46
|
+
</template>
|
|
47
|
+
|
|
48
|
+
<style scoped>
|
|
49
|
+
.title {
|
|
50
|
+
top: 100;
|
|
51
|
+
width: 1280;
|
|
52
|
+
height: 100;
|
|
53
|
+
line-height: 100px;
|
|
54
|
+
text-align: center;
|
|
55
|
+
font-size: 55;
|
|
56
|
+
}
|
|
57
|
+
</style>
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import HorizontalButtonList from "../components/HorizontalButtonList.vue";
|
|
3
|
+
import { useRouter } from "vue-router";
|
|
4
|
+
import { computed } from "vue";
|
|
5
|
+
const props = defineProps({
|
|
6
|
+
name: String,
|
|
7
|
+
jumpTo: String,
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
console.log("cchtest subpage", props.name, props.jumpTo);
|
|
11
|
+
const router = useRouter();
|
|
12
|
+
const buttonListConfig = computed(() => {
|
|
13
|
+
return [
|
|
14
|
+
{
|
|
15
|
+
name: "跳转子界面-" + props.jumpTo,
|
|
16
|
+
route: {
|
|
17
|
+
path: "SubPage" + props.jumpTo,
|
|
18
|
+
query: { from: "sub" + props.name },
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
];
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
const onButtonClick = (idx) => {
|
|
25
|
+
const config = buttonListConfig.value[idx];
|
|
26
|
+
console.log("Jump page to: " + config.name, props);
|
|
27
|
+
router.push(config.route);
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const onBack = () => {
|
|
31
|
+
router.go(-1);
|
|
32
|
+
};
|
|
33
|
+
</script>
|
|
34
|
+
|
|
35
|
+
<template>
|
|
36
|
+
<div>
|
|
37
|
+
<div class="title">这是子界面{{ name }}</div>
|
|
38
|
+
<HorizontalButtonList
|
|
39
|
+
:style="{ top: 230 }"
|
|
40
|
+
:buttonConfig="buttonListConfig"
|
|
41
|
+
:onButtonClick="onButtonClick"
|
|
42
|
+
:onBack="onBack"
|
|
43
|
+
/>
|
|
44
|
+
<div class="tip">按返回键返回前一页</div>
|
|
45
|
+
</div>
|
|
46
|
+
</template>
|
|
47
|
+
|
|
48
|
+
<style scoped>
|
|
49
|
+
.title {
|
|
50
|
+
top: 100;
|
|
51
|
+
width: 1280;
|
|
52
|
+
height: 100;
|
|
53
|
+
line-height: 100px;
|
|
54
|
+
text-align: center;
|
|
55
|
+
font-size: 55;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.tip {
|
|
59
|
+
top: 330;
|
|
60
|
+
width: 1280;
|
|
61
|
+
height: 100;
|
|
62
|
+
line-height: 100px;
|
|
63
|
+
text-align: center;
|
|
64
|
+
font-size: 30;
|
|
65
|
+
}
|
|
66
|
+
</style>
|