feat: added local storage for save totp directly on watches
This commit is contained in:
parent
24e097a253
commit
5fa5455e00
3
app.json
3
app.json
@ -13,7 +13,8 @@
|
|||||||
"description": "TOTP Authenticator for Amazfit devices"
|
"description": "TOTP Authenticator for Amazfit devices"
|
||||||
},
|
},
|
||||||
"permissions": [
|
"permissions": [
|
||||||
"data:os.device.info"
|
"data:os.device.info",
|
||||||
|
"device:os.local_storage"
|
||||||
],
|
],
|
||||||
"runtime": {
|
"runtime": {
|
||||||
"apiVersion": {
|
"apiVersion": {
|
||||||
|
@ -1,19 +1,23 @@
|
|||||||
import { RenderAddButton } from "./render/totpRenderer";
|
import { RenderAddButton } from "./render/totpRenderer";
|
||||||
import { initLoop } from "./render/index/renderer";
|
import { initLoop } from "./render/index/renderer";
|
||||||
import { BasePage } from "@zeppos/zml/base-page";
|
import { BasePage } from "@zeppos/zml/base-page";
|
||||||
|
import { LocalStorage } from '@zos/storage';
|
||||||
|
|
||||||
const app = getApp();
|
const app = getApp();
|
||||||
let waitForFetch = true;
|
let waitForFetch = true;
|
||||||
|
let localStorage = new LocalStorage();
|
||||||
Page(
|
Page(
|
||||||
BasePage({
|
BasePage({
|
||||||
onInit() {
|
onInit() {
|
||||||
this.getTOTPData()
|
this.getTOTPData()
|
||||||
.then((x) => {
|
.then((x) => {
|
||||||
app._options.globalData.TOTPS = JSON.parse(x) ?? [];
|
app._options.globalData.TOTPS = JSON.parse(x) ?? []
|
||||||
|
localStorage.setItem('TOTPs', JSON.stringify(app._options.globalData.TOTPS))
|
||||||
this.initPage();
|
this.initPage();
|
||||||
})
|
})
|
||||||
.catch((x) => {
|
.catch((x) => {
|
||||||
app._options.globalData.TOTPS = [];
|
console.log(`Init failed: ${x}`)
|
||||||
|
app._options.globalData.TOTPS = JSON.parse(localStorage.getItem('TOTPs', null) ?? []);
|
||||||
this.initPage();
|
this.initPage();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user