智慧园区前端大屏
shuishen
2024-11-01 fa0866fc8a4f200d491acfa0ad9e7b1e96ff37a1
系统增加退出登录
4 files modified
74 ■■■■■ changed files
src/api/user.js 7 ●●●●● patch | view | raw | blame | history
src/store/login.js 21 ●●●●● patch | view | raw | blame | history
src/views/layout/index.vue 42 ●●●●● patch | view | raw | blame | history
src/views/survey/components/rightContainer.vue 4 ●●● patch | view | raw | blame | history
src/api/user.js
@@ -19,4 +19,11 @@
      scope: 'all',
      type,
    },
  })
export const logout = () =>
  request({
    url: '/blade-auth/oauth/logout',
    method: 'get',
    authorization: false,
  })
src/store/login.js
@@ -1,6 +1,7 @@
// src/stores/useUserStore.js
import {
  loginByUsername,
  logout
} from '@/api/user'
import { defineStore } from 'pinia'
import md5 from 'js-md5'
@@ -38,7 +39,6 @@
          userInfo.code
        )
          .then(res => {
            console.log(res, 122222)
            const data = res.data
            if (data.error_description) {
              ElMessage({
@@ -73,7 +73,24 @@
    SET_USER_INFO (userInfo) {
      this.userInfo = userInfo
    }
    },
    // 登出
    LogOut () {
      return new Promise((resolve, reject) => {
        logout()
          .then(() => {
            this.SET_TOKEN('')
            this.SET_REFRESH_TOKEN('')
            this.SET_TENANT_ID('')
            this.SET_USER_INFO('')
            resolve()
          })
          .catch((error) => {
            reject(error)
          })
      })
    },
  },
  persist: {
src/views/layout/index.vue
@@ -2,7 +2,7 @@
 * @Author: shuishen 1109946754@qq.com
 * @Date: 2022-08-18 16:18:24
 * @LastEditors: shuishen 1109946754@qq.com
 * @LastEditTime: 2024-11-01 10:37:23
 * @LastEditTime: 2024-11-01 20:00:52
 * @FilePath: \bigScreen\src\views\layout\index.vue
 * @Description: 
 * 
@@ -15,6 +15,11 @@
        <div v-if="showContent" class="main-content" id="MainContent">
          <div class="main-header">
            <div class="title">吉水化工园区“一园一策一图”VR平台</div>
            <div class="login-out" @click="signOut">
              <img :src="loginOutBg" class="img" />
              <span>退出</span>
            </div>
          </div>
          <div class="main-container">
@@ -32,10 +37,16 @@
</template>
<script setup>
import { useRouter, useRoute } from 'vue-router'
let router = useRouter()
import { getAssetsFile } from 'utils/utils'
const loginOutBg = getAssetsFile('login.png', '/images')
import mainSearch from './components/mainSearch.vue'
import mainTool from './components/mainTool.vue'
import mainMenu from './components/mainMenu.vue'
import { useLogin } from 'store/login'
const loginStore = useLogin()
import { useMap } from 'store/map'
const store = useMap()
const showContent = ref(false)
@@ -50,6 +61,12 @@
  },
  { immediate: true } // 设置immediate为true以便在组件挂载时立即检查createB的值  
)
const signOut = () => {
  loginStore.LogOut().then(res => {
    router.push('/login')
  })
}
</script>
<style scoped lang="scss">
@@ -113,6 +130,29 @@
        // -webkit-background-clip: text;
        // -webkit-text-fill-color: transparent;
      }
      .login-out {
        position: absolute;
        top: 10px;
        right: 40px;
        height: 36px;
        color: #fff;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: space-between;
        cursor: pointer;
        .img {
          width: 16px;
          height: 16px;
        }
        span {
          font-size: 13px;
        }
      }
    }
    .main-container {
src/views/survey/components/rightContainer.vue
@@ -2,7 +2,7 @@
 * @Author: shuishen 1109946754@qq.com
 * @Date: 2023-03-10 15:27:59
 * @LastEditors: shuishen 1109946754@qq.com
 * @LastEditTime: 2024-11-01 10:42:13
 * @LastEditTime: 2024-11-01 11:22:02
 * @FilePath: \bigScreen\src\views\survey\components\rightContainer.vue
 * @Description: 
 * 
@@ -16,6 +16,8 @@
</script>
<template>
  <div class="mt-10 w100 h100 flex f-d-c a-i-c j-c-s-p"></div>
  <div class="right-container">
    <div class="h0 fire-source box">
      <title-box>