更新
This commit is contained in:
@ -37,7 +37,7 @@
|
|||||||
<p>上传文件提取文本内容(支持 .png, .jpg )</p>
|
<p>上传文件提取文本内容(支持 .png, .jpg )</p>
|
||||||
<div class="container flex" style="height: 248px;">
|
<div class="container flex" style="height: 248px;">
|
||||||
<div class="mr10">
|
<div class="mr10">
|
||||||
<el-upload class="upload-demo" action="abc" :auto-upload="false" :on-change="onHandleChange" :show-file-list="false">
|
<el-upload class="upload-demo" accept=".png,.jpg" action="abc" :auto-upload="false" :on-change="onHandleChange" :show-file-list="false">
|
||||||
<el-button size="medium" type="primary">上传图片</el-button>
|
<el-button size="medium" type="primary">上传图片</el-button>
|
||||||
</el-upload>
|
</el-upload>
|
||||||
<p id="file-info">{{ files.name || '未选择文件' }} </p>
|
<p id="file-info">{{ files.name || '未选择文件' }} </p>
|
||||||
@ -71,8 +71,7 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import * as ocr from "@paddlejs-models/ocr";
|
import * as ocr from "@paddlejs-models/ocr";
|
||||||
import { drawBox } from "@/utils/ocrUtils";
|
import { drawBox } from "@/utils/ocrUtils";
|
||||||
import { nextTick, onMounted,reactive, ref,getCurrentInstance, watch } from "vue";
|
import { nextTick,reactive, ref,getCurrentInstance, watch } from "vue";
|
||||||
import { init } from "echarts";
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
modelValue: {
|
modelValue: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
@ -95,7 +94,7 @@ const textStyle = reactive({
|
|||||||
width: "",
|
width: "",
|
||||||
height: ""
|
height: ""
|
||||||
})
|
})
|
||||||
const hasLoadingJS = ref(false)
|
const hasLoadingJS = ref(null) //加载的状态 1 :成功,2:失败
|
||||||
|
|
||||||
watch(()=>props.modelValue,val=>{
|
watch(()=>props.modelValue,val=>{
|
||||||
if(val) initDemo();
|
if(val) initDemo();
|
||||||
@ -103,7 +102,7 @@ watch(()=>props.modelValue,val=>{
|
|||||||
|
|
||||||
|
|
||||||
const initDemo = () =>{
|
const initDemo = () =>{
|
||||||
if(!hasLoadingJS.value) initPage();
|
if(hasLoadingJS.value == null || hasLoadingJS.value == 2) initPage();
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
const fileInput = document.getElementById("file-input");
|
const fileInput = document.getElementById("file-input");
|
||||||
const fileInfo = document.getElementById("file-info");
|
const fileInfo = document.getElementById("file-info");
|
||||||
@ -237,11 +236,11 @@ const initPage = async () => {
|
|||||||
await ocr.init();// 模型初始化
|
await ocr.init();// 模型初始化
|
||||||
proxy.$message({ type: "success", message: "加载成功" });
|
proxy.$message({ type: "success", message: "加载成功" });
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
hasLoadingJS.value = true;
|
hasLoadingJS.value = 1;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
proxy.$message({ type: "error", message: "加载失败,请刷新页面" });
|
proxy.$message({ type: "error", message: "加载失败,请刷新页面" });
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
hasLoadingJS.value = false;
|
hasLoadingJS.value = 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@ -274,7 +273,7 @@ const getRecognize = async () => {
|
|||||||
// 切换标签
|
// 切换标签
|
||||||
const changeRadio = (val) =>{
|
const changeRadio = (val) =>{
|
||||||
if(val == '图片解析') {
|
if(val == '图片解析') {
|
||||||
if(!hasLoadingJS.value) initPage()
|
if(hasLoadingJS.value == 2) initPage();
|
||||||
}
|
}
|
||||||
const resultDiv = document.getElementById("result");
|
const resultDiv = document.getElementById("result");
|
||||||
resultDiv.textContent = "请先上传文件...";
|
resultDiv.textContent = "请先上传文件...";
|
||||||
|
Reference in New Issue
Block a user