fix(components): refresh cached routes

This commit is contained in:
alue_mobile
2023-03-01 13:56:04 +08:00
parent 506ffb8adf
commit b0f98e4bfa
2 changed files with 27 additions and 2 deletions

View File

@ -5,18 +5,27 @@
</template>
<script setup lang="ts">
import { useAppStore } from '@/store';
import { useRoute } from 'vue-router';
import { useAppStore, useRouteStore } from '@/store';
import { useLoading } from '@/hooks';
defineOptions({ name: 'ReloadButton' });
const app = useAppStore();
const routeStore = useRouteStore();
const route = useRoute();
const { loading, startLoading, endLoading } = useLoading();
function handleRefresh() {
const isCached = routeStore.cacheRoutes.includes(String(route.name));
if (isCached) {
routeStore.removeCacheRoute(route.name as AuthRoute.AllRouteKey);
}
startLoading();
app.reloadPage();
setTimeout(() => {
if (isCached) {
routeStore.addCacheRoute(route.name as AuthRoute.AllRouteKey);
}
endLoading();
}, 1000);
}