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) { onFileChange (event) {
this.getFileInfo(event.target.files[0]) if (event.target.files && event.target.files.length > 0) { this.getFileInfo(event.target.files[0]) }
}, },
// changeFile () { // changeFile () {
// document.getElementById(this.id).click() // document.getElementById(this.id).click()

View File

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

View File

@ -30,23 +30,19 @@ export default {
handlePhotoChange (value) { handlePhotoChange (value) {
this.image = 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 () { clear () {
this.image = null this.image = null
this.result = null this.result = null
}, },
getResult () { async getResult () {
this.loading = true this.loading = true
setTimeout(() => {
this.result = this.checkPhoto(this.image) const formData = new FormData()
this.loading = false formData.append('image', this.image.file)
}, 1500)
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) => { file: ({ commit, rootState, state, dispatch }, params) => {
// eslint-disable-next-line // eslint-disable-next-line
return new Promise(async (resolve, reject) => { return new Promise(async (resolve, reject) => {
const request = await axios.post(`${state.url}${params[0]}`, params[1]).catch((error) => { const request = await axios.post(`${state.url}${params[0]}`, params[1])
dispatch('error', error.response)
})
resolve(request) resolve(request)
}) })