@shijiu/jsview-vue-samples 2.2.35 → 2.2.128

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.
@@ -6,7 +6,12 @@
6
6
  * @Description: file content
7
7
  -->
8
8
  <script setup>
9
- import { VERTICAL, MetroWidget, METRO_WIDGET_CONST, SeamlessSlide } from "jsview";
9
+ import {
10
+ VERTICAL,
11
+ MetroWidget,
12
+ METRO_WIDGET_CONST,
13
+ SeamlessSlide,
14
+ } from "jsview";
10
15
  import WidgetItem from "./WidgetItem.vue";
11
16
  import { shallowRef, watch, onBeforeUnmount } from "vue";
12
17
 
@@ -26,11 +31,17 @@ const props = defineProps({
26
31
 
27
32
  const widgetRef = shallowRef(null);
28
33
 
29
- const slideSetting = props.data.tabIndex == 0 ? new SeamlessSlide({
30
- startPercent: 0.5,
31
- endPercent: 0.5,
32
- fixFirstPage: true,
33
- }) : new SeamlessSlide();
34
+ const slideSetting =
35
+ props.data.tabIndex == 0
36
+ ? new SeamlessSlide({
37
+ startPercent: 0.5,
38
+ endPercent: 0.5,
39
+ fixFirstPage: true,
40
+ })
41
+ : new SeamlessSlide({
42
+ startPercent: 0.5,
43
+ endPercent: 0.5,
44
+ });
34
45
 
35
46
  const provideData = () => {
36
47
  return props.data.data;
@@ -52,8 +63,7 @@ const watcher = watch(
52
63
 
53
64
  onBeforeUnmount(() => {
54
65
  watcher();
55
- })
56
-
66
+ });
57
67
  </script>
58
68
 
59
69
  <template>
@@ -77,4 +87,4 @@ onBeforeUnmount(() => {
77
87
  ></widget-item>
78
88
  </template>
79
89
  </metro-widget>
80
- </template>
90
+ </template>
@@ -92,4 +92,10 @@ export default [
92
92
  component: () =>
93
93
  import("jsview-vue-samples/MetroWidgetDemos/SeamlessSlide/App.vue"),
94
94
  },
95
+ {
96
+ name: "多item分段显示",
97
+ path: "/metroWidget/MassiveItems",
98
+ component: () =>
99
+ import("jsview-vue-samples/MetroWidgetDemos/MassiveItems/App.vue"),
100
+ },
95
101
  ]
@@ -0,0 +1,160 @@
1
+ <template>
2
+ <jsv-focus-block autoFocus :onKeyDown="procKeyDown">
3
+ <div class="bgSty">
4
+ <!-- 提示 -->
5
+ <div class="text" :style="{ left: 210, top: 20 }">
6
+ {{
7
+ "操作提示:\n触控进行左右拖拽\n点击进度条空白处游标直接跳过去\n按 返回 键退出"
8
+ }}
9
+ </div>
10
+ <div
11
+ class="logo-bg"
12
+ :style="{
13
+ left: 210,
14
+ top: 200,
15
+ }"
16
+ >
17
+ <!-- 三个背景色块 -->
18
+ <div class="bg1" />
19
+ <div class="bg2" />
20
+ <div class="bg3" />
21
+ <!-- 进度条 -->
22
+ <div :style="{ top: 80, left: 0 }">
23
+ <JsvScrollBox
24
+ ref="rJsvScrollBox"
25
+ :style="{
26
+ width: 800,
27
+ height: 84,
28
+ }"
29
+ :direction="HORIZONTAL"
30
+ :sliderSize="{
31
+ width: 84,
32
+ }"
33
+ >
34
+ <template #FixedBox="{ boxWidth, boxHeight }">
35
+ <div
36
+ :style="{
37
+ width: boxWidth,
38
+ height: boxHeight,
39
+ lineHeight: boxHeight,
40
+ backgroundColor: 'rgba(255,255,255,0.3)',
41
+ borderRadius: Math.floor(boxHeight / 2),
42
+ fontSize: Math.floor(boxHeight * 0.5),
43
+ textAlign: 'center',
44
+ color: 'rgba(0,0,0,1)',
45
+ }"
46
+ >
47
+ {{ `进度:${rPercentDisp}` }}
48
+ </div>
49
+ </template>
50
+ <template #SliderBox="{ boxWidth, boxHeight }">
51
+ <div
52
+ :style="{
53
+ top: -15,
54
+ left: -15,
55
+ width: boxWidth + 30,
56
+ height: boxHeight + 30,
57
+ backgroundColor: 'rgba(255, 0,0,0.8)',
58
+ borderRadius: Math.floor((boxHeight + 30) / 2),
59
+ }"
60
+ @click="fncOnClick"
61
+ />
62
+ </template>
63
+ </JsvScrollBox>
64
+ </div>
65
+ <!-- 图1说明 -->
66
+ <div :style="{ left: 0, top: 26 }" class="text">
67
+ {{ "pin模式下拖拽(拖动点尺寸略大于进度条)" }}
68
+ </div>
69
+ </div>
70
+ </div>
71
+ </jsv-focus-block>
72
+ </template>
73
+
74
+ <script setup>
75
+ import { shallowRef, onMounted } from "vue";
76
+ import { JsvScrollBox, HORIZONTAL } from "jsview";
77
+
78
+ //进度百分比
79
+ let myProgress = shallowRef(20);
80
+ //按键事件 控制进度条的width
81
+ const procKeyDown = (ev) => {
82
+ switch (ev.keyCode) {
83
+ case 37:
84
+ myProgress.value -= 5;
85
+ if (myProgress.value <= 0) {
86
+ myProgress.value = 0;
87
+ }
88
+ break;
89
+ case 39:
90
+ myProgress.value += 5;
91
+ if (myProgress.value >= 100) {
92
+ myProgress.value = 100;
93
+ }
94
+ break;
95
+ case 13:
96
+ myProgress.value = 0;
97
+ break;
98
+ default:
99
+ break;
100
+ }
101
+ };
102
+
103
+ let fncOnClick = () => {};
104
+
105
+ let rJsvScrollBox = shallowRef(null);
106
+ let rPercentDisp = shallowRef(0);
107
+
108
+ onMounted(() => {
109
+ rJsvScrollBox.value.setSensor((percent, x, y) => {
110
+ rPercentDisp.value = Math.floor(percent * 100) / 100;
111
+ console.log(
112
+ `onProgress dragged percent=${percent} \
113
+ x=${Math.floor(x)} \
114
+ y=${Math.floor(y)}`
115
+ );
116
+ }, 15);
117
+ });
118
+ </script>
119
+
120
+ <style scoped>
121
+ .bgSty {
122
+ background-color: #5490d1;
123
+ width: 1280;
124
+ height: 720;
125
+ }
126
+ .logo-bg {
127
+ width: 800;
128
+ height: 400;
129
+ }
130
+ .text {
131
+ width: 800;
132
+ height: 200;
133
+ font-size: 24;
134
+ font-weight: bold;
135
+ line-height: 32;
136
+ color: #ffffff;
137
+ text-align: center;
138
+ }
139
+ .bg1 {
140
+ left: 0;
141
+ top: 0;
142
+ height: 400;
143
+ width: 267;
144
+ background-color: #007f00;
145
+ }
146
+ .bg2 {
147
+ left: 267;
148
+ top: 0;
149
+ height: 400;
150
+ width: 267;
151
+ background-color: #3049b8;
152
+ }
153
+ .bg3 {
154
+ left: 534;
155
+ top: 0;
156
+ height: 400;
157
+ width: 266;
158
+ background-color: #d12b8c;
159
+ }
160
+ </style>
@@ -1,6 +1,12 @@
1
1
  <script setup>
