Skip to content

Commit

Permalink
Merge pull request #182 from eleliauk/main
Browse files Browse the repository at this point in the history
🔧 chore:新增审核大法!
  • Loading branch information
eleliauk authored Nov 17, 2024
2 parents 50c82e4 + 7fc9d3c commit dd9175e
Show file tree
Hide file tree
Showing 11 changed files with 32 additions and 57 deletions.
6 changes: 5 additions & 1 deletion src/common/components/Comment/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import './style.scss';
import { useCourseStore } from '@/pages/main/store/store';

import IconFont from '@/common/components/iconfont';
import { formatIsoDate } from '@/common/utils';
import { CourseDetailsType, PublisherDetailsType } from '@/pages/main/store/types';
import ShowStar from '../showStar/showStar';

Expand Down Expand Up @@ -72,7 +73,10 @@ const CommentHeader: React.FC<CommentProps> = memo((props) => {
style={`background-image: url(${publisher_info?.avatar});`}
></View>
<View className="userName">{publisher_info?.nickname}</View>
<View className="time">{new Date(ctime as number).toLocaleString()}</View>
<View className="time">
{' '}
{formatIsoDate(new Date(ctime as number).toISOString())}
</View>
<View className="stars">
<ShowStar score={star_rating}></ShowStar>
</View>
Expand Down
23 changes: 15 additions & 8 deletions src/common/components/CommentComponent/CommentComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@
/* eslint-disable @typescript-eslint/no-unsafe-call */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable import/first */

// Comment.tsx
import { Image, Text, View } from '@tarojs/components';
import React, { useEffect, useState } from 'react';

import './index.scss';

import { get } from '@/common/utils';
// eslint-disable-next-line import/first
import { formatIsoDate, get } from '@/common/utils';
// eslint-disable-next-line import/first
import { useCourseStore } from '@/pages/main/store/store';

interface CommentProps {
Expand Down Expand Up @@ -72,10 +74,11 @@ const CommentComponent: React.FC<CommentProps> = ({ comments, onCommentClick })
void fetchAllReplies();
}, []);

const ctimeToString = (ctime: number) => {
const ctimeDate = new Date(ctime);
return <Text className="time">{ctimeDate.toLocaleString()}</Text>;
};
// const ctimeToString = (ctime: number) => {
// return (
// <Text className="time">formatIsoDate(new Date(ctime as number).toISOString())</Text>
// );
// };

// 辅助函数:获取回复者的昵称
const getReplyToNickname = (replyToUid: number): string => {
Expand Down Expand Up @@ -103,7 +106,9 @@ const CommentComponent: React.FC<CommentProps> = ({ comments, onCommentClick })
<View className="comment-header">
<Image src={comment.user?.avatar ?? ''} className="avatar" />
<Text className="nickname">{comment.user?.nickname}</Text>
{ctimeToString(comment.ctime)}
<View className="time">
{formatIsoDate(new Date(comment.ctime).toISOString())}
</View>
</View>
<View className="comment-content">
<Text>{comment.content}</Text>
Expand All @@ -128,7 +133,9 @@ const CommentComponent: React.FC<CommentProps> = ({ comments, onCommentClick })
</Text>
) : null}
</Text>
{ctimeToString(reply.ctime)}
<View className="time">
{formatIsoDate(new Date(comment.ctime).toISOString())}
</View>
</View>
<View className="reply-content">
<Text>{reply.content}</Text>
Expand Down
14 changes: 0 additions & 14 deletions src/common/components/SearchInput/SearchInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,6 @@ const SearchInput: React.FC<SearchInputProps> = ({
// const [isSearchActive, setIsSearchActive] = useState(true);
const [searchText, setSearchText] = useState(''); // 添加状态来存储搜索文本

// const handleClick = () => {
// // if (!isSearchActive) {
// // setIsSearchActive(true);
// onSearchToggle();
// // }
// };

// const handleBlur = () => {
// // if (isSearchActive) {
// // setIsSearchActive(false);
// onSearchToggle();
// // }
// };

// 添加点击图片时的搜索逻辑
const handleImageClick = (e: any) => {
// 阻止事件冒泡
Expand Down
Empty file added src/common/types/projectType.ts
Empty file.
6 changes: 5 additions & 1 deletion src/common/utils/checkToken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ import Taro from '@tarojs/taro';

const checkToken = () => {
const token: string = Taro.getStorageSync('shortToken');

const accountInfo = Taro.getAccountInfoSync();
void Taro.setStorage({
key: 'accountInfo',
data: accountInfo,
});
if (token) {
void Taro.switchTab({ url: '/pages/main/index' });
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/pages/classInfo/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ export default function Index() {
</View>
)}
{questionlist.length === 0 && (
<Text className="mr-auto flex items-center justify-center">
<Text className="mb-2 mr-auto mt-2 flex items-center justify-center">
暂无内容敬请期待
</Text>
)}
Expand Down
30 changes: 4 additions & 26 deletions src/pages/evaluate/evaluate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,7 @@ import Star from '@/common/components/star/star';
import { post } from '@/common/utils';

export default function evaluate() {
// function generateUniqueID() {
// const timestamp = Date.now().toString(36); // 时间戳转换为36进制
// const randomString = Math.random().toString(36).substr(2, 5); // 随机数转换为36进制并截取部分字符

// const uniqueID = timestamp + randomString;
// return uniqueID;
// }

// 示例用法
//const uniqueID = generateUniqueID();

const accoutInfo = Taro.getStorageSync('accountInfo');
// 初始化状态,存储所有选中的 Radio 项的值
const [selectedValues, setSelectedValues] = useState<string[]>([]);

Expand All @@ -51,20 +41,6 @@ export default function evaluate() {
{ value: 'NoAssessment', text: '无考核' },
];

// const [checkedClass,setCheckedClass] = useState([{ content: '只能评价自己学过的课程哦' }]);

// enum FeatureTag {
// EasyToLearn = '课程简单易学',
// RichInContent = '课程干货满满',
// Challenging = '课程很有挑战',
// RigorousAndResponsible = '老师严谨负责',
// KindAndEasygoing = '老师温柔随和',
// Humorous = '老师风趣幽默',
// LessHomework = '平时作业少',
// KeyPointsForFinal = '期末划重点',
// ComprehensiveOnlineMaterials = '云课堂资料全',
// }

const features = [
{ value: 'EasyToLearn', content: '课程简单易学' },
{ value: 'RichInContent', content: '课程干货满满' },
Expand Down Expand Up @@ -177,7 +153,9 @@ export default function evaluate() {
}
};

return (
return accoutInfo.miniProgram.envVersion !== 'develop' ? (
<>因为政策原因,暂时无法评价课程</>
) : (
<Form className="view">
<View className="p">
<Text> 选择课程 : </Text>
Expand Down
3 changes: 2 additions & 1 deletion src/pages/index/index.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { Navigator, View } from '@tarojs/components';
// import Taro from '@tarojs/taro';
import { useState } from 'react';
import { AtFloatLayout } from 'taro-ui';

import './index.scss';

export default function Index() {
const [isFloatLayoutVisible, setIsFloatLayoutVisible] = useState(false); // 控制 AtFloatLayout 显示的状态

// 处理打开 FloatLayout 的方法

const handleFloatLayoutChange = (isVisible: boolean) => {
console.log(1);
setIsFloatLayoutVisible(isVisible);
Expand Down
2 changes: 0 additions & 2 deletions src/pages/main/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ export default function Index() {

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

const geneHandler = () => {
Expand Down
2 changes: 0 additions & 2 deletions src/pages/questionList/index.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
/* eslint-disable import/first */
/* eslint-disable no-console */
import { Button, View } from '@tarojs/components';
import Taro from '@tarojs/taro';
import { useEffect, useState } from 'react';

// import './index.scss';

import CourseInfo from '@/common/components/CourseInfo/CourseInfo';
import QuestionListComponent from '@/common/components/QuestionListComponent/QuestionListComponent';
import { get } from '@/common/utils';
Expand Down
1 change: 0 additions & 1 deletion src/pages/research/research.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ const Research: React.FC = () => {
const handleSearch = (searchText: string) => {
console.log('搜索文本:', searchText);
setSpread(true);
// 这里可以添加发送API请求的代码
get(`/search?biz=Course&keyword=${searchText}&search_location=Home`).then((res) => {
console.log(res);
setClasses(res.data);
Expand Down

0 comments on commit dd9175e

Please sign in to comment.