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,6 +5,10 @@ const instance = axios.create({
baseURL: url
})
const ax = axios.create({
baseURL: window.location.origin
})
const getUid = async () => await instance.get('/uid')
const getUidRegional = async (regional: number) => await instance.get('/uid?regional=' + regional)
const getRegional = async () => await instance.get('/regional')
@ -13,6 +17,7 @@ const getJenisTransaksi = async () => await instance.get('/jenisTransaksi')
const getUp3 = async (uid: number) => await instance.get('/up3?uid=' + uid)
const getUlp = async (up3: number) => await instance.get('/ulp?up3=' + up3)
const getPosko = async (uppp: number) => await instance.get('/posko?up3=' + uppp)
const getVersion = async () => await ax.get('/version.json')
export {
getUid,
getUp3,
@ -21,5 +26,6 @@ export {
getMedia,
getJenisTransaksi,
getUidRegional,
getRegional
getRegional,
getVersion
}

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>