finished cat testing
This commit is contained in:
parent
57188ede8e
commit
4fee0dc4ef
@ -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()
|
||||
|
@ -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">
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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)
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user