提交 3f5a51e0 authored 作者: 龙菲's avatar 龙菲

修复以图搜图多次请求的问题

上级 2ace68be
...@@ -29,11 +29,13 @@ ...@@ -29,11 +29,13 @@
ref="uploader" ref="uploader"
class="upload-area" class="upload-area"
accept=".jpg,.png" accept=".jpg,.png"
action action="#"
:before-upload="handleBeforeUpload" :limit="1"
:http-request="httpRequest"
:show-file-list="false" :show-file-list="false"
:on-success="handleSuccess" :on-success="handleSuccess"
:disabled="loading" :disabled="loading"
:file-list="fileList"
> >
<el-button ref="uploadButton" class="upload-button">上传</el-button> <el-button ref="uploadButton" class="upload-button">上传</el-button>
</el-upload> </el-upload>
...@@ -50,7 +52,6 @@ ...@@ -50,7 +52,6 @@
<script> <script>
import ImgList from "./components/imgList"; import ImgList from "./components/imgList";
// import { imgList } from "./mock";
import { searchImageByUpload, searchImageByImg } from "@/api/culturalRelic"; import { searchImageByUpload, searchImageByImg } from "@/api/culturalRelic";
export default { export default {
components: { components: {
...@@ -60,11 +61,10 @@ export default { ...@@ -60,11 +61,10 @@ export default {
return { return {
showResult: false, //是否展示图片结果 showResult: false, //是否展示图片结果
currentImg: "", //当前搜索的图片 currentImg: "", //当前搜索的图片
// currentImg: imgList[0].pressUrl,
loading: false, //是否正在上传 loading: false, //是否正在上传
imgList: [], imgList: [],
// imgList,
size: 20, size: 20,
fileList: [],
}; };
}, },
mounted() { mounted() {
...@@ -91,7 +91,8 @@ export default { ...@@ -91,7 +91,8 @@ export default {
} }
}, },
// 上传前钩子,处理文件类型 // 上传前钩子,处理文件类型
async handleBeforeUpload(file) { async httpRequest(value) {
const { file } = value;
let reg = /(?<=\.)[a-z]+$/g; let reg = /(?<=\.)[a-z]+$/g;
let fileType = file.name.match(reg) + ""; let fileType = file.name.match(reg) + "";
let typeArr = ["png", "jpg", "jpeg"]; let typeArr = ["png", "jpg", "jpeg"];
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论