Skip to content

Let's use AI to Earn!

树苗问题优化

daoyian068d8d772a98
diff --git a/src/components/SignInCard/index.tsx b/src/components/SignInCard/index.tsx
index 1b8fb2eb..1acee896 100644
--- a/src/components/SignInCard/index.tsx
+++ b/src/components/SignInCard/index.tsx
@@ -1,16 +1,19 @@
-import { useEffect, useState } from 'react';
+import { useEffect, useState, forwardRef, useImperativeHandle } from 'react';
import { signInApi, SignInType } from '@/api/signIn';
import { Button, Progress, message } from 'antd';
import { CheckCircleFilled, ClockCircleOutlined } from '@ant-design/icons';
import styles from './SignInCard.module.scss';
import treeSvg from '@/assets/svgs/tree.svg';
+import { useNavigate } from 'react-router-dom';
-export default function SignInCard() {
+const SignInCard = forwardRef((props, ref) => {
const [loading, setLoading] = useState(false);
const [signInList, setSignInList] = useState<any[]>([]);
const [thisWeekSigned, setThisWeekSigned] = useState(false);
const [continueWeeks, setContinueWeeks] = useState(0);
+ const navigate = useNavigate();
+
// 获取打卡列表
const fetchSignInList = async () => {
setLoading(true);
@@ -57,12 +60,21 @@ export default function SignInCard() {
setLoading(false);
};
- useEffect(() => {
- fetchSignInList();
- }, []);
+ useImperativeHandle(ref, () => ({
+ fetchSignInList,
+ }));
+
+ // useEffect(() => {
+ // fetchSignInList();
+ // }, []);
// 打卡
const handleSignIn = async () => {
+
+ navigate('/publish');
+
+ return
+
setLoading(true);
try {
await signInApi.createSignInRecord();
@@ -115,7 +127,7 @@ export default function SignInCard() {
<Button
type="primary"
block
- disabled={thisWeekSigned}
+ // disabled={thisWeekSigned}
loading={loading}
onClick={handleSignIn}
style={{ marginTop: 16 }}
@@ -124,4 +136,6 @@ export default function SignInCard() {
</Button>
</div>
);
-}
\ No newline at end of file
+});
+
+export default SignInCard;
\ No newline at end of file
diff --git a/src/layout/Navigation/index.tsx b/src/layout/Navigation/index.tsx
index d3183b2d..9943cfe8 100644
--- a/src/layout/Navigation/index.tsx
+++ b/src/layout/Navigation/index.tsx
@@ -10,7 +10,7 @@ import logo from '@/assets/logo.png';
import styles from './navigation.module.scss';
import { router } from '@/router';
import SysMenu from '../SysMenu';
-import { useEffect, useState } from 'react';
+import { useEffect, useState, useRef } from 'react';
import { ipcAppInfo } from '../../icp/app';
import Windowcontrolbuttons from '../../components/WindowControlButtons/WindowControlButtons';
import Bellmessage from '../BellMessage';
@@ -24,6 +24,8 @@ const Navigation = () => {
const [pathname, setPathname] = useState('/');
const [platform, setPlatform] = useState('');
+ const signInCardRef = useRef<any>(null);
+
useEffect(() => {
setPathname('/' + (location.pathname.split('/')[1] || ''));
}, [location]);
@@ -69,9 +71,14 @@ const Navigation = () => {
<div className="navigation-userinfo">
<Popover
- content={<SignInCard />}
+ content={<SignInCard ref={signInCardRef} />}
trigger="hover"
placement="bottom"
+ onOpenChange={(open) => {
+ if (open) {
+ signInCardRef.current?.fetchSignInList();
+ }
+ }}
>
<div className="navigation-icon">
<img src={calendarSvg} alt="打卡" style={{ width: 20, height: 20, verticalAlign: 'middle' }} />
diff --git a/src/views/publish/children/imagePage/page.tsx b/src/views/publish/children/imagePage/page.tsx
index b64e431f..e11e9c56 100644
--- a/src/views/publish/children/imagePage/page.tsx
+++ b/src/views/publish/children/imagePage/page.tsx
@@ -24,6 +24,7 @@ import { useAccountStore } from '../../../../store/commont';
import { useNavigate } from 'react-router-dom';
import { usePubStroe } from '../../../../store/pubStroe';
import { ExclamationCircleFilled } from '@ant-design/icons';
+import { signInApi, SignInType } from '@/api/signIn';
const { confirm } = Modal;
@@ -125,6 +126,8 @@ export default function Page() {
const pubCore = async () => {
setPubProgressModuleOpen(true);
setLoading(true);
+ await signInApi.createSignInRecord();
+
const err = () => {
setLoading(false);
message.error('网络繁忙,请稍后重试!');
diff --git a/src/views/publish/children/videoPage/components/VideoPubSetModal/VideoPubSetModal.tsx b/src/views/publish/children/videoPage/components/VideoPubSetModal/VideoPubSetModal.tsx
index b3364b3f..3650d2fc 100644
--- a/src/views/publish/children/videoPage/components/VideoPubSetModal/VideoPubSetModal.tsx
+++ b/src/views/publish/children/videoPage/components/VideoPubSetModal/VideoPubSetModal.tsx
@@ -55,6 +55,7 @@ import {
NoticeType,
useBellMessageStroe,
} from '../../../../../../store/bellMessageStroe';
+import { signInApi, SignInType } from '@/api/signIn';
export interface IVideoPubSetModalRef {}
@@ -189,6 +190,8 @@ const VideoPubSetModal = memo(
const pubCore = async () => {
setLoading(false);
+
+ await signInApi.createSignInRecord();
const err = () => {
setLoading(false);
message.error('网络繁忙,请稍后重试!');