From dd82b192e84b16be07fb5091e44b16253b4dfe99 Mon Sep 17 00:00:00 2001 From: lulu Date: Tue, 10 Sep 2024 10:33:48 +0800 Subject: [PATCH] fix: css --- src/APIClient/APIClient10.js | 8 +-- src/components/Cards/CardSettings.js | 13 +---- src/components/Login/Endpoint.js | 49 ++++++++-------- src/components/Login/SetPassword.js | 4 +- src/components/Modals/ChangePasswordModal.js | 2 +- src/components/Modals/LogoutComfirmModal.js | 59 ++++++++++++++++++++ src/components/Modals/PasswordVerifyModal.js | 7 ++- src/components/Sidebar/Sidebar.js | 4 +- src/locale/en.js | 6 +- src/locale/zh.js | 3 +- 10 files changed, 105 insertions(+), 50 deletions(-) create mode 100644 src/components/Modals/LogoutComfirmModal.js diff --git a/src/APIClient/APIClient10.js b/src/APIClient/APIClient10.js index 1ef2860..4c00a8a 100644 --- a/src/APIClient/APIClient10.js +++ b/src/APIClient/APIClient10.js @@ -427,11 +427,11 @@ class APIClient10 { login(arg){ return this.request(`/api/v1/dashboard/login?arg=${arg}`); } - loginValidate(arg,token){ - return this.request(`/api/v1/dashboard/validate?arg=${arg}&token=${token}`); + loginValidate(arg){ + return this.request(`/api/v1/dashboard/validate?arg=${arg}`); } - changePassword(arg,newpassword,token){ - return this.request(`/api/v1/dashboard/change?arg=${arg}&arg=${newpassword}&token=${token}`); + changePassword(arg,newpassword){ + return this.request(`/api/v1/dashboard/change?arg=${arg}&arg=${newpassword}`); } resetLoginPassword(privateKey, password){ return this.request(`/api/v1/dashboard/reset?arg=${privateKey}&arg=${password}`); diff --git a/src/components/Cards/CardSettings.js b/src/components/Cards/CardSettings.js index 5082d78..1b7cdde 100755 --- a/src/components/Cards/CardSettings.js +++ b/src/components/Cards/CardSettings.js @@ -3,13 +3,12 @@ import { Tooltip } from 'antd'; import { QuestionCircleOutlined } from '@ant-design/icons'; import { mainContext } from 'reducer'; import Emitter from 'utils/eventBus'; -import Cookies from 'js-cookie'; -import { useHistory } from 'react-router-dom'; import { nodeStatusCheck, getPrivateKey, getRepo, setApiUrl } from 'services/otherService.js'; import { t } from 'utils/text.js'; import { urlCheck } from 'utils/checks.js'; import PathConfirmModal from 'components/Modals/PathConfirmModal.js'; +import LogoutConfirmModal from 'components/Modals/LogoutComfirmModal'; import CardConfig from './CardConfig'; import ConfigConfirmModal from 'components/Modals/ConfigConfirmModal'; import ClipboardCopy from 'components/Utils/ClipboardCopy'; @@ -17,7 +16,6 @@ import S3CardConfig from './S3CardConfig'; import { getParameterByName } from 'utils/BTFSUtil.js'; import { MAIN_PAGE_MODE } from 'utils/constants'; -import { logout } from 'services/login.js'; export default function CardSettings({ color }) { const apiUrl = getParameterByName('api', window.location.href); @@ -28,7 +26,6 @@ export default function CardSettings({ color }) { setApiUrl(apiUrl); NODE_URL = apiUrl; } - const history = useHistory(); const inputRef = useRef(null); const { state } = useContext(mainContext); const { pageMode } = state; @@ -77,12 +74,7 @@ export default function CardSettings({ color }) { }; const handleLogout = async () => { - await logout(); - let NODE_URL = localStorage.getItem('NODE_URL') - ? localStorage.getItem('NODE_URL') - : 'http://localhost:5001'; - Cookies.remove(NODE_URL); - history.push('/login'); + Emitter.emit('openLogoutConfirmModal', {}); }; const changePath = async e => { @@ -188,6 +180,7 @@ export default function CardSettings({ color }) { + ); } diff --git a/src/components/Login/Endpoint.js b/src/components/Login/Endpoint.js index 5792de3..db7c791 100644 --- a/src/components/Login/Endpoint.js +++ b/src/components/Login/Endpoint.js @@ -1,41 +1,38 @@ -import React, {useRef,useEffect} from 'react'; -import { QuestionCircleOutlined } from '@ant-design/icons'; +import React, { useRef, useEffect } from 'react'; +// import { QuestionCircleOutlined } from '@ant-design/icons'; import Emitter from 'utils/eventBus'; import { setApiUrl } from 'services/otherService.js'; import { urlCheck } from 'utils/checks.js'; -import { Tooltip } from 'antd'; +// import { Tooltip } from 'antd'; import { t } from 'utils/text.js'; import { getParameterByName } from 'utils/BTFSUtil.js'; - - - const Endpoint = ({ color }) => { const inputRef = useRef(null); - const getEndpoint = ()=>{ + const getEndpoint = () => { const apiUrl = getParameterByName('api', window.location.href); let NODE_URL = localStorage.getItem('NODE_URL') - ? localStorage.getItem('NODE_URL') - : 'http://localhost:5001'; + ? localStorage.getItem('NODE_URL') + : 'http://localhost:5001'; if (apiUrl && urlCheck(apiUrl) && NODE_URL !== apiUrl) { NODE_URL = apiUrl; } - if(NODE_URL){ + if (NODE_URL) { inputRef.current.value = NODE_URL; } - } + }; - const getNodeUrl = () => { + const getNodeUrl = () => { let node_url = inputRef.current.value.replace(/\s*/g, ''); if (node_url.charAt(node_url.length - 1) === '/') { - node_url = node_url.substr(0, node_url.length - 1); + node_url = node_url.substr(0, node_url.length - 1); } if (!urlCheck(node_url)) { - return null; + return null; } return node_url; - }; + }; const save = async (e, wallet) => { e.preventDefault(); @@ -52,7 +49,7 @@ const Endpoint = ({ color }) => { // }; useEffect(() => { - getEndpoint() + getEndpoint(); }, []); return ( @@ -60,17 +57,19 @@ const Endpoint = ({ color }) => {
{t('login')}
- {t('login_endpoint_desc')} + {t('login_endpoint_desc')}
-
- API {t('endpoint')} -
- {t('copy_url_tips')}

}> - {/* */} - -
-
+
+ API {t('endpoint')} +
+ { + // {t('copy_url_tips')}

}> + // {/* */} + // + //
+ } +
{ - {t('set_login_password')} + {t(`${isReset?'re':''}set_login_password`)} -
{t('set_login_password_desc')}
+
{t(`${isReset?'re':''}set_login_password_desc`)}
API {t('enter_old_password')} +
{t('enter_old_password')}
} name="oldpassword" rules={[ diff --git a/src/components/Modals/LogoutComfirmModal.js b/src/components/Modals/LogoutComfirmModal.js new file mode 100644 index 0000000..426316d --- /dev/null +++ b/src/components/Modals/LogoutComfirmModal.js @@ -0,0 +1,59 @@ +import React, { useState, useEffect } from 'react'; +import Emitter from 'utils/eventBus'; +import Cookies from 'js-cookie'; +import { logout } from 'services/login.js'; +import { t } from 'utils/text.js'; +import { useHistory } from 'react-router-dom'; +import CommonModal from './CommonModal'; + +export default function LogoutConfirmModal({ color }) { + const [showModal, setShowModal] = useState(false); + const history = useHistory(); + + useEffect(() => { + const set = function (params) { + openModal(); + }; + Emitter.on('openLogoutConfirmModal', set); + return () => { + Emitter.removeListener('openLogoutConfirmModal'); + }; + }, []); + + const openModal = () => { + setShowModal(true); + }; + + const closeModal = () => { + setShowModal(false); + }; + + const handleLogout = async () => { + // Emitter.emit('handleResetConfig', {}); + + await logout(); + let NODE_URL = localStorage.getItem('NODE_URL') + ? localStorage.getItem('NODE_URL') + : 'http://localhost:5001'; + Cookies.remove(NODE_URL); + history.push('/login'); + closeModal(); + }; + + return ( + +
+
{t('lougout_comfirm_modal_title')}
+
{t('lougout_comfirm_modal_desc')}
+
+ + +
+
+
+ ); +} diff --git a/src/components/Modals/PasswordVerifyModal.js b/src/components/Modals/PasswordVerifyModal.js index c076364..bd8868c 100644 --- a/src/components/Modals/PasswordVerifyModal.js +++ b/src/components/Modals/PasswordVerifyModal.js @@ -6,7 +6,7 @@ import { Spin, } from 'antd'; import Emitter from 'utils/eventBus'; import { t } from 'utils/text.js'; import CommonModal from './CommonModal'; -import Cookies from 'js-cookie'; +// import Cookies from 'js-cookie'; import { aseEncode } from 'utils/BTFSUtil'; @@ -76,6 +76,7 @@ export default function PasswordVerifyModal({ color }) { const handleSubmit = async () => { if (!password) { setValidateMsg(t('password_validate_required')); + return; } if (password && !checkPassword(password)) { setValidateMsg(t('password_validate_pattern')); @@ -86,9 +87,9 @@ export default function PasswordVerifyModal({ color }) { ? localStorage.getItem('NODE_URL') : 'http://localhost:5001'; let asePassowrd = aseEncode(password, NODE_URL); - const token = Cookies.get(NODE_URL) + // const token = Cookies.get(NODE_URL) try { - let res = await loginValidate(asePassowrd,token); + let res = await loginValidate(asePassowrd); setLoading(false); if (res && res.Success) { callbackFn.current(); diff --git a/src/components/Sidebar/Sidebar.js b/src/components/Sidebar/Sidebar.js index f36afc9..9164d52 100755 --- a/src/components/Sidebar/Sidebar.js +++ b/src/components/Sidebar/Sidebar.js @@ -156,7 +156,7 @@ export default function Sidebar() { 'theme-sidebar-link md:block text-left md:pb-2 mr-0 inline-block whitespace-nowrap text-sm uppercase font-bold p-4 px-0' } to="/"> - BTFS 3.0.0 + BTFS 3.1.0
@@ -187,7 +187,7 @@ export default function Sidebar() { {/* Navigation */}
  • - {t('version')} 3.0.0 + {t('version')} 3.1.0
  • diff --git a/src/locale/en.js b/src/locale/en.js index 92c9a3d..6abe965 100644 --- a/src/locale/en.js +++ b/src/locale/en.js @@ -480,8 +480,10 @@ const en_US = { logout: "Logout", - reset_password_success:'密码重置成功', - set_password_success:'密码设置成功', + reset_password_success:'Password has been successfully set', + set_password_success:'Password has been successfully set', + lougout_comfirm_modal_title:'Logout', + lougout_comfirm_modal_desc:'Are you sure you want to log out of the current node?' }; diff --git a/src/locale/zh.js b/src/locale/zh.js index c5a85fc..e2eca3c 100644 --- a/src/locale/zh.js +++ b/src/locale/zh.js @@ -469,7 +469,8 @@ const zh_CN = { reset_password_success:'密码重置成功', set_password_success:'密码设置成功', - + lougout_comfirm_modal_title:'退出登录', + lougout_comfirm_modal_desc:'确认要退出当前节点登录吗?' };