MeterSphere/frontend/src/business/App.vue

131 lines
2.9 KiB
Vue
Raw Normal View History

2020-02-03 14:01:28 +08:00
<template>
<el-col v-if="auth">
2020-09-22 19:48:44 +08:00
<el-row v-if="licenseHeader != null">
<el-col>
2020-09-22 19:48:44 +08:00
<component :is="licenseHeader"></component>
</el-col>
</el-row>
2020-02-03 14:01:28 +08:00
<el-row id="header-top" type="flex" justify="space-between" align="middle">
2020-04-23 15:34:38 +08:00
<el-col :span="12">
2020-02-20 17:42:22 +08:00
<a class="logo"/>
<ms-top-menus/>
</el-col>
2020-04-23 15:34:38 +08:00
2020-05-13 16:29:19 +08:00
<el-col :span="12" class="align-right">
2020-05-13 16:26:51 +08:00
<!-- float right -->
2020-05-13 16:29:19 +08:00
<ms-user/>
<ms-language-switch/>
<ms-header-org-ws/>
2020-02-20 17:42:22 +08:00
</el-col>
2020-02-03 14:01:28 +08:00
</el-row>
2020-03-12 15:57:02 +08:00
2020-02-03 14:01:28 +08:00
<ms-view/>
</el-col>
</template>
<script>
2020-03-12 17:04:27 +08:00
import MsTopMenus from "./components/common/head/HeaderTopMenus";
import MsView from "./components/common/router/View";
import MsUser from "./components/common/head/HeaderUser";
2020-05-13 16:07:18 +08:00
import MsHeaderOrgWs from "./components/common/head/HeaderOrgWs";
import MsLanguageSwitch from "./components/common/head/LanguageSwitch";
2020-08-17 10:09:19 +08:00
import {saveLocalStorage} from "../common/js/utils";
2020-09-22 19:48:44 +08:00
const requireComponent = require.context('@/business/components/xpack/', true, /\.vue$/);
2020-09-23 10:11:06 +08:00
const header = requireComponent.keys().length > 0 ? requireComponent("./license/LicenseMessage.vue") : {};
2020-02-03 14:01:28 +08:00
export default {
name: 'app',
2020-09-22 19:48:44 +08:00
props: {},
2020-02-03 14:01:28 +08:00
data() {
return {
2020-09-22 19:48:44 +08:00
licenseHeader: null,
auth: false,
header: {},
2020-02-03 14:01:28 +08:00
}
},
beforeCreate() {
this.$get("/isLogin").then(response => {
if (response.data.success) {
2020-08-17 10:09:19 +08:00
this.$setLang(response.data.data.language);
saveLocalStorage(response.data);
2020-02-03 14:01:28 +08:00
this.auth = true;
2020-09-22 19:48:44 +08:00
// 是否显示校验信息
if (header.default !== undefined) {
2020-09-22 19:50:47 +08:00
this.licenseHeader = "LicenseMessage";
2020-09-22 19:48:44 +08:00
}
2020-02-03 14:01:28 +08:00
} else {
window.location.href = "/login"
}
}).catch(() => {
window.location.href = "/login"
});
},
2020-09-22 19:48:44 +08:00
components: {
MsLanguageSwitch,
MsUser,
MsView,
MsTopMenus,
MsHeaderOrgWs,
2020-09-22 19:50:47 +08:00
"LicenseMessage": header.default
2020-09-22 19:48:44 +08:00
}
2020-02-03 14:01:28 +08:00
}
</script>
2020-09-22 19:48:44 +08:00
2020-02-03 14:01:28 +08:00
<style scoped>
#header-top {
width: 100%;
padding: 0 10px;
background-color: rgb(44, 42, 72);
color: rgb(245, 245, 245);
font-size: 14px;
}
.logo {
width: 156px;
2020-06-11 11:43:39 +08:00
margin-bottom: 0;
border: 0;
2020-02-03 14:01:28 +08:00
margin-right: 20px;
display: inline-block;
2020-06-11 11:43:39 +08:00
line-height: 37px;
2020-02-03 14:01:28 +08:00
background-size: 156px 30px;
2020-06-11 11:43:39 +08:00
box-sizing: border-box;
height: 37px;
2020-02-03 14:01:28 +08:00
background-repeat: no-repeat;
background-position: 50% center;
2020-06-09 15:26:19 +08:00
background-image: url("../assets/logo-light-MeterSphere.svg");
2020-02-03 14:01:28 +08:00
}
.menus > * {
color: inherit;
padding: 0;
max-width: 180px;
white-space: pre;
cursor: pointer;
line-height: 40px;
}
2020-04-23 15:34:38 +08:00
.header-top-menus {
display: inline-block;
border: 0;
}
2020-02-03 14:01:28 +08:00
.menus > a {
padding-right: 15px;
text-decoration: none;
}
2020-05-13 16:26:51 +08:00
.align-right {
float: right;
}
.license-head {
height: 30px;
background: #BA331B;
text-align: center;
line-height: 30px;
color: white;
}
2020-02-03 14:01:28 +08:00
</style>