Commit 707d3dc0 by 李伟康

修改样式

1 parent 0cf1dfcb
......@@ -78,6 +78,7 @@ class Draw {
textWidth,
maxWidth,
fontSize,
lastFont,
opacity,
lineNum,
width,
......@@ -134,16 +135,19 @@ class Draw {
this[_ctx_].textAlign = textAlign
this[_ctx_].lineWidth = this.toRpx(2)
const drawOneLineText = () => {
let textArr = text.split('')
let newText = ''
let textArr = text.split(''),
newText = '',
ellipsis = false
try {
textArr.map(e => {
newText += e
if (this.getTextWidth(newText) > width - fontX) throw newText
if (this.getTextWidth(newText) > width - fontX) throw true
})
} catch (error) {
newText = `${error}…`
ellipsis = error
}
if (ellipsis) newText += '…'
if(lastFont) newText += lastFont
this[_ctx_].fillText(newText, x, y, maxWidth)
if (checkTextDecoration(textDecoration)) {
this.drawDecoration({
......@@ -182,11 +186,11 @@ class Draw {
if (this.getTextWidth(lastText) > width - fontX - this.getTextWidth('…')) throw lastText
})
} catch (error) {
let {lastFont} = textParams
if (lastFont) e = `${error.substring(0, error.length - lastFont.length)}…${lastFont}`
else e = `${error}…`
}
}
if (lastFont && e.indexOf(lastFont) == -1 && textRowArr.length < 2) e = `${e.substring(0, e.length - lastFont.length)}…${lastFont}`
let textHeight = y + index * (lineHeight || fontSize)
this[_ctx_].fillText(e, x, textHeight, maxWidth)
if (checkTextDecoration(textDecoration)) {
......
......@@ -85,12 +85,10 @@ export default {
labelList = [...labelList, '商品名称:', '支付时间:']
valueList = [...valueList, goodsName, new Date(createdDate).format('yyyy年M月d日 hh:mm:ss')]
if (formContentFirst) {
if (formDescribeFirst.length < 5) formDescribeFirst += ':'
labelList.push(formDescribeFirst)
valueList.push(formContentFirst)
}
if (formContentSecond) {
if (formDescribeSecond.length < 5) formDescribeSecond += ':'
labelList.push(formDescribeSecond)
valueList.push(formContentSecond)
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!