lrf402788946 5 anni fa
parent
commit
a8527599ce
2 ha cambiato i file con 9 aggiunte e 4 eliminazioni
  1. 3 3
      src/plugins/methods.js
  2. 6 1
      src/router/index.js

+ 3 - 3
src/plugins/methods.js

@@ -1,5 +1,4 @@
 import Vue from 'vue';
-import router from '@/router/index';
 const Plugin = {
   install(vue, options) {
     vue.prototype.$turnTo = item => {
@@ -7,8 +6,9 @@ const Plugin = {
         window.open(item.url);
       } else {
         let router = window.vm.$router;
-        let route = window.vm.$route.path;
-        if (route.includes('member')) router.push({ path: '/memberDetail', query: { id: item.id } });
+        let path = window.vm.$route.path;
+        if (path.includes('member')) router.push({ path: '/memberDetail', query: { id: item.id } });
+        // else if (path === '/index') window.open(`/detail?id=${item.id}`);
         else router.push({ path: `/detail?id=${item.id}` });
       }
     };

+ 6 - 1
src/router/index.js

@@ -99,7 +99,12 @@ const router = new Router({
     },
   ],
 });
-
+router.beforeEach((to, from, next) => {
+  let fPath = from.path;
+  let tPath = to.fullPath;
+  if (fPath === '/index') window.open(tPath);
+  else next();
+});
 router.afterEach((to, from, next) => {
   window.scrollTo(0, 0);
 });