Compare commits

..

No commits in common. "e38380e5530ab2e57895418cb4647fd2a2dae85f" and "5fe2d4478852e7da98a6306971537f2153ca2959" have entirely different histories.

2 changed files with 7 additions and 62 deletions

View File

@ -1,19 +1,15 @@
<script setup>
import { PerfectScrollbar } from 'vue3-perfect-scrollbar'
import { VNodeRenderer } from './VNodeRenderer'
import { layoutConfig } from '@layouts'
import {
VerticalNavGroup,
VerticalNavLink,
VerticalNavSectionTitle,
VerticalNavGroup,
VerticalNavLink,
VerticalNavSectionTitle,
} from '@layouts/components'
import { useLayoutConfigStore } from '@layouts/stores/config'
import { injectionKeyIsVerticalNavHovered } from '@layouts/symbols'
import { PerfectScrollbar } from 'vue3-perfect-scrollbar'
import { useStore } from 'vuex'
import { VNodeRenderer } from './VNodeRenderer'
const store = useStore();
const router = useRouter()
const ability = useAbility()
const userData = useCookie('userData')
const props = defineProps({
tag: {
type: null,
@ -55,26 +51,7 @@ Close overlay vertical nav when link is clicked
*/
const route = useRoute()
watch(() => route.name, async () => {
console.log('name=====')
await store.dispatch('checkLogin')
const isLoggedIn = await store.getters.getCheckLoginExpire
console.log('check login', isLoggedIn)
// Add additional logic or redirection based on login status if needed
if (isLoggedIn) {
await store.dispatch('updateCheckToken',false)
// Redirect to login page or perform any other action
useCookie('accessToken').value = null
localStorage.removeItem('admin_access_token');
useCookie('userAbilityRules').value = null
ability.update([])
router.push({ name: 'login' })
}
watch(() => route.name, () => {
props.toggleIsOverlayNavActive(false)
})

View File

@ -48,17 +48,12 @@ export default createStore({
siteSetting: null,
showMessage: null,
timeout: null,
checkLoginExpire:false
},
mutations: {
setLoading(state, payload) {
console.log('payload');
state.isLoading = payload
},
setCheckLoginExpire(state, payload) {
console.log('payload');
state.checkLoginExpire = payload
},
setErrorMsg(state, payload) {
console.log('payload');
clearTimeout(state.timeout)
@ -122,9 +117,6 @@ export default createStore({
async updateIsLoading({ commit }, payload) {
commit('setLoading', payload)
},
async updateCheckToken({ commit }, payload) {
commit('setCheckLoginExpire', payload)
},
async patientList({ commit }, payload) {
commit('setLoading', true)
console.log(localStorage.getItem('admin_access_token'))
@ -693,27 +685,6 @@ export default createStore({
console.error('Error:', error);
});
},
async checkLogin({ commit }, payload) {
//commit('setLoading', true)
await axios.post(ADMIN_LOGIN_DETAIL, {}, {
headers: {
'Authorization': `Bearer ${localStorage.getItem('admin_access_token')}`,
}
}) .then(response => {
//commit('setLoading', false)
console.log('Response:', response.data);
})
.catch(error => {
//commit('setLoading', false)
console.error('Error:', error);
if (error.response && error.response.status === 401 && error.response.data.error === 'Token has expired') {
commit('setCheckLoginExpire', true)
}
});
},
},
getters: {
getIsLoading(state){
@ -767,8 +738,5 @@ export default createStore({
getSiteSetting(state){
return state.siteSetting
},
getCheckLoginExpire(state){
return state.checkLoginExpire
},
}
})