mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2025-12-12 09:18:14 +08:00
🚸 查看原图
This commit is contained in:
@@ -1,15 +1,30 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="tp-image-box" @click="showOverlay = true" v-if="localUrl !== undefined">
|
<div class="tp-image-box" @click="showOverlay = true" v-if="localUrl !== undefined">
|
||||||
<img :src="localUrl" :alt="props.data.insert.image" :title="getImageTitle()" />
|
<img :src="localUrl" :alt="props.data.insert.image" :title="getImageTitle()" />
|
||||||
|
<div
|
||||||
|
class="act"
|
||||||
|
@click.stop="showOri = true"
|
||||||
|
title="查看原图"
|
||||||
|
v-if="!showOri"
|
||||||
|
data-html2canvas-ignore
|
||||||
|
>
|
||||||
|
<v-icon size="16" color="white">mdi-magnify</v-icon>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div v-else class="tp-image-load" :title="props.data.insert.image">
|
<div v-else class="tp-image-load" :title="props.data.insert.image">
|
||||||
<v-progress-circular :indeterminate="true" color="primary" size="small" />
|
<v-progress-circular :indeterminate="true" color="primary" size="small" />
|
||||||
<span>加载中...</span>
|
<span>加载中...</span>
|
||||||
</div>
|
</div>
|
||||||
<VpOverlayImage :image="props.data" v-model="showOverlay" />
|
<VpOverlayImage
|
||||||
|
:image="props.data"
|
||||||
|
v-model="showOverlay"
|
||||||
|
v-model:link="localUrl"
|
||||||
|
v-model:ori="showOri"
|
||||||
|
/>
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { computed, onMounted, onUnmounted, ref } from "vue";
|
import showLoading from "@comp/func/loading.js";
|
||||||
|
import { computed, onMounted, onUnmounted, ref, watch } from "vue";
|
||||||
|
|
||||||
import VpOverlayImage from "./vp-overlay-image.vue";
|
import VpOverlayImage from "./vp-overlay-image.vue";
|
||||||
|
|
||||||
@@ -32,6 +47,7 @@ type TpImageProps = { data: TpImage };
|
|||||||
const appStore = useAppStore();
|
const appStore = useAppStore();
|
||||||
const props = defineProps<TpImageProps>();
|
const props = defineProps<TpImageProps>();
|
||||||
const showOverlay = ref<boolean>(false);
|
const showOverlay = ref<boolean>(false);
|
||||||
|
const showOri = ref<boolean>(props.data.insert.image.endsWith(".gif"));
|
||||||
const localUrl = ref<string>();
|
const localUrl = ref<string>();
|
||||||
|
|
||||||
const imgWidth = computed<string>(() => {
|
const imgWidth = computed<string>(() => {
|
||||||
@@ -47,6 +63,17 @@ onMounted(async () => {
|
|||||||
localUrl.value = await saveImgLocal(link);
|
localUrl.value = await saveImgLocal(link);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => showOri.value,
|
||||||
|
async () => {
|
||||||
|
if (!showOri.value) return;
|
||||||
|
await showLoading.start("加载中...");
|
||||||
|
if (localUrl.value) URL.revokeObjectURL(localUrl.value);
|
||||||
|
localUrl.value = await saveImgLocal(props.data.insert.image);
|
||||||
|
await showLoading.end();
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
if (localUrl.value) URL.revokeObjectURL(localUrl.value);
|
if (localUrl.value) URL.revokeObjectURL(localUrl.value);
|
||||||
});
|
});
|
||||||
@@ -68,6 +95,7 @@ function getImageTitle(): string {
|
|||||||
</script>
|
</script>
|
||||||
<style lang="css" scoped>
|
<style lang="css" scoped>
|
||||||
.tp-image-box {
|
.tp-image-box {
|
||||||
|
position: relative;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
@@ -89,4 +117,20 @@ function getImageTitle(): string {
|
|||||||
margin: 10px auto;
|
margin: 10px auto;
|
||||||
column-gap: 5px;
|
column-gap: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.act {
|
||||||
|
position: absolute;
|
||||||
|
right: 5px;
|
||||||
|
bottom: 5px;
|
||||||
|
display: flex;
|
||||||
|
width: 25px;
|
||||||
|
height: 25px;
|
||||||
|
box-sizing: border-box;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
border-radius: 50%;
|
||||||
|
background: var(--tgc-od-white);
|
||||||
|
box-shadow: 0 0 5px rgb(0 0 0 / 50%);
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
<TOverlay v-model="visible" blur-val="10px">
|
<TOverlay v-model="visible" blur-val="10px">
|
||||||
<div class="tpoi-box">
|
<div class="tpoi-box">
|
||||||
<div :class="{ 'tpoi-top-ori': isOriSize, 'tpoi-top': !isOriSize }">
|
<div :class="{ 'tpoi-top-ori': isOriSize, 'tpoi-top': !isOriSize }">
|
||||||
<img :src="localCover" alt="图片" @click="isOriSize = !isOriSize" v-if="localCover" />
|
<img :src="localLink" alt="图片" @click="isOriSize = !isOriSize" />
|
||||||
</div>
|
</div>
|
||||||
<div class="tpoi-bottom">
|
<div class="tpoi-bottom">
|
||||||
<div class="tpoi-info" v-if="props.image.attributes">
|
<div class="tpoi-info" v-if="props.image.attributes">
|
||||||
@@ -13,7 +13,10 @@
|
|||||||
<p>格式:{{ format }}</p>
|
<p>格式:{{ format }}</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="tpoi-tools">
|
<div class="tpoi-tools">
|
||||||
<v-icon @click="setBlackBg" title="切换背景色">mdi-format-color-fill</v-icon>
|
<v-icon @click="setBlackBg" title="切换背景色" v-if="showOri">
|
||||||
|
mdi-format-color-fill
|
||||||
|
</v-icon>
|
||||||
|
<v-icon @click="showOri = true" title="查看原图" v-else>mdi-magnify</v-icon>
|
||||||
<v-icon @click="onCopy" title="复制到剪贴板">mdi-content-copy</v-icon>
|
<v-icon @click="onCopy" title="复制到剪贴板">mdi-content-copy</v-icon>
|
||||||
<v-icon @click="onDownload" title="下载到本地">mdi-download</v-icon>
|
<v-icon @click="onDownload" title="下载到本地">mdi-download</v-icon>
|
||||||
<v-icon @click="visible = false" title="关闭浮窗">mdi-close</v-icon>
|
<v-icon @click="visible = false" title="关闭浮窗">mdi-close</v-icon>
|
||||||
@@ -26,22 +29,21 @@
|
|||||||
import TOverlay from "@comp/app/t-overlay.vue";
|
import TOverlay from "@comp/app/t-overlay.vue";
|
||||||
import showLoading from "@comp/func/loading.js";
|
import showLoading from "@comp/func/loading.js";
|
||||||
import showSnackbar from "@comp/func/snackbar.js";
|
import showSnackbar from "@comp/func/snackbar.js";
|
||||||
import { computed, onMounted, onUnmounted, ref, shallowRef } from "vue";
|
import { computed, ref, shallowRef } from "vue";
|
||||||
|
|
||||||
import type { TpImage } from "./tp-image.vue";
|
import type { TpImage } from "./tp-image.vue";
|
||||||
|
|
||||||
import { useAppStore } from "@/store/modules/app.js";
|
import { copyToClipboard, getImageBuffer, saveCanvasImg } from "@/utils/TGShare.js";
|
||||||
import { copyToClipboard, getImageBuffer, saveCanvasImg, saveImgLocal } from "@/utils/TGShare.js";
|
|
||||||
import { bytesToSize } from "@/utils/toolFunc.js";
|
import { bytesToSize } from "@/utils/toolFunc.js";
|
||||||
|
|
||||||
type TpoImageProps = { image: TpImage };
|
type TpoImageProps = { image: TpImage };
|
||||||
|
|
||||||
const appStore = useAppStore();
|
|
||||||
const props = defineProps<TpoImageProps>();
|
const props = defineProps<TpoImageProps>();
|
||||||
const visible = defineModel<boolean>();
|
const visible = defineModel<boolean>();
|
||||||
|
const localLink = defineModel<string>("link");
|
||||||
|
const showOri = defineModel<boolean>("ori");
|
||||||
const bgMode = ref<number>(0); // 0: transparent, 1: black, 2: white
|
const bgMode = ref<number>(0); // 0: transparent, 1: black, 2: white
|
||||||
const isOriSize = ref<boolean>(false);
|
const isOriSize = ref<boolean>(false);
|
||||||
const localCover = ref<string>();
|
|
||||||
const buffer = shallowRef<Uint8Array | null>(null);
|
const buffer = shallowRef<Uint8Array | null>(null);
|
||||||
const format = computed<string>(() => {
|
const format = computed<string>(() => {
|
||||||
if (props.image.attributes?.ext) return props.image.attributes.ext;
|
if (props.image.attributes?.ext) return props.image.attributes.ext;
|
||||||
@@ -50,16 +52,6 @@ const format = computed<string>(() => {
|
|||||||
return "png";
|
return "png";
|
||||||
});
|
});
|
||||||
|
|
||||||
onMounted(async () => {
|
|
||||||
const link = appStore.getImageUrl(props.image.insert.image);
|
|
||||||
localCover.value = await saveImgLocal(link);
|
|
||||||
});
|
|
||||||
|
|
||||||
onUnmounted(() => {
|
|
||||||
if (localCover.value) URL.revokeObjectURL(localCover.value);
|
|
||||||
buffer.value = null;
|
|
||||||
});
|
|
||||||
|
|
||||||
function setBlackBg(): void {
|
function setBlackBg(): void {
|
||||||
bgMode.value = (bgMode.value + 1) % 3;
|
bgMode.value = (bgMode.value + 1) % 3;
|
||||||
const bgLabelList = ["透明", "黑色", "白色"];
|
const bgLabelList = ["透明", "黑色", "白色"];
|
||||||
|
|||||||
Reference in New Issue
Block a user