支持接口鉴权,支持修改密码,

This commit is contained in:
panlinlin
2021-04-14 16:33:10 +08:00
parent 123ce171d2
commit cb5849d8a1
20 changed files with 752 additions and 16 deletions

View File

@@ -215,8 +215,8 @@
console.log(`修改传输方式为 ${row.streamMode}${row.deviceId} `);
let that = this;
this.$axios({
method: 'get',
url: '/api/device/query/transport' + row.deviceId + '/' + row.streamMode
method: 'post',
url: '/api/device/query/transport/' + row.deviceId + '/' + row.streamMode
}).then(function(res) {
}).catch(function(e) {

View File

@@ -63,7 +63,7 @@ export default {
this.$axios({
method: 'get',
url:"/api/user/login",
url:"/api/user/login",
params: loginParam
}).then(function (res) {
console.log(JSON.stringify(res));
@@ -81,7 +81,7 @@ export default {
});
}
}).catch(function (error) {
that.$message.error(error.response.statusText);
that.$message.error(error.response.data.msg);
that.isLoging = false;
});
},

View File

@@ -1,21 +1,30 @@
<template>
<div id="UiHeader">
<el-menu router :default-active="this.$route.path" background-color="#545c64" text-color="#fff" active-text-color="#ffd04b" mode="horizontal">
<el-menu router :default-active="this.$route.path" menu-trigger="click" background-color="#545c64" text-color="#fff" active-text-color="#ffd04b" mode="horizontal">
<el-menu-item index="/">控制台</el-menu-item>
<el-menu-item index="/deviceList">设备列表</el-menu-item>
<el-menu-item index="/pushVideoList">推流列表</el-menu-item>
<el-menu-item index="/streamProxyList">拉流代理</el-menu-item>
<el-menu-item index="/parentPlatformList/15/1">国标级联</el-menu-item>
<el-menu-item @click="openDoc">在线文档</el-menu-item>
<el-switch v-model="alarmNotify" active-text="报警信息推送" style="display: block float: right" @change="sseControl"></el-switch>
<el-menu-item style="float: right;" @click="loginout">退出</el-menu-item>
<!-- <el-menu-item style="float: right;" @click="loginout">退出</el-menu-item>-->
<el-submenu index="" style="float: right;" >
<template slot="title">欢迎{{this.$cookies.get("session").username}}</template>
<el-menu-item @click="changePassword">修改密码</el-menu-item>
<el-menu-item @click="loginout">注销</el-menu-item>
</el-submenu>
</el-menu>
<changePasswordDialog ref="changePasswordDialog"></changePasswordDialog>
</div>
</template>
<script>
import changePasswordDialog from './dialog/changePassword.vue'
export default {
name: "UiHeader",
components: { Notification },
components: { Notification, changePasswordDialog },
data() {
return {
alarmNotify: true,
@@ -24,10 +33,25 @@ export default {
},
methods:{
loginout(){
this.$axios({
method: 'get',
url:"/api/user/logout"
}).then((res)=> {
// 删除cookie回到登录页面
this.$cookies.remove("session");
this.$router.push('/login');
this.sseSource.close();
}).catch((error)=> {
console.error("登出失败")
console.error(error)
});
},
changePassword(){
this.$refs.changePasswordDialog.openDialog()
},
openDoc(){
console.log(process.env.BASE_API)
window.open( !!process.env.BASE_API? process.env.BASE_API + "/doc.html": "/doc.html")
},
beforeunloadHandler() {
this.sseSource.close();

View File

@@ -0,0 +1,107 @@
<template>
<div id="changePassword" v-loading="isLoging">
<el-dialog
title="修改密码"
width="40%"
top="2rem"
:close-on-click-modal="false"
:visible.sync="showDialog"
:destroy-on-close="true"
@close="close()"
>
<div id="shared" style="margin-right: 20px;">
<el-form ref="passwordForm" :rules="rules" status-icon label-width="80px">
<el-form-item label="新密码" prop="newPassword" >
<el-input v-model="newPassword" autocomplete="off"></el-input>
</el-form-item>
<el-form-item label="确认密码" prop="confirmPassword">
<el-input v-model="confirmPassword" autocomplete="off"></el-input>
</el-form-item>
<el-form-item>
<div style="float: right;">
<el-button type="primary" @click="onSubmit">保存</el-button>
<el-button @click="close">取消</el-button>
</div>
</el-form-item>
</el-form>
</div>
</el-dialog>
</div>
</template>
<script>
export default {
name: "changePassword",
props: {},
computed: {},
created() {},
data() {
let validatePass = (rule, value, callback) => {
if (value === '') {
callback(new Error('请输入密码'));
} else {
if (this.confirmPassword !== '') {
this.$refs.passwordForm.validateField('confirmPassword');
}
callback();
}
};
let validatePass2 = (rule, value, callback) => {
if (this.confirmPassword === '') {
callback(new Error('请再次输入密码'));
} else if (this.confirmPassword !== this.newPassword) {
callback(new Error('两次输入密码不一致!'));
} else {
callback();
}
};
return {
newPassword: null,
confirmPassword: null,
showDialog: false,
isLoging: false,
rules: {
newPassword: [{ required: true, validator: validatePass, trigger: "blur" }],
confirmPassword: [{ required: true, validator: validatePass2, trigger: "blur" }],
},
};
},
methods: {
openDialog: function () {
this.showDialog = true;
},
onSubmit: function () {
this.$axios({
method: 'post',
url:"/api/user/changePassword",
params: {
password: this.newPassword
}
}).then((res)=> {
if (res.data === "success"){
this.$message({
showClose: true,
message: '修改成功,请重新登陆',
type: 'success'
});
this.showDialog = false;
setTimeout(()=>{
// 删除cookie回到登录页面
this.$cookies.remove("session");
this.$router.push('/login');
this.sseSource.close();
},800)
}
}).catch((error)=> {
console.error(error)
});
},
close: function () {
this.showDialog = false;
this.newPassword= null;
this.confirmPassword=null;
},
},
};
</script>