2
- import { JsvNativeSharedDiv, JsvFocusBlock, jJsvRuntimeBridge, enableNativeViewListener, disableNativeViewListener } from "jsview"
3
- import { onBeforeUnmount, onMounted, reactive, watch, shallowRef } from 'vue';
2
+ import {
3
+ JsvNativeSharedDiv,
4
+ JsvFocusBlock,
5
+ jJsvRuntimeBridge,
6
+ enableNativeViewListener,
7
+ disableNativeViewListener,
8
+ } from "jsview";
9
+ import { onBeforeUnmount, onMounted, reactive, watch, shallowRef } from "vue";
4
10
 
5
11
  let state = reactive({
6
12
  outX: 20,
@@ -18,29 +24,35 @@ let _TestData = [
18
24
  let _Index = 0;
19
25
 
20
26
  //给两个div给定不同的响应式变量
21
- let view1 = shallowRef('null')
22
- let view2 = shallowRef('null')
23
- let isShow=shallowRef(false)
24
- let isStop=shallowRef(false)
27
+ let view1 = shallowRef("null");
28
+ let view2 = shallowRef("null");
29
+ let isShow = shallowRef(false);
30
+ let isStop = shallowRef(false);
25
31
  //创造出需要的四个属性的对象
26
32
  const obj = (newValue) => {
27
- const resultObj = {}
28
- const newObj = JSON.parse(newValue.replace(/(\w+)\=/g, "\"$1\":").replace(/'/g, "\"").replace(/^Bundle\[/, "").replace(/\]$/, ""));
33
+ const resultObj = {};
34
+ const newObj = JSON.parse(
35
+ newValue
36
+ .replace(/(\w+)\=/g, '"$1":')
37
+ .replace(/'/g, '"')
38
+ .replace(/^Bundle\[/, "")
39
+ .replace(/\]$/, "")
40
+ );
29
41
  for (const key in newObj) {
30
- if (key == 'height' || key == 'width' || key == 'x' || key == 'y') {
42
+ if (key == "height" || key == "width" || key == "x" || key == "y") {
31
43
  resultObj[key] = newObj[key];
32
44
  }
33
45
  }
34
- return resultObj
35
- }
46
+ return resultObj;
47
+ };
36
48
  //监听
37
49
  watch(view1, (n, o) => {
38
- view1 = obj(n)
39
- })
50
+ view1 = obj(n);
51
+ });
40
52
  watch(view2, (n, o) => {
41
- view2 = obj(n)
42
- isShow.value=true
43
- })
53
+ view2 = obj(n);
54
+ isShow.value = true;
55
+ });
44
56
  // 每2秒进行位置变化以测试位置信息更新
45
57
  let loopTimer = setInterval(() => {
46
58
  _Index = (_Index + 1) % 3;
@@ -59,7 +71,7 @@ let _ResiterCallbackId2 = -1;
59
71
 
60
72
  let getId = (id) => {
61
73
  if (_ReisterId !== id) {
62
- _ResiterCallbackId1 = enableNativeViewListener(id, view1)
74
+ _ResiterCallbackId1 = enableNativeViewListener(id, view1);
63
75
  _ReisterId = id;
64
76
  }
65
77
  };
@@ -79,7 +91,7 @@ let getId2 = (id) => {
79
91
  timeout2 = setTimeout(() => {
80
92
  timeout2 = -1;
81
93
  disableNativeViewListener(_ResiterCallbackId2);
82
- isStop.value=true
94
+ isStop.value = true;
83
95
  _ResiterCallbackId2 = -1;
84
96
  }, 10000);
85
97
  }, 1000);
@@ -110,116 +122,197 @@ onBeforeUnmount(() => {
110
122
  disableNativeViewListener(_ResiterCallbackId2);
111
123
  _ResiterCallbackId2 = -1;
112
124
  }
113
- })
125
+ });
114
126
 
