Skip to content

Commit b54a1f5

Browse files
committed
update icon & improve worker demo
1 parent 695df9f commit b54a1f5

File tree

5 files changed

+13
-7
lines changed

5 files changed

+13
-7
lines changed

page/API/pages/worker/worker.js

+12-6
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,18 @@ Page({
1010

1111
data: {
1212
res: '',
13-
input: 33,
13+
input: 35,
14+
},
15+
16+
onLoad() {
17+
this._worker = wx.createWorker('workers/fib/index.js')
1418
},
1519

1620
onUnload() {
1721
clearInterval(this.interval)
1822
if (this._worker) this._worker.terminate()
1923
},
20-
24+
2125
bindInput(e) {
2226
const val = Number(e.detail.value)
2327
if (val > 40) return {value: 40}
@@ -34,7 +38,9 @@ Page({
3438

3539
compute() {
3640
this.reset()
37-
wx.showLoading()
41+
wx.showLoading({
42+
title: '计算中...'
43+
})
3844
const t0 = +Date.now()
3945
const res = fib(this.data.input)
4046
const t1 = +Date.now()
@@ -47,8 +53,9 @@ Page({
4753

4854
multiThreadCompute() {
4955
this.reset()
50-
wx.showLoading()
51-
this._worker = wx.createWorker('workers/fib/index.js')
56+
wx.showLoading({
57+
title: '计算中...'
58+
})
5259

5360
const t0 = +Date.now()
5461
this._worker.postMessage({
@@ -59,7 +66,6 @@ Page({
5966
if (res.type === 'execFunc_fib') {
6067
wx.hideLoading()
6168
const t1 = +Date.now()
62-
this._worker.terminate()
6369
this.setData({
6470
res: res.result,
6571
time: t1 - t0

page/API/resources/kind/worker.png

-1.76 KB
Loading

page/component/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ Page({
4242
name: '画布',
4343
pages: ['canvas']
4444
}, {
45-
id: 'ad',
45+
id: 'open',
4646
name: '开放能力',
4747
pages: ['ad', 'open-data', 'web-view']
4848
}

page/component/resources/kind/ad.png

-715 Bytes
Binary file not shown.
1.35 KB
Loading

0 commit comments

Comments
 (0)