@shijiu/jsview-vue-samples 2.0.1021 → 2.0.1073

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.
Files changed (93) hide show
  1. package/Basic/components/div/DivBackground.vue +1 -1
  2. package/Basic/components/div/DivCssVar.vue +34 -16
  3. package/CommonUtils/ResourceData.js +11 -0
  4. package/CommonUtils/getSearchQuery.js +44 -0
  5. package/CssPreprocessor/Less/App.vue +1 -1
  6. package/CssPreprocessor/Less/components/less-group1/LessComments.vue +2 -2
  7. package/CssPreprocessor/Less/components/less-group1/LessConditionals.vue +2 -2
  8. package/CssPreprocessor/Less/components/less-group1/LessVariables.vue +6 -6
  9. package/CssPreprocessor/Less/components/less-group2/LessIteration.vue +1 -1
  10. package/CssPreprocessor/Less/components/less-group2/LessMethods.vue +2 -2
  11. package/CssPreprocessor/Less/components/less-group3/LessExtends.vue +2 -2
  12. package/CssPreprocessor/Less/components/less-group3/LessNesting.vue +4 -4
  13. package/CssPreprocessor/Less/components/less-group4/LessKeyframes.vue +1 -1
  14. package/CssPreprocessor/Less/components/less-group4/LessMaps.vue +1 -1
  15. package/CssPreprocessor/Less/components/less-group4/LessMixins.vue +1 -1
  16. package/CssPreprocessor/Less/components/less-group5/LessImporting.vue +7 -3
  17. package/CssPreprocessor/Less/components/less-group5/TextSettings.less +8 -1
  18. package/CssPreprocessor/Scss/App.vue +1 -1
  19. package/CssPreprocessor/Scss/components/scss-group1/ScssComments.vue +11 -10
  20. package/CssPreprocessor/Scss/components/scss-group1/ScssConditionals.vue +8 -6
  21. package/CssPreprocessor/Scss/components/scss-group1/ScssOperations.vue +2 -2
  22. package/CssPreprocessor/Scss/components/scss-group1/ScssVariables.vue +6 -6
  23. package/CssPreprocessor/Scss/components/scss-group2/ScssIteration.vue +2 -2
  24. package/CssPreprocessor/Scss/components/scss-group2/ScssMethods.vue +9 -9
  25. package/CssPreprocessor/Scss/components/scss-group3/ScssExtends.vue +2 -2
  26. package/CssPreprocessor/Scss/components/scss-group3/ScssNesting.vue +3 -3
  27. package/CssPreprocessor/Scss/components/scss-group4/ScssKeyframes.vue +1 -1
  28. package/CssPreprocessor/Scss/components/scss-group4/ScssMaps.vue +1 -1
  29. package/CssPreprocessor/Scss/components/scss-group4/ScssMixins.vue +1 -1
  30. package/CssPreprocessor/Scss/components/scss-group5/ScssImporting.vue +7 -3
  31. package/CssPreprocessor/Scss/components/scss-group5/TextSettings.scss +8 -1
  32. package/CssPreprocessor/Stylus/App.vue +1 -1
  33. package/CssPreprocessor/Stylus/components/stylus-group1/StylusComments.vue +2 -2
  34. package/CssPreprocessor/Stylus/components/stylus-group1/StylusConditionals.vue +2 -2
  35. package/CssPreprocessor/Stylus/components/stylus-group1/StylusVariables.vue +7 -7
  36. package/CssPreprocessor/Stylus/components/stylus-group2/StylusIteration.vue +1 -1
  37. package/CssPreprocessor/Stylus/components/stylus-group2/StylusMethods.vue +3 -3
  38. package/CssPreprocessor/Stylus/components/stylus-group3/StylusExtends.vue +2 -2
  39. package/CssPreprocessor/Stylus/components/stylus-group3/StylusNesting.vue +5 -5
  40. package/CssPreprocessor/Stylus/components/stylus-group4/StylusKeyframes.vue +1 -1
  41. package/CssPreprocessor/Stylus/components/stylus-group4/StylusMaps.vue +1 -1
  42. package/CssPreprocessor/Stylus/components/stylus-group4/StylusMixins.vue +1 -1
  43. package/CssPreprocessor/Stylus/components/stylus-group5/StylusImporting.vue +7 -3
  44. package/CssPreprocessor/Stylus/components/stylus-group5/TextSettings.styl +8 -1
  45. package/CssPreprocessor/utils/ContentBlock.vue +5 -3
  46. package/CssPreprocessor/utils/FontStyle.css +1 -1
  47. package/CssPreprocessor/utils/Panel.vue +1 -1
  48. package/CssPreprocessor/utils/TitleBar.vue +4 -2
  49. package/DemoHomepage/App.vue +22 -19
  50. package/DemoHomepage/router.js +9 -0
  51. package/FilterDemo/AnimatePic.vue +6 -1
  52. package/FocusMoveStyle/App.vue +37 -46
  53. package/FocusMoveStyle/Item.vue +7 -17
  54. package/FocusMoveStyle/assets/redCircle.png +0 -0
  55. package/GiftRain/App.vue +52 -27
  56. package/GiftRain/components/RedPacket.vue +17 -15
  57. package/JsvRadarChart/App.vue +99 -0
  58. package/JsvRadarChart/assets/Square.png +0 -0
  59. package/JsvRadarChart/assets/resultSquare.png +0 -0
  60. package/MetroWidgetDemos/SkeletonDiagram/App.vue +78 -0
  61. package/MetroWidgetDemos/SkeletonDiagram/Item.vue +111 -0
  62. package/MetroWidgetDemos/SkeletonDiagram/assets/imageList.json +237 -0
  63. package/MetroWidgetDemos/SkeletonDiagram/data.js +16 -0
  64. package/MetroWidgetDemos/itemSizeUpdate/App.vue +51 -0
  65. package/MetroWidgetDemos/itemSizeUpdate/backward/Backward.vue +107 -0
  66. package/MetroWidgetDemos/itemSizeUpdate/backward/Item.vue +133 -0
  67. package/MetroWidgetDemos/itemSizeUpdate/center/Center.vue +106 -0
  68. package/MetroWidgetDemos/itemSizeUpdate/center/Item.vue +118 -0
  69. package/MetroWidgetDemos/ninePatchFocusPage/App.vue +105 -0
  70. package/MetroWidgetDemos/ninePatchFocusPage/Item.vue +69 -0
  71. package/MetroWidgetDemos/ninePatchFocusPage/PageRow.vue +89 -0
  72. package/MetroWidgetDemos/routeList.js +18 -5
  73. package/MetroWidgetDemos/slideSetting/App.vue +8 -8
  74. package/MockjsDemo/App.vue +54 -0
  75. package/MockjsDemo/KeyEventCatcher.vue +19 -0
  76. package/MockjsDemo/mock/index.js +12 -0
  77. package/NinePatchDemo/App.vue +2 -2
  78. package/NinePatchDemo/Item.vue +15 -5
  79. package/Preload/Item.vue +27 -10
  80. package/SprayView/App.vue +71 -63
  81. package/SprayView/assets/goldencoin1.png +0 -0
  82. package/SprayView/assets/goldencoin2.png +0 -0
  83. package/SprayView/assets/redpacket1.png +0 -0
  84. package/SprayView/assets/redpacket2.png +0 -0
  85. package/SprayView/assets/star1.png +0 -0
  86. package/SprayView/assets/star2.png +0 -0
  87. package/SprayView/assets/star3.png +0 -0
  88. package/SprayView/assets/star4.png +0 -0
  89. package/Swiper/App.vue +1 -1
  90. package/TextureAnimation/App2.vue +4 -2
  91. package/TouchSample/Item.vue +0 -1
  92. package/package.json +2 -1
  93. /package/{FocusMoveStyle/assets/focus.png → assets/focus1.png} +0 -0
