Browse Source

极测看板,router增加自动1分钟切换车间

xiaost 8 months ago
parent
commit
5c5edf969d
4 changed files with 20 additions and 3 deletions
  1. 17 0
      src/router/index.js
  2. 1 1
      src/views/lab/index.vue
  3. 1 1
      src/views/shop/index.vue
  4. 1 1
      src/views/shopmonth/index.vue

+ 17 - 0
src/router/index.js

@@ -46,4 +46,21 @@ const routes = [{
 const router = new VueRouter({
   routes
 })
+router.beforeEach((to, from, next) => {
+  // 清除之前的定时器
+  if (router.timer) {
+    clearTimeout(router.timer);
+  }
+  // 设置新的定时器,例如每60秒切换到下一个页面
+  router.timer = setTimeout(() => {
+    if (to.path === '/shop') {
+      next('/lab');
+    } else if(to.path === '/lab') {
+      next('/shopmonth');
+    }else {
+      next('/shop');
+    }
+  }, 60000);
+  next();
+});
 export default router

+ 1 - 1
src/views/lab/index.vue

@@ -157,7 +157,7 @@ export default {
     cancelLoading() {
       setTimeout(() => {
         this.loading = false
-      }, 5000)
+      }, 2000)
     },
     getProject (){
       this.$http.get("kanban/getProject.action").then(

+ 1 - 1
src/views/shop/index.vue

@@ -141,7 +141,7 @@ export default {
     cancelLoading() {
       setTimeout(() => {
         this.loading = false
-      }, 5000)
+      }, 2000)
     },
     handleBlur (val){
       sessionStorage.setItem('ST_CODE',val);

+ 1 - 1
src/views/shopmonth/index.vue

@@ -141,7 +141,7 @@ export default {
     cancelLoading() {
       setTimeout(() => {
         this.loading = false
-      }, 5000)
+      }, 2000)
     },
     handleBlur (val){
       sessionStorage.setItem('ST_CODE',val);