mirror of
https://github.com/YMFE/yapi.git
synced 2025-04-18 15:20:25 +08:00
fix: 继续修改user页的显示
This commit is contained in:
parent
83739b3a4e
commit
66ba6549b0
@ -1,9 +1,7 @@
|
||||
import moment from 'moment'
|
||||
import regex_parse from './parseCommon.js';
|
||||
// import regex_parse from './parseCommon.js';
|
||||
|
||||
|
||||
exports.formatTime = (timestamp) => {
|
||||
return moment.unix(timestamp).format("YYYY-MM-DD HH:mm:ss")
|
||||
}
|
||||
|
||||
console.log(regex_parse)
|
||||
|
@ -6,7 +6,6 @@ import PropTypes from 'prop-types'
|
||||
import { connect } from 'react-redux'
|
||||
|
||||
@connect(state=>{
|
||||
console.log(state);
|
||||
return {
|
||||
curUid: state.user.uid,
|
||||
userType: state.user.type,
|
||||
@ -156,7 +155,6 @@ class Profile extends Component {
|
||||
if(userinfo.uid === this.props.curUid){//本人
|
||||
btn = <Button icon="edit" onClick={() => { this.handleEdit('usernameEdit', true) }}>修改</Button>;
|
||||
}else{
|
||||
|
||||
if(this.props.curRole === "admin"){
|
||||
btn = <Button icon="edit" onClick={() => { this.handleEdit('usernameEdit', true) }}>修改</Button>;
|
||||
}else{
|
||||
@ -192,6 +190,9 @@ class Profile extends Component {
|
||||
if(userType){
|
||||
if(userinfo.uid === this.props.curUid){//本人
|
||||
btn = <Button icon="edit" onClick={() => { this.handleEdit('emailEdit', true) }}>修改</Button>
|
||||
if(userinfo.role === 'admin'){
|
||||
btn = "";
|
||||
}
|
||||
}else{
|
||||
if(this.props.curRole === "admin"){
|
||||
btn = <Button icon="edit" onClick={() => { this.handleEdit('emailEdit', true) }}>修改</Button>
|
||||
@ -236,13 +237,13 @@ class Profile extends Component {
|
||||
|
||||
if (this.state.secureEdit === false) {
|
||||
let btn = "";
|
||||
if(this.props.curRole === "admin" && userType){
|
||||
if(userType){
|
||||
btn = <Button icon="edit" onClick={() => { this.handleEdit('secureEdit', true) }}>修改</Button>
|
||||
}
|
||||
secureEditHtml = btn;
|
||||
} else {
|
||||
secureEditHtml = <div>
|
||||
<Input style={{display: this.props.curRole === 'admin' ? 'none': ''}} placeholder="旧的密码" type="password" name="old_password" id="old_password" />
|
||||
<Input style={{display: this.props.curRole === 'admin'&& userinfo.role!='admin' ? 'none': ''}} placeholder="旧的密码" type="password" name="old_password" id="old_password" />
|
||||
<Input placeholder="新的密码" type="password" name="password" id="password" />
|
||||
<Input placeholder="确认密码" type="password" name="verify_pass" id="verify_pass" />
|
||||
<ButtonGroup className="edit-buttons" >
|
||||
@ -254,7 +255,7 @@ class Profile extends Component {
|
||||
|
||||
return <div className="user-profile">
|
||||
<Row className="user-item" type="flex" justify="start">
|
||||
<Col span={24}>{userinfo.uid === this.props.curUid?<AvatarUpload uid={userinfo.uid}>点击上传头像</AvatarUpload>:<img className = "avatarImg" src = {`/api/user/avatar?uid=${userinfo.uid}`} />}</Col>
|
||||
<Col span={24}>{userinfo.uid === this.props.curUid?<AvatarUpload uid={userinfo.uid}>点击上传头像</AvatarUpload>:<div className = "avatarImg"><img src = {`/api/user/avatar?uid=${userinfo.uid}`} /></div>}</Col>
|
||||
<Col span={4}>用户id</Col>
|
||||
<Col span={12}>
|
||||
{userinfo.uid}
|
||||
@ -291,7 +292,7 @@ class Profile extends Component {
|
||||
</Col>
|
||||
</Row>
|
||||
|
||||
{(this.props.curRole === "admin" && userType)?<Row className="user-item" type="flex" justify="start">
|
||||
{(userType)?<Row className="user-item" type="flex" justify="start">
|
||||
<Col span={4}>密码</Col>
|
||||
<Col span={12}>
|
||||
{secureEditHtml}
|
||||
|
@ -29,13 +29,9 @@ class User extends Component {
|
||||
super(props)
|
||||
}
|
||||
|
||||
componentDidMount () {
|
||||
// console.log(this.props.match)
|
||||
}
|
||||
|
||||
render () {
|
||||
let navData = [{
|
||||
name: '个人资料',
|
||||
name: '用户资料',
|
||||
path: `/user/profile/${this.props.curUid}`
|
||||
}];
|
||||
if(this.props.role === "admin"){
|
||||
|
@ -126,6 +126,11 @@
|
||||
.avatarImg{
|
||||
width: 100px;
|
||||
border-radius: 50px;
|
||||
overflow: hidden;
|
||||
height: 100px;
|
||||
img{
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
.avatar-uploader {
|
||||
display: block;
|
||||
|
@ -19,7 +19,8 @@ const initialState = {
|
||||
email: '',
|
||||
loginState: LOADING_STATUS,
|
||||
loginWrapActiveKey: "1",
|
||||
role: ""
|
||||
role: "",
|
||||
type: ""
|
||||
};
|
||||
|
||||
export default (state = initialState, action) => {
|
||||
@ -43,7 +44,8 @@ export default (state = initialState, action) => {
|
||||
loginState: MEMBER_STATUS,
|
||||
uid: action.payload.data.data.uid,
|
||||
userName: action.payload.data.data.username,
|
||||
role: action.payload.data.data.role
|
||||
role: action.payload.data.data.role,
|
||||
type: action.payload.data.data.type
|
||||
};
|
||||
} else {
|
||||
return state;
|
||||
@ -56,7 +58,8 @@ export default (state = initialState, action) => {
|
||||
loginState: GUEST_STATUS,
|
||||
userName: null,
|
||||
uid: null,
|
||||
role: ""
|
||||
role: "",
|
||||
type: ""
|
||||
}
|
||||
}
|
||||
case LOGIN_TYPE: {
|
||||
@ -71,7 +74,8 @@ export default (state = initialState, action) => {
|
||||
isLogin: true,
|
||||
loginState: MEMBER_STATUS,
|
||||
uid: action.payload.data.data.uid,
|
||||
userName: action.payload.data.data.username
|
||||
userName: action.payload.data.data.username,
|
||||
type: action.payload.data.data.type
|
||||
};
|
||||
}
|
||||
default:
|
||||
@ -83,7 +87,6 @@ export default (state = initialState, action) => {
|
||||
export function checkLoginState() {
|
||||
return(dispatch)=> {
|
||||
axios.get('/api/user/status').then((res) => {
|
||||
console.log(res)
|
||||
dispatch({
|
||||
type: GET_LOGIN_STATE,
|
||||
payload: res
|
||||
|
@ -287,7 +287,8 @@ class userController extends baseController {
|
||||
username: user.username,
|
||||
add_time: user.add_time,
|
||||
up_time: user.up_time,
|
||||
role: 'member'
|
||||
role: 'member',
|
||||
type: user.type
|
||||
});
|
||||
yapi.commons.sendMail({
|
||||
to: user.email,
|
||||
|
@ -39,19 +39,19 @@ class userModel extends baseModel {
|
||||
}
|
||||
|
||||
list() {
|
||||
return this.model.find().select('_id username email role add_time up_time').exec(); //显示id name email role
|
||||
return this.model.find().select('_id username email role type add_time up_time').exec(); //显示id name email role
|
||||
}
|
||||
|
||||
findByUids(uids) {
|
||||
return this.model.find({
|
||||
_id: { $in: uids }
|
||||
}).select('_id username email role add_time up_time').exec();
|
||||
}).select('_id username email role type add_time up_time').exec();
|
||||
}
|
||||
|
||||
listWithPaging(page, limit) {
|
||||
page = parseInt(page);
|
||||
limit = parseInt(limit);
|
||||
return this.model.find().sort({ _id: -1 }).skip((page - 1) * limit).limit(limit).select('_id username email role add_time up_time').exec();
|
||||
return this.model.find().sort({ _id: -1 }).skip((page - 1) * limit).limit(limit).select('_id username email role type add_time up_time').exec();
|
||||
}
|
||||
|
||||
listCount() {
|
||||
|
@ -590,7 +590,8 @@ var userController = function (_baseController) {
|
||||
username: user.username,
|
||||
add_time: user.add_time,
|
||||
up_time: user.up_time,
|
||||
role: 'member'
|
||||
role: 'member',
|
||||
type: user.type
|
||||
});
|
||||
_yapi2.default.commons.sendMail({
|
||||
to: user.email,
|
||||
|
@ -78,21 +78,21 @@ var userModel = function (_baseModel) {
|
||||
}, {
|
||||
key: 'list',
|
||||
value: function list() {
|
||||
return this.model.find().select('_id username email role add_time up_time').exec(); //显示id name email role
|
||||
return this.model.find().select('_id username email role type add_time up_time').exec(); //显示id name email role
|
||||
}
|
||||
}, {
|
||||
key: 'findByUids',
|
||||
value: function findByUids(uids) {
|
||||
return this.model.find({
|
||||
_id: { $in: uids }
|
||||
}).select('_id username email role add_time up_time').exec();
|
||||
}).select('_id username email role type add_time up_time').exec();
|
||||
}
|
||||
}, {
|
||||
key: 'listWithPaging',
|
||||
value: function listWithPaging(page, limit) {
|
||||
page = parseInt(page);
|
||||
limit = parseInt(limit);
|
||||
return this.model.find().sort({ _id: -1 }).skip((page - 1) * limit).limit(limit).select('_id username email role add_time up_time').exec();
|
||||
return this.model.find().sort({ _id: -1 }).skip((page - 1) * limit).limit(limit).select('_id username email role type add_time up_time').exec();
|
||||
}
|
||||
}, {
|
||||
key: 'listCount',
|
||||
|
Loading…
x
Reference in New Issue
Block a user