Parcourir la source

不需要登录

CzRger il y a 1 an
Parent
commit
753a81c6f3
2 fichiers modifiés avec 55 ajouts et 5 suppressions
  1. 17 5
      src/router/index.ts
  2. 38 0
      src/views/map/index.vue

+ 17 - 5
src/router/index.ts

@@ -13,6 +13,13 @@ const routes = [
         path: '/screen',
         component: () => import('@/views/screen/index.vue'),
     },
+    {
+        path: '/map',
+        component: () => import('@/views/map/index.vue'),
+        meta: {
+            noLogin: true
+        }
+    },
 ]
 
 const router = createRouter({
@@ -21,12 +28,17 @@ const router = createRouter({
 });
 
 router.beforeEach((to, from, next) => {
-    if (localStorage.getItem('sc_token')) {
-        store.dispatch('app/LOAD_USER_INFO').then(() => {
-            next()
-        })
-    } else {
+    if (to.meta.noLogin) {
         next()
+    } else {
+        if (localStorage.getItem('sc_token')) {
+            store.dispatch('app/LOAD_USER_INFO').then(() => {
+                next()
+            })
+        } else {
+            next()
+        }
     }
+
 })
 export default router;

+ 38 - 0
src/views/map/index.vue

@@ -0,0 +1,38 @@
+<template>
+  地图
+</template>
+
+<script lang="ts">
+import {
+  defineComponent,
+  computed,
+  onMounted,
+  ref,
+  reactive,
+  watch,
+  getCurrentInstance,
+  ComponentInternalInstance,
+  toRefs,
+  nextTick
+} from 'vue'
+import {useStore} from 'vuex'
+import {useRouter, useRoute} from 'vue-router'
+
+export default defineComponent({
+  name: '',
+  components: {},
+  setup() {
+    const store = useStore();
+    const router = useRouter();
+    const route = useRoute();
+    const that = (getCurrentInstance() as ComponentInternalInstance).appContext.config.globalProperties
+    const state = reactive({})
+    return {
+      ...toRefs(state)
+    }
+  },
+})
+</script>
+
+<style scoped lang="scss">
+</style>