|
|
|
@ -30,7 +30,7 @@ const MyAccountSection: React.FC<Props> = () => {
|
|
|
|
|
|
|
|
|
|
const handleConfirmEditUsernameBtnClick = async () => {
|
|
|
|
|
if (user.name === "guest") {
|
|
|
|
|
toastHelper.info("🈲 不要修改我的用户名");
|
|
|
|
|
toastHelper.info("Do not change my username");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -40,7 +40,7 @@ const MyAccountSection: React.FC<Props> = () => {
|
|
|
|
|
|
|
|
|
|
const usernameValidResult = validate(username, validateConfig);
|
|
|
|
|
if (!usernameValidResult.result) {
|
|
|
|
|
toastHelper.error("用户名 " + usernameValidResult.reason);
|
|
|
|
|
toastHelper.error("Username " + usernameValidResult.reason);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -48,13 +48,13 @@ const MyAccountSection: React.FC<Props> = () => {
|
|
|
|
|
const isUsable = await userService.checkUsernameUsable(username);
|
|
|
|
|
|
|
|
|
|
if (!isUsable) {
|
|
|
|
|
toastHelper.error("用户名无法使用");
|
|
|
|
|
toastHelper.error("Username is not available");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
await userService.updateUsername(username);
|
|
|
|
|
await userService.doSignIn();
|
|
|
|
|
toastHelper.info("修改成功~");
|
|
|
|
|
toastHelper.info("Username changed");
|
|
|
|
|
} catch (error: any) {
|
|
|
|
|
toastHelper.error(error.message);
|
|
|
|
|
}
|
|
|
|
@ -62,7 +62,7 @@ const MyAccountSection: React.FC<Props> = () => {
|
|
|
|
|
|
|
|
|
|
const handleChangePasswordBtnClick = () => {
|
|
|
|
|
if (user.name === "guest") {
|
|
|
|
|
toastHelper.info("🈲 不要修改我的密码");
|
|
|
|
|
toastHelper.info("Do not change my password");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -81,21 +81,21 @@ const MyAccountSection: React.FC<Props> = () => {
|
|
|
|
|
return (
|
|
|
|
|
<>
|
|
|
|
|
<div className="section-container account-section-container">
|
|
|
|
|
<p className="title-text">基本信息</p>
|
|
|
|
|
<p className="title-text">Account Information</p>
|
|
|
|
|
<label className="form-label input-form-label">
|
|
|
|
|
<span className="normal-text">ID:</span>
|
|
|
|
|
<span className="normal-text">ID:</span>
|
|
|
|
|
<span className="normal-text">{user.id}</span>
|
|
|
|
|
</label>
|
|
|
|
|
<label className="form-label input-form-label">
|
|
|
|
|
<span className="normal-text">创建时间:</span>
|
|
|
|
|
<span className="normal-text">Created at:</span>
|
|
|
|
|
<span className="normal-text">{utils.getDateString(user.createdAt)}</span>
|
|
|
|
|
</label>
|
|
|
|
|
<label className="form-label input-form-label username-label">
|
|
|
|
|
<span className="normal-text">账号:</span>
|
|
|
|
|
<span className="normal-text">Username:</span>
|
|
|
|
|
<input type="text" value={username} onChange={handleUsernameChanged} />
|
|
|
|
|
<div className={`btns-container ${username === user.name ? "hidden" : ""}`} onClick={handlePreventDefault}>
|
|
|
|
|
<span className="btn confirm-btn" onClick={handleConfirmEditUsernameBtnClick}>
|
|
|
|
|
保存
|
|
|
|
|
Save
|
|
|
|
|
</span>
|
|
|
|
|
<span
|
|
|
|
|
className="btn cancel-btn"
|
|
|
|
@ -103,25 +103,25 @@ const MyAccountSection: React.FC<Props> = () => {
|
|
|
|
|
setUsername(user.name);
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
撤销
|
|
|
|
|
Cancel
|
|
|
|
|
</span>
|
|
|
|
|
</div>
|
|
|
|
|
</label>
|
|
|
|
|
<label className="form-label password-label">
|
|
|
|
|
<span className="normal-text">密码:</span>
|
|
|
|
|
<span className="normal-text">Password:</span>
|
|
|
|
|
<span className="btn" onClick={handleChangePasswordBtnClick}>
|
|
|
|
|
修改密码
|
|
|
|
|
Change It
|
|
|
|
|
</span>
|
|
|
|
|
</label>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="section-container openapi-section-container">
|
|
|
|
|
<p className="title-text">Open API(实验性功能)</p>
|
|
|
|
|
<p className="title-text">Open API (Experimental feature)</p>
|
|
|
|
|
<p className="value-text">{openAPIRoute}</p>
|
|
|
|
|
<span className="reset-btn" onClick={handleResetOpenIdBtnClick}>
|
|
|
|
|
重置 API
|
|
|
|
|
Reset API
|
|
|
|
|
</span>
|
|
|
|
|
<div className="usage-guide-container">
|
|
|
|
|
<p className="title-text">使用方法:</p>
|
|
|
|
|
<p className="title-text">Usage guide:</p>
|
|
|
|
|
<pre>{`POST ${openAPIRoute}\nContent-type: application/json\n{\n "content": "Hello, #memos ${window.location.origin}"\n}`}</pre>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|