diff --git a/controller/user.go b/controller/user.go index 51328d783b..b6241d368f 100644 --- a/controller/user.go +++ b/controller/user.go @@ -467,6 +467,13 @@ func CreateUser(c *gin.Context) { }) return } + if err := common.Validate.Struct(&user); err != nil { + c.JSON(http.StatusOK, gin.H{ + "success": false, + "message": "输入不合法 " + err.Error(), + }) + return + } if user.DisplayName == "" { user.DisplayName = user.Username } diff --git a/web/src/components/UsersTable.js b/web/src/components/UsersTable.js index 31acaf9246..1fdd892322 100644 --- a/web/src/components/UsersTable.js +++ b/web/src/components/UsersTable.js @@ -4,6 +4,7 @@ import { Link } from 'react-router-dom'; import { API, showError, showSuccess } from '../helpers'; import { ITEMS_PER_PAGE } from '../constants'; +import { renderText } from '../helpers/render'; function renderRole(role) { switch (role) { @@ -64,7 +65,7 @@ const UsersTable = () => { (async () => { const res = await API.post('/api/user/manage', { username, - action, + action }); const { success, message } = res.data; if (success) { @@ -161,18 +162,18 @@ const UsersTable = () => { { - sortUser('username'); + sortUser('id'); }} > - 用户名 + ID { - sortUser('display_name'); + sortUser('username'); }} > - 显示名称 + 用户名 { if (user.deleted) return <>; return ( - {user.username} - {user.display_name} - {user.email ? user.email : '无'} + {user.id} + + {renderText(user.username, 10)}} + hoverable + /> + + {user.email ? renderText(user.email, 30) : '无'} {user.quota} {renderRole(user.role)} {renderStatus(user.status)} diff --git a/web/src/helpers/render.js b/web/src/helpers/render.js new file mode 100644 index 0000000000..20bfedd5ed --- /dev/null +++ b/web/src/helpers/render.js @@ -0,0 +1,6 @@ +export function renderText(text, limit) { + if (text.length > limit) { + return text.slice(0, limit - 3) + '...'; + } + return text; +} \ No newline at end of file