|
| 1 | +<script setup lang="ts"> |
| 2 | +const props = defineProps<{ |
| 3 | + width?: number; |
| 4 | + height?: number; |
| 5 | + text?: string; |
| 6 | + textColor?: string; |
| 7 | +
|
| 8 | + backgroundType?: "gradient" | "plain"; |
| 9 | + backgroundPositionX?: number; |
| 10 | + backgroundPositionY?: number; |
| 11 | + backgroundEndPositionX?: number; |
| 12 | + backgroundEndPositionY?: number; |
| 13 | + backgroundColor?: string; |
| 14 | + backgroundColors?: string[]; |
| 15 | +
|
| 16 | + textAlign?: "left" | "center" | "right"; |
| 17 | + textBorder?: boolean; |
| 18 | + textBorderWidth?: number; |
| 19 | + textBorderColor?: string; |
| 20 | + pattern?: "none" | "dots" | "stripes"; |
| 21 | + topShadow?: boolean; |
| 22 | +}>(); |
| 23 | +
|
| 24 | +import userbarGenerator from '@/external/userbar-generator/src/index'; |
| 25 | +import { useObjectUrl } from '@vueuse/core'; |
| 26 | +
|
| 27 | +const blob = await userbarGenerator({ |
| 28 | + width: props.width, |
| 29 | + height: props.height, |
| 30 | + text: props.text, |
| 31 | + textColor: props.textColor, |
| 32 | +
|
| 33 | + background: props.backgroundType !== undefined ? { |
| 34 | + type: props.backgroundType, |
| 35 | + positionX: props.backgroundPositionX, |
| 36 | + positionY: props.backgroundPositionY, |
| 37 | + endPositionX: props.backgroundEndPositionX, |
| 38 | + endPositionY: props.backgroundEndPositionY, |
| 39 | + colors: props.backgroundColors ?? (props.backgroundColor ? [props.backgroundColor] : undefined) ?? [], |
| 40 | + } : undefined, |
| 41 | +
|
| 42 | + textAlign: props.textAlign, |
| 43 | + textBorder: props.textBorder, |
| 44 | + textBorderWidth: props.textBorderWidth, |
| 45 | + textBorderColor: props.textBorderColor, |
| 46 | + pattern: props.pattern, |
| 47 | + topShadow: props.topShadow, |
| 48 | +}); |
| 49 | +
|
| 50 | +const objectUrl = useObjectUrl(blob); |
| 51 | +</script> |
| 52 | + |
| 53 | +<template> |
| 54 | + <img v-bind="$attrs" :src="objectUrl" > |
| 55 | +</template> |
0 commit comments