From d8fc3ec09f864dc336b649f66a2c62345da12629 Mon Sep 17 00:00:00 2001 From: yj <2077506045@qq.com> Date: 星期三, 08 五月 2024 18:02:19 +0800 Subject: [PATCH] 答题LOGO自定义功能 --- src/layout/index.vue | 41 ++++++++++++++++++++++++++++++++++------- 1 files changed, 34 insertions(+), 7 deletions(-) diff --git a/src/layout/index.vue b/src/layout/index.vue index 2e6a7e1..ca5a298 100644 --- a/src/layout/index.vue +++ b/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 }) } } -- Gitblit v1.9.1