Skip to content

Commit

Permalink
fix:bug修复,创建用户可控制密码显隐
Browse files Browse the repository at this point in the history
  • Loading branch information
QwQ-wuwuwu committed Jul 9, 2024
1 parent feb5e5e commit 4152e4e
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 17 deletions.
1 change: 1 addition & 0 deletions src/frontend/public/locales/en/bs.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"document": "Documentation",
"logout": "Logout",
"logoutDescription": "Log out",
"logoutContent": "Are you sure to log out",
"forBestExperience": "For the best experience, please access this website on a PC",
"onlineDocumentation": "Online Documentation",
"changePwd": "Password"
Expand Down
1 change: 1 addition & 0 deletions src/frontend/public/locales/zh/bs.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"document": "文档",
"logout": "退出",
"logoutDescription": "退出登录",
"logoutContent": "确认退出登录吗",
"forBestExperience": "为了您的良好体验,请在 PC 端访问该网站",
"onlineDocumentation": "在线文档",
"changePwd": "修改密码"
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/src/layout/MainLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export default function MainLayout() {
const handleLogout = () => {
bsConfirm({
title: `${t('prompt')}!`,
desc: `${t('menu.logoutDescription')}?`,
desc: `${t('menu.logoutContent')}?`,
okTxt: t('system.confirm'),
onOk(next) {
captureAndAlertRequestErrorHoc(logoutApi()).then(_ => {
Expand Down
6 changes: 3 additions & 3 deletions src/frontend/src/pages/LogPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ export default function index() {
<TableHead className="w-[150px] min-w-[100px]">{t('log.objectType')}</TableHead>
<TableHead className="w-[200px] min-w-[100px]">{t('log.operationObject')}</TableHead>
<TableHead className="w-[150px]">{t('log.ipAddress')}</TableHead>
<TableHead className="w-[250px] min-w-[250px] text-center">{t('log.remark')}</TableHead>
<TableHead className="w-[250px] min-w-[250px]">{t('log.remark')}</TableHead>
</TableRow>
</TableHeader>
<TableBody>
Expand All @@ -158,10 +158,10 @@ export default function index() {
<TableCell>{transformModule(log.system_id)}</TableCell>
<TableCell>{transformEvent(log.event_type)}</TableCell>
<TableCell>{transformObjectType(log.object_type)}</TableCell>
<TableCell><div className="max-w-[200px] break-all truncate-multiline">{log.object_name}</div></TableCell>
<TableCell><div className="max-w-[200px] break-all truncate-multiline">{log.object_name || '无'}</div></TableCell>
<TableCell>{log.ip_address}</TableCell>
<TableCell className="max-w-[250px]">
<div className="whitespace-pre-line break-all">{log.note?.replace('编辑后', `\n编辑后`)}</div>
<div className="whitespace-pre-line break-all">{log.note?.replace('编辑后', `\n编辑后`) || '无'}</div>
</TableCell>
</TableRow>
))}
Expand Down
41 changes: 28 additions & 13 deletions src/frontend/src/pages/SystemPage/components/CreateUser.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
import { Dialog, DialogContent, DialogFooter, DialogHeader, DialogTitle } from "@/components/bs-ui/dialog"
import { Button } from "@/components/bs-ui/button"
import { useTranslation } from "react-i18next"
import { Label } from "@/components/bs-ui/label"
import { Dialog, DialogContent, DialogFooter, DialogHeader, DialogTitle } from "@/components/bs-ui/dialog"
import { Input } from "@/components/bs-ui/input"
import UserRoleItem from "./UserRoleItem"
import { PlusIcon } from "@radix-ui/react-icons"
import { useState } from "react"
import { generateUUID } from "@/components/bs-ui/utils"
import { Label } from "@/components/bs-ui/label"
import { useToast } from "@/components/bs-ui/toast/use-toast"
import { handleEncrypt, PWD_RULE } from "@/pages/LoginPage/utils"
import { copyText } from "@/utils"
import { generateUUID } from "@/components/bs-ui/utils"
import { createUserApi } from "@/controllers/API/user"
import { captureAndAlertRequestErrorHoc } from "@/controllers/request"
import { handleEncrypt, PWD_RULE } from "@/pages/LoginPage/utils"
import { copyText } from "@/utils"
import { EyeNoneIcon, EyeOpenIcon, PlusIcon } from "@radix-ui/react-icons"
import { useState } from "react"
import { useTranslation } from "react-i18next"
import UserRoleItem from "./UserRoleItem"

enum inputType {
PASSWORD = 'password',
TEXT = 'text'
}
const EyeIconStyle = 'absolute right-7 cursor-pointer'

export default function CreateUser({open, onClose, onSave}) {
const { t } = useTranslation()
Expand Down Expand Up @@ -59,6 +65,11 @@ export default function CreateUser({open, onClose, onSave}) {
}))
}

const [type, setType] = useState(inputType.PASSWORD)
const handleShowPwd = () => {
type === inputType.PASSWORD ? setType(inputType.TEXT) : setType(inputType.PASSWORD)
}

return <Dialog open={open} onOpenChange={b => onClose(b)}>
<DialogContent className="sm:max-w-[625px]">
<DialogHeader>
Expand All @@ -68,16 +79,20 @@ export default function CreateUser({open, onClose, onSave}) {
<div>
<Label htmlFor="user" className="bisheng-label">{t('log.username')}</Label>
<Input id="user" value={form.user_name} onChange={(e) => setForm({...form, user_name:e.target.value})}
placeholder="后续使用此用户名进行登录,用户名不可修改"/>
placeholder="后续使用此用户名进行登录,用户名不可修改" className="h-[50px]"/>
</div>
<div>
<Label htmlFor="password" className="bisheng-label">初始密码</Label>
<Input id="password" value={form.password} placeholder="至少 8 个字符,必须包含大写字母、小写字母、数字和符号的组合"
onChange={(e) => setForm({...form, password:e.target.value})}/>
<div className="flex place-items-center">
<Input type={type} id="password" value={form.password} placeholder="至少 8 个字符,必须包含大写字母、小写字母、数字和符号的组合"
onChange={(e) => setForm({...form, password:e.target.value})} className="h-[50px]"/>
{type === inputType.PASSWORD ? <EyeNoneIcon onClick={handleShowPwd} className={EyeIconStyle}/>
: <EyeOpenIcon onClick={handleShowPwd} className={EyeIconStyle}/>}
</div>
</div>
<div className="flex flex-col gap-2">
<Label className="bisheng-label">用户组/角色选择</Label>
<div className="max-h-[520px] py-1 overflow-y-auto flex flex-col gap-2">
<div className="max-h-[520px] overflow-y-auto flex flex-col gap-2">
{items.map((item, index) => <UserRoleItem key={item.key}
groupId={item.groupId + ''}
showDel={items.length > 1}
Expand Down

0 comments on commit 4152e4e

Please sign in to comment.