Explorar o código

添加登陆开发模式情况和生产模式情况

lrf402788946 %!s(int64=5) %!d(string=hai) anos
pai
achega
4315c517be
Modificáronse 1 ficheiros con 12 adicións e 4 borrados
  1. 12 4
      src/views/login.vue

+ 12 - 4
src/views/login.vue

@@ -1,5 +1,7 @@
 <template>
-  <div id="login"></div>
+  <div id="login">
+    <van-button type="primary" @click="toIndex" v-if="is_dev">去首页(开发用)</van-button>
+  </div>
 </template>
 
 <script>
@@ -10,7 +12,9 @@ export default {
   name: 'login',
   props: {},
   components: {},
-  data: () => ({}),
+  data: () => ({
+    is_dev: process.env.NODE_ENV === 'development',
+  }),
   created() {
     this.$toast.loading({
       message: '登陆中...',
@@ -19,11 +23,15 @@ export default {
     let token = this.$route.query.token;
     let user = jwt.decode(token);
     localStorage.setItem('user', JSON.stringify(user));
-    this.$router.push({ path: '/' });
     this.$toast.clear();
+    if (!this.is_dev) this.toIndex();
   },
   computed: {},
-  methods: {},
+  methods: {
+    toIndex() {
+      this.$router.push({ path: '/' });
+    },
+  },
 };
 </script>