[测评系统]--前端(用户答题页面)
yj
2024-05-08 d8fc3ec09f864dc336b649f66a2c62345da12629
src/layout/index.vue
@@ -1,21 +1,21 @@
<template>
  <el-container>
    <el-header height="60" class="student-header header" :style="{'background-color': productType==='API_Fan'?'#fff':'#409eff'}">
    <el-header height="60" class="student-header header" :style="{'background-color': logo!='none'?'#fff':'#409eff'}">
      <div class="head-language" v-if="langFlag">
        <!--<lang-select class="right-menu-item" />-->
        <!--国际化的语言选择-->
        <!--<component :is="langSelect"></component>-->
      </div>
      <div class="head-user" style="float:left;">
        <span></span>
        <el-dropdown trigger="click" placement="bottom">
          <el-image v-if="productType==='API_Fan'" :style="{'height': isMobile?'50px':'60px','margin-top':'5px'}" :src="require('@/assets/logo-apifan.png')" fit="fill"></el-image>
          <el-badge v-else style="height: 50px;">
          <el-image v-if="productType=='API_Fan'" :style="{'max-height': isMobile?'50px':'50px','margin-top':'5px','height':logoHeight+'px'}" :src="require('@/assets/logo-apifan.png')" fit="fill"></el-image>
          <el-image @load="imageLoad" @error="imageError" v-else-if="logo!='none'" :style="{'max-height': isMobile?'50px':'50px','margin-top':'5px','height':logoHeight+'px'}" :src="logo" fit="fill"></el-image>
          <el-badge v-else-if="logo=='none'" style="height: 50px;">
            <el-avatar  class="el-dropdown-avatar" size="medium"  :src="userInfo.imagePath === null ? require('@/assets/logo-t.jpg') : userInfo.imagePath"></el-avatar>
          </el-badge>
          <el-dropdown-menu slot="dropdown">
<!--            <el-dropdown-item divided>保存退出</el-dropdown-item>-->
          </el-dropdown-menu>
          </el-dropdown-menu>
        </el-dropdown>
      </div>
    </el-header>
@@ -29,12 +29,14 @@
<script>
import LangSelect from '@/components/LangSelect'
import { mapState } from 'vuex'
import { mapMutations, mapState } from 'vuex'
export default {
  name: 'Layout',
  data () {
    return {
      defaultUrl: '/index',
      logoHeight: 50,
      logoUrl: null,
      userInfo: {
        imagePath: null
      },
@@ -44,17 +46,42 @@
  },
  created () {
  },
  computed: {
  },
  methods: {
    logout: function () {
      window.opener = null
      window.open('about:blank', '_top').close()
    }
    },
    getLogoHeight: function () {
    },
    imageLoad: function (e) {
      sessionStorage.setItem('logoUrl', this.logo)
      let that = this
      var img = new Image()
      img.onload = function () {
        that.logoHeight = img.height
        if (that.logoHeight > 50) {
          that.logoHeight = 50
        }
      }
      img.src = that.logo
    },
    imageError: function (e) {
      if (this.logo === null) {
        this.setLogo(sessionStorage.getItem('logoUrl'))
      }
    },
    ...mapMutations('user', ['setLogo'])
  },
  components: {
    'langSelect': LangSelect
  },
  computed: {
    ...mapState('user', { langFlag: state => state.langFlag }),
    ...mapState('user', { logo: state => state.logo }),
    ...mapState('exam', { productType: state => state.productType })
  }
}