Skip to content

Commit

Permalink
🐞 fix:修正一些 ESLint 警告
Browse files Browse the repository at this point in the history
  • Loading branch information
BlackishGreen33 committed Sep 1, 2024
1 parent 3c44bb8 commit 2722dfc
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions src/pages/main/index.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
/* eslint-disable react-hooks/exhaustive-deps */
/* eslint-disable no-console */
/* eslint-disable @typescript-eslint/no-floating-promises */
/* eslint-disable @typescript-eslint/no-unsafe-argument */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */

/* eslint-disable import/first */
import { ScrollView, View } from '@tarojs/components';
import Taro, { useDidShow } from '@tarojs/taro';
Expand Down Expand Up @@ -43,40 +38,49 @@ export default function Index() {
changeType,
})
);

useDidShow(() => {
dispatch.refershComments();
void dispatch.refershComments();
});

useEffect(() => {
dispatch.loadMoreComments();
void dispatch.loadMoreComments();
}, [dispatch.loadMoreComments]);

const handleChangeType = (type) => {
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
dispatch.changeType(type);
};

useEffect(() => {
!comments[classType].length && dispatch.refershComments();
void (!comments[classType].length && dispatch.refershComments());
}, [classType]);

const handleSearch = (searchText: string) => {
console.log('搜索文本:', searchText);
// 这里可以添加发送API请求的代码
// 例如: fetchSearchResults(searchText);
};

const geneHandler = () => {
let timeNow = Date.now();
return (e) => {
if (
!useCourseStore.getState().loading &&
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
e.detail.scrollTop > e.detail.scrollHeight / 2 &&
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
e.detail.deltaY < 0 &&
Date.now() - timeNow > 1000
) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
console.log(e.detail);
dispatch.loadMoreComments();
void dispatch.loadMoreComments();
timeNow = Date.now();
}
};
};

const loadMoreHandler = useMemo(() => {
return geneHandler();
}, [loading]);
Expand Down Expand Up @@ -115,7 +119,7 @@ export default function Index() {
<Comment
onClick={(props) => {
const serializedComment = encodeURIComponent(JSON.stringify(props));
Taro.navigateTo({
void Taro.navigateTo({
url: `/pages/evaluateInfo/index?comment=${serializedComment}`,
});
}}
Expand Down

0 comments on commit 2722dfc

Please sign in to comment.