diff --git a/web/src/components/HeaderBar.js b/web/src/components/HeaderBar.js index 63a174c..4e7e3b8 100644 --- a/web/src/components/HeaderBar.js +++ b/web/src/components/HeaderBar.js @@ -1,4 +1,4 @@ -import React, {useContext, useState} from 'react'; +import React, {useContext, useEffect, useState} from 'react'; import {Link, useNavigate} from 'react-router-dom'; import {UserContext} from '../context/User'; @@ -45,8 +45,10 @@ const HeaderBar = () => { let navigate = useNavigate(); const [showSidebar, setShowSidebar] = useState(false); + const [dark, setDark] = useState(false); const systemName = getSystemName(); const logo = getLogo(); + var themeMode = localStorage.getItem('theme-mode'); async function logout() { setShowSidebar(false); @@ -57,37 +59,22 @@ const HeaderBar = () => { navigate('/login'); } + useEffect(() => { + if (themeMode === 'dark') { + switchMode(true); + } + }, []); - const renderButtons = (isMobile) => { - return headerButtons.map((button) => { - if (button.admin && !isAdmin()) return <>; - if (isMobile) { - return ( - { - navigate(button.to); - setShowSidebar(false); - }} - > - {button.name} - - ); - } - return ( - - - {button.name} - - ); - }); - }; const switchMode = (model) => { const body = document.body; if (!model) { body.removeAttribute('theme-mode'); + localStorage.setItem('theme-mode', 'light'); } else { body.setAttribute('theme-mode', 'dark'); + localStorage.setItem('theme-mode', 'dark'); } + setDark(model); }; return ( <> @@ -119,7 +106,7 @@ const HeaderBar = () => { footer={ <> } /> - + {userState.user ? <> { ) : ( <> )} - {status.wechat_login ? ( - - - - - + {/* setShowWeChatLoginModal(false)}*/} + {/* onOpen={() => setShowWeChatLoginModal(true)}*/} + {/* open={showWeChatLoginModal}*/} + {/* size={'mini'}*/} + {/*>*/} + {/* */} + {/* */} + {/* */} + {/*
*/} + {/*

*/} + {/* 微信扫码关注公众号,输入「验证码」获取验证码(三分钟内有效)*/} + {/*

*/} + {/*
*/} + {/*
*/} + {/* */} + {/* */} + {/* 登录*/} + {/* */} + {/* */} + {/*
*/} + {/*
*/} + {/**/} {turnstileEnabled ? (
diff --git a/web/src/components/SiderBar.js b/web/src/components/SiderBar.js index 0bc66c5..fc22b81 100644 --- a/web/src/components/SiderBar.js +++ b/web/src/components/SiderBar.js @@ -114,34 +114,6 @@ const HeaderBar = () => { navigate('/login'); } - const toggleSidebar = () => { - setShowSidebar(!showSidebar); - }; - - const renderButtons = (isMobile) => { - return headerButtons.map((button) => { - if (button.admin && !isAdmin()) return <>; - if (isMobile) { - return ( - { - navigate(button.to); - setShowSidebar(false); - }} - > - {button.name} - - ); - } - return ( - - - {button.name} - - ); - }); - }; - return ( <> diff --git a/web/src/pages/TopUp/index.js b/web/src/pages/TopUp/index.js index dbbad2f..5822aa4 100644 --- a/web/src/pages/TopUp/index.js +++ b/web/src/pages/TopUp/index.js @@ -1,14 +1,15 @@ import React, {useEffect, useState} from 'react'; -import {Button, Card, Confirm, Form, Grid, Header, Segment, Statistic} from 'semantic-ui-react'; +import {Confirm} from 'semantic-ui-react'; import {API, isMobile, showError, showInfo, showSuccess} from '../../helpers'; import {renderNumber, renderQuota} from '../../helpers/render'; -import {Col, Layout, Row, Typography} from "@douyinfe/semi-ui"; +import {Col, Layout, Row, Typography, Card, Button, Form, Divider, Space, Modal} from "@douyinfe/semi-ui"; +import Title from "@douyinfe/semi-ui/lib/es/typography/title"; const TopUp = () => { const [redemptionCode, setRedemptionCode] = useState(''); const [topUpCode, setTopUpCode] = useState(''); const [topUpCount, setTopUpCount] = useState(10); - const [amount, setAmount] = useState(0); + const [amount, setAmount] = useState(0.0); const [topUpLink, setTopUpLink] = useState(''); const [userQuota, setUserQuota] = useState(0); const [isSubmitting, setIsSubmitting] = useState(false); @@ -17,7 +18,7 @@ const TopUp = () => { const topUp = async () => { if (redemptionCode === '') { - showInfo('请输入充值码!') + showInfo('请输入兑换码!') return; } setIsSubmitting(true); @@ -27,7 +28,8 @@ const TopUp = () => { }); const {success, message, data} = res.data; if (success) { - showSuccess('充值成功!'); + showSuccess('兑换成功!'); + Modal.success({title: '兑换成功!', content: '成功兑换额度:' + renderQuota(data), centered: true}); setUserQuota((quota) => { return quota + data; }); @@ -142,7 +144,7 @@ const TopUp = () => { const {message, data} = res.data; // showInfo(message); if (message === 'success') { - setAmount(parseInt(data)); + setAmount(parseFloat(data)); } else { showError(data); // setTopUpCount(parseInt(res.data.count)); @@ -168,91 +170,90 @@ const TopUp = () => {

我的钱包

-
+ +

充值数量:{topUpCount}

+

充值金额:{renderAmount()}

+

是否确认充值?

+
+
- -

兑换

- - -
- { - setRedemptionCode(e.target.value); - }} - /> - - : null + } + - -
- - - - {renderQuota(userQuota)} - 剩余额度 - - - -
-
- -
在线充值,最低1
- - -
- { - setTopUpCount(e.target.value); - await getAmount(e.target.value); - }} - /> -
+
+ + 在线充值 + +
+ { + setTopUpCount(value); + await getAmount(value); + }} + /> + + - - - - - - - {renderAmount()} - 支付金额 - - - - + + +