mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2025-12-06 08:32:51 +08:00
🐛 修复自定义表情格式解析异常,增加文本清晰度
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
<!-- 自定义表情组件 -->
|
||||||
<template>
|
<template>
|
||||||
<div class="tp-emo-box" title="自定义表情" v-if="localUrl !== undefined">
|
<div class="tp-emo-box" title="自定义表情" v-if="localUrl !== undefined">
|
||||||
<img
|
<img
|
||||||
@@ -18,6 +19,7 @@
|
|||||||
v-model="showOverlay"
|
v-model="showOverlay"
|
||||||
v-model:link="localUrl"
|
v-model:link="localUrl"
|
||||||
:ori="true"
|
:ori="true"
|
||||||
|
:format="fmt"
|
||||||
v-model:bgColor="bgColor"
|
v-model:bgColor="bgColor"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
@@ -28,34 +30,58 @@ import { computed, onMounted, onUnmounted, ref } from "vue";
|
|||||||
import type { TpImage } from "./tp-image.vue";
|
import type { TpImage } from "./tp-image.vue";
|
||||||
import VpOverlayImage from "./vp-overlay-image.vue";
|
import VpOverlayImage from "./vp-overlay-image.vue";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 自定义表情组件数据
|
||||||
|
*/
|
||||||
type TpCustomEmoticon = {
|
type TpCustomEmoticon = {
|
||||||
|
/* 插入内容 */
|
||||||
insert: {
|
insert: {
|
||||||
|
/* 自定义表情 */
|
||||||
backup_text: "[自定义表情]";
|
backup_text: "[自定义表情]";
|
||||||
|
/* 自定义表情信息 */
|
||||||
custom_emoticon: {
|
custom_emoticon: {
|
||||||
|
/* 表情ID */
|
||||||
id: string;
|
id: string;
|
||||||
|
/* 表情链接 */
|
||||||
url: string;
|
url: string;
|
||||||
size: { width: number; height: number; file_size?: number };
|
/* 表情尺寸 */
|
||||||
|
size: {
|
||||||
|
/* 宽度 */
|
||||||
|
width: number;
|
||||||
|
/* 高度 */
|
||||||
|
height: number;
|
||||||
|
/* 文件大小 */
|
||||||
|
file_size?: number;
|
||||||
|
};
|
||||||
|
/* 是否可用 */
|
||||||
is_available: boolean;
|
is_available: boolean;
|
||||||
|
/* 哈希值 */
|
||||||
hash: string;
|
hash: string;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
type TpEmoticonProps = { data: TpCustomEmoticon };
|
/**
|
||||||
|
* 自定义表情组件属性
|
||||||
|
*/
|
||||||
|
type TpEmoticonProps = {
|
||||||
|
/* 组件数据 */
|
||||||
|
data: TpCustomEmoticon;
|
||||||
|
};
|
||||||
|
|
||||||
const props = defineProps<TpEmoticonProps>();
|
const props = defineProps<TpEmoticonProps>();
|
||||||
|
|
||||||
const localUrl = ref<string>();
|
const localUrl = ref<string>();
|
||||||
const showOverlay = ref<boolean>(false);
|
const showOverlay = ref<boolean>(false);
|
||||||
const bgColor = ref<string>("transparent");
|
const bgColor = ref<string>("transparent");
|
||||||
const image = computed<TpImage>(() => {
|
const fmt = computed<string>(() => getImageExt());
|
||||||
return {
|
const image = computed<TpImage>(() => ({
|
||||||
insert: { image: props.data.insert.custom_emoticon.url },
|
insert: { image: props.data.insert.custom_emoticon.url },
|
||||||
attributes: {
|
attributes: {
|
||||||
width: props.data.insert.custom_emoticon.size.width,
|
width: props.data.insert.custom_emoticon.size.width,
|
||||||
height: props.data.insert.custom_emoticon.size.height,
|
height: props.data.insert.custom_emoticon.size.height,
|
||||||
size: props.data.insert.custom_emoticon.size.file_size,
|
size: props.data.insert.custom_emoticon.size.file_size,
|
||||||
},
|
},
|
||||||
};
|
}));
|
||||||
});
|
|
||||||
|
|
||||||
console.log("tp-emoticon", props.data.insert.custom_emoticon);
|
console.log("tp-emoticon", props.data.insert.custom_emoticon);
|
||||||
|
|
||||||
@@ -66,6 +92,11 @@ onMounted(async () => {
|
|||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
if (localUrl.value) URL.revokeObjectURL(localUrl.value);
|
if (localUrl.value) URL.revokeObjectURL(localUrl.value);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function getImageExt(): string {
|
||||||
|
const arr = props.data.insert.custom_emoticon.url.split(".");
|
||||||
|
return arr[arr.length - 1];
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.tp-emo-box {
|
.tp-emo-box {
|
||||||
@@ -102,6 +133,7 @@ onUnmounted(() => {
|
|||||||
cursor: default;
|
cursor: default;
|
||||||
font-family: var(--font-title);
|
font-family: var(--font-title);
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
|
text-shadow: 1px 1px 1px var(--tgc-dark-1);
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
Reference in New Issue
Block a user