Skip to content

Commit

Permalink
🔨 refactor:合并代码
Browse files Browse the repository at this point in the history
  • Loading branch information
eleliauk committed Aug 24, 2024
2 parents 0913428 + 2982ca4 commit 756b156
Show file tree
Hide file tree
Showing 79 changed files with 538 additions and 802 deletions.
1 change: 0 additions & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/usr/bin/env sh
export GIT_TERMINAL_PROMPT=0
. "$(dirname -- "$0")/_/husky.sh"
. "$(dirname -- "$0")/common.sh"

yarn lint
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"dev:qq": "npm run build:qq -- --watch",
"dev:jd": "npm run build:jd -- --watch",
"dev:quickapp": "npm run build:quickapp -- --watch",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0 --fix",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 40 --fix",
"prepare": "husky install",
"prettier": "prettier --write .",
"postinstall": "weapp-tw patch"
Expand All @@ -45,6 +45,7 @@
"@taro-hooks/plugin-react": "^2.0.11",
"@taroify/core": "^0.3.0-alpha.0",
"@tarojs/components": "3.6.35",
"@tarojs/components-advanced": "^3.6.35",
"@tarojs/helper": "3.6.34",
"@tarojs/plugin-framework-react": "3.6.34",
"@tarojs/plugin-platform-alipay": "3.6.34",
Expand All @@ -60,6 +61,7 @@
"@tarojs/taro": "4.0.3",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.2.1",
"immer": "^10.1.1",
"lodash": "4.17.21",
"prettier": "^3.3.3",
"qiniu-js": "^4.0.0-beta.3",
Expand Down Expand Up @@ -93,7 +95,7 @@
"eslint-plugin-react-hooks": "^4.6.2",
"eslint-plugin-simple-import-sort": "^12.1.1",
"eslint-plugin-unused-imports": "^4.0.1",
"husky": "^9.1.2",
"husky": "^9.1.5",
"postcss": "^8.4.40",
"postcss-rem-to-responsive-pixel": "^6.0.1",
"prettier-plugin-organize-imports": "^4.0.0",
Expand Down
16 changes: 12 additions & 4 deletions src/app.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@
// { pagePath: 'pages/456/index', text: '456' },
// ],
// },
// // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
// usingComponents: Object.assign({
// iconfont: `common/components/iconfont/weapp/weapp`,
// }),
// lazyCodeLoading: 'requiredComponents',
// });

Expand All @@ -60,10 +56,22 @@ export default defineAppConfig({
'pages/index/index',
'pages/editUser/index',
],
// tabBar: {
// /* tab页面必须放在主包里 */
// custom: true,
// list: [
// {
// pagePath: 'pages/123/index',
// text: '123',
// },
// { pagePath: 'pages/456/index', text: '456' },
// ],
// },
window: {
backgroundTextStyle: 'light',
navigationBarBackgroundColor: '#fff',
navigationBarTitleText: 'WeChat',
navigationBarTextStyle: 'black',
},
lazyCodeLoading: 'requiredComponents',
});
Empty file removed src/app.scss
Empty file.
2 changes: 1 addition & 1 deletion src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Component, PropsWithChildren } from 'react';

import '@/common/styles/app.scss';

import checkToken from '@/utils/checkToken';
import checkToken from '@/common/utils/checkToken';

