|
@@ -1,5 +1,5 @@
|
|
|
<template>
|
|
|
- <el-row :gutter="20">
|
|
|
+ <el-row :gutter="20" class="page">
|
|
|
<el-col :span="12" class="place">
|
|
|
<el-row class="small-title">
|
|
|
<h2>版面分析</h2>
|
|
@@ -7,46 +7,19 @@
|
|
|
<el-row style="color: gray; font-size: small;">
|
|
|
<p>目前支持检测图片与表格</p>
|
|
|
</el-row>
|
|
|
+ <el-row>
|
|
|
+ <ShowImage :show-src-image=true />
|
|
|
+ </el-row>
|
|
|
+ <el-row>
|
|
|
+ <FileUpload />
|
|
|
+ </el-row>
|
|
|
<el-row style="color: gray; font-size: small;">
|
|
|
- <h4>支持jpg, png, bmp, pdf等文件格式</h4>
|
|
|
+ <h4>支持jpg, png, bmp, pdf等文件格式,点击灰色区域或者直接拖拽文件至灰色区域上传文件</h4>
|
|
|
</el-row>
|
|
|
- <div class="common-layout">
|
|
|
- <el-upload class="upload-demo" drag :before-upload="beforeUpload" multiple>
|
|
|
- <el-icon class="el-icon--upload"><upload-filled /></el-icon>
|
|
|
- <div class="el-upload__text">
|
|
|
- Drop file here or <em>click to upload</em>
|
|
|
- </div>
|
|
|
- <template #tip>
|
|
|
- <div class="el-upload__tip">
|
|
|
- {{ fileName }}
|
|
|
- </div>
|
|
|
- </template>
|
|
|
- </el-upload>
|
|
|
+ <el-row style="position: absolute;">
|
|
|
+ <PdfPreview />
|
|
|
<el-button type="primary" @click="predict" :loading="loading">Predict</el-button>
|
|
|
- </div>
|
|
|
- <div v-show="is_pdf">
|
|
|
- <el-row>
|
|
|
- <el-button-group>
|
|
|
- <el-button type="primary" :icon="ArrowLeft" @click="prePage">上一页</el-button>
|
|
|
- <el-button type="primary" @click="nextPage">
|
|
|
- 下一页<el-icon class="el-icon--right">
|
|
|
- <ArrowRight />
|
|
|
- </el-icon>
|
|
|
- </el-button>
|
|
|
- </el-button-group>
|
|
|
- <div class="page-tool-item">{{ state.pageNum }}/{{ state.numPages }}</div>
|
|
|
- <el-container>
|
|
|
- <el-input type="number" v-model="pdf_page"></el-input>
|
|
|
- <el-button type="primary" @click="SetPdfPage" plain>页面跳转</el-button>
|
|
|
- </el-container>
|
|
|
- </el-row>
|
|
|
- </div>
|
|
|
- <el-row>
|
|
|
- <!-- 用于展示图片 -->
|
|
|
- <img id="show-img" class="show-area" />
|
|
|
</el-row>
|
|
|
- <canvas id="canvas"></canvas>
|
|
|
- <canvas id="img_canvas" style="display: none;"></canvas>
|
|
|
</el-col>
|
|
|
<el-col :span="12" class="place">
|
|
|
<el-row class="small-title">
|
|
@@ -83,159 +56,32 @@
|
|
|
<script lang="ts" setup>
|
|
|
import { Detection, SubmitBug } from '../../../../api/api'
|
|
|
import { fabric } from 'fabric';
|
|
|
-import { reactive, ref } from 'vue'
|
|
|
-import { onMounted } from "vue";
|
|
|
-import { createLoadingTask } from "vue3-pdfjs/esm"; // 获得总页数
|
|
|
-import {
|
|
|
- ArrowLeft,
|
|
|
- ArrowRight,
|
|
|
- UploadFilled
|
|
|
-} from '@element-plus/icons-vue'
|
|
|
+import { reactive, ref, onMounted } from 'vue'
|
|
|
|
|
|
import { storeToRefs } from 'pinia'
|
|
|
-import { useServerIpStore } from '../../../../store/ServerIp';
|
|
|
-import { useServerPortStore } from '../../../../store/ServerPort';
|
|
|
-
|
|
|
-const si = useServerIpStore();
|
|
|
-const { server_ip } = storeToRefs(si);
|
|
|
-const sp = useServerPortStore();
|
|
|
-const { server_port } = storeToRefs(sp);
|
|
|
-
|
|
|
-const api = "/v1/detection/layout_parser";
|
|
|
-
|
|
|
-let loadingTask: any;
|
|
|
-const is_pdf = ref(false);
|
|
|
-const pdf_page = ref(1);
|
|
|
-const pdf_img: any = ref("")
|
|
|
-
|
|
|
-const input_file = ref(null as unknown as File)
|
|
|
-
|
|
|
-const state = reactive({
|
|
|
- source: "", //预览pdf文件地址
|
|
|
- pageNum: 1, //当前页面
|
|
|
- numPages: 0, // 总页数
|
|
|
-});
|
|
|
-
|
|
|
-function dataURLtoBlob(dataURL: any) {
|
|
|
- var arr = dataURL.split(','),
|
|
|
- mime = arr[0].match(/:(.*?);/)[1],
|
|
|
- bstr = atob(arr[1]),
|
|
|
- n = bstr.length,
|
|
|
- u8arr = new Uint8Array(n);
|
|
|
- while (n--) {
|
|
|
- u8arr[n] = bstr.charCodeAt(n);
|
|
|
- }
|
|
|
- return new Blob([u8arr], { type: mime });
|
|
|
-}
|
|
|
-
|
|
|
-function getPdfImage(index: number) {
|
|
|
- console.log(index, state.pageNum)
|
|
|
- const showImg = document.getElementById("show-img") as HTMLImageElement;
|
|
|
- loadingTask.promise.then((pdf: any) => {
|
|
|
- state.numPages = pdf.numPages;
|
|
|
- pdf.getPage(index).then((page: any) => {
|
|
|
- const viewport = page.getViewport({ scale: 2.0 })
|
|
|
- img_canvas.value.height = viewport.height;
|
|
|
- img_canvas.value.width = viewport.width;
|
|
|
- canvas.value.height = viewport.height;
|
|
|
- canvas.value.width = viewport.width;
|
|
|
- const destWidth = 398;
|
|
|
- img_canvas.value.style.width = destWidth + 'px';
|
|
|
-
|
|
|
- img_canvas.value.style.height = destWidth * (viewport.height / viewport.width) + 'px';
|
|
|
- canvas.value.style.width = destWidth + 'px';
|
|
|
-
|
|
|
- canvas.value.style.height = destWidth * (viewport.height / viewport.width) + 'px';
|
|
|
- const ctx = img_canvas.value.getContext('2d');
|
|
|
- page.render({
|
|
|
- canvasContext: ctx,
|
|
|
- viewport,
|
|
|
- });
|
|
|
- img_canvas.value.toBlob(function (blob) {
|
|
|
- let data = img_canvas.value.toDataURL('images/png', 1.0)
|
|
|
- pdf_img.value = dataURLtoBlob(data)
|
|
|
- showImg.src = data;
|
|
|
- showImg.onload = () => {
|
|
|
- canvas.value.width = showImg.width;
|
|
|
- canvas.value.height = showImg.height;
|
|
|
- if (fa_canvas != null) {
|
|
|
- fa_canvas.dispose();
|
|
|
- fa_canvas = null;
|
|
|
- }
|
|
|
- fa_canvas = new fabric.Canvas(canvas.value);
|
|
|
- fa_canvas.clear()
|
|
|
- figure_rects.splice(0)
|
|
|
- table_rects.splice(0)
|
|
|
- figureSelectedItem.value = -1;
|
|
|
- tableSelectedItem.value = -1;
|
|
|
- }
|
|
|
- });
|
|
|
- })
|
|
|
- });
|
|
|
-}
|
|
|
-
|
|
|
-function SetPdfPage() {
|
|
|
- if (pdf_page.value >= 1 && pdf_page.value <= state.numPages) {
|
|
|
- console.log(pdf_page.value)
|
|
|
- state.pageNum = Number(pdf_page.value);
|
|
|
- getPdfImage(state.pageNum);
|
|
|
- } else {
|
|
|
- console.log(pdf_page.value)
|
|
|
- alert('输入的pdf页面无效!')
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-function prePage() {
|
|
|
- if (state.pageNum > 1) {
|
|
|
- state.pageNum -= 1;
|
|
|
- getPdfImage(state.pageNum);
|
|
|
- }
|
|
|
-}
|
|
|
+import { useServerStore } from '../../../../store/Server';
|
|
|
+import { useCanvasImgStore } from '../../../../store/CanvasImg';
|
|
|
|
|
|
-function nextPage() {
|
|
|
- if (state.pageNum < state.numPages) {
|
|
|
- state.pageNum += 1;
|
|
|
- getPdfImage(state.pageNum);
|
|
|
- }
|
|
|
-}
|
|
|
+import FileUpload from '../../../../components/FileUpload.vue'
|
|
|
+import ShowImage from '../../../../components/ShowImage.vue'
|
|
|
+import PdfPreview from '../../../../components/PdfPreview.vue'
|
|
|
|
|
|
-// 构建 File 对象
|
|
|
-function blobToFile(blob: any, fileName: any) {
|
|
|
- blob.lastModifiedDate = new Date();
|
|
|
- blob.name = fileName;
|
|
|
- return blob;
|
|
|
-}
|
|
|
+const si = useServerStore();
|
|
|
+const { server_ip, server_port, api_layout_analysis } = storeToRefs(si);
|
|
|
+const my_canvas = useCanvasImgStore();
|
|
|
+const { input_file, fabric_canvas, show_canvas, show_image } = storeToRefs(my_canvas);
|
|
|
|
|
|
-async function convertCanvasToFile(canvas: HTMLCanvasElement, fileName: any) {
|
|
|
- // 将 Canvas 转为 Blob 对象
|
|
|
- const blob = await new Promise(resolve => canvas.toBlob(blob => {
|
|
|
- resolve(blob);
|
|
|
- }, pdf_img.value.type, 1.0));
|
|
|
- // 手动构造 File 对象
|
|
|
- let file = null;
|
|
|
- try {
|
|
|
- file = new File([pdf_img.value], fileName, { type: pdf_img.value.type });
|
|
|
- } catch (e) {
|
|
|
- // Safari 浏览器不支持直接通过 new File() 创建文件对象,需要手动构造
|
|
|
- const rawFile = blobToFile(blob, fileName);
|
|
|
- file = Object.assign(rawFile, { lastModifiedDate: new Date(), name: fileName });
|
|
|
- }
|
|
|
- return file;
|
|
|
-}
|
|
|
|
|
|
let loading = ref(false)
|
|
|
let show_predict = ref(false)
|
|
|
let predictTime = ref(0)
|
|
|
const fileName = ref(null as unknown as string);
|
|
|
-const canvas = ref(null as unknown as HTMLCanvasElement);
|
|
|
-const img_canvas = ref(null as unknown as HTMLCanvasElement);
|
|
|
let figureSelectedItem = ref(-1)
|
|
|
let tableSelectedItem = ref(-1)
|
|
|
|
|
|
let figureArr: any = ref([])
|
|
|
let tableArr: any = ref([])
|
|
|
|
|
|
-let fa_canvas: any = null;
|
|
|
let bugId = ref("");
|
|
|
const json_result = ref("");
|
|
|
|
|
@@ -249,56 +95,6 @@ interface iRect {
|
|
|
let figure_rects: any = []
|
|
|
let table_rects: any = []
|
|
|
|
|
|
-onMounted(async () => {
|
|
|
- canvas.value = document.getElementById("canvas") as HTMLCanvasElement;
|
|
|
- img_canvas.value = document.getElementById("img_canvas") as HTMLCanvasElement;
|
|
|
-});
|
|
|
-
|
|
|
-const beforeUpload = (file: File): boolean | Promise<boolean> => {
|
|
|
- if (fa_canvas != null) {
|
|
|
- fa_canvas.dispose();
|
|
|
- fa_canvas = null;
|
|
|
- }
|
|
|
-
|
|
|
- const showImg = document.getElementById("show-img") as HTMLImageElement;
|
|
|
-
|
|
|
- const post_ = file.name.substring(file.name.lastIndexOf("."), file.name.length).toLowerCase();
|
|
|
- if (post_ == ".pdf") {
|
|
|
- state.pageNum = 1;
|
|
|
- state.source = URL.createObjectURL(file);
|
|
|
- is_pdf.value = true
|
|
|
- loadingTask = createLoadingTask(state.source);
|
|
|
- getPdfImage(state.pageNum);
|
|
|
- } else
|
|
|
- if (post_ == ".jpg" || post_ == ".png" || post_ == ".bmp" || post_ == ".jpeg") {
|
|
|
- showImg.src = URL.createObjectURL(file);
|
|
|
- input_file.value = file
|
|
|
- showImg.onload = () => {
|
|
|
- canvas.value.width = showImg.width;
|
|
|
- canvas.value.height = showImg.height;
|
|
|
- if (fa_canvas != null) {
|
|
|
- fa_canvas.dispose();
|
|
|
- fa_canvas = null;
|
|
|
- }
|
|
|
- fa_canvas = new fabric.Canvas(canvas.value);
|
|
|
- fa_canvas.clear()
|
|
|
- figure_rects.splice(0)
|
|
|
- table_rects.splice(0)
|
|
|
- figureSelectedItem.value = -1;
|
|
|
- tableSelectedItem.value = -1;
|
|
|
- }
|
|
|
- is_pdf.value = false
|
|
|
- } else {
|
|
|
- alert('不支持的文件格式!')
|
|
|
- fileName.value = ''
|
|
|
- }
|
|
|
- fileName.value = file.name
|
|
|
-
|
|
|
- if (show_predict.value === true)
|
|
|
- show_predict.value = !show_predict.value;
|
|
|
- return true
|
|
|
-}
|
|
|
-
|
|
|
type RectWithId = fabric.Rect & { id: number };
|
|
|
|
|
|
function CreateRect(canvas: any, i: number, left: number, top: number, width: number, height: number, highlight: boolean, label: number) {
|
|
@@ -319,135 +115,77 @@ function CreateRect(canvas: any, i: number, left: number, top: number, width: nu
|
|
|
}
|
|
|
|
|
|
const predict = async () => {
|
|
|
+ fileName.value = ''
|
|
|
+ fileName.value = input_file.value?.name
|
|
|
if (fileName.value == undefined || fileName.value == '') {
|
|
|
alert('请上传图片!')
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- if (fa_canvas != null) {
|
|
|
- fa_canvas.dispose();
|
|
|
- fa_canvas = null;
|
|
|
- fa_canvas = new fabric.Canvas(canvas.value);
|
|
|
- fa_canvas.clear()
|
|
|
+ if (fabric_canvas.value != null) {
|
|
|
+ fabric_canvas.value.dispose();
|
|
|
+ fabric_canvas.value = null;
|
|
|
+ fabric_canvas.value = new fabric.Canvas(show_canvas.value);
|
|
|
+ fabric_canvas.value.clear()
|
|
|
}
|
|
|
figure_rects.splice(0)
|
|
|
table_rects.splice(0)
|
|
|
|
|
|
- const img = document.getElementById("show-img") as HTMLImageElement;
|
|
|
-
|
|
|
loading.value = !loading.value
|
|
|
var data = new FormData();
|
|
|
-
|
|
|
- if (is_pdf.value) {
|
|
|
- const file: any = convertCanvasToFile(img_canvas.value, "pdf.png").then(result => {
|
|
|
- console.log(result)
|
|
|
- data.append('image', result);
|
|
|
- Detection(api, data).then(res => {
|
|
|
- console.log(res.code)
|
|
|
- json_result.value = JSON.stringify(res.data, null, 4);
|
|
|
- console.log(res.data);
|
|
|
- figureArr.value.splice(0);
|
|
|
- tableArr.value.splice(0);
|
|
|
- let tmp_labels = res.data.labels;
|
|
|
- if (tmp_labels.length == 0) {
|
|
|
- alert("no result!");
|
|
|
- } else {
|
|
|
- let tmp_boxes = res.data.boxes;
|
|
|
- const h_radio = img.height / img.naturalHeight;
|
|
|
- const w_radio = img.width / img.naturalWidth;
|
|
|
-
|
|
|
- for (let i = 0; i < tmp_labels.length; i++) {
|
|
|
- let left = w_radio * tmp_boxes[i][0];
|
|
|
- let top = h_radio * tmp_boxes[i][1];
|
|
|
- let width = w_radio * (tmp_boxes[i][2] - tmp_boxes[i][0]);
|
|
|
- let height = h_radio * (tmp_boxes[i][3] - tmp_boxes[i][1]);
|
|
|
- const rect: iRect = { left, top, width, height };
|
|
|
- if (tmp_labels[i] == "Figure") {
|
|
|
- figureArr.value.push("图片");
|
|
|
- figure_rects.push(rect);
|
|
|
- CreateRect(fa_canvas, i, left, top, width, height, false, 1);
|
|
|
- } else if (tmp_labels[i] == "Table_0" || tmp_labels[i] == "Table_std") {
|
|
|
- tableArr.value.push("表格(" + tmp_labels[i] + ")");
|
|
|
- table_rects.push(rect);
|
|
|
- CreateRect(fa_canvas, i, left, top, width, height, false, 2);
|
|
|
- }
|
|
|
- }
|
|
|
- figureArr.value.reverse();
|
|
|
- tableArr.value.reverse();
|
|
|
- table_rects.reverse();
|
|
|
- for (let i = 0; i < figureArr.value.length; i++) {
|
|
|
- figureArr.value[i] = figureArr.value[i] + " -- " + String(i + 1);
|
|
|
- }
|
|
|
- for (let i = 0; i < tableArr.value.length; i++) {
|
|
|
- tableArr.value[i] = tableArr.value[i] + " -- " + String(i + 1);
|
|
|
- }
|
|
|
- }
|
|
|
- predictTime.value = res.data.cost;
|
|
|
- loading.value = !loading.value;
|
|
|
- bugId.value = res.response_id;
|
|
|
- if (show_predict.value === false)
|
|
|
- show_predict.value = !show_predict.value;
|
|
|
- }).catch(function (err) {
|
|
|
- loading.value = !loading.value;
|
|
|
- bugId.value = ""
|
|
|
- predictTime.value = 0
|
|
|
- });
|
|
|
- })
|
|
|
- } else {
|
|
|
- data.append('image', input_file.value);
|
|
|
-
|
|
|
- Detection(api, data).then(res => {
|
|
|
- console.log(res.code)
|
|
|
- json_result.value = JSON.stringify(res.data, null, 4);
|
|
|
- console.log(res.data);
|
|
|
- // rec_result.value = res.data.text.reduce((total: any, cur: any) => total + `<p>${cur}</p>`);
|
|
|
- figureArr.value.splice(0);
|
|
|
- tableArr.value.splice(0);
|
|
|
- let tmp_labels = res.data.labels;
|
|
|
- if (tmp_labels.length == 0) {
|
|
|
- alert("no result!");
|
|
|
- } else {
|
|
|
- let tmp_boxes = res.data.boxes;
|
|
|
- const h_radio = img.height / img.naturalHeight;
|
|
|
- const w_radio = img.width / img.naturalWidth;
|
|
|
-
|
|
|
- for (let i = 0; i < tmp_labels.length; i++) {
|
|
|
- let left = w_radio * tmp_boxes[i][0];
|
|
|
- let top = h_radio * tmp_boxes[i][1];
|
|
|
- let width = w_radio * (tmp_boxes[i][2] - tmp_boxes[i][0]);
|
|
|
- let height = h_radio * (tmp_boxes[i][3] - tmp_boxes[i][1]);
|
|
|
- const rect: iRect = { left, top, width, height };
|
|
|
- if (tmp_labels[i] == "Figure") {
|
|
|
- figureArr.value.push("图片");
|
|
|
- figure_rects.push(rect);
|
|
|
- CreateRect(fa_canvas, i, left, top, width, height, false, 1);
|
|
|
- } else if (tmp_labels[i] == "Table_0" || tmp_labels[i] == "Table_std") {
|
|
|
- tableArr.value.push("表格(" + tmp_labels[i] + ")");
|
|
|
- table_rects.push(rect);
|
|
|
- CreateRect(fa_canvas, i, left, top, width, height, false, 2);
|
|
|
- }
|
|
|
- }
|
|
|
- figureArr.value.reverse();
|
|
|
- tableArr.value.reverse();
|
|
|
- table_rects.reverse();
|
|
|
- for (let i = 0; i < figureArr.value.length; i++) {
|
|
|
- figureArr.value[i] = figureArr.value[i] + " -- " + String(i + 1);
|
|
|
- }
|
|
|
- for (let i = 0; i < tableArr.value.length; i++) {
|
|
|
- tableArr.value[i] = tableArr.value[i] + " -- " + String(i + 1);
|
|
|
+ data.append('image', input_file.value);
|
|
|
+
|
|
|
+ Detection(api_layout_analysis.value, data).then(res => {
|
|
|
+ // console.log(res.code)
|
|
|
+ json_result.value = JSON.stringify(res.data, null, 4);
|
|
|
+ // console.log(res.data);
|
|
|
+ // rec_result.value = res.data.text.reduce((total: any, cur: any) => total + `<p>${cur}</p>`);
|
|
|
+ figureArr.value.splice(0);
|
|
|
+ tableArr.value.splice(0);
|
|
|
+ let tmp_labels = res.data.labels;
|
|
|
+ if (tmp_labels.length == 0) {
|
|
|
+ alert("no result!");
|
|
|
+ } else {
|
|
|
+ let tmp_boxes = res.data.boxes;
|
|
|
+ const h_radio = show_image.value.height / show_image.value.naturalHeight;
|
|
|
+ const w_radio = show_image.value.width / show_image.value.naturalWidth;
|
|
|
+
|
|
|
+ for (let i = 0; i < tmp_labels.length; i++) {
|
|
|
+ let left = w_radio * tmp_boxes[i][0];
|
|
|
+ let top = h_radio * tmp_boxes[i][1];
|
|
|
+ let width = w_radio * (tmp_boxes[i][2] - tmp_boxes[i][0]);
|
|
|
+ let height = h_radio * (tmp_boxes[i][3] - tmp_boxes[i][1]);
|
|
|
+ const rect: iRect = { left, top, width, height };
|
|
|
+ if (tmp_labels[i] == "Figure") {
|
|
|
+ figureArr.value.push("图片");
|
|
|
+ figure_rects.push(rect);
|
|
|
+ CreateRect(fabric_canvas.value, i, left, top, width, height, false, 1);
|
|
|
+ } else if (tmp_labels[i] == "Table_0" || tmp_labels[i] == "Table_std") {
|
|
|
+ tableArr.value.push("表格(" + tmp_labels[i] + ")");
|
|
|
+ table_rects.push(rect);
|
|
|
+ CreateRect(fabric_canvas.value, i, left, top, width, height, false, 2);
|
|
|
}
|
|
|
}
|
|
|
- predictTime.value = res.data.cost;
|
|
|
- loading.value = !loading.value;
|
|
|
- bugId.value = res.response_id;
|
|
|
- if (show_predict.value === false)
|
|
|
- show_predict.value = !show_predict.value;
|
|
|
- }).catch(function (err) {
|
|
|
- loading.value = !loading.value;
|
|
|
- bugId.value = ""
|
|
|
- predictTime.value = 0
|
|
|
- });
|
|
|
- }
|
|
|
+ figureArr.value.reverse();
|
|
|
+ tableArr.value.reverse();
|
|
|
+ table_rects.reverse();
|
|
|
+ for (let i = 0; i < figureArr.value.length; i++) {
|
|
|
+ figureArr.value[i] = figureArr.value[i] + " -- " + String(i + 1);
|
|
|
+ }
|
|
|
+ for (let i = 0; i < tableArr.value.length; i++) {
|
|
|
+ tableArr.value[i] = tableArr.value[i] + " -- " + String(i + 1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ predictTime.value = res.data.cost;
|
|
|
+ loading.value = !loading.value;
|
|
|
+ bugId.value = res.response_id;
|
|
|
+ if (show_predict.value === false)
|
|
|
+ show_predict.value = !show_predict.value;
|
|
|
+ }).catch(function (err) {
|
|
|
+ loading.value = !loading.value;
|
|
|
+ bugId.value = ""
|
|
|
+ predictTime.value = 0
|
|
|
+ });
|
|
|
};
|
|
|
|
|
|
const submitBug = async () => {
|
|
@@ -456,7 +194,7 @@ const submitBug = async () => {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- SubmitBug(api, bugId.value).then(res => {
|
|
|
+ SubmitBug(api_layout_analysis.value, bugId.value).then(res => {
|
|
|
console.log(res.code, res.data)
|
|
|
}).catch(function (err) {
|
|
|
console.log(err)
|
|
@@ -464,89 +202,44 @@ const submitBug = async () => {
|
|
|
});
|
|
|
};
|
|
|
|
|
|
+onMounted(async () => {
|
|
|
+ console.log('layout analysis mounted')
|
|
|
+ input_file.value = undefined
|
|
|
+})
|
|
|
+
|
|
|
async function figureHandleClick(index: any, item: any, rects: any) {
|
|
|
figureSelectedItem.value = index;
|
|
|
tableSelectedItem.value = -1;
|
|
|
- let objects = fa_canvas.getObjects();
|
|
|
+ let objects = fabric_canvas.value.getObjects();
|
|
|
for (let i = 0; i < objects.length; i++) {
|
|
|
if (objects[i].name === 'high') {
|
|
|
// 找到名为 rectName 的矩形元素,执行删除操作等
|
|
|
- fa_canvas.remove(objects[i]);
|
|
|
+ fabric_canvas.value.remove(objects[i]);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
- CreateRect(fa_canvas, index, rects[index].left, rects[index].top, rects[index].width, rects[index].height, true, 1);
|
|
|
+ CreateRect(fabric_canvas.value, index, rects[index].left, rects[index].top, rects[index].width, rects[index].height, true, 1);
|
|
|
}
|
|
|
|
|
|
async function tableHandleClick(index: any, item: any, rects: any) {
|
|
|
tableSelectedItem.value = index;
|
|
|
figureSelectedItem.value = -1;
|
|
|
- let objects = fa_canvas.getObjects();
|
|
|
+ let objects = fabric_canvas.value.getObjects();
|
|
|
for (let i = 0; i < objects.length; i++) {
|
|
|
if (objects[i].name === 'high') {
|
|
|
// 找到名为 rectName 的矩形元素,执行删除操作等
|
|
|
- fa_canvas.remove(objects[i]);
|
|
|
+ fabric_canvas.value.remove(objects[i]);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
- CreateRect(fa_canvas, index, rects[index].left, rects[index].top, rects[index].width, rects[index].height, true, 2);
|
|
|
+ CreateRect(fabric_canvas.value, index, rects[index].left, rects[index].top, rects[index].width, rects[index].height, true, 2);
|
|
|
}
|
|
|
</script>
|
|
|
|
|
|
<style scoped>
|
|
|
-#canvas {
|
|
|
- position: absolute;
|
|
|
- top: 0;
|
|
|
- left: 0;
|
|
|
- z-index: 0;
|
|
|
- /* 设置Canvas的层级,使其显示在图像之上 */
|
|
|
- background-color: transparent;
|
|
|
-}
|
|
|
-
|
|
|
-#show-img {
|
|
|
- position: absolute;
|
|
|
- top: 0;
|
|
|
- left: 0;
|
|
|
- z-index: 0;
|
|
|
-}
|
|
|
-
|
|
|
-.demo-image__placeholder .block {
|
|
|
- padding: 30px 0;
|
|
|
- text-align: center;
|
|
|
- border-right: solid 1px var(--el-border-color);
|
|
|
- display: inline-block;
|
|
|
- width: 50%;
|
|
|
- box-sizing: border-box;
|
|
|
- vertical-align: top;
|
|
|
-}
|
|
|
-
|
|
|
-.demo-image__placeholder .demonstration {
|
|
|
- display: block;
|
|
|
- color: var(--el-text-color-secondary);
|
|
|
- font-size: 14px;
|
|
|
- margin-bottom: 20px;
|
|
|
-}
|
|
|
-
|
|
|
-.demo-image__placeholder .el-image {
|
|
|
- padding: 0 5px;
|
|
|
- max-width: 300px;
|
|
|
- max-height: 200px;
|
|
|
-}
|
|
|
-
|
|
|
-.demo-image__placeholder.image-slot {
|
|
|
- display: flex;
|
|
|
- justify-content: center;
|
|
|
- align-items: center;
|
|
|
+.page {
|
|
|
width: 100%;
|
|
|
height: 100%;
|
|
|
- background: var(--el-fill-color-light);
|
|
|
- color: var(--el-text-color-secondary);
|
|
|
- font-size: 14px;
|
|
|
-}
|
|
|
-
|
|
|
-.demo-image__placeholder .dot {
|
|
|
- animation: dot 2s infinite steps(3, start);
|
|
|
- overflow: hidden;
|
|
|
}
|
|
|
|
|
|
.place {
|
|
@@ -555,18 +248,8 @@ async function tableHandleClick(index: any, item: any, rects: any) {
|
|
|
border-right: solid 1px #ccc;
|
|
|
}
|
|
|
|
|
|
-.show-area {
|
|
|
- width: 100%;
|
|
|
-}
|
|
|
-
|
|
|
.small-title {
|
|
|
justify-content: space-between;
|
|
|
align-items: center;
|
|
|
}
|
|
|
-
|
|
|
-.page-tool-item {
|
|
|
- padding: 8px 15px;
|
|
|
- padding-left: 10px;
|
|
|
- cursor: pointer;
|
|
|
-}
|
|
|
</style>
|