@@ -0,0 +1,106 @@
1
+ <!--
2
+ * @Author: ChenChanghua
3
+ * @Date: 2023-03-08 14:52:08
4
+ * @Description: file content
5
+ -->
6
+ <script setup>
7
+ import {
8
+ ListWidget,
9
+ HORIZONTAL,
10
+ useFocusHub,
11
+ FixPositionSlide,
12
+ EdgeDirection,
13
+ } from "jsview";
14
+ import Item from "./Item.vue";
15
+
16
+ const focusHub = useFocusHub();
17
+
18
+ const randomColor = () => {
19
+ let randomColor = Math.round(Math.random() * 2 ** 24).toString(16);
20
+ return (
21
+ "#" + new Array(6 - randomColor.length).fill("0").join("") + randomColor
22
+ );
23
+ };
24
+
25
+ const fixPositionSlide = new FixPositionSlide();
26
+
27
+ const dataLength = 30;
28
+ const provideData = () => {
29
+ const data = [];
30
+ for (let i = 0; i < dataLength; ++i) {
31
+ data.push({
32
+ width: 100,
33
+ height: 150,
34
+ marginRight: 10,
35
+ color: randomColor(),
36
+ content: i,
37
+ });
38
+ }
39
+ return data;
40
+ };
41
+
42
+ const measures = (data) => {
43
+ return {
44
+ width: data.width,
45
+ height: data.height,
46
+ marginRight: data.marginRight,
47
+ marginBottom: data.marginBottom,
48
+ };
49
+ };
50
+
51
+ const onEdge = (edgeInfo) => {
52
+ if (edgeInfo.direction == EdgeDirection.bottom) {
53
+ focusHub.setFocus("itemResizeBackward");
54
+ }
55
+ };
56
+
57
+ const widgetLayout = {
58
+ left: 0,
59
+ top: 0,
60
+ width: 600,
61
+ height: 200,
62
+ };
63
+
64
+ const padding = {
65
+ left: 25,
66
+ top: 25,
67
+ right: 25,
68
+ bottom: 25,
69
+ };
70
+
71
+ const name = "itemResizeCenter";
72
+ </script>
73
+
74
+ <template>
75
+ <div>
76
+ <div
77
+ :style="{
78
+ ...widgetLayout,
79
+ backgroundColor: 'rgba(255,0,0,0.5)',
80
+ }"
81
+ ></div>
82
+ <list-widget
83
+ ref="widgetRef"
84
+ :name="name"
85
+ :left="widgetLayout.left"
86
+ :top="widgetLayout.top"
87
+ :width="widgetLayout.width"
88
+ :height="widgetLayout.height"
89
+ :provideData="provideData"
90
+ :direction="HORIZONTAL"
91
+ :slideSetting="fixPositionSlide"
92
+ :measures="measures"
93
+ :padding="padding"
94
+ :onEdge="onEdge"
95
+ >
96
+ <template #renderItem="{ data, onAction, query }">
97
+ <item
98
+ :data="data"
99
+ :onAction="onAction"
100
+ :query="query"
101
+ :dataLength="dataLength"
102
+ />
103
+ </template>
104
+ </list-widget>
105
+ </div>
106
+ </template>
@@ -0,0 +1,118 @@
1
+ <!--
2
+ * @Author: ChenChanghua
3
+ * @Date: 2023-03-08 14:52:17
4
+ * @Description: file content
5
+ -->
6
+ <script setup>
7
+ import {
8
+ ref,
9
+ shallowRef,
10
+ inject,
11
+ onUpdated,
12
+ onMounted,
13
+ onBeforeUnmount,
14
+ } from "vue";
15
+ import { METRO_WIDGET_CONST } from "jsview";
16
+
17
+ const props = defineProps({
18
+ data: Object,
19
+ onAction: Object,
20
+ query: Object,
21
+ dataLength: Number,
22
+ });
23
+
24
+ const focused = ref(false);
25
+
26
+ const width = ref(props.data.width);
27
+ const duration = 200;
28
+
29
+ let timeoutHandler = -1;
30
+
31
+ const getResizeAnchor = () => {
32
+ if (props.query.index == 0) {
33
+ return 0;
34
+ } else if (props.query.index == props.dataLength - 1) {
35
+ return 1;
36
+ } else {
37
+ return 0.5;
38
+ }
39
+ };
40
+
41
+ const locateSetting = {
42
+ type: METRO_WIDGET_CONST.ITEM_RESIZE.WIDGET_SET,
43
+ };
44
+
45
+ const animInfo = {
46
+ duration: duration,
47
+ onEnd: () => {
48
+ console.log("resize end");
49
+ },
50
+ };
51
+
52
+ const onFocus = () => {
53
+ focused.value = true;
54
+ if (width.value == props.data.width) {
55
+ timeoutHandler = setTimeout(() => {
56
+ width.value = props.data.width + 400;
57
+ props.query.updateItemSize(
58
+ props.query.index,
59
+ {
60
+ width: width.value,
61
+ height: props.data.height,
62
+ },
63
+ locateSetting,
64
+ animInfo
65
+ );
66
+ }, 1000); /* 延迟1秒变化 */
67
+ }
68
+ };
69
+
70
+ const onBlur = () => {
71
+ focused.value = false;
72
+ if (width.value !== props.data.width) {
73
+ width.value = props.data.width;
74
+ props.query.updateItemSize(
75
+ props.query.index,
76
+ {
77
+ width: width.value,
78
+ height: props.data.height,
79
+ },
80
+ locateSetting,
81
+ animInfo
82
+ );
83
+ }
84
+ clearTimeout(timeoutHandler);
85
+ timeoutHandler = -1;
86
+ };
87
+
88
+ const onClick = () => {
89
+ console.log("onClick");
90
+ };
91
+
92
+ props.onAction.register("onFocus", onFocus);
93
+ props.onAction.register("onBlur", onBlur);
94
+ props.onAction.register("onClick", onClick);
95
+
96
+ onBeforeUnmount(() => {
97
+ clearTimeout(timeoutHandler);
98
+ timeoutHandler = -1;
99
+ });
100
+ </script>
101
+
102
+ <template>
103
+ <div
104
+ :style="{
105
+ width: width,
106
+ height: data.height,
107
+ fontSize: 30,
108
+ color: focused ? '#FF0000' : '#FFFFFF',
109
+ backgroundColor: data.color,
110
+ transition: `left ${duration / 1000}s, top ${duration / 1000}s, width ${
111
+ duration / 1000
112
+ }s, height ${duration / 1000}s`,
113
+ borderRadius: 10,
114
+ }"
115
+ >
116
+ {{ data.content }}
117
+ </div>
118
+ </template>
@@ -0,0 +1,105 @@
1
+ <!--
2
+ * @Author: ChenChanghua
3
+ * @Date: 2022-07-11 13:31:36
4
+ * @Description: file content
5
+ -->
6
+ <script setup>
7
+ import {
8
+ MetroWidget,
9
+ VERTICAL,
10
+ EdgeDirection,
11
+ useFocusHub,
12
+ JsvNinePatch,
13
+ } from "jsview";
14
+ import { onMounted, reactive, provide } from "vue";
15
+ import PageRow from "./PageRow.vue";
16
+ import focusImg from "../../assets/focus1.png";
17
+
18
+ const focusHub = useFocusHub();
19
+
20
+ const focusSize = reactive({
21
+ width: 0,
22
+ height: 0,
23
+ left: 0,
24
+ top: 0,
25
+ });
26
+ provide("focusSize", focusSize);
27
+
28
+ const provideData = () => {
29
+ const data = [];
30
+ for (let i = 0; i < 10; i++) {
31
+ data.push({
32
+ width: 500,
33
+ height: 170,
34
+ name: "widget_" + i,
35
+ marginBottom: 10,
36
+ index: i,
37
+ });
38
+ }
39
+ return data;
40
+ };
41
+
42
+ const measures = (item) => {
43
+ return {
44
+ width: item.width,
45
+ height: item.height,
46
+ marginRight: item.marginRight,
47
+ marginBottom: item.marginBottom,
48
+ /**重要代码: doSlide设置为false, 由子MetroWidget控制滚动 */
49
+ doSlide: false,
50
+ };
51
+ };
52
+
53
+ onMounted(() => {
54
+ focusHub.setFocus("mwWidget");
55
+ });
56
+ </script>
57
+
58
+ <template>
59
+ <div :style="{ width: 1280, height: 720, backgroundColor: '#007788' }">
60
+ <div
61
+ :style="{
62
+ left: 100,
63
+ top: 20,
64
+ width: 800,
65
+ height: 400,
66
+ fontSize: 30,
67
+ color: '#FFFFFF',
68
+ }"
69
+ >
70
+ {{ "一个带焦点移动的简单页面示例" }}
71
+ </div>
72
+ <!-- 为了保证边缘的item缩放后依旧完整显示, 需要设置padding, 注意width/height是包含padding的 -->
73
+ <metro-widget
74
+ name="mwWidget"
75
+ :top="80"
76
+ :left="50"
77
+ :width="660"
78
+ :height="600"
79
+ :provideData="provideData"
80
+ :padding="{ left: 30, right: 30 }"
81
+ :direction="VERTICAL"
82
+ :measures="measures"
83
+ >
84
+ <!-- 重要代码: 为了实现焦点就近移动, 需要传递onItemEdge回调 -->
85
+ <template #renderItem="{ data, onAction, onItemEdge }">
86
+ <page-row :data="data" :onAction="onAction" :onItemEdge="onItemEdge" />
87
+ </template>
88
+ </metro-widget>
89
+ <jsv-nine-patch
90
+ :style="{
91
+ width: focusSize.width,
92
+ height: focusSize.height,
93
+ top: focusSize.top,
94
+ left: focusSize.left,
95
+ }"
96
+ :imageUrl="focusImg"
97
+ :imageWidth="55"
98
+ :centerWidth="1"
99
+ :borderOutset="13"
100
+ :imageDspWidth="55"
101
+ :animTime="0.2"
102
+ :waitForInit="true"
103
+ ></jsv-nine-patch>
104
+ </div>
105
+ </template>
@@ -0,0 +1,69 @@
1
+ <!--
2
+ * @Author: ChenChanghua
3
+ * @Date: 2023-03-09 15:33:54
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 focused = ref(false);
15
+ const focusSize = inject("focusSize");
16
+ const divRef = shallowRef(null);
17
+
18
+ // 自身的焦点状态自己记录, 通过回调来改变
19
+ const onFocus = () => {
20
+ focused.value = true;
21
+ divRef.value?.jsvGetBoundingClientRect().then(
22
+ (data) => {
23
+ focusSize.width = data.width;
24
+ focusSize.height = data.height;
25
+ focusSize.left = data.left;
26
+ focusSize.top = data.top;
27
+ },
28
+ (error) => {
29
+ console.log("get absolute position failed", error);
30
+ }
31
+ );
32
+ };
33
+ const onBlur = () => {
34
+ focused.value = false;
35
+ };
36
+ const onClick = () => {
37
+ console.log("item onclick ", props.data);
38
+ };
39
+
40
+ // 一般在create的时候进行回调的注册, 使用 option api的可以在created时进行注册
41
+ props.onAction.register("onFocus", onFocus);
42
+ props.onAction.register("onBlur", onBlur);
43
+ props.onAction.register("onClick", onClick);
44
+ </script>
45
+
46
+ <template>
47
+ <div
48
+ :style="{
49
+ width: data.width,
50
+ height: data.height,
51
+ transform: focused ? 'scale3d(1.2, 1.2, 1.2)' : '',
52
+ transition: 'transform 0.2s linear',
53
+ }"
54
+ >
55
+ <div
56
+ ref="divRef"
57
+ :style="{
58
+ width: data.width,
59
+ height: data.height,
60
+ fontSize: 30,
61
+ color: '#FFFFFF',
62
+ backgroundColor: data.color,
63
+ borderRadius: 10,
64
+ }"
65
+ >
66
+ {{ data.content }}
67
+ </div>
68
+ </div>
69
+ </template>
@@ -0,0 +1,89 @@
1
+
2
+ <script setup>
3
+ import { HORIZONTAL, MetroWidget, useFocusHub } from "jsview";
4
+ import { ref, shallowRef } from "vue";
5
+ import Item from "./Item.vue";
6
+
7
+ const props = defineProps({
8
+ data: Object,
9
+ onItemEdge: Function,
10
+ onAction: Object,
11
+ });
12
+ const focusHub = useFocusHub();
13
+ const mwRef = shallowRef(null);
14
+
15
+ const measures = (item) => {
16
+ return item;
17
+ };
18
+ const randomColor = () => {
19
+ let randomColor = Math.round(Math.random() * 2 ** 24).toString(16);
20
+ return (
21
+ "#" + new Array(6 - randomColor.length).fill("0").join("") + randomColor
22
+ );
23
+ };
24
+ const provideData = () => {
25
+ const data = [];
26
+ for (let i = 0; i < 10; i++) {
27
+ data.push({
28
+ width: (i + props.data.index) % 2 == 0 ? 90 : 180,
29
+ height: 90,
30
+ marginRight: 10,
31
+ marginBottom: 10,
32
+ content: i,
33
+ color: randomColor(),
34
+ });
35
+ }
36
+ return data;
37
+ };
38
+ const onFocus = (rect) => {
39
+ /** 重要代码: 参数rect为父MetroWidget传递的, 焦点过来的区域
40
+ * 因此需要调用setEnterFocusRect来设置焦点进入区域, 以寻找最近的焦点
41
+ */
42
+ mwRef.value?.setEnterFocusRect(rect);
43
+ focusHub.setFocus(props.data.name);
44
+ };
45
+ const onBlur = () => {
46
+ //onBlur时需要返还焦点给父MetroWidget
47
+ focusHub.returnFocusToParent();
48
+ };
49
+
50
+ props.onAction.register("onFocus", onFocus);
51
+ props.onAction.register("onBlur", onBlur);
52
+ </script>
53
+
54
+ <template>
55
+ <div
56
+ :style="{
57
+ width: 900,
58
+ height: 50,
59
+ fontSize: 30,
60
+ color: '#FFFFFF',
61
+ }"
62
+ >
63
+ {{ data.name }}
64
+ </div>
65
+ <!-- 重要代码: sendFocusRectEvent可以让MetroWidget的item在获焦时发送事件, 通知父的MetroWidget进行滚动 -->
66
+ <!-- 重要代码: onItemEdge直接作为onEdge回调, 既子MetroWidget到达边缘时触发父的onItemEdge -->
67
+ <metro-widget
68
+ ref="mwRef"
69
+ :name="data.name"
70
+ :top="50"
71
+ :width="data.width"
72
+ :height="data.height"
73
+ :provideData="provideData"
74
+ :direction="HORIZONTAL"
75
+ :padding="{
76
+ left: 30,
77
+ right: 30,
78
+ top: 10,
79
+ bottom: 10,
80
+ }"
81
+ :measures="measures"
82
+ :onEdge="onItemEdge"
83
+ :sendFocusRectEvent="true"
84
+ >
85
+ <template #renderItem="{ data, onAction }">
86
+ <item :data="data" :onAction="onAction" />
87
+ </template>
88
+ </metro-widget>
89
+ </template>
@@ -44,11 +44,6 @@ export default [
44
44
  path: "/metroWidget/focusableItemMetroWidget",
45
45
  component: () => import("jsview-vue-samples/MetroWidgetDemos/focusableItemMetroWidget/App.vue"),
46
46
  },
47
- // {
48
- // name: "嵌套示例",
49
- // path: "/metroWidget/Advanced",
50
- // component: () => import("jsview-vue-samples/MetroWidgetDemos/Advanced/App.vue"),
51
- // },
52
47
  {
53
48
  name: "乒乓模式",
54
49
  path: "/metroWidget/PingPong",
@@ -61,4 +56,22 @@ export default [
61
56
  component: () =>
62
57
  import("jsview-vue-samples/MetroWidgetDemos/PerformanceTest/App.vue"),
63
58
  },
59
+ {
60
+ name: "骨架图",
61
+ path: "/metroWidget/SkeletonDiagram",
62
+ component: () =>
63
+ import("jsview-vue-samples/MetroWidgetDemos/SkeletonDiagram/App.vue"),
64
+ },
65
+ {
66
+ name: ".9焦点页面",
67
+ path: "/metroWidget/ninePatchFocusPage",
68
+ component: () =>
69
+ import("jsview-vue-samples/MetroWidgetDemos/ninePatchFocusPage/App.vue"),
70
+ },
71
+ {
72
+ name: "item尺寸更新",
73
+ path: "/metroWidget/itemSizeUpdate",
74
+ component: () =>
75
+ import("jsview-vue-samples/MetroWidgetDemos/itemSizeUpdate/App.vue"),
76
+ },
64
77
  ]