115
127
  onMounted(() => {
116
128
  console.log("TestNativeSharedView mounted");
117
129
  jJsvRuntimeBridge.notifyPageLoaded();
118
- })
119
-
130
+ });
120
131
  </script>
121
132
 
122
133
  <template>
123
134
  <jsv-focus-block autoFocus>
124
135
  <!-- 一个无限动画元素,来测试卡顿 -->
125
- <div :style="{
126
- top: 100,
127
- left: 1000,
128
- height: 150,
129
- width: 150,
130
- backgroundColor: '#334455',
131
- animation: 'test-anim-rotate 1s infinite linear',
132
- }" />
136
+ <div
137
+ :style="{
138
+ top: 100,
139
+ left: 1000,
140
+ height: 150,
141
+ width: 150,
142
+ backgroundColor: '#334455',
143
+ animation: 'test-anim-rotate 1s infinite linear',
144
+ }"
145
+ />
133
146
  <!-- 显示参数 -->
134
- <div :style="{ top: 400, left: 1000, width: 256, height: 240, backgroundColor: 'rgba(27,38,151,0.8)' }">
135
- <div :style="{ top: 0, left: 0, width: 120, height: 30, color: '#FFFFFF', fontSize: 20, textAlign: 'center' }">{{
136
- 'view1的参数'
137
- }}</div>
138
- <div v-for="(value, key, index) in view1" :style="{
139
- top: 30 + index * 40,
140
- left: 10,
141
- width: 100,
142
- height: 40,
143
- fontSize: 20,
144
- color: '#FFFFFF',
145
- textAlign: 'center'
146
- }">{{ key }}:{{ value }}</div>
147
- <div :style="{ top: 0, left: 130, width: 120, height: 30, color: '#FFFFFF', fontSize: 20, textAlign: 'center' }">{{
148
- 'view2的参数'
149
- }}</div>
147
+ <div
148
+ :style="{
149
+ top: 400,
150
+ left: 1000,
151
+ width: 256,
152
+ height: 240,
153
+ backgroundColor: 'rgba(27,38,151,0.8)',
154
+ }"
155
+ >
156
+ <div
157
+ :style="{
158
+ top: 0,
159
+ left: 0,
160
+ width: 120,
161
+ height: 30,
162
+ color: '#FFFFFF',
163
+ fontSize: 20,
164
+ textAlign: 'center',
165
+ }"
166
+ >
167
+ {{ "view1的参数" }}
168
+ </div>
169
+ <div
170
+ v-for="(value, key, index) in view1"
171
+ :style="{
172
+ top: 30 + index * 40,
173
+ left: 10,
174
+ width: 100,
175
+ height: 40,
176
+ fontSize: 20,
177
+ color: '#FFFFFF',
178
+ textAlign: 'center',
179
+ }"
180
+ >
181
+ {{ key }}:{{ value }}
182
+ </div>
183
+ <div
184
+ :style="{
185
+ top: 0,
186
+ left: 130,
187
+ width: 120,
188
+ height: 30,
189
+ color: '#FFFFFF',
190
+ fontSize: 20,
191
+ textAlign: 'center',
192
+ }"
193
+ >
194
+ {{ "view2的参数" }}
195
+ </div>
150
196
  <div v-if="isShow">
