51 lines
1.4 KiB
Vue
51 lines
1.4 KiB
Vue
<script setup lang="ts">
|
|
import { computed } from "vue";
|
|
import { avatarColor, isHuman } from "./avatar-constants";
|
|
|
|
const props = withDefaults(defineProps<{ type: string; size?: number }>(), { size: 36 });
|
|
const color = computed(() => avatarColor(props.type));
|
|
const human = computed(() => isHuman(props.type));
|
|
</script>
|
|
|
|
<template>
|
|
<span
|
|
class="inline-flex shrink-0 items-center justify-center rounded-xl"
|
|
:style="{ width: `${size}px`, height: `${size}px`, backgroundColor: color.bg }"
|
|
>
|
|
<!-- 真人 -->
|
|
<svg
|
|
v-if="human"
|
|
:width="size * 0.58"
|
|
:height="size * 0.58"
|
|
viewBox="0 0 24 24"
|
|
fill="none"
|
|
:stroke="color.fg"
|
|
stroke-width="2"
|
|
stroke-linecap="round"
|
|
stroke-linejoin="round"
|
|
>
|
|
<circle cx="12" cy="8" r="4" />
|
|
<path d="M4 21c0-4 4-6 8-6s8 2 8 6" />
|
|
</svg>
|
|
<!-- 机器人 -->
|
|
<svg
|
|
v-else
|
|
:width="size * 0.6"
|
|
:height="size * 0.6"
|
|
viewBox="0 0 24 24"
|
|
fill="none"
|
|
:stroke="color.fg"
|
|
stroke-width="2"
|
|
stroke-linecap="round"
|
|
stroke-linejoin="round"
|
|
>
|
|
<rect x="4" y="8" width="16" height="11" rx="3" />
|
|
<path d="M12 8V4" />
|
|
<circle cx="12" cy="3" r="1" :fill="color.fg" />
|
|
<circle cx="9" cy="13" r="1.2" :fill="color.fg" stroke="none" />
|
|
<circle cx="15" cy="13" r="1.2" :fill="color.fg" stroke="none" />
|
|
<path d="M9 16.5h6" />
|
|
</svg>
|
|
</span>
|
|
</template>
|