@@ -30,8 +30,8 @@ const randomColor = () => {
30
30
  const data = [];
31
31
  for (let i = 0; i < 30; i++) {
32
32
  data.push({
33
- width: 90,
34
- height: 90,
33
+ width: 60,
34
+ height: 60,
35
35
  marginRight: 10,
36
36
  marginBottom: 10,
37
37
  color: randomColor(),
@@ -59,8 +59,8 @@ const widget1 = {
59
59
  widgetLayout: {
60
60
  left: 50,
61
61
  top: 50,
62
- width: 500,
63
- height: 200,
62
+ width: 350,
63
+ height: 140,
64
64
  },
65
65
  slideSetting: new SeamlessSlide({
66
66
  startPercent: 0.2,
@@ -90,8 +90,8 @@ const widget2 = {
90
90
  widgetLayout: {
91
91
  left: 50,
92
92
  top: 300,
93
- width: 500,
94
- height: 220,
93
+ width: 350,
94
+ height: 160,
95
95
  },
96
96
  slideSetting: new WholePageSlide(),
97
97
  };
@@ -116,8 +116,8 @@ const widget3 = {
116
116
  widgetLayout: {
117
117
  left: 50,
118
118
  top: 550,
119
- width: 500,
120
- height: 200,
119
+ width: 350,
120
+ height: 140,
121
121
  },
122
122
  slideSetting: new FixPositionSlide({ fixPercent: 0.5 }),
123
123
  };
@@ -0,0 +1,54 @@
1
+ <script>
2
+ import KeyEventCatcher from './KeyEventCatcher.vue';
3
+ import resImage from '../assets/pngNoAlphaDemo.png';
4
+ import { ref } from 'vue';
5
+ // if(process.env.NODE_ENV == 'development') {
6
+ await import('./mock/index.js')
7
+ // }
8
+
9
+ export default {
10
+ components: {
11
+ KeyEventCatcher,
12
+ },
13
+ data() {
14
+ const defName = "这是Mock前的数据"
15
+ return {
16
+ defName: defName,
17
+ name: ref(defName),
18
+ resImage: resImage,
19
+ }
20
+ },
21
+ mounted() {
22
+ setInterval(async () => {
23
+ if (this.name != this.defName) {
24
+ this.name = this.defName;
25
+ } else {
26
+ const xhr = new XMLHttpRequest();
27
+ xhr.open('GET', '/api/testData');
28
+ xhr.onload = () => {
29
+ if (xhr.status !== 200) {
30
+ console.error('Failed to get data from mockjs')
31
+ return;
32
+ }
33
+ const jsonData = JSON.parse(xhr.responseText);
34
+ this.name = jsonData.data.name;
35
+ };
36
+ xhr.send();
37
+ }
38
+ }, 3000)
39
+ }
40
+ }
41
+
42
+ </script>
43
+
44
+ <template>
45
+ <KeyEventCatcher/>
46
+ <div :style="{left:450, top: 200, width:500,
47
+ fontSize: 50, color: '#6688FF'}">
48
+ {{ name }}
49
+ </div>
50
+ <img :src="resImage" :style="{left:100, top:100, width: 300}" />
51
+ </template>
52
+
53
+ <style scoped>
54
+ </style>
@@ -0,0 +1,19 @@
1
+ <script setup>
2
+ import { useRouter } from "vue-router";
3
+ const router = useRouter();
4
+ const onKeyDown = (ev) => {
5
+ // 8:Backspace, 27:Escape, 10000:盒子返回键
6
+ if (ev.keyCode == 8 || ev.keyCode == 27 || ev.keyCode == 10000) {
7
+ router.go(-1); // 有router时,回退
8
+ return true;
9
+ }
10
+ return false;
11
+ }
12
+ </script>
13
+
14
+ <template>
15
+ <jsv-focus-block autoFocus :onKeyDown="onKeyDown"/>
16
+ </template>
17
+
18
+ <style scoped>
19
+ </style>
@@ -0,0 +1,12 @@
1
+ import Mock from 'mockjs'
2
+
3
+ console.log("Generating mock data...");
4
+
5
+ Mock.mock('/api/testData', 'get', {
6
+ code: 0,
7
+ data: {
8
+ name: '从Mockjs获取的数据'
9
+ }
10
+ })
11
+
12
+ export default Mock;
@@ -82,8 +82,8 @@ onMounted(() => {
82
82
  :measures="measures"
83
83
  :padding="{ left: 50, right: 50, top: 50, height: 50 }"
84
84
  >
85
- <template #renderItem="{ data, onAction }">
86
- <item :data="data" :onAction="onAction" />
85
+ <template #renderItem="{ data, onAction, query }">
86
+ <item :data="data" :onAction="onAction" :query="query" />
87
87
  </template>
88
88
  </metro-widget>
89
89
  <jsv-nine-patch