finished cat testing

This commit is contained in:
Novembert 2022-01-18 19:48:10 +01:00
parent 57188ede8e
commit 4fee0dc4ef
4 changed files with 11 additions and 17 deletions

View File

@ -101,7 +101,7 @@ export default {
}
},
onFileChange (event) {
this.getFileInfo(event.target.files[0])
if (event.target.files && event.target.files.length > 0) { this.getFileInfo(event.target.files[0]) }
},
// changeFile () {
// document.getElementById(this.id).click()

View File

@ -1,7 +1,7 @@
<template>
<div v-if="result" id="true">
<fa :icon="['fas', 'check-circle']" />
CORRECTS, THAT'S A CAT
CORRECT, THAT'S A CAT
<fa :icon="['fas', 'check-circle']" />
</div>
<div v-else id="false">

View File

@ -30,23 +30,19 @@ export default {
handlePhotoChange (value) {
this.image = value
},
async checkPhoto (photo) {
const formData = new FormData()
formData.append('image', photo.file)
const res = await this.$store.dispatch('axios/file', ['/image/check', formData])
return res
},
clear () {
this.image = null
this.result = null
},
getResult () {
async getResult () {
this.loading = true
setTimeout(() => {
this.result = this.checkPhoto(this.image)
this.loading = false
}, 1500)
const formData = new FormData()
formData.append('image', this.image.file)
const res = await this.$store.dispatch('axios/file', ['/image/check', formData])
this.result = res.data.is_cat === '1'
this.loading = false
}
}
}

View File

@ -37,9 +37,7 @@ export const actions = {
file: ({ commit, rootState, state, dispatch }, params) => {
// eslint-disable-next-line
return new Promise(async (resolve, reject) => {
const request = await axios.post(`${state.url}${params[0]}`, params[1]).catch((error) => {
dispatch('error', error.response)
})
const request = await axios.post(`${state.url}${params[0]}`, params[1])
resolve(request)
})