Let's use AI to Earn!
TypeScript auto-publishdouyindouyin-apielectron-appelectron-reactkuaishoukwaipublishedshipinhaotoolxiaohongshu
爱团团打卡
daoyiand02e6982442b
diff --git a/src/assets/svgs/calendar.svg b/src/assets/svgs/calendar.svgnew file mode 100644index 00000000..643c8be2--- /dev/null+++ b/src/assets/svgs/calendar.svg@@ -0,0 +1,10 @@+<svg width="1em" height="1em" viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg">+ <rect x="6" y="10" width="36" height="32" rx="4" fill="#E6F7FF" stroke="#1890FF" stroke-width="3"/>+ <rect x="6" y="18" width="36" height="24" rx="2" fill="#fff"/>+ <rect x="14" y="26" width="6" height="6" rx="2" fill="#1890FF"/>+ <rect x="28" y="26" width="6" height="6" rx="2" fill="#1890FF"/>+ <rect x="14" y="34" width="6" height="6" rx="2" fill="#91D5FF"/>+ <rect x="28" y="34" width="6" height="6" rx="2" fill="#91D5FF"/>+ <rect x="14" y="2" width="4" height="12" rx="2" fill="#1890FF"/>+ <rect x="30" y="2" width="4" height="12" rx="2" fill="#1890FF"/>+</svg>\ No newline at end of filediff --git a/src/assets/svgs/tree.svg b/src/assets/svgs/tree.svgnew file mode 100644index 00000000..a2c86299--- /dev/null+++ b/src/assets/svgs/tree.svg@@ -0,0 +1,6 @@+<svg width="1em" height="1em" viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg">+ <circle cx="24" cy="24" r="22" fill="#f0f0f0"/>+ <path d="M24 44V18M14 26s2-8 10-8 10 8 10 8" stroke="#52C41A" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/>+ <path d="M24 18c-4 0-7 3-7 7v0" stroke="#9FDB8E" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/>+ <path d="M24 18c4 0 7 3 7 7v0" stroke="#9FDB8E" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/>+</svg>\ No newline at end of filediff --git a/src/assets/svgs/watering.svg b/src/assets/svgs/watering.svgnew file mode 100644index 00000000..f2323069--- /dev/null+++ b/src/assets/svgs/watering.svg@@ -0,0 +1,8 @@+<svg width="1em" height="1em" viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg">+ <g>+ <circle cx="24" cy="24" r="20" fill="#E6F7E6"/>+ <path d="M24 36c6-4 10-10 10-16a10 10 0 1 0-20 0c0 6 4 12 10 16z" fill="#52C41A"/>+ <path d="M24 30a6 6 0 0 0 6-6" stroke="#fff" stroke-width="2" stroke-linecap="round"/>+ <circle cx="24" cy="18" r="2" fill="#fff"/>+ </g>+</svg>\ No newline at end of filediff --git a/src/components/SignInCard/SignInCard.module.scss b/src/components/SignInCard/SignInCard.module.scssnew file mode 100644index 00000000..e359253a--- /dev/null+++ b/src/components/SignInCard/SignInCard.module.scss@@ -0,0 +1,15 @@+.signInCard {+ width: 320px;+ background: #fff;+ border-radius: 12px;+ box-shadow: 0 2px 8px #eee;+ padding: 24px 20px;+ text-align: center;+ .icon { margin-bottom: 8px; }+ .title { font-size: 15px; color: #333; margin-bottom: 8px; }+ .status { margin-bottom: 8px; }+ .signed { color: #52c41a; font-weight: bold; }+ .notSigned { color: #aaa; }+ .progress { margin: 8px 0; }+ .desc { color: #666; font-size: 13px; margin-bottom: 8px; }+}\ No newline at end of filediff --git a/src/components/SignInCard/index.tsx b/src/components/SignInCard/index.tsxnew file mode 100644index 00000000..1b8fb2eb--- /dev/null+++ b/src/components/SignInCard/index.tsx@@ -0,0 +1,127 @@+import { useEffect, useState } 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';++export default function SignInCard() {+ const [loading, setLoading] = useState(false);+ const [signInList, setSignInList] = useState<any[]>([]);+ const [thisWeekSigned, setThisWeekSigned] = useState(false);+ const [continueWeeks, setContinueWeeks] = useState(0);++ // 获取打卡列表+ const fetchSignInList = async () => {+ setLoading(true);+ try {+ const res = await signInApi.getSignInList({ type: SignInType.PUL_VIDEO });+ const list = res?.items || [];+ console.log('dak',list)+ setSignInList(list);++ // 计算本周是否已打卡和连续周数+ const now = new Date();+ const getWeek = (date: Date) => {+ const firstDay = new Date(date.getFullYear(), 0, 1);+ const dayOfYear = Math.floor((date.getTime() - firstDay.getTime()) / 86400000) + 1;+ return Math.ceil(dayOfYear / 7);+ };+ const thisYear = now.getFullYear();+ const thisWeek = getWeek(now);++ let signed = false;+ let maxContinue = 0;+ let curContinue = 0;+ let lastYear = thisYear, lastWeek = thisWeek;++ for (const item of list) {+ const d = new Date(item.createTime);+ const y = d.getFullYear();+ const w = getWeek(d);+ if (y === thisYear && w === thisWeek) signed = true;+ if ((y === lastYear && w === lastWeek) || (y === lastYear && w === lastWeek - 1) || (y === lastYear - 1 && lastWeek === 1 && w === 52)) {+ curContinue++;+ lastYear = y;+ lastWeek = w - 1;+ } else {+ break;+ }+ }+ maxContinue = curContinue;+ setThisWeekSigned(signed);+ setContinueWeeks(maxContinue);+ } catch (e) {+ message.error('获取打卡信息失败');+ }+ setLoading(false);+ };++ useEffect(() => {+ fetchSignInList();+ }, []);++ // 打卡+ const handleSignIn = async () => {+ setLoading(true);+ try {+ await signInApi.createSignInRecord();+ message.success('打卡成功!');+ fetchSignInList();+ } catch {+ message.error('打卡失败');+ }+ setLoading(false);+ };++ const totalWeeks = 7;+ const diff = totalWeeks - continueWeeks;++ return (+ <div className={styles.signInCard}>+ <div className={styles.icon}>+ <img+ src={treeSvg}+ alt="tree"+ style={{+ width: 48,+ filter: thisWeekSigned ? 'none' : 'grayscale(100%)',+ opacity: thisWeekSigned ? 1 : 0.6+ }}+ />+ </div>+ <div className={styles.title}>每周使用一键发布视频即可为小树苗浇水</div>+ <div className={styles.status}>+ {thisWeekSigned ? (+ <div className={styles.signed}>+ <CheckCircleFilled style={{ color: '#52c41a', marginRight: 4 }} /> 本周已完成浇水+ </div>+ ) : (+ <div className={styles.notSigned}>+ <ClockCircleOutlined style={{ color: '#aaa', marginRight: 4 }} /> 本周待浇水+ <div style={{ color: 'red', marginTop: 4, fontSize: 13 }}>如果未浇水,小树苗就会枯死</div>+ </div>+ )}+ </div>+ <div className={styles.progress}>+ <span>连续浇水进度</span>+ <span style={{ float: 'right' }}>{continueWeeks}/{totalWeeks}周</span>+ <Progress percent={Math.round((continueWeeks / totalWeeks) * 100)} showInfo={false} style={{ margin: '4px 0' }} />+ </div>+ <div className={styles.desc}>+ 你已连续浇水 <b>{continueWeeks}</b> 周<br />+ 距离获得「快速提现」权益,仅差 <b>{diff}</b> 周+ </div>+ <Button+ type="primary"+ block+ disabled={thisWeekSigned}+ loading={loading}+ onClick={handleSignIn}+ style={{ marginTop: 16 }}+ >+ 立即发布视频+ </Button>+ </div>+ );+}\ No newline at end of filediff --git a/src/layout/Navigation/index.tsx b/src/layout/Navigation/index.tsxindex 0b77602f..d3183b2d 100644--- a/src/layout/Navigation/index.tsx+++ b/src/layout/Navigation/index.tsx@@ -15,6 +15,9 @@ import { ipcAppInfo } from '../../icp/app';import Windowcontrolbuttons from '../../components/WindowControlButtons/WindowControlButtons';import Bellmessage from '../BellMessage';import { BellOutlined } from '@ant-design/icons';+import { Popover } from 'antd';+import SignInCard from '@/components/SignInCard';+import calendarSvg from '@/assets/svgs/calendar.svg';const Navigation = () => {const location = useLocation();@@ -65,12 +68,25 @@ const Navigation = () => {<div className="navigation_drag" /><div className="navigation-userinfo">+ <Popover+ content={<SignInCard />}+ trigger="hover"+ placement="bottom"+ >+ <div className="navigation-icon">+ <img src={calendarSvg} alt="打卡" style={{ width: 20, height: 20, verticalAlign: 'middle' }} />+ <span className="navigation-icon-text">打卡</span>+ </div>+ </Popover>+ <div className="navigation-line"></div>+<Bellmessage><div className="navigation-icon"><BellOutlined /><span className="navigation-icon-text">消息</span></div></Bellmessage>+<div className="navigation-line"></div><SysMenu /><div className="navigation-line"></div>diff --git a/tsconfig.node.json b/tsconfig.node.jsonindex 5fea4a95..14082e69 100644--- a/tsconfig.node.json+++ b/tsconfig.node.json@@ -10,4 +10,5 @@"vite.config.ts","package.json"]-}\ No newline at end of file+}+