From 3ed4ae6784ef5de7c50208d0741cdc5ec5b27855 Mon Sep 17 00:00:00 2001 From: kolirt Date: Wed, 24 Jul 2024 20:10:35 +0300 Subject: [PATCH] implement CloudStorage --- README.md | 18 ++++++++++++++++-- lib/actions/cloudStorage/getItem.ts | 13 +++++++++++++ lib/actions/cloudStorage/getItems.ts | 13 +++++++++++++ lib/actions/cloudStorage/getKeys.ts | 13 +++++++++++++ lib/actions/cloudStorage/index.ts | 6 ++++++ lib/actions/cloudStorage/removeItem.ts | 13 +++++++++++++ lib/actions/cloudStorage/removeItems.ts | 13 +++++++++++++ lib/actions/cloudStorage/setItem.ts | 13 +++++++++++++ lib/actions/index.ts | 3 ++- package.json | 2 +- 10 files changed, 103 insertions(+), 4 deletions(-) create mode 100644 lib/actions/cloudStorage/getItem.ts create mode 100644 lib/actions/cloudStorage/getItems.ts create mode 100644 lib/actions/cloudStorage/getKeys.ts create mode 100644 lib/actions/cloudStorage/index.ts create mode 100644 lib/actions/cloudStorage/removeItem.ts create mode 100644 lib/actions/cloudStorage/removeItems.ts create mode 100644 lib/actions/cloudStorage/setItem.ts diff --git a/README.md b/README.md index 54502ad..563a130 100644 --- a/README.md +++ b/README.md @@ -60,11 +60,25 @@ app.mount('#app') - [X] headerColor - [X] backgroundColor - [X] isClosingConfirmationEnabled -- [X] BackButton +- [ ] BackButton + - [ ] isVisible + - [X] BackButton.onClick + - [X] BackButton.offClick + - [X] BackButton.show + - [X] BackButton.hide - [ ] MainButton - [ ] SettingsButton - [X] HapticFeedback -- [ ] CloudStorage + - [X] HapticFeedback.impactOccurred + - [X] HapticFeedback.notificationOccurred + - [X] HapticFeedback.selectionChanged +- [X] CloudStorage + - [X] CloudStorage.setItem + - [X] CloudStorage.getItem + - [X] CloudStorage.getItems + - [X] CloudStorage.removeItem + - [X] CloudStorage.removeItems + - [X] CloudStorage.getKeys - [ ] BiometricManager - [ ] isVersionAtLeast - [X] setHeaderColor(color) diff --git a/lib/actions/cloudStorage/getItem.ts b/lib/actions/cloudStorage/getItem.ts new file mode 100644 index 0000000..fdfb8e2 --- /dev/null +++ b/lib/actions/cloudStorage/getItem.ts @@ -0,0 +1,13 @@ +import { webApp } from '../../webApp' + +export function getItem(key: string) { + return new Promise((resolve, reject) => { + webApp.CloudStorage.getItem(key, function (error: any, value: string) { + if (error) { + reject(error) + } + + resolve(value) + }) + }) +} diff --git a/lib/actions/cloudStorage/getItems.ts b/lib/actions/cloudStorage/getItems.ts new file mode 100644 index 0000000..fd19150 --- /dev/null +++ b/lib/actions/cloudStorage/getItems.ts @@ -0,0 +1,13 @@ +import { webApp } from '../../webApp' + +export function getItems(keys: T) { + return new Promise((resolve, reject) => { + webApp.CloudStorage.getItems(keys, function (error: any, value: T) { + if (error) { + reject(error) + } + + resolve(value) + }) + }) +} diff --git a/lib/actions/cloudStorage/getKeys.ts b/lib/actions/cloudStorage/getKeys.ts new file mode 100644 index 0000000..569fd41 --- /dev/null +++ b/lib/actions/cloudStorage/getKeys.ts @@ -0,0 +1,13 @@ +import { webApp } from '../../webApp' + +export function getKeys() { + return new Promise((resolve, reject) => { + webApp.CloudStorage.getKeys(function (error: any, value: string[]) { + if (error) { + reject(error) + } + + resolve(value) + }) + }) +} diff --git a/lib/actions/cloudStorage/index.ts b/lib/actions/cloudStorage/index.ts new file mode 100644 index 0000000..367dfd2 --- /dev/null +++ b/lib/actions/cloudStorage/index.ts @@ -0,0 +1,6 @@ +export { getItem } from './getItem' +export { getItems } from './getItems' +export { getKeys } from './getKeys' +export { removeItem } from './removeItem' +export { removeItems } from './removeItems' +export { setItem } from './setItem' diff --git a/lib/actions/cloudStorage/removeItem.ts b/lib/actions/cloudStorage/removeItem.ts new file mode 100644 index 0000000..50ed198 --- /dev/null +++ b/lib/actions/cloudStorage/removeItem.ts @@ -0,0 +1,13 @@ +import { webApp } from '../../webApp' + +export function removeItem(key: string) { + return new Promise((resolve, reject) => { + webApp.CloudStorage.removeItem(key, function (error: any) { + if (error) { + reject(error) + } + + resolve() + }) + }) +} diff --git a/lib/actions/cloudStorage/removeItems.ts b/lib/actions/cloudStorage/removeItems.ts new file mode 100644 index 0000000..8953d5e --- /dev/null +++ b/lib/actions/cloudStorage/removeItems.ts @@ -0,0 +1,13 @@ +import { webApp } from '../../webApp' + +export function removeItems(keys: string[]) { + return new Promise((resolve, reject) => { + webApp.CloudStorage.removeItem(keys, function (error: any) { + if (error) { + reject(error) + } + + resolve() + }) + }) +} diff --git a/lib/actions/cloudStorage/setItem.ts b/lib/actions/cloudStorage/setItem.ts new file mode 100644 index 0000000..9b916c9 --- /dev/null +++ b/lib/actions/cloudStorage/setItem.ts @@ -0,0 +1,13 @@ +import { webApp } from '../../webApp' + +export function setItem(key: string, value: string) { + return new Promise((resolve, reject) => { + webApp.CloudStorage.setItem(key, value, function (error: any) { + if (error) { + reject(error) + } + + resolve() + }) + }) +} diff --git a/lib/actions/index.ts b/lib/actions/index.ts index 522186e..e4dfbb9 100644 --- a/lib/actions/index.ts +++ b/lib/actions/index.ts @@ -1,4 +1,5 @@ import * as BackButton from './backButton' +import * as CloudStorage from './cloudStorage' import * as HapticFeedback from './hapticFeedback' export { close } from './close' @@ -8,4 +9,4 @@ export { autoExpand, expand, stopAutoExpand } from './expand' export { ready } from './ready' export { setBackgroundColor } from './setBackgroundColor' export { setHeaderColor } from './setHeaderColor' -export { BackButton, HapticFeedback } +export { BackButton, CloudStorage, HapticFeedback } diff --git a/package.json b/package.json index 328f0ed..ef5fa35 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@kolirt/vue-telegram-mini-app", - "version": "0.0.6", + "version": "0.0.7", "type": "module", "description": "Vue 3 telegram mini app package", "author": "kolirt",