Comparing version 1.0.0 to 1.0.1
@@ -6,2 +6,3 @@ "use strict"; | ||
var febs = require("febs"); | ||
var componentEnum = require('../src/componentEnum'); | ||
@@ -11,11 +12,3 @@ var components = [ | ||
"button", | ||
"navbar-view", | ||
"checkbox", | ||
"radio", | ||
"switch", | ||
"input", | ||
"dialog", | ||
"picker", | ||
"actionsheet", | ||
"popover" | ||
...componentEnum.ComponentName | ||
]; | ||
@@ -22,0 +15,0 @@ |
@@ -43,3 +43,3 @@ { | ||
"name": "bpui.js", | ||
"version": "1.0.0" | ||
"version": "1.0.1" | ||
} |
@@ -6,15 +6,4 @@ | ||
var pkg = require('../package.json'); | ||
var componentEnum = require('./componentEnum'); | ||
const ComponentName1 = { | ||
navbarView: 'navbarView', | ||
checkbox: 'checkbox', | ||
radio: 'radio', | ||
switch: 'switch', | ||
input: 'input', | ||
dialog: 'dialog', | ||
picker: 'picker', | ||
actionsheet: 'actionsheet', | ||
popover: 'popover', | ||
} | ||
function registerComponents(App:any, components?:string[]):Promise<void> { | ||
@@ -42,2 +31,16 @@ // vue. | ||
function getLayout(layouts:any, newRoute:any, oldRoute:any):any { | ||
let newRoutePath = newRoute.path; | ||
if (newRoutePath[0] == '/') newRoutePath = newRoutePath.substring(1); | ||
for (let p in layouts) { | ||
if (p[0] == '/') p = p.substring(1); | ||
if (newRoutePath == p || newRoutePath.indexOf(p + '/') >= 0) { | ||
return (layouts as any)[p]; | ||
} | ||
} | ||
// 默认值. | ||
return (layouts as any)['default']; | ||
} | ||
class Hook { | ||
@@ -68,3 +71,4 @@ /** | ||
static libs = libs; | ||
static ComponentName = ComponentName1; | ||
static ComponentName = componentEnum.ComponentName; | ||
static getLayout = getLayout; | ||
@@ -71,0 +75,0 @@ // |
@@ -34,2 +34,5 @@ 'use strict'; | ||
components = Array.from(new Set(components)); | ||
if (components.indexOf('navbarView') < 0) { | ||
components.push('navbarView'); | ||
} | ||
} | ||
@@ -36,0 +39,0 @@ |
@@ -49,3 +49,11 @@ import '@bpui/libs/types'; | ||
/** | ||
* 通过route来获得适合的layout组件. | ||
* @param layouts | ||
* @param newRoute | ||
* @param oldRoute | ||
*/ | ||
export function getLayout(layouts: any, newRoute: bp.Location, oldRoute: bp.Location): any; | ||
export interface Hook { | ||
@@ -52,0 +60,0 @@ /** |
26244
18
779