feat(staging): added transfer for data from settings app(part 2)
This commit is contained in:
@@ -1,23 +1,47 @@
|
||||
import { setStatusBarVisible } from '@zos/ui'
|
||||
import { RenderAddButton } from './render/totpRenderer'
|
||||
import { initLoop } from './render/index/renderer'
|
||||
import { BasePage } from '@zeppos/zml/base-page'
|
||||
import { LocalStorage } from "@zos/storage"
|
||||
|
||||
const localStorage = new LocalStorage()
|
||||
const app = getApp()
|
||||
let waitForFetch = true;
|
||||
Page(
|
||||
BasePage({
|
||||
onInit() {
|
||||
this.getTOTPData().then((x) => {
|
||||
console.log(x)
|
||||
localStorage.setItem('TOTPs', x)
|
||||
app._options.globalData.TOTPS = x
|
||||
this.initPage();
|
||||
})
|
||||
.catch((x) => {
|
||||
app._options.globalData.TOTPS = localStorage.getItem('TOTPs')
|
||||
this.initPage()
|
||||
})
|
||||
},
|
||||
build() {
|
||||
let fetch = setInterval(() => {
|
||||
if(waitForFetch)
|
||||
return;
|
||||
|
||||
Page({
|
||||
onInit() {
|
||||
//If app has no saved TOTPs
|
||||
if (app._options.globalData.TOTPS.length < 1)
|
||||
setStatusBarVisible(true)
|
||||
else
|
||||
setStatusBarVisible(false)
|
||||
},
|
||||
build() {
|
||||
const buffer = app._options.globalData.TOTPS
|
||||
if (buffer.length < 1)
|
||||
RenderAddButton('page/tip')
|
||||
else{
|
||||
initLoop(buffer)
|
||||
clearInterval(fetch);
|
||||
const buffer = app._options.globalData.TOTPS
|
||||
if (buffer.length < 1){
|
||||
RenderAddButton('page/tip')
|
||||
}
|
||||
else {
|
||||
initLoop(buffer)
|
||||
}
|
||||
}, 100);
|
||||
},
|
||||
initPage() {
|
||||
waitForFetch = false;
|
||||
},
|
||||
getTOTPData() {
|
||||
return this.request({
|
||||
method: 'totps'
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
)
|
||||
Reference in New Issue
Block a user