diff --git a/src/layout/components/AppMain.vue b/src/layout/components/AppMain.vue
index 3ca5f31..aad4ef6 100644
--- a/src/layout/components/AppMain.vue
+++ b/src/layout/components/AppMain.vue
@@ -1,11 +1,19 @@
-
-
+
+
+
+
diff --git a/src/layout/components/sidebar/components/SideMenu.vue b/src/layout/components/sidebar/components/SideMenu.vue
index 83142c2..3547169 100644
--- a/src/layout/components/sidebar/components/SideMenu.vue
+++ b/src/layout/components/sidebar/components/SideMenu.vue
@@ -6,7 +6,7 @@
:collapsed-icon-size="22"
:collapsed-width="64"
:options="menuOptions"
- :value="(currentRoute.meta && currentRoute.meta.activeMenu) || currentRoute.name"
+ :value="curRoute.meta?.activeMenu || curRoute.name"
@update:value="handleMenuSelect"
/>
@@ -19,9 +19,9 @@ import { useAppStore } from '@/store/modules/app'
import { renderCustomIcon, renderIcon } from '@/utils/icon'
const router = useRouter()
+const curRoute = useRoute()
const permissionStore = usePermissionStore()
const appStore = useAppStore()
-const { currentRoute } = router
const menuOptions = computed(() => {
return permissionStore.menus.map((item) => getMenuItem(item)).sort((a, b) => a.order - b.order)
@@ -87,7 +87,7 @@ function handleMenuSelect(key, item) {
if (isExternal(item.path)) {
window.open(item.path)
} else {
- if (item.path === currentRoute.value.path) {
+ if (item.path === curRoute.path) {
appStore.reloadPage()
} else {
router.push(item.path)
diff --git a/src/layout/components/tags/ContextMenu.vue b/src/layout/components/tags/ContextMenu.vue
index a6c5119..03c81e4 100644
--- a/src/layout/components/tags/ContextMenu.vue
+++ b/src/layout/components/tags/ContextMenu.vue
@@ -72,10 +72,15 @@ const options = computed(() => [
},
])
+const route = useRoute()
const actionMap = new Map([
[
'reload',
() => {
+ if (route.meta?.keepAlive) {
+ // 重置keepAlive
+ route.meta.key = +new Date()
+ }
appStore.reloadPage()
},
],
diff --git a/src/views/demo/base/keep-alive/index.vue b/src/views/demo/base/keep-alive/index.vue
new file mode 100644
index 0000000..387ebb6
--- /dev/null
+++ b/src/views/demo/base/keep-alive/index.vue
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/src/views/demo/base/route.js b/src/views/demo/base/route.js
index 5b25d2b..00581a7 100644
--- a/src/views/demo/base/route.js
+++ b/src/views/demo/base/route.js
@@ -38,5 +38,15 @@ export default {
icon: 'material-symbols:auto-awesome-outline-rounded',
},
},
+ {
+ name: 'KeepAlive',
+ path: 'keep-alive',
+ component: () => import('./keep-alive/index.vue'),
+ meta: {
+ title: 'KeepAlive',
+ icon: 'material-symbols:auto-awesome-outline-rounded',
+ keepAlive: true,
+ },
+ },
],
}
diff --git a/src/views/demo/editor/md-editor.vue b/src/views/demo/editor/md-editor.vue
index ed63a2d..dc8e41f 100644
--- a/src/views/demo/editor/md-editor.vue
+++ b/src/views/demo/editor/md-editor.vue
@@ -19,6 +19,8 @@
import MdEditor from 'md-editor-v3'
import 'md-editor-v3/lib/style.css'
+defineOptions({ name: 'MDEditor' })
+
// refs
let post = ref({})
let btnLoading = ref(false)
diff --git a/src/views/demo/route.js b/src/views/demo/route.js
index 1cb0c13..0a462c3 100644
--- a/src/views/demo/route.js
+++ b/src/views/demo/route.js
@@ -22,6 +22,7 @@ export default {
icon: 'ic:baseline-table-view',
role: ['admin'],
requireAuth: true,
+ keepAlive: true,
},
},
{
@@ -33,6 +34,7 @@ export default {
icon: 'ri:markdown-line',
role: ['admin'],
requireAuth: true,
+ keepAlive: true,
},
},
],
diff --git a/src/views/demo/table/index.vue b/src/views/demo/table/index.vue
index c771ebc..62f7331 100644
--- a/src/views/demo/table/index.vue
+++ b/src/views/demo/table/index.vue
@@ -88,6 +88,8 @@ import { useCRUD } from '@/composables'
import api from './api'
import { isNullOrUndef } from '@/utils/is'
+defineOptions({ name: 'CrudTable' })
+
const $table = ref(null)
/** QueryBar筛选参数(可选) */
const queryItems = ref({})