| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178 |
- <template>
- <div class="sidebar-logo-container" :class="{'collapse':collapse}" style="height: 70px" :style="{ backgroundColor: sideTheme === 'theme-dark' ? variables.menuBackground : variables.menuLightBackground }">
- <transition name="sidebarLogoFade">
- <!--<router-link v-if="collapse" key="collapse" class="sidebar-logo-link" to="/">-->
- <!--<img v-if="logo" :src="logo" class="sidebar-logo" />-->
- <!--<h1 v-else class="sidebar-title" :style="{ color: sideTheme === 'theme-dark' ? variables.logoTitleColor : variables.logoLightTitleColor }">{{ title }} </h1>-->
- <!--</router-link>-->
- <router-link key="expand" class="sidebar-logo-link" to="/">
- <img v-if="logo" :src="logo" style="width: 100%; margin-right: 81px;height: 100%;"/>
- <h1 class="sidebar-title" style="margin-left:-40px;" :style="{ color: sideTheme === 'theme-dark' ? variables.logoTitleColor : variables.logoLightTitleColor}"></h1>
- </router-link>
- </transition>
- </div>
- </template>
- <script>
- import logoImg from '@/assets/logo/logo.png'
- import Cookies from "js-cookie";
- import variables from '@/assets/styles/variables.scss'
- import { changeLanguages,systemConfiguration,equipmentMintenance } from "@/api/pdu/pduServer";
- export default {
- name: 'SidebarLogo',
- props: {
- collapse: {
- type: Boolean,
- required: true
- }
- },
- computed: {
- variables() {
- return variables;
- },
- sideTheme() {
- return this.$store.state.settings.sideTheme
- }
- },
- data() {
- return {
- title: this.$i18n.t('loginFormTitle'),
- logo: "",
- language:[
- {"key":"zh-CN","value":"简体中文","id":"1"},
- // {"key":"zh-TW","value":"繁體中文"},
- {"key":"en-US","value":"English","id":"2"},
- {"key":"ru-RU","value":"俄语","id":"3"}
- ],
- }
- },
- created() {
- this.systemConfiguration();
- },
- methods: {
- // 获取系统配置
- systemConfiguration(){
- systemConfiguration({}).then(response => {
- if(response.data!=null){
- if(response.data.logo!='' &&response.data.logo!=undefined && response.data.logo!=null ){
- this.logo=response.data.logo;
- }
- var data=response.data;
- var webSocket=data.webSocket;
- var systemLanguage=data.systemLanguage;
- let language = Cookies.get("flowinnIotLanguage");
- if(systemLanguage!='' && systemLanguage!=null){
- for (var i = 0; i < this.language.length; i++) {
- let item = this.language[i]
- if (systemLanguage== item.id) {
- let cookieslanguage = Cookies.get("flowinnIotLanguage");
- if(cookieslanguage!=item.key){
- // 用户修改了显示语言,重新设置语言
- this.chooseLanguage = item.key;
- // 临时保存到cookies中,后面由具体的方法去处理
- Cookies.set("flowinnIotLanguage", this.chooseLanguage,{ expires: 3000 });
- this.setWebLanguage();
- window.location.reload();
- }
- }
- }
- }else{
- this.setWebLanguage();
- }
- }
- });
- },
- setWebLanguage(){
- // cookies中是刚才用户选择的语言
- let language = Cookies.get("flowinnIotLanguage");
- if(language != null && language != "" && language != undefined){
- this.chooseLanguage = language;
- }else{
- // 如果cookies中没有,说明用户第一次打开系统,直接获取系统的语言
- let systemLanguage = (navigator.language || navigator.userLanguage).substring(0, 2);
- if(systemLanguage != null && systemLanguage != "" && systemLanguage != undefined){
- // 这里获取到的是zh和es,不是zh-CN需要单独处理
- this.chooseLanguage = systemLanguage;
- }
- }
- if(this.chooseLanguage == "zh" || this.chooseLanguage == "zh-CN"){
- this.chooseLanguage = "zh-CN";
- }else if(this.chooseLanguage == "zh-TW"){
- this.chooseLanguage = "zh-TW";
- }else if(this.chooseLanguage == "ru-RU"){
- this.chooseLanguage = "ru-RU";
- }else{
- this.chooseLanguage = "en-US";
- }
- var time = new Date().getTime();
- // 设置一个3年的有效期
- let timeNum = time + (3 * 365 * 24 * 60 * 60);
- Cookies.set("flowinnIotLanguage", this.chooseLanguage,{ expires: timeNum });
- // 保存到全局变量中,后面可以使用
- localStorage.setItem("language", this.chooseLanguage);
- // 页面刷新语言进行显示
- this.$i18n.locale = this.chooseLanguage;
- // 修改页面标题
- document.title = (this.$i18n.t('loginFormTitle')).replace("PDU","");
- },
- }
- }
- </script>
- <style lang="scss" scoped>
- .sidebarLogoFade-enter-active {
- transition: opacity 1.5s;
- }
- .sidebarLogoFade-enter,
- .sidebarLogoFade-leave-to {
- opacity: 0;
- }
- .sidebar-logo-container {
- position: relative;
- width: 100%;
- height: 50px;
- line-height: 50px;
- background: #2b2f3a;
- text-align: center;
- overflow: hidden;
- & .sidebar-logo-link {
- height: 100%;
- width: 100%;
- & .sidebar-logo {
- width: 32px;
- height: 32px;
- vertical-align: middle;
- margin-right: 12px;
- }
- & .sidebar-title {
- display: inline-block;
- margin: 0;
- color: #fff;
- font-weight: 600;
- line-height: 50px;
- font-size: 14px;
- font-family: Avenir, Helvetica Neue, Arial, Helvetica, sans-serif;
- vertical-align: middle;
- }
- }
- &.collapse {
- .sidebar-logo {
- margin-right: 0px;
- }
- }
- }
- </style>
|