@smt-ui/component
Advanced tools
Comparing version 1.1.67 to 1.1.69
{ | ||
"name": "@smt-ui/component", | ||
"version": "1.1.67", | ||
"version": "1.1.69", | ||
"description": "extension base", | ||
@@ -48,3 +48,3 @@ "author": "jialipeng <jialipeng@baidu.com>", | ||
}, | ||
"gitHead": "eb9ab66c1b229fee79bd15422ab0ec960760862c" | ||
"gitHead": "a54eb60f4d3c7b3ba383941aff8a5eaaec9a6fa1" | ||
} |
@@ -8,4 +8,5 @@ /** | ||
import {preventRepeat} from '../../common/utils/index.js'; | ||
import {NAV_PROPS} from '../../common/utils/consts.js'; | ||
import {NAV_PROPS} from '../../common/utils/consts.js'; | ||
// 顶部导航页面中只会出现一次,所以没用缓存 | ||
const { | ||
@@ -61,10 +62,3 @@ statusBarHeight, | ||
data: { | ||
statusBarHeight, | ||
navigationBarHeight, | ||
safeWidth: screenWidth - menuRectWidth, | ||
isIos: platform === 'ios', | ||
iconsMap: { | ||
'arrow-left': 'back', | ||
'home': 'home' | ||
} | ||
isIos: platform === 'ios' | ||
}, | ||
@@ -74,7 +68,73 @@ | ||
attached: function () { | ||
this.appData = { | ||
iconsMap: { | ||
'arrow-left': 'back', | ||
'home': 'home' | ||
}, | ||
safeWidth: screenWidth - menuRectWidth | ||
}; | ||
this.initIcons(); | ||
this.setData({ | ||
computeContainerStyle: this.computeContainerRect(), | ||
computeContentStyle: this.computeContentRect(), | ||
computeScreenWidth: this.computeScreenRect() | ||
}); | ||
} | ||
}, | ||
methods: { | ||
/** | ||
* 初始化容器的行间样式 | ||
* | ||
* @return {string} styleStr 处理后的容器行间样式 | ||
*/ | ||
computeContainerRect() { | ||
let styleStr = ''; | ||
const { | ||
opacity, | ||
frontColor, | ||
backgroundColor, | ||
navigationStyle | ||
} = this.data; | ||
const style = { | ||
opacity, | ||
'padding-top': statusBarHeight + 'px', | ||
'height': navigationBarHeight + 'px', | ||
'color': frontColor, | ||
'background-color': backgroundColor, | ||
...navigationStyle | ||
}; | ||
for (let key in style) { | ||
styleStr += `${key}:${style[key]};`; | ||
} | ||
return styleStr; | ||
}, | ||
/** | ||
* 初始化容器内容的行间样式 | ||
* | ||
* @return {string} styleStr 处理后的容器内容的行间样式 | ||
*/ | ||
computeContentRect() { | ||
const navigationAreaStyle = this.data.navigationAreaStyle; | ||
let styleStr = ''; | ||
for (let key in navigationAreaStyle) { | ||
styleStr += `${key}:${navigationAreaStyle[key]};`; | ||
} | ||
return styleStr; | ||
}, | ||
/** | ||
* 初始化顶部的宽度 | ||
* | ||
* @return {string} 顶部宽度行间样式 | ||
*/ | ||
computeScreenRect() { | ||
return this.data.isFullScreenWidth | ||
? '' | ||
: `width:${this.appData.safeWidth}px`; | ||
}, | ||
/** | ||
* 初始化首页、返回上一级icon | ||
@@ -88,14 +148,19 @@ * | ||
homeIconSize, | ||
backIconSize | ||
backIconSize, | ||
isFullScreenWidth | ||
} = this.data; | ||
const isFullScreenWidthClass = isFullScreenWidth | ||
? ' full-screen-width-mode' | ||
: ' '; | ||
this.setData({ | ||
icons: [{ | ||
type: 'arrow-left', | ||
show: backIcon, | ||
size: backIconSize | ||
size: backIconSize, | ||
class: `${backIcon ? ' ' : ' hide'} ${isFullScreenWidthClass} ` | ||
}, { | ||
type: 'home', | ||
show: homeIcon, | ||
size: homeIconSize | ||
size: homeIconSize, | ||
// 配置了两个icon时,第二个icon增加特殊class | ||
class: `${homeIcon ? (backIcon ? ' second-icon' : '') : ' hide'} ${isFullScreenWidthClass}` | ||
}] | ||
@@ -116,8 +181,8 @@ }); | ||
const type = event.currentTarget.dataset.type; | ||
const eventHdl = `${this.data.iconsMap[type]}Hdl`; | ||
const eventHdl = `${this.appData.iconsMap[type]}Hdl`; | ||
preventRepeat( | ||
() => this.dispatch(eventHdl) | ||
, 120); | ||
, 0); | ||
} | ||
} | ||
}); |
@@ -1,1 +0,1 @@ | ||
{"name":"component","label":"布局组件","type":"component","configPath":"./smart-design-config.json","version":"1.1.66"} | ||
{"name":"component","label":"布局组件","type":"component","configPath":"./smart-design-config.json","version":"1.1.68"} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
1553238
296
11671