mirror of
https://gitee.com/niucloud-team/niucloud.git
synced 2026-01-26 04:28:10 +00:00
48 lines
1.3 KiB
Vue
48 lines
1.3 KiB
Vue
<template>
|
|
<div class="overflow-hidden" :style="componentStyle">{{ data.value }}</div>
|
|
</template>
|
|
|
|
<script lang="ts" setup>
|
|
import { ref,computed } from 'vue'
|
|
import usePosterStore from '@/stores/modules/poster'
|
|
|
|
const posterStore = usePosterStore()
|
|
|
|
const prop = defineProps({
|
|
value: {
|
|
type: Object,
|
|
default: {}
|
|
}
|
|
})
|
|
|
|
const data = computed(()=> {
|
|
return prop.value;
|
|
})
|
|
|
|
const componentStyle = computed(()=> {
|
|
var style = '';
|
|
style += `font-size: ${prop.value.fontSize}px;color: ${prop.value.fontColor};line-height: ${prop.value.lineHeight + prop.value.fontSize}px;`;
|
|
if(prop.value.x == 'left' || prop.value.x == 'center' || prop.value.x == 'right'){
|
|
style += `text-align: ${prop.value.x};`;
|
|
}
|
|
if(prop.value.weight){
|
|
style += `font-weight: bold;`;
|
|
}
|
|
if(!prop.value.fontFamily || prop.value.fontFamily == 'static/font/SourceHanSansCN-Regular.ttf'){
|
|
style += `font-family: poster_default_font;`;
|
|
}
|
|
let box: any = document.getElementById(prop.value.id)
|
|
if (box) {
|
|
style += `width:${box.offsetWidth}px;height:${box.offsetHeight}px;`;
|
|
}else{
|
|
style += `width:${prop.value.width}px;height:${prop.value.height}px;`;
|
|
}
|
|
return style;
|
|
})
|
|
|
|
defineExpose({})
|
|
|
|
</script>
|
|
|
|
<style lang="scss" scoped></style>
|