Refactor build-and-push.js and deploy.js to improve code structure and update version number in package.json

This commit is contained in:
Dede Fuji Abdul
2024-04-18 14:31:22 +07:00
parent fedbdfff16
commit 34e6f328b0
6 changed files with 100 additions and 53 deletions

View File

@@ -5,7 +5,7 @@ import { useMenuStore } from '@/stores/menu'
import { RouterView } from 'vue-router'
import { useDialogStore } from '@/stores/dialog'
import { onMounted } from 'vue'
import { version } from '../../package.json'
import { getVersion } from '@/utils/api/api.rest'
const menu = useMenuStore()
const dialog = useDialogStore()
@@ -23,17 +23,28 @@ const showDialogUpdate = () => {
dialog.open = true
}
onMounted(() => {
const localVersion = localStorage.getItem('version')
if (localVersion) {
if (localVersion !== version) {
localStorage.setItem('version', version)
showDialogUpdate()
const checkVersion = () => {
getVersion().then((response) => {
if (response.data.version) {
const version = response.data.version
const localVersion = localStorage.getItem('version')
if (localVersion) {
if (localVersion !== version) {
localStorage.setItem('version', version)
showDialogUpdate()
}
} else {
localStorage.setItem('version', version)
}
}
} else {
localStorage.setItem('version', version)
}
})
setTimeout(() => {
checkVersion()
}, 60000)
})
}
onMounted(() => checkVersion())
</script>
<template>