2 Commits aa55fd4327 ... 6f9e729589

Author SHA1 Message Date
  zzs 6f9e729589 Merge branch 'master' of http://219.147.85.210:8080/gmcs/HongHu-PSM 2 months ago
  zzs aceb41043a 1 2 months ago
2 changed files with 14 additions and 16 deletions
  1. 12 0
      quote-info-record-player/src/App.vue
  2. 2 16
      quote-info-record-player/src/store/user.js

+ 12 - 0
quote-info-record-player/src/App.vue

@@ -6,10 +6,22 @@
 </template>
 
 <script setup>
+import { getInfo } from '@/api/login'
 import ReRecord from './components/ReRecord.vue'
 import Login from './components/Login.vue'
 import useUserStore from "@/store/user";
+import { onMounted } from 'vue';
 const userStore = useUserStore();
+
+onMounted(() => {
+  getInfo().then(res => {
+    if (res.code == 200) {
+      userStore.setLogin(true);
+    }
+  }).catch(err => {
+    userStore.setLogin(false);
+  });
+});
 </script>
 
 <style lang="scss" scoped></style>

+ 2 - 16
quote-info-record-player/src/store/user.js

@@ -1,29 +1,15 @@
 import { defineStore } from 'pinia'
-import { getInfo } from '@/api/login'
-
-import { ElMessage } from 'element-plus'
 const useUserStore = defineStore('user', {
   state: () => ({
     isLogin: false
   }),
   getters: {
-    async getLogin() {
-      const res = await getInfo()
-      if (res.code === 200) {
-        if (res.roles.includes('admin')) {
-          return true
-        } else {
-          ElMessage.error('无权限访问')
-          false
-        }
-      } else {
-        return false
-      }
+    getLogin() {
+      return this.isLogin
     }
   },
   actions: {
     setLogin(flag) {
-      console.log(flag)
       this.isLogin = flag
     }
   }