Commit 707d3dc0 by 李伟康

修改样式

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