Browse Source

feat: 返回指定页面方法

huangziyang 3 days ago
parent
commit
4e70e29306
2 changed files with 7 additions and 3 deletions
  1. 6 2
      components/Container/Container.vue
  2. 1 1
      utils/router.js

+ 6 - 2
components/Container/Container.vue

@@ -1,7 +1,7 @@
 <script setup>
 import Empty from "../Empty/Empty.vue";
 import { ref, onMounted, watchEffect } from "vue";
-import { router, getRoute } from "../../utils/router";
+import { router, getRoute, normalizeParams } from "../../utils/router";
 import { getRect, debounce } from "../../utils";
 import { getCurrentInstance } from "vue";
 import pages from "@/pages.json";
@@ -81,6 +81,10 @@ const onBack = async () => {
   if (props.onBack) {
     const res = await props.onBack();
     if (!res) return;
+    if (typeof res === "string") {
+      router.reLaunch(normalizeParams(res));
+      return;
+    }
     router.back();
     return;
   }
@@ -296,4 +300,4 @@ scroll-view ::-webkit-scrollbar {
   white-space: nowrap;
   display: inline-flex;
 }
-</style>
+</style>

+ 1 - 1
utils/router.js

@@ -22,7 +22,7 @@ export const urlParamsToObj = (url) => {
 };
 
 // 参数归一化路由参数
-const normalizeParams = (url, options) => {
+export const normalizeParams = (url, options) => {
   let normalizeOptions = {
     url: "",
   };