fix: correct back button work
This commit is contained in:
@@ -1,12 +1,15 @@
|
||||
<template>
|
||||
<FullscreenViewport/>
|
||||
<router-view />
|
||||
<div class="app-container">
|
||||
<FullscreenViewport/>
|
||||
<router-view />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import {onMounted, ref} from "vue";
|
||||
import { useWebAppViewport } from 'vue-tg';
|
||||
import {onMounted, ref, watch} from "vue";
|
||||
import { useWebAppViewport, useBackButton } from 'vue-tg';
|
||||
import { useMiniApp, FullscreenViewport } from 'vue-tg';
|
||||
import {useRoute, useRouter} from "vue-router";
|
||||
|
||||
const tg = useMiniApp();
|
||||
const platform = ref();
|
||||
@@ -14,4 +17,28 @@ platform.value = tg.platform;
|
||||
|
||||
const { disableVerticalSwipes } = useWebAppViewport();
|
||||
disableVerticalSwipes();
|
||||
|
||||
const router = useRouter();
|
||||
const route = useRoute();
|
||||
const backButton = useBackButton();
|
||||
|
||||
watch(
|
||||
() => route.fullPath,
|
||||
() => {
|
||||
if (route.name === 'home') {
|
||||
if (typeof backButton.hide === 'function') {
|
||||
backButton.hide();
|
||||
}
|
||||
} else {
|
||||
if (typeof backButton.show === 'function') {
|
||||
backButton.show();
|
||||
backButton.onClick(() => {
|
||||
router.back();
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
},
|
||||
{ immediate: true }
|
||||
);
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user