fix: 调整记录剪贴板方式 修复漏数据的问题 #21 #28

This commit is contained in:
ZiuChen
2022-09-05 23:43:58 +08:00
parent 7d551e93ea
commit 621911524d
3 changed files with 124 additions and 57 deletions

21
public/time.worker.js Normal file
View File

@@ -0,0 +1,21 @@
// author: inu1255
const apis = {
sleep(ms) {
return new Promise((resolve) => setTimeout(resolve, ms))
}
}
onmessage = (event) => {
const data = event.data
if (!data) return
const { cb, method, args } = data
if (!apis[method]) {
postMessage({ cb, err: 'no such method' })
return
}
apis[method].apply(null, args).then(
(res) => postMessage({ cb, data: res }),
(err) => postMessage({ cb, err })
)
}