From 966b4b21bdc46021ab2984819125d70690160b7f Mon Sep 17 00:00:00 2001 From: eleliauk <2831336720@qq.com> Date: Sun, 22 Dec 2024 13:32:57 +0800 Subject: [PATCH 1/3] =?UTF-8?q?feat(magic=EF=BC=89:=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E9=97=AE=E9=97=AE=E5=90=8C=E5=AD=A6=E5=AE=A1=E6=A0=B8=E5=A4=A7?= =?UTF-8?q?=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/questionList/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/questionList/index.tsx b/src/pages/questionList/index.tsx index d330bbf..0202bac 100644 --- a/src/pages/questionList/index.tsx +++ b/src/pages/questionList/index.tsx @@ -1,6 +1,6 @@ /* eslint-disable no-console */ import { Button, Image, Text, View } from '@tarojs/components'; -import Taro, {useDidShow} from '@tarojs/taro'; +import Taro, { useDidShow } from '@tarojs/taro'; import { useEffect, useState } from 'react'; // import './index.scss'; From 477d59b45f03f1ba5b5727aba0027dca42131e69 Mon Sep 17 00:00:00 2001 From: eleliauk <2831336720@qq.com> Date: Sun, 22 Dec 2024 13:32:57 +0800 Subject: [PATCH 2/3] =?UTF-8?q?feat(magic=EF=BC=89:=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E9=97=AE=E9=97=AE=E5=90=8C=E5=AD=A6=E5=AE=A1=E6=A0=B8=E5=A4=A7?= =?UTF-8?q?=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/main/index.tsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/pages/main/index.tsx b/src/pages/main/index.tsx index b1f9a6d..aced008 100644 --- a/src/pages/main/index.tsx +++ b/src/pages/main/index.tsx @@ -90,13 +90,11 @@ export default function Index() { const res = (await postBool('/checkStatus', { name: 'kestack', })) as StatusResponse; - setTest(res.data.status); } catch (error) { console.error('Error fetching status:', error); } }; - void getParams(); }, []); useEffect(() => { From a24e1b80d3003f9c023eac61c44085f6921164be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B6=85=E7=BA=A7=E6=97=A0=E6=95=8C=E6=95=B0=E7=A0=81?= =?UTF-8?q?=E6=9A=B4=E9=BE=99=E6=88=98=E5=A3=AB?= <1845519693@qq.com> Date: Tue, 24 Dec 2024 22:13:03 +0800 Subject: [PATCH 3/3] =?UTF-8?q?chore:=20=E6=94=B9=E5=96=84=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E4=BD=93=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/common/components/chart/index.tsx | 10 ++- src/modules/login/components/Login.tsx | 2 +- .../notification/components/Notification.tsx | 13 +++- src/pages/classInfo/index.config.ts | 1 + src/pages/editUser/index.config.ts | 1 + src/pages/evaluate/evaluate.config.ts | 1 + src/pages/evaluateInfo/index.config.ts | 1 + src/pages/feedback/index.config.ts | 1 + src/pages/guide/index.config.ts | 1 + src/pages/index/index.config.ts | 1 + src/pages/main/index.config.ts | 1 + src/pages/main/index.tsx | 62 ++++++++++++++----- src/pages/myclass/myclass.config.ts | 1 + src/pages/myclass/myclass.tsx | 2 +- src/pages/myclass/store/store.ts | 8 +++ src/pages/notification/index.config.ts | 1 + src/pages/profile/index.config.ts | 1 + src/pages/publishQuestion/index.config.ts | 1 + src/pages/questionInfo/index.config.ts | 1 + src/pages/research/research.config.ts | 1 + src/pages/research/research.tsx | 2 +- 21 files changed, 89 insertions(+), 24 deletions(-) create mode 100644 src/pages/myclass/store/store.ts diff --git a/src/common/components/chart/index.tsx b/src/common/components/chart/index.tsx index f7e496a..09d516f 100644 --- a/src/common/components/chart/index.tsx +++ b/src/common/components/chart/index.tsx @@ -135,10 +135,10 @@ const LineChart: React.FC = (props) => { // 高亮 ctx.lineWidth = 1; const highlightPos = heightLightPercent ?? DEFAULT_HEIGHTLIGHT_POS; - const centerX = ((width - 2 * padding) / 7) * highlightPos + (1 / 2) * barWidth; + const centerX = ((width - 2 * padding) / 7) * Math.ceil(highlightPos); drawGradientRectangle( ctx, - centerX + barWidth / 2, + centerX + padding, padding - 6, barWidth, height - 2 * padding + 6, @@ -148,7 +148,11 @@ const LineChart: React.FC = (props) => { ctx.beginPath(); ctx.fillStyle = DEFAULT_TEXT_COLOR; ctx.font = '15px sans-serif'; - ctx.fillText(title ?? DEFAULT_TITLE, centerX, padding / 2); + ctx.fillText( + title ?? DEFAULT_TITLE, + centerX + (1 / 2) * (title ?? DEFAULT_TITLE)?.length, + padding / 2 + ); void ctx.draw(); }; diff --git a/src/modules/login/components/Login.tsx b/src/modules/login/components/Login.tsx index cd5aa9d..845fc83 100644 --- a/src/modules/login/components/Login.tsx +++ b/src/modules/login/components/Login.tsx @@ -6,7 +6,7 @@ import { TopBackground } from '@/common/assets/img/login'; import AuthForm from './AuthForm'; const Login: React.FC = memo(() => ( - + diff --git a/src/modules/notification/components/Notification.tsx b/src/modules/notification/components/Notification.tsx index a4de0da..1d55e75 100644 --- a/src/modules/notification/components/Notification.tsx +++ b/src/modules/notification/components/Notification.tsx @@ -128,10 +128,19 @@ const Notification: React.FC = memo(() => { }, [test]); const handleScroll = useCallback( (event) => { - if (end) return; + if (end) { + void Taro.showToast({ + title: '没有更多啦', + icon: 'none', + }); + return; + } + void Taro.showLoading({ title: '加载中 ...' }); if (!loading) { console.log('fetching', event); - void fetchData(); + void fetchData().then(() => { + void Taro.hideLoading(); + }); } }, [loading, currentMessage.length, end] diff --git a/src/pages/classInfo/index.config.ts b/src/pages/classInfo/index.config.ts index 59645b8..be3099d 100644 --- a/src/pages/classInfo/index.config.ts +++ b/src/pages/classInfo/index.config.ts @@ -1,4 +1,5 @@ export default definePageConfig({ navigationBarTitleText: '课程主页', navigationBarBackgroundColor: '#F9F9F2', + disableScroll: true, }); diff --git a/src/pages/editUser/index.config.ts b/src/pages/editUser/index.config.ts index 86a8a11..1dacdc4 100644 --- a/src/pages/editUser/index.config.ts +++ b/src/pages/editUser/index.config.ts @@ -1,3 +1,4 @@ export default definePageConfig({ navigationBarTitleText: '修改个人信息', + disableScroll: true, }); diff --git a/src/pages/evaluate/evaluate.config.ts b/src/pages/evaluate/evaluate.config.ts index d27cbd3..28f37ad 100644 --- a/src/pages/evaluate/evaluate.config.ts +++ b/src/pages/evaluate/evaluate.config.ts @@ -1,4 +1,5 @@ export default definePageConfig({ navigationBarTitleText: '评课', navigationBarBackgroundColor: '#F9F9F2', + disableScroll: true, }); diff --git a/src/pages/evaluateInfo/index.config.ts b/src/pages/evaluateInfo/index.config.ts index 10e4e25..379594b 100644 --- a/src/pages/evaluateInfo/index.config.ts +++ b/src/pages/evaluateInfo/index.config.ts @@ -1,3 +1,4 @@ export default definePageConfig({ navigationBarTitleText: '首页', + disableScroll: true, }); diff --git a/src/pages/feedback/index.config.ts b/src/pages/feedback/index.config.ts index a55e147..82d0655 100644 --- a/src/pages/feedback/index.config.ts +++ b/src/pages/feedback/index.config.ts @@ -1,3 +1,4 @@ export default definePageConfig({ navigationBarTitleText: '意见反馈', + disableScroll: true, }); diff --git a/src/pages/guide/index.config.ts b/src/pages/guide/index.config.ts index d1af031..a8c80bd 100644 --- a/src/pages/guide/index.config.ts +++ b/src/pages/guide/index.config.ts @@ -1,3 +1,4 @@ export default definePageConfig({ navigationBarTitleText: '选课手册', + disableScroll: true, }); diff --git a/src/pages/index/index.config.ts b/src/pages/index/index.config.ts index 10e4e25..379594b 100644 --- a/src/pages/index/index.config.ts +++ b/src/pages/index/index.config.ts @@ -1,3 +1,4 @@ export default definePageConfig({ navigationBarTitleText: '首页', + disableScroll: true, }); diff --git a/src/pages/main/index.config.ts b/src/pages/main/index.config.ts index 10e4e25..379594b 100644 --- a/src/pages/main/index.config.ts +++ b/src/pages/main/index.config.ts @@ -1,3 +1,4 @@ export default definePageConfig({ navigationBarTitleText: '首页', + disableScroll: true, }); diff --git a/src/pages/main/index.tsx b/src/pages/main/index.tsx index aced008..a8806c9 100644 --- a/src/pages/main/index.tsx +++ b/src/pages/main/index.tsx @@ -2,7 +2,7 @@ /* eslint-disable import/first */ import { Image, ScrollView, Text, View } from '@tarojs/components'; import Taro from '@tarojs/taro'; -import { useCallback, useEffect, useMemo, useState } from 'react'; +import { useCallback, useEffect, useMemo, useRef, useState } from 'react'; import './index.scss'; @@ -24,7 +24,6 @@ const COURSE_NAME_MAP = { export default function Index() { const handleSearchToggle = () => { - // console.log(isSearchActive); void Taro.navigateTo({ url: '/pages/research/research', }); @@ -42,6 +41,36 @@ export default function Index() { changeType, }) ); + const touchStartX = useRef(0); // 记录触摸起始点 + const touchEndX = useRef(0); // 记录触摸结束点 + + const handleTouchStart = (e) => { + //eslint-disable-next-line @typescript-eslint/no-unsafe-member-access + touchStartX.current = e?.touches[0].pageX as number; // 记录起始触摸点 + }; + const handleTouchMove = (e) => { + //eslint-disable-next-line @typescript-eslint/no-unsafe-member-access + touchEndX.current = e?.touches[0].pageX as number; // 实时记录滑动点 + }; + + const handleTouchEnd = () => { + const deltaX = touchEndX.current - touchStartX.current; // 计算滑动距离 + const tabs = Object.entries(COURSE_NAME_MAP); + const currentTab = tabs.findIndex(([name, value]) => name === classType); + if (Math.abs(deltaX) > 50) { + // 判断滑动距离是否足够切换 Tab + if (deltaX > 0 && currentTab > 0) { + // 向右滑动且不是第一个 Tab + handleChangeType(tabs[currentTab - 1][0]); + } else if (deltaX < 0 && currentTab < tabs.length - 1) { + // 向左滑动且不是最后一个 Tab + handleChangeType(tabs[currentTab + 1][0]); + } + } + // 重置滑动记录 + touchStartX.current = 0; + touchEndX.current = 0; + }; useEffect(() => { void dispatch.loadMoreComments(); @@ -67,19 +96,6 @@ export default function Index() { } }, [classType]); - // useDidShow(() => { - // void Taro.showLoading({ title: '加载中' }); - // void dispatch - // .refershComments() - // .then(() => { - // Taro.hideLoading(); - // }) - // .catch(() => { - // Taro.hideLoading(); - // void Taro.showToast({ title: '加载失败', icon: 'none' }); - // }); - // }); - const handleSearch = (searchText: string) => { console.log('搜索文本:', searchText); }; @@ -103,6 +119,8 @@ export default function Index() { const geneHandler = () => { let timeNow = Date.now(); return (e) => { + console.log(e); + if ( !useCourseStore.getState().loading && // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access @@ -111,7 +129,16 @@ export default function Index() { e.detail.deltaY < 0 && Date.now() - timeNow > 1000 ) { - void dispatch.loadMoreComments(); + void Taro.showLoading({ title: '加载中...' }); + void dispatch + .loadMoreComments() + .then(() => { + Taro.hideLoading(); + }) + .catch(() => { + Taro.hideLoading(); + void Taro.showToast({ title: '加载失败', icon: 'error' }); + }); timeNow = Date.now(); } }; @@ -163,6 +190,9 @@ export default function Index() { })} + = (...args) => ({}); diff --git a/src/pages/notification/index.config.ts b/src/pages/notification/index.config.ts index 49681eb..e38eb66 100644 --- a/src/pages/notification/index.config.ts +++ b/src/pages/notification/index.config.ts @@ -1,3 +1,4 @@ export default definePageConfig({ navigationBarTitleText: '消息提醒', + disableScroll: true, }); diff --git a/src/pages/profile/index.config.ts b/src/pages/profile/index.config.ts index 3a2a3ad..04da532 100644 --- a/src/pages/profile/index.config.ts +++ b/src/pages/profile/index.config.ts @@ -1,3 +1,4 @@ export default definePageConfig({ navigationBarTitleText: '个人主页', + disableScroll: true, }); diff --git a/src/pages/publishQuestion/index.config.ts b/src/pages/publishQuestion/index.config.ts index fd01a30..4a8392c 100644 --- a/src/pages/publishQuestion/index.config.ts +++ b/src/pages/publishQuestion/index.config.ts @@ -1,4 +1,5 @@ export default definePageConfig({ navigationBarTitleText: '问问同学', navigationBarBackgroundColor: '#F9F9F2', + disableScroll: true, }); diff --git a/src/pages/questionInfo/index.config.ts b/src/pages/questionInfo/index.config.ts index fd01a30..4a8392c 100644 --- a/src/pages/questionInfo/index.config.ts +++ b/src/pages/questionInfo/index.config.ts @@ -1,4 +1,5 @@ export default definePageConfig({ navigationBarTitleText: '问问同学', navigationBarBackgroundColor: '#F9F9F2', + disableScroll: true, }); diff --git a/src/pages/research/research.config.ts b/src/pages/research/research.config.ts index e26cc93..7dd0866 100644 --- a/src/pages/research/research.config.ts +++ b/src/pages/research/research.config.ts @@ -1,3 +1,4 @@ export default definePageConfig({ navigationBarTitleText: '搜索', + disableScroll: true, }); diff --git a/src/pages/research/research.tsx b/src/pages/research/research.tsx index ef9cbac..c3867da 100644 --- a/src/pages/research/research.tsx +++ b/src/pages/research/research.tsx @@ -91,7 +91,7 @@ const Research: React.FC = () => { return ( { handleClick(); }}