|
|
@@ -37,7 +37,7 @@
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
import api from '@/api'
|
|
|
-import { useRoute, useRouter } from 'vue-router'
|
|
|
+import { useRoute, useRouter, onBeforeRouteLeave } from 'vue-router'
|
|
|
import { ElMessage } from "element-plus";
|
|
|
import { onMounted, onUnmounted } from 'vue'
|
|
|
|
|
|
@@ -47,7 +47,8 @@ const myRouter = useRouter()
|
|
|
let detailData = ref(undefined)
|
|
|
|
|
|
let moduleName = ref('')
|
|
|
-
|
|
|
+const activeName = ref(myRoute.query.activeindex || '')
|
|
|
+const activeindex = myRoute.query.activeindex
|
|
|
// 格式化换行符,将 \r\n 和 \r 统一转换为 \n
|
|
|
const formatLineBreaks = (text) => {
|
|
|
if (!text) return ''
|
|
|
@@ -105,9 +106,8 @@ const optTypeMAP = (optType) => {
|
|
|
}
|
|
|
}
|
|
|
onBeforeMount(() => {
|
|
|
- console.log(myRoute.query)
|
|
|
|
|
|
- detailData.value = myRoute.query;
|
|
|
+ detailData.value = JSON.parse(myRoute.query.info);
|
|
|
console.log(detailData.value)
|
|
|
if (detailData.value.module && detailData.value.subModule) {
|
|
|
moduleName.value = `${detailData.value.module}/${detailData.value.subModule}`
|
|
|
@@ -118,6 +118,16 @@ onBeforeMount(() => {
|
|
|
}
|
|
|
})
|
|
|
|
|
|
+// 离开页面时,将 activeindex 传回上一页
|
|
|
+onBeforeRouteLeave((to) => {
|
|
|
+ if (activeindex && !to.query.activeindex) {
|
|
|
+ return {
|
|
|
+ path: to.path,
|
|
|
+ query: { ...to.query, activeindex: activeindex as string }
|
|
|
+ }
|
|
|
+ }
|
|
|
+})
|
|
|
+
|
|
|
const handleEscKey = (event: KeyboardEvent) => {
|
|
|
if (event.key === 'Escape' || event.keyCode === 27) {
|
|
|
myRouter.back()
|
|
|
@@ -205,4 +215,4 @@ onUnmounted(() => {
|
|
|
width: 50%;
|
|
|
}
|
|
|
}
|
|
|
-</style>
|
|
|
+</style>
|