@dolphinweex/weex-harmony 0.1.93 → 0.1.95

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dolphinweex/weex-harmony",
3
- "version": "0.1.93",
3
+ "version": "0.1.95",
4
4
  "description": "weex harmony adapter",
5
5
  "main": "index.js",
6
6
  "files": [
@@ -0,0 +1,87 @@
1
+ <template>
2
+ <BaseSameLayer
3
+ :hosSameLayerArgs="hosSameLayerArgs"
4
+ embedType="native/midea-audio-input-view"
5
+ :defaultWidth="300"
6
+ :defaultHeight="300"
7
+ ref="audioWaveRef"
8
+ ></BaseSameLayer>
9
+ </template>
10
+
11
+ <script>
12
+ import BaseSameLayer from "./baseSameLayer.vue";
13
+ const weexModule = weex.requireModule('weexModule');
14
+
15
+ export default {
16
+ name: "mideaAudioInputView",
17
+ data() {
18
+ return {
19
+ width: 0,
20
+ height: 0
21
+ }
22
+ },
23
+ components: {
24
+ BaseSameLayer,
25
+ },
26
+ props: {
27
+ hosUniqueProps: {
28
+ type: Object,
29
+ default() {
30
+ return {};
31
+ },
32
+ },
33
+ data: {
34
+ type: Object,
35
+ default() {
36
+ return {
37
+ embedId:''
38
+ };
39
+ },
40
+ },
41
+ accessible: {
42
+ type: Boolean,
43
+ default: true
44
+ },
45
+ ariaLabel: {
46
+ type: String,
47
+ default: '确认'
48
+ },
49
+ },
50
+ computed: {
51
+ hosSameLayerArgs() {
52
+ return {
53
+ ...this.hosUniqueProps, // 鸿蒙原生组件独有属性
54
+ width: this.width,
55
+ height: this.height,
56
+ data: this.data,
57
+ accessible: this.accessible,
58
+ btnText: this.ariaLabel,
59
+ onAudioInputStart: this.onAudioInputStart,
60
+ onAudioInputCancel: this.onAudioInputCancel,
61
+ onAudioInputFail: this.onAudioInputFail,
62
+ onAudioInputComplete: this.onAudioInputComplete,
63
+ };
64
+ },
65
+ },
66
+ mounted() {
67
+ this.width = this.$el.clientWidth;
68
+ this.height = this.$el.clientHeight;
69
+ this.embedId = this.$refs.audioWaveRef.embedId;
70
+ },
71
+
72
+ methods: {
73
+ onAudioInputStart(res){
74
+ this.$emit("onAudioInputStart", res);
75
+ },
76
+ onAudioInputCancel(res){
77
+ this.$emit("onAudioInputCancel", res);
78
+ },
79
+ onAudioInputFail(res){
80
+ this.$emit("onAudioInputFail", res);
81
+ },
82
+ onAudioInputComplete(res){
83
+ this.$emit("onAudioInputComplete", res);
84
+ }
85
+ },
86
+ };
87
+ </script>
@@ -86,6 +86,25 @@ export default {
86
86
  },
87
87
 
88
88
  methods: {
89
+ /** 判断组件是否可见 */
90
+ isInBrowserViewport() {
91
+ const el = this.$el;
92
+ if (!el || typeof el.getBoundingClientRect !== "function") {
93
+ return false;
94
+ }
95
+ const rect = el.getBoundingClientRect();
96
+ const vw = window.innerWidth || 0;
97
+ const vh = window.innerHeight || 0;
98
+ if (!vw || !vh) {
99
+ return false;
100
+ }
101
+ return (
102
+ rect.bottom > 0 &&
103
+ rect.right > 0 &&
104
+ rect.top < vh &&
105
+ rect.left < vw
106
+ );
107
+ },
89
108
  // 自定义拓展其它逻辑
90
109
  handleOnChange(res) {
91
110
  if (res.mode == 1) {
@@ -109,7 +128,12 @@ export default {
109
128
  this.$emit("finish", event || {});
110
129
  },
111
130
  appear(event) {
112
- this.$emit("appear", event || {});
131
+ this.$nextTick(() => {
132
+ if (!this.isInBrowserViewport()) {
133
+ return;
134
+ }
135
+ this.$emit("appear", event || {});
136
+ });
113
137
  },
114
138
  },
115
139
  };