🐛 修复 align:right 不生效的问题

*PostID:51080404
This commit is contained in:
目棃
2024-04-07 14:56:24 +08:00
parent f50398f6e3
commit 98541e1b49

View File

@@ -1,10 +1,10 @@
<template> <template>
<div :style="getLineStyle()" class="tp-texts"> <div :style="getLineStyle()" class="tp-texts">
<TpText v-for="(text, indexT) in props.data.children" :data="text" :key="indexT" /> <TpText v-for="(text, index) in props.data.children" :data="text" :key="index" />
</div> </div>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { onMounted, StyleValue, toRaw } from "vue"; import { StyleValue } from "vue";
import TpText, { type TpText as TpTextType } from "./tp-text.vue"; import TpText, { type TpText as TpTextType } from "./tp-text.vue";
@@ -18,10 +18,6 @@ interface TpTextsProps {
const props = defineProps<TpTextsProps>(); const props = defineProps<TpTextsProps>();
if (props.data.attributes) {
console.warn("TpTexts", props.data.attributes);
}
function getLineStyle(): StyleValue { function getLineStyle(): StyleValue {
const style = <Array<StyleValue>>[]; const style = <Array<StyleValue>>[];
if (props.data.attributes === undefined) { if (props.data.attributes === undefined) {
@@ -31,8 +27,7 @@ function getLineStyle(): StyleValue {
const headerFontSizes = ["2rem", "1.75rem", "1.5rem", "1.25rem", "1rem", "0.75rem"]; const headerFontSizes = ["2rem", "1.75rem", "1.5rem", "1.25rem", "1rem", "0.75rem"];
if (props.data.attributes.align) { if (props.data.attributes.align) {
const ruleAlign: StyleValue = `textAlign: ${props.data.attributes.align}`; const ruleAlign: StyleValue = `textAlign: ${props.data.attributes.align}`;
if (props.data.attributes.align !== "center") style.push("display: inline"); style.push(ruleAlign);
else style.push(ruleAlign);
} }
if (props.data.attributes.header) { if (props.data.attributes.header) {
const ruleHeader: StyleValue = `fontSize: ${headerFontSizes[props.data.attributes.header - 1]}`; const ruleHeader: StyleValue = `fontSize: ${headerFontSizes[props.data.attributes.header - 1]}`;