mirror of
https://github.com/danielsogl/awesome-cordova-plugins.git
synced 2025-04-06 23:20:33 +08:00
Deep keys
This commit is contained in:
parent
a05462526d
commit
eb0b857b96
@ -1,6 +1,8 @@
|
|||||||
import {PluginConfig} from './plugin-config'
|
import {PluginConfig} from './plugin-config'
|
||||||
import {promisifyCordova} from './cordova';
|
import {promisifyCordova} from './cordova';
|
||||||
|
|
||||||
|
import {get} from './util';
|
||||||
|
|
||||||
let wrappedPlugins = {}
|
let wrappedPlugins = {}
|
||||||
|
|
||||||
let promised;
|
let promised;
|
||||||
@ -8,7 +10,7 @@ let promised;
|
|||||||
function newPluginClass(config) {
|
function newPluginClass(config) {
|
||||||
let obj = {
|
let obj = {
|
||||||
installed: () => {
|
installed: () => {
|
||||||
return config.pluginRef && window.hasOwnProperty(config.pluginRef);
|
return config.pluginRef && get(window, config.pluginRef);
|
||||||
},
|
},
|
||||||
|
|
||||||
plugin: config.plugin
|
plugin: config.plugin
|
||||||
|
@ -1,4 +1,10 @@
|
|||||||
export var PluginConfig = [
|
export var PluginConfig = [
|
||||||
|
{
|
||||||
|
id: 'device',
|
||||||
|
className: 'Device',
|
||||||
|
plugin: 'cordova-plugin-device',
|
||||||
|
pluginRef: 'device'
|
||||||
|
},
|
||||||
{
|
{
|
||||||
id: 'camera',
|
id: 'camera',
|
||||||
className: 'Camera',
|
className: 'Camera',
|
||||||
@ -7,9 +13,9 @@ export var PluginConfig = [
|
|||||||
pluginRef: 'navigator.camera'
|
pluginRef: 'navigator.camera'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'device',
|
id: 'applinks',
|
||||||
className: 'Device',
|
className: 'AppLinks',
|
||||||
plugin: 'cordova-plugin-device',
|
plugin: 'com.lampa.startapp',
|
||||||
pluginRef: 'device'
|
pluginRef: 'navigator.startApp'
|
||||||
}
|
},
|
||||||
]
|
]
|
||||||
|
6
src/util.js
Normal file
6
src/util.js
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
export function get(obj, path) {
|
||||||
|
for (var i=0, path = path.split('.'), len = path.length; i < len; i++) {
|
||||||
|
obj = obj[path[i]];
|
||||||
|
}
|
||||||
|
return obj;
|
||||||
|
};
|
Loading…
x
Reference in New Issue
Block a user