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 @@ - - - - - - - - + + + + + + + +