| | |
| | | axios.defaults.baseURL = 'http://127.0.0.1:8919/zijing_sx/'; |
| | | } |
| | | |
| | | axios.defaults.withCredentials=true; |
| | | |
| | | |
| | | // 添加请求拦截器 |
| | | axios.interceptors.request.use(function (config) { |
| | | if (process.env.NODE_ENV != 'dev') { |
| | |
| | | <span class="hdw-avatar-icon"> |
| | | <i class="iconfont el-icon-Userselect"></i> |
| | | </span> |
| | | <el-dropdown> |
| | | <el-dropdown @command="commandClick"> |
| | | <span class="hdw-avatar-text"> |
| | | superuser<i class="el-icon-arrow-down el-icon--right"></i> |
| | | {{username}}<i class="el-icon-arrow-down el-icon--right"></i> |
| | | </span> |
| | | <el-dropdown-menu slot="dropdown"> |
| | | <el-dropdown-item>密码修改</el-dropdown-item> |
| | | <el-dropdown-item>安全退出</el-dropdown-item> |
| | | <el-dropdown-item command="outSystem">安全退出</el-dropdown-item> |
| | | </el-dropdown-menu> |
| | | </el-dropdown> |
| | | </div> |
| | |
| | | |
| | | <script> |
| | | export default { |
| | | |
| | | data() { |
| | | return { |
| | | username: sessionStorage.getItem('username'), |
| | | } |
| | | }, |
| | | methods: { |
| | | outSystem() { |
| | | this.$router.push('/login'); |
| | | }, |
| | | commandClick(name) { |
| | | switch(name) { |
| | | case 'outSystem': |
| | | this.outSystem(); |
| | | break; |
| | | default: |
| | | this.$layer.msg('该功能暂未开放!'); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | | |
| | |
| | | <div class="page-content-tools"> |
| | | <el-popover |
| | | placement="bottom" |
| | | trigger="hover"> |
| | | trigger="hover" |
| | | v-show="showControl"> |
| | | <div class="hdw-menu-list"> |
| | | <ul> |
| | | <li class="hdw-menu-item"><a @click="dischargeDialog.show = true" href="javascript:void(0);">启动核容测试</a></li> |
| | |
| | | }, |
| | | data() { |
| | | return { |
| | | username: sessionStorage.getItem('username'), |
| | | /* 电池状态 模块 组端展示 */ |
| | | inputs: { |
| | | group_vol: 0 /* 端电压-组端电压 */, |
| | |
| | | } else { |
| | | return "未知设备(待开发)" |
| | | } |
| | | }, |
| | | showControl() { |
| | | if(this.username == 'superuser' || this.username == 'admin') { |
| | | return true; |
| | | }else { |
| | | return false; |
| | | } |
| | | } |
| | | }, |
| | | mounted() { |
| | |
| | | // 设置激活的导航 |
| | | this.acTabs = menu.name; |
| | | }, |
| | | checkUserLogin() { |
| | | checkUserLogin().then(res=>{ |
| | | let rs = JSON.parse(res.data.result); |
| | | if(rs.code == 1) { |
| | | alert(rs.msg); |
| | | this.$router.push('/login'); |
| | | }else { |
| | | clearInterval(this.timer); |
| | | this.timer = setTimeout(()=>{ |
| | | this.checkUserLogin(); |
| | | },5000); |
| | | } |
| | | }).catch(error=>{ |
| | | clearInterval(this.timer); |
| | | this.timer = setTimeout(()=>{ |
| | | this.checkUserLogin(); |
| | | },5000); |
| | | }); |
| | | }, |
| | | }, |
| | | mounted() { |
| | | // 开启用户重复登录检测 |
| | | this.checkUserLogin(); |
| | | |
| | | window.addEventListener('message', (msg)=>{ |
| | | // 处理数据 |
| | | this.handleMessage(msg.data); |
| | |
| | | if (res.result && JSON.parse(res.result).code == 0) |
| | | return this.$message.error(JSON.parse(res.result).msg); |
| | | this.$message.success("登录成功"); |
| | | sessionStorage.setItem('username', this.loginForm.username); |
| | | this.$router.push("/home"); |
| | | }); |
| | | } |
| | | }, |
| | | mounted() { |
| | | // 初始化登录状态 |
| | | sessionStorage.setItem('username', ""); |
| | | } |
| | | }; |
| | | </script> |
| | |
| | | routes |
| | | }); |
| | | |
| | | router.beforeEach((to, from, next)=>{ |
| | | if(to.name != 'login' && !sessionStorage.getItem('username')) { |
| | | next('\login'); |
| | | }else { |
| | | next(); |
| | | } |
| | | }); |
| | | |
| | | export default router; |