add eslint working conf
This commit is contained in:
@@ -22,50 +22,50 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: "OpenWeatherCard",
|
||||
data: function () {
|
||||
return {
|
||||
loading: true,
|
||||
meteo: null,
|
||||
}
|
||||
},
|
||||
methods : {
|
||||
dateFormat(date) {
|
||||
const d = new Date(date)
|
||||
const dtf = new Intl.DateTimeFormat('fr', { year: '2-digit', month: 'short', day: '2-digit', hour: 'numeric' })
|
||||
const [{ value: mo },,{ value: da },,{ value: ye },,{value: ho }] = dtf.formatToParts(d)
|
||||
return `${mo}/${da} - ${ho}h`
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
let refreshMeteo = false
|
||||
export default {
|
||||
name: 'OpenWeatherCard',
|
||||
data: function () {
|
||||
return {
|
||||
loading: true,
|
||||
meteo: null,
|
||||
}
|
||||
},
|
||||
methods : {
|
||||
dateFormat(date) {
|
||||
const d = new Date(date)
|
||||
const dtf = new Intl.DateTimeFormat('fr', { year: '2-digit', month: 'short', day: '2-digit', hour: 'numeric' })
|
||||
const [{ value: mo },,{ value: da },,{value: ho }] = dtf.formatToParts(d)
|
||||
return `${mo}/${da} - ${ho}h`
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
let refreshMeteo = false
|
||||
|
||||
if(localStorage.getItem('meteo')) {
|
||||
this.meteo = JSON.parse(localStorage.getItem('meteo'))
|
||||
let deltaTime = new Date() - new Date(this.meteo.list[0].dt_txt)
|
||||
if (deltaTime/1000/3600 > 3) {
|
||||
refreshMeteo = true
|
||||
}
|
||||
this.loading = false
|
||||
console.log('in storage', this.meteo.list[0], this.meteo.list[0].dt_txt)
|
||||
} else {
|
||||
if(localStorage.getItem('meteo')) {
|
||||
this.meteo = JSON.parse(localStorage.getItem('meteo'))
|
||||
let deltaTime = new Date() - new Date(this.meteo.list[0].dt_txt)
|
||||
if (deltaTime/1000/3600 > 3) {
|
||||
refreshMeteo = true
|
||||
}
|
||||
this.loading = false
|
||||
console.log('in storage', this.meteo.list[0], this.meteo.list[0].dt_txt)
|
||||
} else {
|
||||
refreshMeteo = true
|
||||
}
|
||||
|
||||
if (refreshMeteo) {
|
||||
console.log("refreshing meteo data")
|
||||
axios.get('/api/meteo')
|
||||
.then(response => {
|
||||
this.meteo = response.data
|
||||
this.loading = false
|
||||
localStorage.setItem('meteo', JSON.stringify(response.data));
|
||||
})
|
||||
.catch(error => {
|
||||
console.log('Unable to fetch meteo.')
|
||||
})
|
||||
}
|
||||
},
|
||||
}
|
||||
if (refreshMeteo) {
|
||||
// eslint-disable-next-line no-undef
|
||||
axios.get('/api/meteo')
|
||||
.then(response => {
|
||||
this.meteo = response.data
|
||||
this.loading = false
|
||||
localStorage.setItem('meteo', JSON.stringify(response.data))
|
||||
})
|
||||
.catch(() => {
|
||||
console.log('Unable to fetch meteo.')
|
||||
})
|
||||
}
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user