From 2d8812212cfda75cdd9c8bd5359143b13b3f1eda Mon Sep 17 00:00:00 2001 From: fuhao Date: Tue, 10 Sep 2024 16:37:05 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E9=A2=84=E7=BD=AE=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E7=95=8C=E9=9D=A2=E4=BC=98=E5=8C=96):?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/views/board/component/TextPreview.vue | 23 +- ruoyi-ui/src/views/board/content/index.vue | 255 ++++++++++-------- 2 files changed, 158 insertions(+), 120 deletions(-) diff --git a/ruoyi-ui/src/views/board/component/TextPreview.vue b/ruoyi-ui/src/views/board/component/TextPreview.vue index 734bb78a..3486a353 100644 --- a/ruoyi-ui/src/views/board/component/TextPreview.vue +++ b/ruoyi-ui/src/views/board/component/TextPreview.vue @@ -35,7 +35,7 @@ export default { }; }, props: { - fontStyle: { + fontFamily: { type: String, default: 'normal', }, @@ -73,7 +73,15 @@ export default { }, content: { type: String, - default: '这里是示例内容,哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈', + default: '这里是示例内容', + }, + horizontalCenter: { + type: Boolean, + default: false, + }, + verticalCenter: { + type: Boolean, + default: false, }, }, computed: { @@ -85,20 +93,19 @@ export default { background: '#000000', overflow: 'hidden', display: 'flex', - alignItems: 'center', - justifyContent: 'center', + alignItems: this.verticalCenter ? 'center' : 'flex-start', + justifyContent: this.horizontalCenter ? 'center' : 'flex-start', }; }, textStyle() { return { - position: 'absolute', - top: `${-this.fontY * this.scale}px`, - left: `${this.fontX * this.scale}px`, - fontStyle: this.fontStyle, + fontFamily: this.fontFamily, + whiteSpace: 'preserve-breaks', color: this.fontColor, fontSize: `${this.fontSize * this.scale}px`, letterSpacing: `${this.letterSpacing * this.scale}px`, lineHeight: `${this.lineHeight}`, + transform: `translate(${this.horizontalCenter ? this.fontX * this.scale : this.fontX}px, ${this.verticalCenter ? this.fontY * this.scale : this.fontY}px)`, }; }, }, diff --git a/ruoyi-ui/src/views/board/content/index.vue b/ruoyi-ui/src/views/board/content/index.vue index 15927470..c090d0aa 100644 --- a/ruoyi-ui/src/views/board/content/index.vue +++ b/ruoyi-ui/src/views/board/content/index.vue @@ -60,14 +60,14 @@ - - - - - - - - + + + + + + + +