151
- <div v-for="(value, key, index) in view2" :style="{
197
+ <div
198
+ v-for="(value, key, index) in view2"
199
+ :style="{
152
200
  top: 30 + index * 40,
153
201
  left: 130,
154
202
  width: 100,
155
203
  height: 40,
156
204
  fontSize: 20,
157
205
  color: '#FFFFFF',
158
- textAlign: 'center'
159
- }">{{ key }}:{{ value }}</div>
160
- <div :style="{top: 200,
161
- left: 130,
162
- width: 100,
163
- height: 40,
164
- fontSize: 20,
165
- color: '#FFFFFF',
166
- textAlign: 'center'}">{{ isStop ? "监听停止":"" }}</div>
167
- </div>
168
- <div
169
- v-else
206
+ textAlign: 'center',
207
+ }"
208
+ >
209
+ {{ key }}:{{ value }}
210
+ </div>
211
+ <div
170
212
  :style="{
171
- top: 30 + 2*30,
213
+ top: 200,
172
214
  left: 130,
173
215
  width: 100,
174
216
  height: 40,
175
217
  fontSize: 20,
176
218
  color: '#FFFFFF',
177
- textAlign: 'center'}">{{ '未监听' }}</div>
219
+ textAlign: 'center',
220
+ }"
221
+ >
222
+ {{ isStop ? "监听停止" : "" }}
223
+ </div>
224
+ </div>
225
+ <div
226
+ v-else
227
+ :style="{
228
+ top: 30 + 2 * 30,
229
+ left: 130,
230
+ width: 100,
231
+ height: 40,
232
+ fontSize: 20,
233
+ color: '#FFFFFF',
234
+ textAlign: 'center',
235
+ }"
236
+ >
237
+ {{ "未监听" }}
238
+ </div>
178
239
  </div>
