Commit 28791da8 authored by chenqikuai's avatar chenqikuai

fix

parent 59a8f53c
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<Transition> <Transition>
<div <div
v-if="visible" v-if="visible"
class="fixed h-screen w-screen top-0 left-0 flex items-center justify-center flex-col z-30" class="fixed h-screen w-screen top-0 left-0 flex items-center flex-col z-30"
> >
<div class="opacity-70 bg-black absolute w-full h-full"></div> <div class="opacity-70 bg-black absolute w-full h-full"></div>
<div <div
...@@ -11,17 +11,23 @@ ...@@ -11,17 +11,23 @@
> >
<img src="@/assets/img/close.png" class="w-9" alt="" srcset="" /> <img src="@/assets/img/close.png" class="w-9" alt="" srcset="" />
</div> </div>
<ElImage <div
id="imageDisplay" style="height: 100%"
:src="url" class="flex flex-col justify-center items-center"
:style="{ >
transform: `scale(${scale})`, <ElImage
zIndex: 1, id="imageDisplay"
position: 'relative', :src="url"
}" :style="{
/> height: '70%',
<div class="relative z-10"> zIndex: 1,
<slot></slot> position: 'relative',
overflow: 'hidden',
}"
/>
<div class="relative z-10">
<slot></slot>
</div>
</div> </div>
</div> </div>
</Transition> </Transition>
...@@ -29,7 +35,7 @@ ...@@ -29,7 +35,7 @@
<script setup lang="ts"> <script setup lang="ts">
import { ElImage } from "element-plus"; import { ElImage } from "element-plus";
import { ref, watch } from "vue"; import { ref, useSlots, watch } from "vue";
import { useEventListener } from "@vueuse/core"; import { useEventListener } from "@vueuse/core";
const props = defineProps<{ const props = defineProps<{
...@@ -37,30 +43,12 @@ const props = defineProps<{ ...@@ -37,30 +43,12 @@ const props = defineProps<{
url: string; url: string;
}>(); }>();
const emit = defineEmits(["update:visible"]); const emit = defineEmits(["update:visible"]);
const scale = ref(1);
watch(
() => [props.visible, props.url],
() => {
scale.value = 1;
}
);
useEventListener(window, "keydown", (e) => { useEventListener(window, "keydown", (e) => {
if (e.key === "Escape") { if (e.key === "Escape") {
emit("update:visible", false); emit("update:visible", false);
} }
}); });
useEventListener(document, "wheel", (e) => {
if (e.deltaY > 0) {
if (scale.value < 0.2) return;
scale.value /= 1.1;
} else {
if (scale.value > 7) return;
scale.value *= 1.1;
}
});
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
......
...@@ -66,6 +66,7 @@ ...@@ -66,6 +66,7 @@
打印证书 打印证书
</div> </div>
</div> </div>
<div class="flex-grow"></div>
</ImageDisplay> </ImageDisplay>
</div> </div>
</div> </div>
......
...@@ -94,8 +94,9 @@ ...@@ -94,8 +94,9 @@
<div class="imgBtn" @click="printJS('imageDisplay', 'html')"> <div class="imgBtn" @click="printJS('imageDisplay', 'html')">
打印证书 打印证书
</div> </div>
</div></ImageDisplay </div>
> <div class="flex-grow"></div>
</ImageDisplay>
</LayoutVue> </LayoutVue>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment