Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
canifa_note
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vũ Hoàng Anh
canifa_note
Commits
e37bc5a8
Commit
e37bc5a8
authored
Jan 04, 2022
by
email
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: edit username inputer
parent
63ddb291
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
21 deletions
+5
-21
MyAccountSection.tsx
web/src/components/MyAccountSection.tsx
+5
-16
my-account-section.less
web/src/less/my-account-section.less
+0
-5
No files found.
web/src/components/MyAccountSection.tsx
View file @
e37bc5a8
...
...
@@ -21,7 +21,6 @@ const MyAccountSection: React.FC<Props> = () => {
const
{
userState
}
=
useContext
(
appContext
);
const
user
=
userState
.
user
as
Model
.
User
;
const
[
username
,
setUsername
]
=
useState
<
string
>
(
user
.
username
);
const
[
showEditUsernameInputs
,
setShowEditUsernameInputs
]
=
useState
(
false
);
const
[
showConfirmUnbindGithubBtn
,
setShowConfirmUnbindGithubBtn
]
=
useState
(
false
);
const
handleUsernameChanged
=
(
e
:
React
.
ChangeEvent
<
HTMLInputElement
>
)
=>
{
...
...
@@ -36,7 +35,6 @@ const MyAccountSection: React.FC<Props> = () => {
}
if
(
username
===
user
.
username
)
{
setShowEditUsernameInputs
(
false
);
return
;
}
...
...
@@ -56,7 +54,6 @@ const MyAccountSection: React.FC<Props> = () => {
await
userService
.
updateUsername
(
username
);
await
userService
.
doSignIn
();
setShowEditUsernameInputs
(
false
);
toastHelper
.
info
(
"修改成功~"
);
}
catch
(
error
:
any
)
{
toastHelper
.
error
(
error
.
message
);
...
...
@@ -88,6 +85,7 @@ const MyAccountSection: React.FC<Props> = () => {
const
handlePreventDefault
=
(
e
:
React
.
MouseEvent
)
=>
{
e
.
preventDefault
();
e
.
stopPropagation
();
};
return
(
...
...
@@ -104,24 +102,15 @@ const MyAccountSection: React.FC<Props> = () => {
</
label
>
<
label
className=
"form-label input-form-label username-label"
>
<
span
className=
"normal-text"
>
账号:
</
span
>
<
input
type=
"text"
readOnly=
{
!
showEditUsernameInputs
}
value=
{
username
}
onClick=
{
()
=>
{
setShowEditUsernameInputs
(
true
);
}
}
onChange=
{
handleUsernameChanged
}
/>
<
div
className=
"btns-container"
onClick=
{
handlePreventDefault
}
>
<
span
className=
{
"btn confirm-btn "
+
(
showEditUsernameInputs
?
""
:
"hidden"
)
}
onClick=
{
handleConfirmEditUsernameBtnClick
}
>
<
input
type=
"text"
value=
{
username
}
onChange=
{
handleUsernameChanged
}
/>
<
div
className=
{
`btns-container ${username === user.username ? "hidden" : ""}`
}
onClick=
{
handlePreventDefault
}
>
<
span
className=
"btn confirm-btn"
onClick=
{
handleConfirmEditUsernameBtnClick
}
>
保存
</
span
>
<
span
className=
{
"btn cancel-btn "
+
(
showEditUsernameInputs
?
""
:
"hidden"
)
}
className=
"btn cancel-btn"
onClick=
{
()
=>
{
setUsername
(
user
.
username
);
setShowEditUsernameInputs
(
false
);
}
}
>
撤销
...
...
web/src/less/my-account-section.less
View file @
e37bc5a8
...
...
@@ -17,10 +17,6 @@
&:focus {
border-color: black;
+ .btns-container {
display: flex;
}
}
}
...
...
@@ -28,7 +24,6 @@
.flex(row, flex-start, center);
margin-left: 8px;
flex-shrink: 0;
display: none;
> .btn {
font-size: 12px;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment