修改用户声明,修改用户头像显示方式,随意添加了一个默认头像。
This commit is contained in:
parent
6a980e69d3
commit
136e8dfa95
|
@ -44,7 +44,7 @@ export default [
|
||||||
{
|
{
|
||||||
order_no: '@guid()',
|
order_no: '@guid()',
|
||||||
timestamp: +Mock.Random.date('T'),
|
timestamp: +Mock.Random.date('T'),
|
||||||
username: '@name()',
|
userName: '@name()',
|
||||||
price: '@float(1000, 15000, 0, 2)',
|
price: '@float(1000, 15000, 0, 2)',
|
||||||
'status|1': ['success', 'pending']
|
'status|1': ['success', 'pending']
|
||||||
}
|
}
|
||||||
|
|
BIN
src/assets/layout/user.png
Normal file
BIN
src/assets/layout/user.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 276 KiB |
|
@ -29,13 +29,17 @@
|
||||||
<!-- <SizeSelect />-->
|
<!-- <SizeSelect />-->
|
||||||
<!-- <LangSelect />-->
|
<!-- <LangSelect />-->
|
||||||
<el-dropdown trigger="click" size="medium">
|
<el-dropdown trigger="click" size="medium">
|
||||||
<div class="avatar-wrapper">
|
<div class="avatar-wrapper" :title="(userInfo?.realName || userInfo?.userName) + ' - 在线'">
|
||||||
<img src="https://github.jzfai.top/file/images/nav-right-logo.gif" class="user-avatar" />
|
<img :src="userInfo.avatar ?? userImage" alt="用户头像" class="user-avatar" />
|
||||||
|
<div class="user-avatar-status" />
|
||||||
</div>
|
</div>
|
||||||
<template #dropdown>
|
<template #dropdown>
|
||||||
<el-dropdown-menu>
|
<el-dropdown-menu class="drop-down">
|
||||||
|
<el-dropdown-item class="welcome-user">
|
||||||
|
{{ time }}好,<b>{{ userInfo.realName || userImage.userName || "平台用户" }}</b>
|
||||||
|
</el-dropdown-item>
|
||||||
<router-link to="/">
|
<router-link to="/">
|
||||||
<el-dropdown-item>{{ langTitle("Home") }}</el-dropdown-item>
|
<el-dropdown-item divided>{{ langTitle("Home") }}</el-dropdown-item>
|
||||||
</router-link>
|
</router-link>
|
||||||
<a target="_blank" href="https://github.com/jzfai/vue3-admin-plus">
|
<a target="_blank" href="https://github.com/jzfai/vue3-admin-plus">
|
||||||
<el-dropdown-item>{{ langTitle("Github") }}</el-dropdown-item>
|
<el-dropdown-item>{{ langTitle("Github") }}</el-dropdown-item>
|
||||||
|
@ -66,9 +70,10 @@ import { resetState } from "@/hooks/use-permission";
|
||||||
import { elMessage } from "@/hooks/use-element";
|
import { elMessage } from "@/hooks/use-element";
|
||||||
import { useBasicStore } from "@/store/basic";
|
import { useBasicStore } from "@/store/basic";
|
||||||
import { langTitle } from "@/hooks/use-common";
|
import { langTitle } from "@/hooks/use-common";
|
||||||
|
import userImage from "@/assets/layout/user.png";
|
||||||
|
|
||||||
const basicStore = useBasicStore();
|
const basicStore = useBasicStore();
|
||||||
const { settings, sidebar, setToggleSideBar, navbar } = basicStore;
|
const { settings, sidebar, setToggleSideBar, navbar, userInfo } = basicStore;
|
||||||
|
|
||||||
const toggleSideBar = () => {
|
const toggleSideBar = () => {
|
||||||
setToggleSideBar();
|
setToggleSideBar();
|
||||||
|
@ -82,6 +87,18 @@ const loginOut = () => {
|
||||||
resetState();
|
resetState();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const time = computed(() => {
|
||||||
|
const hover = new Date().getHours();
|
||||||
|
if (hover > 20) return "晚上";
|
||||||
|
if (hover > 17) return "傍晚";
|
||||||
|
if (hover > 13) return "下午";
|
||||||
|
if (hover > 11) return "中午";
|
||||||
|
if (hover > 8) return "上午";
|
||||||
|
if (hover > 5) return "早上";
|
||||||
|
return "凌晨";
|
||||||
|
});
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
@ -94,6 +111,7 @@ const loginOut = () => {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
overflow-x: auto;
|
overflow-x: auto;
|
||||||
|
|
||||||
&::-webkit-scrollbar {
|
&::-webkit-scrollbar {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
@ -106,23 +124,28 @@ const loginOut = () => {
|
||||||
.navbar-left {
|
.navbar-left {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
|
||||||
> * {
|
> * {
|
||||||
margin-right: 1em;
|
margin-right: 1em;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.navbar-center {
|
.navbar-center {
|
||||||
flex: 1 1;
|
flex: 1 1;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
|
|
||||||
> * {
|
> * {
|
||||||
margin: 0.5em;
|
margin: 0.5em;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.navbar-right {
|
.navbar-right {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: flex-end;
|
justify-content: flex-end;
|
||||||
|
|
||||||
> * {
|
> * {
|
||||||
margin-left: 1em;
|
margin-left: 1em;
|
||||||
}
|
}
|
||||||
|
@ -158,6 +181,17 @@ const loginOut = () => {
|
||||||
border-radius: 10px;
|
border-radius: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.user-avatar-status {
|
||||||
|
position: absolute;
|
||||||
|
right: -2px;
|
||||||
|
bottom: 0;
|
||||||
|
height: 10px;
|
||||||
|
width: 10px;
|
||||||
|
border-radius: 50%;
|
||||||
|
background-color: #55e802;
|
||||||
|
box-shadow: 0 0 3px black;
|
||||||
|
}
|
||||||
|
|
||||||
.el-icon-caret-bottom {
|
.el-icon-caret-bottom {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
@ -169,4 +203,6 @@ const loginOut = () => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.drop-down {
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -4,12 +4,20 @@ import { defineStore } from 'pinia'
|
||||||
import type { RouterTypes } from '~/basic'
|
import type { RouterTypes } from '~/basic'
|
||||||
import defaultSettings from '@/settings'
|
import defaultSettings from '@/settings'
|
||||||
import router, { constantRoutes } from '@/router'
|
import router, { constantRoutes } from '@/router'
|
||||||
|
|
||||||
export const useBasicStore = defineStore('basic', {
|
export const useBasicStore = defineStore('basic', {
|
||||||
state: () => {
|
state: () => {
|
||||||
return {
|
return {
|
||||||
token: '',
|
token: '',
|
||||||
getUserInfo: false,
|
getUserInfo: false,
|
||||||
userInfo: { username: '', avatar: '' }, //user info
|
userInfo: {
|
||||||
|
userName: '',
|
||||||
|
realName: '',
|
||||||
|
avatar: '',
|
||||||
|
phone: '',
|
||||||
|
id: '',
|
||||||
|
isUse: true
|
||||||
|
}, //user info
|
||||||
//router
|
//router
|
||||||
allRoutes: [] as RouterTypes,
|
allRoutes: [] as RouterTypes,
|
||||||
buttonCodes: [],
|
buttonCodes: [],
|
||||||
|
@ -46,13 +54,11 @@ export const useBasicStore = defineStore('basic', {
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
setUserInfo({ userInfo, roles, codes }) {
|
setUserInfo({ userInfo, roles, codes }) {
|
||||||
const { username, avatar } = userInfo
|
|
||||||
this.$patch((state) => {
|
this.$patch((state) => {
|
||||||
state.roles = roles
|
state.roles = roles
|
||||||
state.codes = codes
|
state.codes = codes
|
||||||
state.getUserInfo = true
|
state.getUserInfo = true
|
||||||
state.userInfo.username = username
|
state.userInfo = userInfo
|
||||||
state.userInfo.avatar = avatar
|
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
resetState() {
|
resetState() {
|
||||||
|
@ -65,8 +71,14 @@ export const useBasicStore = defineStore('basic', {
|
||||||
state.buttonCodes = []
|
state.buttonCodes = []
|
||||||
state.filterAsyncRoutes = []
|
state.filterAsyncRoutes = []
|
||||||
//reset userInfo
|
//reset userInfo
|
||||||
state.userInfo.username = ''
|
state.userInfo = {
|
||||||
state.userInfo.avatar = ''
|
userName: '',
|
||||||
|
realName: '',
|
||||||
|
avatar: '',
|
||||||
|
phone: '',
|
||||||
|
id: '',
|
||||||
|
isUse: true
|
||||||
|
}
|
||||||
})
|
})
|
||||||
this.getUserInfo = false
|
this.getUserInfo = false
|
||||||
},
|
},
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
<span class="svg-container">
|
<span class="svg-container">
|
||||||
<ElSvgIcon name="User" :size="14" />
|
<ElSvgIcon name="User" :size="14" />
|
||||||
</span>
|
</span>
|
||||||
<el-input v-model="subForm.username" placeholder="用户名" />
|
<el-input v-model="subForm.userName" placeholder="用户名" />
|
||||||
<!--占位-->
|
<!--占位-->
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item prop="password" :rules="formRules.isNotNull('密码')">
|
<el-form-item prop="password" :rules="formRules.isNotNull('密码')">
|
||||||
|
@ -53,7 +53,7 @@ const { settings } = useBasicStore();
|
||||||
const formRules = useElement().formRules;
|
const formRules = useElement().formRules;
|
||||||
//form
|
//form
|
||||||
const subForm = reactive({
|
const subForm = reactive({
|
||||||
username: "",
|
userName: "",
|
||||||
password: ""
|
password: ""
|
||||||
});
|
});
|
||||||
const state: any = reactive({
|
const state: any = reactive({
|
||||||
|
|
|
@ -8,7 +8,7 @@ export const useBasicStore = defineStore('basic', {
|
||||||
token: '',
|
token: '',
|
||||||
getUserInfo: false,
|
getUserInfo: false,
|
||||||
userInfo: {
|
userInfo: {
|
||||||
username: '',
|
userName: '',
|
||||||
avatar: ''
|
avatar: ''
|
||||||
},
|
},
|
||||||
allRoutes: [],
|
allRoutes: [],
|
||||||
|
|
Loading…
Reference in New Issue
Block a user