添加前端用户信息展示

This commit is contained in:
橙子
2022-04-30 22:04:47 +08:00
parent d6b0c56c35
commit 2f69e0b96c
3 changed files with 21 additions and 19 deletions

View File

@@ -41,6 +41,13 @@ export default {
method: 'put', method: 'put',
data: { user, newPassword } data: { user, newPassword }
}) })
},
getUserAllInfo()
{
return myaxios({
url: `/Account/getUserAllInfo`,
method: 'get'
})
} }
} }

View File

@@ -16,7 +16,7 @@
<v-list :tile="false" flat nav> <v-list :tile="false" flat nav>
<app-bar-item to="/" <app-bar-item to="/"
><v-list-item-title v-text="'用户名:'+$store.state.user.user.username" ><v-list-item-title v-text="'用户名:'+$store.state.user.user.userName"
/></app-bar-item> /></app-bar-item>
<app-bar-item to="/" <app-bar-item to="/"
><v-list-item-title v-text="'称号:'+$store.state.user.user.nick" ><v-list-item-title v-text="'称号:'+$store.state.user.user.nick"
@@ -27,7 +27,7 @@
<template v-for="(p, i) in profile"> <template v-for="(p, i) in profile">
<v-divider v-if="p.divider" :key="`divider-${i}`" class="mb-2 mt-2" /> <v-divider v-if="p.divider" :key="`divider-${i}`" class="mb-2 mt-2" />
<app-bar-item v-else :key="`item-${i}`" to="/"> <app-bar-item v-else :key="`item-${i}`" :to="p.router">
<v-list-item-title v-text="p.title" /> <v-list-item-title v-text="p.title" />
</app-bar-item> </app-bar-item>
</template> </template>
@@ -40,10 +40,10 @@ export default {
name: "DefaultAccount", name: "DefaultAccount",
data: () => ({ data: () => ({
profile: [ profile: [
{ title: "用户信息" }, { title: "用户信息",router:"/userInfo" },
{ title: "设置" }, { title: "设置" },
{ divider: true }, { divider: true },
{ title: "登出" }, { title: "登出",router:"/login" },
], ],
}), }),
}; };

View File

@@ -7,7 +7,7 @@
<v-card-text class="text-center"> <v-card-text class="text-center">
<h6 class="text-h6 mb-2 text--secondary"> <h6 class="text-h6 mb-2 text--secondary">
{{ userInfo.username }} {{ userInfo.userName }}
</h6> </h6>
<h4 class="text-h4 mb-3 text--primary">{{ userInfo.nick }}</h4> <h4 class="text-h4 mb-3 text--primary">{{ userInfo.nick }}</h4>
@@ -61,7 +61,7 @@
<v-text-field <v-text-field
color="purple" color="purple"
label="用户名" label="用户名"
v-model="editInfo.username" v-model="editInfo.userName"
disabled disabled
/> />
</v-col> </v-col>
@@ -154,12 +154,12 @@
<v-list-item-subtitle> <v-list-item-subtitle>
<v-row> <v-row>
<v-col <v-col
v-for="item in editInfo.roles" v-for="item in roleInfo"
:key="item.id" :key="item.id"
cols="6" cols="6"
sm="3" sm="3"
md="1" md="1"
>{{ item.role_name }}</v-col >{{ item.roleName }}</v-col
> >
</v-row> </v-row>
</v-list-item-subtitle> </v-list-item-subtitle>
@@ -178,7 +178,7 @@
cols="6" cols="6"
sm="3" sm="3"
md="1" md="1"
>{{ item.menu_name }}</v-col >{{ item.menuName }}</v-col
> >
</v-row> </v-row>
</v-list-item-subtitle> </v-list-item-subtitle>
@@ -264,7 +264,6 @@
<script> <script>
import fileApi from "../api/fileApi"; import fileApi from "../api/fileApi";
import userApi from "../api/userApi"; import userApi from "../api/userApi";
import menuApi from "../api/menuApi";
import accountApi from "../api/accountApi"; import accountApi from "../api/accountApi";
export default { export default {
name: "UserProfileView", name: "UserProfileView",
@@ -274,6 +273,7 @@ export default {
editInfo: {}, editInfo: {},
newPassword: "", newPassword: "",
dis_newPassword: true, dis_newPassword: true,
roleInfo:[],
menuInfo: [], menuInfo: [],
}), }),
created() { created() {
@@ -313,19 +313,14 @@ export default {
}, },
init() { init() {
this.newPassword = ""; this.newPassword = "";
userApi.GetUserInRolesByHttpUser().then((resp) => { accountApi.getUserAllInfo().then((resp) => {
this.userInfo = resp.data; this.userInfo = resp.data.user;
this.userInfo.password = ""; this.userInfo.password = "";
this.editInfo = Object.assign({}, this.userInfo); this.editInfo = Object.assign({}, this.userInfo);
this.roleInfo=resp.data.roles;
this.menuInfo = resp.data.menus;
this.$store.commit('SET_USER',this.userInfo) this.$store.commit('SET_USER',this.userInfo)
}); });
menuApi.GetTopMenusByHttpUser().then((resp) => {
this.menuInfo = resp.data;
});
}, },
choiceImg() { choiceImg() {
this.$refs.imgFile.dispatchEvent(new MouseEvent("click")); this.$refs.imgFile.dispatchEvent(new MouseEvent("click"));