refactor(projects): add reCacheRoute method

This commit is contained in:
Soybean
2023-09-06 00:32:43 +08:00
parent 1e6d52357e
commit f92ee770e0
4 changed files with 41 additions and 32 deletions

View File

@ -6,28 +6,21 @@
<script setup lang="ts">
import { useRoute } from 'vue-router';
import { useAppStore, useRouteStore } from '@/store';
import { useRouteStore } from '@/store';
import { useLoading } from '@/hooks';
defineOptions({ name: 'ReloadButton' });
const app = useAppStore();
const routeStore = useRouteStore();
const { reCacheRoute } = 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);
}
async function handleRefresh() {
startLoading();
app.reloadPage();
setTimeout(() => {
if (isCached) {
routeStore.addCacheRoute(route.name as AuthRoute.AllRouteKey);
}
endLoading();
}, 1000);
await reCacheRoute(route.name as AuthRoute.AllRouteKey);
endLoading();
}
</script>