mirror of
https://github.com/lana-k/sqliteviz.git
synced 2025-12-06 18:18:53 +08:00
add sleep function
This commit is contained in:
@@ -11,5 +11,11 @@ export default {
|
||||
clearTimeout(timeout)
|
||||
timeout = setTimeout(() => func.apply(this, arguments), ms)
|
||||
}
|
||||
},
|
||||
|
||||
sleep (ms) {
|
||||
return new Promise(resolve => {
|
||||
setTimeout(() => { resolve() }, ms)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,6 +86,7 @@ import PngIcon from '@/components/svg/png'
|
||||
import ClipboardIcon from '@/components/svg/clipboard'
|
||||
import cIo from '@/lib/utils/clipboardIo'
|
||||
import loadingDialog from '@/components/LoadingDialog'
|
||||
import time from '@/lib/utils/time'
|
||||
|
||||
export default {
|
||||
name: 'DataView',
|
||||
@@ -127,12 +128,11 @@ export default {
|
||||
|
||||
nextTick allows you to do something after you have changed the data and VueJS has updated the DOM based on your data change, but before the browser has rendered those changed on the page.
|
||||
|
||||
Lees meer van Katinka Hesselink: http://www.hesselinkwebdesign.nl/2019/nexttick-vs-settimeout-in-vue/
|
||||
http://www.hesselinkwebdesign.nl/2019/nexttick-vs-settimeout-in-vue/
|
||||
|
||||
*/
|
||||
setTimeout(() => {
|
||||
await time.sleep(0)
|
||||
this.$refs.viewComponent.saveAsPng()
|
||||
}, 0)
|
||||
},
|
||||
getOptionsForSave () {
|
||||
return this.$refs.viewComponent.getOptionsForSave()
|
||||
@@ -143,7 +143,7 @@ export default {
|
||||
this.$modal.show('prepareCopy')
|
||||
const t0 = performance.now()
|
||||
|
||||
setTimeout(async () => {
|
||||
await time.sleep(0)
|
||||
this.dataToCopy = await this.$refs.viewComponent.prepareCopy()
|
||||
const t1 = performance.now()
|
||||
if ((t1 - t0) < 950) {
|
||||
@@ -152,7 +152,6 @@ export default {
|
||||
} else {
|
||||
this.preparingCopy = false
|
||||
}
|
||||
}, 0)
|
||||
} else {
|
||||
alert("Your browser doesn't support copying images into the clipboard. If you use Firefox you can enable it by setting dom.events.asyncClipboard.clipboardItem to true.")
|
||||
}
|
||||
|
||||
@@ -70,6 +70,7 @@ import IconButton from '@/components/IconButton'
|
||||
import csv from '@/lib/csv'
|
||||
import fIo from '@/lib/utils/fileIo'
|
||||
import cIo from '@/lib/utils/clipboardIo'
|
||||
import time from '@/lib/utils/time'
|
||||
import loadingDialog from '@/components/LoadingDialog'
|
||||
|
||||
export default {
|
||||
@@ -125,7 +126,7 @@ export default {
|
||||
this.$modal.show('prepareCSVCopy')
|
||||
const t0 = performance.now()
|
||||
|
||||
setTimeout(async () => {
|
||||
await time.sleep(0)
|
||||
this.dataToCopy = csv.serialize(this.result)
|
||||
const t1 = performance.now()
|
||||
if ((t1 - t0) < 950) {
|
||||
@@ -134,7 +135,6 @@ export default {
|
||||
} else {
|
||||
this.preparingCopy = false
|
||||
}
|
||||
}, 0)
|
||||
} else {
|
||||
alert("Your browser doesn't support copying images into the clipboard. If you use Firefox you can enable it by setting dom.events.asyncClipboard.clipboardItem to true.")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user