mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2025-12-12 09:18:14 +08:00
💄 调整图片样式
This commit is contained in:
@@ -1,16 +1,18 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="tp-image-box" @click="showOverlay = true">
|
<div class="tp-image-box" @click="showOverlay = true">
|
||||||
<img
|
<div :style="{ width: getWidth }">
|
||||||
:style="getImageStyle()"
|
<img
|
||||||
:src="localUrl"
|
:style="getImageStyle()"
|
||||||
:alt="props.data.insert.image"
|
:src="localUrl"
|
||||||
:title="getImageTitle()"
|
:alt="props.data.insert.image"
|
||||||
/>
|
:title="getImageTitle()"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<TpoImage :image="props.data" v-model="showOverlay" />
|
<TpoImage :image="props.data" v-model="showOverlay" />
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { StyleValue, ref, onMounted, onUnmounted } from "vue";
|
import { StyleValue, ref, onMounted, onUnmounted, computed } from "vue";
|
||||||
|
|
||||||
import { saveImgLocal } from "../../utils/TGShare.js";
|
import { saveImgLocal } from "../../utils/TGShare.js";
|
||||||
import { bytesToSize } from "../../utils/toolFunc.js";
|
import { bytesToSize } from "../../utils/toolFunc.js";
|
||||||
@@ -45,6 +47,11 @@ onMounted(async () => {
|
|||||||
localUrl.value = await saveImgLocal(link);
|
localUrl.value = await saveImgLocal(link);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const getWidth = computed(() => {
|
||||||
|
if (props.data.attributes == undefined) return "auto";
|
||||||
|
return `${props.data.attributes.width}px`;
|
||||||
|
});
|
||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
if (localUrl.value) URL.revokeObjectURL(localUrl.value);
|
if (localUrl.value) URL.revokeObjectURL(localUrl.value);
|
||||||
});
|
});
|
||||||
@@ -84,6 +91,9 @@ function getImageUrl(): string {
|
|||||||
</script>
|
</script>
|
||||||
<style lang="css" scoped>
|
<style lang="css" scoped>
|
||||||
.tp-image-box {
|
.tp-image-box {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
margin: 10px auto;
|
margin: 10px auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user