class App extends Component<PropsWithChildren> {
//TODO 写成加interceptor 但是我还没写明白 别急
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
27 changes: 27 additions & 0 deletions src/assets/types.ts → src/common/assets/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,30 @@ export interface User {
avatar: string;
nickname: string;
}

/** 评论详情 */
export interface CommentInfo {
/**
* 考核方式,支持多选
*/
assessments?: string[];
content?: string;
course_id?: number;
ctime?: number;
/**
* 课程特点,支持多选
*/
features?: string[];
id?: number;
publisher_id?: number;
/**
* 1支持,0无,-1反对
*/
stance?: number;
star_rating?: number;
status?: string;
total_comment_count?: number;
total_oppose_count?: number;
total_support_count?: number;
utime?: number;
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/no-unsafe-return */
// userService.ts
import { get } from '@/fetch'; // 确保这个路径正确
import { get } from '@/common/utils/fetch'; // 确保这个路径正确

import { User } from './types';

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import React, { useEffect, useState } from 'react';

import './index.scss';

import { get } from '@/fetch';
import { get } from '@/common/utils/fetch';

import { Comment } from '../../assets/types';
import { getUserInfo } from '../../assets/userService';
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
117 changes: 117 additions & 0 deletions src/common/components/comment/comment.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/no-redundant-type-constituents */
/* eslint-disable @typescript-eslint/no-unsafe-argument */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable simple-import-sort/imports */
/* eslint-disable @typescript-eslint/no-floating-promises */
// import React, { useEffect } from "react";
import { Image, Navigator, Text, View } from '@tarojs/components';
import Taro from '@tarojs/taro';
import { useEffect, useTransition } from 'react';

import { useCourseStore } from '@/pages/main/store/store';

import './comment.scss';

import { CommentInfo } from '../../assets/types';
import ShowStar from '../showStar/showStar';

export default function Comment(props: CommentInfo & { type?: string }) {
const { course_id, ctime, publisher_id } = props;
// 创建一个新的Date对象,传入时间戳
const ctimeDate = new Date(ctime || 0);
const courseDetail = useCourseStore((state) => state.courseDetail);
const publisher = useCourseStore((state) => state.publishers);
const [isPublisherInfoPending, startPublisherTransition] = useTransition();
const [isCoursePending, startCourseTransition] = useTransition();
const handleClick = () => {
const serializedComment = encodeURIComponent(JSON.stringify(props));
Taro.navigateTo({
url: `/pages/evaluateInfo/index?comment=${serializedComment}`,
});
};
useEffect(() => {
startCourseTransition(() => {
useCourseStore.getState().getCourseDetail(course_id || 0);
});
startPublisherTransition(() => {
useCourseStore.getState().getPublishers(publisher_id || 0);
});
}, [course_id, publisher_id]);

return (
<View className="bigcomment" onClick={handleClick}>
<View className="commentplus">
{isCoursePending ? (
<>
<View className="classTitle">pending</View>
</>
) : (
<>
<View className="classTitle">
{courseDetail[course_id || 0]?.name +
' (' +
courseDetail[course_id || 0]?.teacher +
') '}
</View>
</>
)}
<View className="comment">
{isPublisherInfoPending || !publisher_id ? (
<>
<View>pending</View>
</>
) : (
<>
<View
className="tx"
style={`background-image: url(${publisher[publisher_id].avatar});`}
></View>
<View className="userName">{publisher[publisher_id].nickname}</View>
<View className="time">{ctimeDate.toLocaleString()}</View>
<View className="stars">
<ShowStar score={props.star_rating}></ShowStar>
</View>
<Image
// style={`display:${props.isHot ? 'block' : 'none'}`}
className="fire"
src="https://s2.loli.net/2023/11/12/2ITKRcDPMZaQCvk.png"
></Image>
</>
)}
<View className="content">{props.content}</View>
<View
className="likes"
style={`display:${props.type == 'inner' ? 'block' : 'none'}`}
>
<View className="icon">
<Navigator className="iconfont">&#xe786;</Navigator>
</View>
<Text className="text1">{props.total_support_count}</Text>
<View className="icon">
<Navigator className="iconfont">&#xe769;</Navigator>
</View>
<Text className="text1">{props.total_comment_count}</Text>
</View>
</View>
</View>
<View
className="likes"
style={`display:${props.type == 'inner' ? 'none' : 'block'}`}
>
<View className="icon">
<Navigator className="iconfont">&#xe786;</Navigator>
</View>
<Text className="text1">{props.total_support_count}</Text>
<View className="icon">
<Navigator className="iconfont">&#xe769;</Navigator>
</View>
<Text className="text1">{props.total_comment_count}</Text>
<View className="icon">
<Navigator className="iconfont">&#xe785;</Navigator>
</View>
<Text className="text1">{props.total_oppose_count}</Text>
</View>
</View>
);
}
2 changes: 0 additions & 2 deletions src/common/components/iconfont/helper.d.ts

This file was deleted.

9 changes: 0 additions & 9 deletions src/common/components/iconfont/helper.js

This file was deleted.

81 changes: 0 additions & 81 deletions src/common/components/iconfont/index.tsx

This file was deleted.

Loading

0 comments on commit 756b156

Please sign in to comment.