|
@@ -0,0 +1,155 @@
|
|
|
+<template>
|
|
|
+ <div class="demo-image">
|
|
|
+ <div v-for="(image, index) in images" :key="image" class="block">
|
|
|
+ <span class="demonstration"> 样例{{ index + 1 }} </span>
|
|
|
+ <el-image style="width: 100px; height: 100px" :src="image" :fit="'contain'" @click="imageClick(index)" />
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script lang="ts" setup>
|
|
|
+import { ref, onMounted } from 'vue'
|
|
|
+import { useCanvasImgStore } from '../store/CanvasImg';
|
|
|
+import { usePdfProperty } from '../store/PdfProperty';
|
|
|
+import { storeToRefs } from 'pinia'
|
|
|
+import { fabric } from 'fabric';
|
|
|
+
|
|
|
+import MagicColor1 from '@/assets/magic_color(1).jpg'
|
|
|
+import MagicColor2 from '@/assets/magic_color(2).jpg'
|
|
|
+import MagicColor3 from '@/assets/magic_color(3).jpg'
|
|
|
+import MagicColor4 from '@/assets/magic_color(4).jpg'
|
|
|
+import MagicColor5 from '@/assets/magic_color(5).jpg'
|
|
|
+
|
|
|
+import OCR1 from '@/assets/ocr(1).jpg'
|
|
|
+import OCR2 from '@/assets/ocr(2).jpg'
|
|
|
+import OCR3 from '@/assets/ocr(3).jpg'
|
|
|
+
|
|
|
+import Dewarp1 from '@/assets/dewarp(1).jpg'
|
|
|
+import Dewarp2 from '@/assets/dewarp(2).jpg'
|
|
|
+
|
|
|
+import LA1 from '@/assets/layout_analysis(1).png'
|
|
|
+import LA2 from '@/assets/layout_analysis(2).png'
|
|
|
+import LA3 from '@/assets/layout_analysis(3).png'
|
|
|
+
|
|
|
+import TableRec1 from '@/assets/table_rec(1).png'
|
|
|
+import TableRec2 from '@/assets/table_rec(2).png'
|
|
|
+import TableRec3 from '@/assets/table_rec(3).png'
|
|
|
+import TableRec4 from '@/assets/table_rec(4).png'
|
|
|
+import TableRec5 from '@/assets/table_rec(5).png'
|
|
|
+
|
|
|
+import Stamp1 from '@/assets/stamp(1).jpg'
|
|
|
+import Stamp2 from '@/assets/stamp(2).jpg'
|
|
|
+import Stamp3 from '@/assets/stamp(3).jpg'
|
|
|
+
|
|
|
+import UIE1 from '@/assets/uie(1).jpg'
|
|
|
+import UIE2 from '@/assets/uie(2).jpg'
|
|
|
+import UIE3 from '@/assets/uie(3).jpg'
|
|
|
+import UIE4 from '@/assets/uie(4).jpg'
|
|
|
+
|
|
|
+const props = defineProps({
|
|
|
+ module: String,
|
|
|
+});
|
|
|
+
|
|
|
+const c_img = useCanvasImgStore();
|
|
|
+const { show_image, show_canvas, fabric_canvas, image_item_index, input_file } = storeToRefs(c_img);
|
|
|
+const pdf = usePdfProperty();
|
|
|
+const { is_pdf } = storeToRefs(pdf);
|
|
|
+
|
|
|
+const fits = ['fill', 'contain', 'cover', 'none', 'scale-down']
|
|
|
+const images: any = ref([])
|
|
|
+onMounted(async () => {
|
|
|
+ if (props.module == 'magic_color') {
|
|
|
+ images.value.push(MagicColor1)
|
|
|
+ images.value.push(MagicColor2)
|
|
|
+ images.value.push(MagicColor3)
|
|
|
+ images.value.push(MagicColor4)
|
|
|
+ images.value.push(MagicColor5)
|
|
|
+ } else if (props.module == 'ocr') {
|
|
|
+ images.value.push(OCR1)
|
|
|
+ images.value.push(OCR2)
|
|
|
+ images.value.push(OCR3)
|
|
|
+ } else if (props.module == 'table_rec') {
|
|
|
+ images.value.push(TableRec1)
|
|
|
+ images.value.push(TableRec2)
|
|
|
+ images.value.push(TableRec3)
|
|
|
+ images.value.push(TableRec4)
|
|
|
+ images.value.push(TableRec5)
|
|
|
+ } else if (props.module == 'layout_analysis') {
|
|
|
+ images.value.push(LA1)
|
|
|
+ images.value.push(LA2)
|
|
|
+ images.value.push(LA3)
|
|
|
+ } else if (props.module == 'dewarp') {
|
|
|
+ images.value.push(Dewarp1)
|
|
|
+ images.value.push(Dewarp2)
|
|
|
+ } else if (props.module == 'stamp') {
|
|
|
+ images.value.push(Stamp1)
|
|
|
+ images.value.push(Stamp2)
|
|
|
+ images.value.push(Stamp3)
|
|
|
+ } else if (props.module == 'uie') {
|
|
|
+ images.value.push(UIE1)
|
|
|
+ images.value.push(UIE2)
|
|
|
+ // images.value.push(UIE3)
|
|
|
+ // images.value.push(UIE4)
|
|
|
+ }
|
|
|
+ imageClick(0)
|
|
|
+ image_item_index.value = 0
|
|
|
+});
|
|
|
+
|
|
|
+async function imageClick(index: number) {
|
|
|
+ if (fabric_canvas.value != null) {
|
|
|
+ fabric_canvas.value.dispose();
|
|
|
+ fabric_canvas.value = null;
|
|
|
+ }
|
|
|
+ image_item_index.value = index
|
|
|
+
|
|
|
+ show_image.value.src = images.value[index]
|
|
|
+ show_image.value.onload = () => {
|
|
|
+ show_canvas.value.width = show_image.value.width;
|
|
|
+ show_canvas.value.height = show_image.value.height;
|
|
|
+ fabric_canvas.value = new fabric.Canvas(show_canvas.value);
|
|
|
+ fabric_canvas.value.clear()
|
|
|
+ }
|
|
|
+ Image2File(images.value[index])
|
|
|
+ is_pdf.value = false
|
|
|
+}
|
|
|
+
|
|
|
+function Image2File(image: any) {
|
|
|
+ fetch(image)
|
|
|
+ .then(res => res.blob())
|
|
|
+ .then(blob => {
|
|
|
+ // 创建File对象
|
|
|
+ input_file.value = new File([blob], 'image.png', { type: 'image/png' })
|
|
|
+ })
|
|
|
+ .catch(err => console.error(err))
|
|
|
+}
|
|
|
+</script>
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+<style scoped>
|
|
|
+.demo-image {
|
|
|
+ width: 100%;
|
|
|
+ height: auto;
|
|
|
+}
|
|
|
+
|
|
|
+.block {
|
|
|
+ padding: 30px 0;
|
|
|
+ text-align: center;
|
|
|
+ border-right: solid 1px var(--el-border-color);
|
|
|
+ display: inline-block;
|
|
|
+ width: 20%;
|
|
|
+ box-sizing: border-box;
|
|
|
+ vertical-align: top;
|
|
|
+}
|
|
|
+
|
|
|
+.demo-image .block:last-child {
|
|
|
+ border-right: none;
|
|
|
+}
|
|
|
+
|
|
|
+.demo-image .demonstration {
|
|
|
+ display: block;
|
|
|
+ color: var(--el-text-color-secondary);
|
|
|
+ font-size: 14px;
|
|
|
+ margin-bottom: 20px;
|
|
|
+}
|
|
|
+</style>
|