179
240
 
180
-
181
- <div :style="{
241
+ <div
242
+ :style="{
182
243
  left: state.outX,
183
244
  top: state.outY,
184
245
  backgroundColor: '#00FF00',
185
246
  width: 600,
186
247
  height: 600,
187
- }">
188
- <jsv-native-shared-div :getId="getId" :style="{
248
+ }"
249
+ >
250
+ <div
251
+ :style="{
252
+ left: state.inX,
253
+ top: state.inY,
254
+ width: 500,
255
+ height: 500,
256
+ backgroundColor: 'rgba(255, 255, 0, 1.0)',
257
+ }"
258
+ />
259
+ <jsv-native-shared-div
260
+ :getId="getId"
261
+ :style="{
189
262
  left: state.inX,
190
263
  top: state.inY,
191
264
  width: 500,
192
265
  height: 500,
193
- }">
194
- <div :style="{
266
+ }"
267
+ >
268
+ <div
269
+ :style="{
195
270
  backgroundColor: '#00FF00',
196
271
  left: 50,
197
272
  top: 40,
198
273
  width: 30,
199
274
  height: 30,
200
- }" />
275
+ }"
276
+ />
201
277
  </jsv-native-shared-div>
202
278
  </div>
203
- <div :style="{
279
+ <div
280
+ :style="{
204
281
  left: state.outX + 200,
205
282
  top: state.outY,
206
283
  backgroundColor: '#00FF00',
207
284
  width: 600,
208
285
  height: 600,
209
- }">
210
- <jsv-native-shared-div :getId="getId2" :style="{
286
+ }"
287
+ >
288
+ <div
289
+ :style="{
211
290
  left: state.inX,
212
291
  top: state.inY,
213
292
  width: 500,
214
293
  height: 500,
215
- }">
216
- <div :style="{
294
+ backgroundColor: 'rgba(255, 255, 0, 1.0)',
295
+ }"
296
+ />
297
+ <jsv-native-shared-div
298
+ :getId="getId2"
299
+ :style="{
300
+ left: state.inX,
301
+ top: state.inY,
302
+ width: 500,
303
+ height: 500,
304
+ }"
305
+ :corner="8"
306
+ >
307
+ <div
308
+ :style="{
217
309
  backgroundColor: '#00FF00',
218
310
  left: 50,
219
311
  top: 40,
220
312
  width: 30,
221
313
  height: 30,
222
- }" />
314
+ }"
315
+ />
223
316
  </jsv-native-shared-div>
224
317
  </div>
225
318
  </jsv-focus-block>
@@ -28,14 +28,15 @@ const rotateAnimation =
28
28
  // 设置设定模拟绘制.9图
29
29
  let canvasRef;
30
30
  let sourceId = shallowRef("");
31
- let sampleImageWidth = 86;
31
+ let sampleImageWidth = 90;
32
32
  canvasRef = JsvTextureStoreApi.canvasTexture(
33
33
  sampleImageWidth,
34
34
  sampleImageWidth
35
35
  ); // 创建画布
36
36
 
37
- let circleRadius = 40;
38
- let circleLineWidth = 5;
37
+ let circleInnerDiameter = 70; // 环形内直径, 为所要包括图形的borderRadius的一倍
38
+ let circleLineWidth = 6; // 线宽
39
+ let circleRadius = Math.floor(circleInnerDiameter / 2 + circleLineWidth / 2); // 绘制线是圆圈的轨迹中线
39
40
  let customPath = canvasRef.circlePath(
40
41
  Math.floor(sampleImageWidth / 2),
41
42
  Math.floor(sampleImageWidth / 2),
@@ -48,9 +49,9 @@ sourceId = canvasRef.commit(); // texture和div的textureStore绑定
48
49
  const ninePatchDecorator1 = {
49
50
  type: DECORATE_NINEPATCH_ALPHA_MIX,
50
51
  url: `jsvtexturestore://${sourceId}`,
51
- imageWidth: 86,
52
- centerWidth: 2,
53
- borderOutset: 0,
52
+ imageWidth: sampleImageWidth, // 等同于画布宽
53
+ centerWidth: 2, // 固定为1或2, 但1在PC上绘制可能有异常
54
+ borderOutset: Math.floor((sampleImageWidth - circleInnerDiameter) / 2), // (画布 - 圆环内直径) / 2
54
55
  animTime: 0.5,
55
56
  };
56
57
 
@@ -110,6 +111,16 @@ onBeforeUnmount(() => {
110
111
  .9型的旋转焦点框,OK键进行随机位置+尺寸变换
111
112
  </div>
112
113
  <div>
114
+ <div
115
+ :style="{
116
+ left: left,
117
+ top: top,
118
+ width: width,
119
+ height: height,
120
+ backgroundColor: 'rgba(0, 255, 0, 0.7)',
121
+ borderRadius: Math.floor(circleInnerDiameter / 2),
122
+ }"
123
+ />
113
124
  <jsv-texture-anim
114
125
  :src="img"
115
126
  :left="left"
@@ -7,16 +7,18 @@
7
7
  :onLoad="audioOnLoad"
8
8
  />
9
9
  <JsvRipple :width="1280" :height="720" ref="rippleViewRef">
10
- <jsv-focus-block
11
- autoFocus
12
- :style="{ width: 1280, height: 720, backgroundImage: bg }"
13
- >
10
+ <jsv-focus-block autoFocus>
11
+ <img
12
+ :src="bg"
13
+ :style="{ width: 1280, height: 720 }"
14
+ :onLoad="funcBackgroundOnLoaded"
15
+ />
14
16
  <div
15
17
  :style="{
16
- width: 200,
17
- height: 200,
18
+ width: 100,
19
+ height: 100,
18
20
  backgroundImage: title,
19
- left: 630,
21
+ left: 900,
20
22
  top: 40,
21
23
  }"
22
24
  ></div>
@@ -77,27 +79,37 @@ const audioOnLoad = () => {
77
79
  console.log("audio on load");
78
80
  _BgAudio.play();
79
81
  };
82
+
83
+ let backgrounLoaded = false;
84
+ const funcBackgroundOnLoaded = () => {
85
+ backgrounLoaded = true;
86
+ console.log("bg image loaded");
87
+ };
88
+
80
89
  onMounted(() => {
81
90
  if (rippleViewRef.value !== null) {
82
91
  timer.id = setInterval(() => {
83
- const p = genSource();
84
- rippleViewRef.value.addSource(
85
- ...p,
86
- {
87
- type: JsvRippleShape.CIRCLE,
88
- },
89
- {
90
- timeDecay: 0.5,
91
- distanceDecay: 8,
92
- speed: 60,
93
- frequency: 2,
94
- waveNum: 2,
95
- }
96
- );
92
+ if (backgrounLoaded) {
93
+ // 图片加载完成后再追加波纹,规避绘出黑色的波圈
94
+ const p = genSource();
95
+ rippleViewRef.value.addSource(
96
+ ...p,
97
+ {
98
+ type: JsvRippleShape.CIRCLE,
99
+ },
100
+ {
101
+ timeDecay: 0.5,
102
+ distanceDecay: 8,
103
+ speed: 60,
104
+ frequency: 2,
105
+ waveNum: 2,
106
+ }
107
+ );
97
108
 
98
- timer.id2 = setTimeout(() => {
99
- mySoundControl.play();
100
- }, 1000);
109
+ timer.id2 = setTimeout(() => {
110
+ mySoundControl.play();
111
+ }, 1000);
112
+ }
101
113
  }, 3000);
102
114
  }
103
115
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shijiu/jsview-vue-samples",
3
- "version": "2.2.35",
3
+ "version": "2.2.128",
4
4
  "license": "MIT",
5
5
  "repository": "system/jsview-framework",
6
6
  "author": "mengxk",