提交 e8339526 编写于 作者: Q qiang

Merge branch 'dev' into alpha

...@@ -113,7 +113,7 @@ global.onAppShow = function(){}; ...@@ -113,7 +113,7 @@ global.onAppShow = function(){};
` : '' ` : ''
return { return {
devtool: process.env.NODE_ENV === 'production' ? false : 'source-map', devtool: process.env.NODE_ENV === 'production' ? false : 'cheap-module-eval-source-map',
resolve: { resolve: {
extensions: ['.nvue'], extensions: ['.nvue'],
alias: { alias: {
......
...@@ -17,7 +17,7 @@ const { ...@@ -17,7 +17,7 @@ const {
} = require('@dcloudio/uni-cli-shared/lib/cache') } = require('@dcloudio/uni-cli-shared/lib/cache')
const { const {
pagesJsonJsFileName, // pagesJsonJsFileName,
initAutoImportComponents initAutoImportComponents
} = require('@dcloudio/uni-cli-shared/lib/pages') } = require('@dcloudio/uni-cli-shared/lib/pages')
...@@ -41,11 +41,11 @@ module.exports = function (content) { ...@@ -41,11 +41,11 @@ module.exports = function (content) {
isAppView = params.type === 'view' isAppView = params.type === 'view'
} }
const pagesJsonJsPath = path.resolve(process.env.UNI_INPUT_DIR, pagesJsonJsFileName) // const pagesJsonJsPath = path.resolve(process.env.UNI_INPUT_DIR, pagesJsonJsFileName)
const manifestJsonPath = path.resolve(process.env.UNI_INPUT_DIR, 'manifest.json') const manifestJsonPath = path.resolve(process.env.UNI_INPUT_DIR, 'manifest.json')
const manifestJson = parseManifestJson(fs.readFileSync(manifestJsonPath, 'utf8')) const manifestJson = parseManifestJson(fs.readFileSync(manifestJsonPath, 'utf8'))
this.addDependency(pagesJsonJsPath) // this.addDependency(pagesJsonJsPath)
this.addDependency(manifestJsonPath) this.addDependency(manifestJsonPath)
const pagesJson = parsePagesJson(content, { const pagesJson = parsePagesJson(content, {
......
<template>
<uni-cover-view
v-on="$listeners">
<div
ref="container"
class="uni-cover-view"/>
</uni-cover-view>
</template>
<script> <script>
import native from '../../mixins/native' import native from '../../mixins/native'
import cover from '../../mixins/cover' import cover from '../../mixins/cover'
...@@ -20,20 +12,23 @@ export default { ...@@ -20,20 +12,23 @@ export default {
coverContent: '' coverContent: ''
} }
}, },
watch: {}, render (createElement) {
mounted () { let coverContent = ''
this._updateContent() const $slots = this.$slots.default || []
this.$watch('$slot', this._updateContent) $slots.forEach(node => {
}, if (!node.tag) {
methods: { coverContent += node.text || ''
_updateContent (val) { }
const $slots = this.$slots.default || [] })
$slots.forEach(node => { this.coverContent = coverContent
if (!node.tag) { return createElement('uni-cover-view', {
this.coverContent += node.text || '' on: {
} on: this.$listeners
}) }
} }, [createElement('div', {
ref: 'container',
staticClass: 'uni-cover-view'
}, [coverContent])])
} }
} }
</script> </script>
......
const base = ['padding', 'borderRadius', 'borderColor', 'borderWidth', 'backgroundColor'] const base = ['borderRadius', 'borderColor', 'borderWidth', 'backgroundColor']
const text = ['color', 'textAlign', 'lineHeight', 'fontSize', 'fontWeight', 'textOverflow', 'whiteSpace'] const text = ['paddingTop', 'paddingRight', 'paddingBottom', 'paddingLeft', 'color', 'textAlign', 'lineHeight', 'fontSize', 'fontWeight', 'textOverflow', 'whiteSpace']
const image = [] const image = []
const textAlign = { start: 'left', end: 'right' } const textAlign = { start: 'left', end: 'right' }
let index = 0 let index = 0
...@@ -35,30 +35,42 @@ export default { ...@@ -35,30 +35,42 @@ export default {
tags () { tags () {
const position = this._getTagPosition() const position = this._getTagPosition()
const style = this.style const style = this.style
return [ const tags = [{
{ tag: 'rect',
tag: 'rect', position,
position, rectStyles: {
rectStyles: { color: style.backgroundColor,
color: style.backgroundColor, radius: style.borderRadius,
radius: style.borderRadius, borderColor: style.borderColor,
borderColor: style.borderColor, borderWidth: style.borderWidth
borderWidth: style.borderWidth }
} }]
}, if (this.coverType === 'image') {
this.coverType === 'image' ? { tags.push({
tag: 'img', tag: 'img',
position, position,
src: this.coverContent src: this.coverContent
} : { })
} else {
const lineSpacing = parseFloat(style.lineHeight) - parseFloat(style.fontSize)
let width = parseFloat(position.width) - parseFloat(style.paddingLeft) - parseFloat(style.paddingRight)
width = width < 0 ? 0 : width
let height = parseFloat(position.height) - parseFloat(style.paddingTop) - lineSpacing / 2 - parseFloat(style.paddingBottom)
height = height < 0 ? 0 : height
tags.push({
tag: 'font', tag: 'font',
position, position: {
top: `${parseFloat(position.top) + parseFloat(style.paddingTop) + lineSpacing / 2}px`,
left: `${parseFloat(position.left) + parseFloat(style.paddingLeft)}px`,
width: `${width}px`,
height: `${height}px`
},
textStyles: { textStyles: {
align: textAlign[style.textAlign] || style.textAlign, align: textAlign[style.textAlign] || style.textAlign,
color: style.color, color: style.color,
decoration: 'none', decoration: 'none',
lineSpacing: (parseFloat(style.lineHeight) - parseFloat(style.fontSize)) + 'px', lineSpacing: `${lineSpacing}px`,
margin: style.padding, margin: '0px',
overflow: style.textOverflow, overflow: style.textOverflow,
size: style.fontSize, size: style.fontSize,
verticalAlign: 'top', verticalAlign: 'top',
...@@ -66,8 +78,9 @@ export default { ...@@ -66,8 +78,9 @@ export default {
whiteSpace: style.whiteSpace whiteSpace: style.whiteSpace
}, },
text: this.coverContent text: this.coverContent
} })
] }
return tags
} }
}, },
mounted () { mounted () {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册