Refactor capacitor plugins, clean up and organize android plugin classes

This commit is contained in:
advplyr
2022-04-04 19:08:27 -05:00
parent cc744bb975
commit 77ef0c119b
26 changed files with 376 additions and 385 deletions
+13
View File
@@ -0,0 +1,13 @@
import { registerPlugin, WebPlugin } from '@capacitor/core';
class AbsAudioPlayerWeb extends WebPlugin {
constructor() {
super()
}
}
const AbsAudioPlayer = registerPlugin('AbsAudioPlayer', {
web: () => new AbsAudioPlayerWeb()
})
export { AbsAudioPlayer }
@@ -1,11 +1,11 @@
import { registerPlugin, Capacitor, WebPlugin } from '@capacitor/core';
class DbWeb extends WebPlugin {
class AbsDatabaseWeb extends WebPlugin {
constructor() {
super()
}
async getDeviceData_WV() {
async getDeviceData() {
var dd = localStorage.getItem('device')
if (dd) {
return JSON.parse(dd)
@@ -18,8 +18,8 @@ class DbWeb extends WebPlugin {
return deviceData
}
async setCurrentServerConnectionConfig_WV(serverConnectionConfig) {
var deviceData = await this.getDeviceData_WV()
async setCurrentServerConnectionConfig(serverConnectionConfig) {
var deviceData = await this.getDeviceData()
var ssc = deviceData.serverConnectionConfigs.find(_ssc => _ssc.id == serverConnectionConfig.id)
if (ssc) {
@@ -44,20 +44,22 @@ class DbWeb extends WebPlugin {
return ssc
}
async removeServerConnectionConfig_WV(serverConnectionConfigCallObject) {
async removeServerConnectionConfig(serverConnectionConfigCallObject) {
var serverConnectionConfigId = serverConnectionConfigCallObject.serverConnectionConfigId
var deviceData = await this.getDeviceData_WV()
var deviceData = await this.getDeviceData()
deviceData.serverConnectionConfigs = deviceData.serverConnectionConfigs.filter(ssc => ssc.id == serverConnectionConfigId)
localStorage.setItem('device', JSON.stringify(deviceData))
}
logout_WV() {
// Nothing to do on web
async logout() {
var deviceData = await this.getDeviceData()
deviceData.lastServerConnectionConfigId = null
localStorage.setItem('device', JSON.stringify(deviceData))
}
}
const DbManager = registerPlugin('DbManager', {
web: () => new DbWeb()
const AbsDatabase = registerPlugin('AbsDatabase', {
web: () => new AbsDatabaseWeb()
})
export { DbManager }
export { AbsDatabase }
+13
View File
@@ -0,0 +1,13 @@
import { registerPlugin, WebPlugin } from '@capacitor/core';
class AbsDownloaderWeb extends WebPlugin {
constructor() {
super()
}
}
const AbsDownloader = registerPlugin('AbsDownloader', {
web: () => new AbsDownloaderWeb()
})
export { AbsDownloader }
+13
View File
@@ -0,0 +1,13 @@
import { registerPlugin, WebPlugin } from '@capacitor/core';
class AbsFileSystemWeb extends WebPlugin {
constructor() {
super()
}
}
const AbsFileSystem = registerPlugin('AbsFileSystem', {
web: () => new AbsFileSystemWeb()
})
export { AbsFileSystem }
+13
View File
@@ -0,0 +1,13 @@
import Vue from 'vue'
import { AbsAudioPlayer } from './AbsAudioPlayer'
import { AbsDownloader } from './AbsDownloader'
import { AbsFileSystem } from './AbsFileSystem'
import { Capacitor } from '@capacitor/core'
Vue.prototype.$platform = Capacitor.getPlatform()
export {
AbsAudioPlayer,
AbsDownloader,
AbsFileSystem
}