From a3c17101d654880d504f7bf0a01a9bb537492d5b Mon Sep 17 00:00:00 2001 From: mozzie Date: Fri, 24 Mar 2023 10:51:37 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20sub=E9=A1=B5=20bg?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/controller/course.controller.ts | 4 +- apps/server/src/controller/user.controller.ts | 3 +- apps/web/src/components/Nav/index.tsx | 10 --- apps/web/src/components/Result/index.tsx | 4 +- apps/web/src/router/index.tsx | 9 +- apps/web/src/view/CourseDetail/index.tsx | 87 +++++++++---------- apps/web/src/view/ResultPage/index.tsx | 7 ++ apps/web/src/view/Subscribe/index.less | 7 +- apps/web/src/view/Subscribe/index.tsx | 33 +++++++ 9 files changed, 99 insertions(+), 65 deletions(-) create mode 100644 apps/web/src/view/ResultPage/index.tsx diff --git a/apps/server/src/controller/course.controller.ts b/apps/server/src/controller/course.controller.ts index 6db4e62..e39dbda 100644 --- a/apps/server/src/controller/course.controller.ts +++ b/apps/server/src/controller/course.controller.ts @@ -70,9 +70,9 @@ export class CourseController { const user = await this.userService.select({ user_login }); // 用户订阅鉴权 if (!user.user_sub) - return { code: BizCode.FORBID, msg: '无权访问订阅课程' }; + return { code: BizCode.AUTH, msg: '无权访问订阅课程' }; if (+user.user_sub_expired < Date.now()) - return { code: BizCode.FORBID, msg: '订阅已过期' }; + return { code: BizCode.AUTH, msg: '订阅已过期' }; const course = await this.courseService.select({ course_id }); const chapterList = await this.chapterService.select(course_id); const guide = await this.guideService.select(course_id); diff --git a/apps/server/src/controller/user.controller.ts b/apps/server/src/controller/user.controller.ts index 4b412d6..2097df4 100644 --- a/apps/server/src/controller/user.controller.ts +++ b/apps/server/src/controller/user.controller.ts @@ -127,7 +127,8 @@ export class UserController { // 防止接口调用 end const code = Math.floor(Math.random() * 9000 + 1000); await this.redisService.set('' + phoneNumbers, code, 'EX', 60); - await this.smsService.send({ code, phoneNumbers }); + if (process.env.EGG_SERVER_ENV === 'prod') + await this.smsService.send({ code, phoneNumbers }); return { code: BizCode.OK }; } catch (error) { this.ctx.logger.error(error); diff --git a/apps/web/src/components/Nav/index.tsx b/apps/web/src/components/Nav/index.tsx index 62aa784..a9e7cad 100644 --- a/apps/web/src/components/Nav/index.tsx +++ b/apps/web/src/components/Nav/index.tsx @@ -8,7 +8,6 @@ import CaretDown20Filled from "@ricons/fluent/CaretDown20Filled"; import Alert20Regular from "@ricons/fluent/Alert20Regular"; import DoorArrowRight20Regular from "@ricons/fluent/DoorArrowRight20Regular"; import Settings20Regular from "@ricons/fluent/Settings20Regular"; -import PremiumPerson20Regular from "@ricons/fluent/PremiumPerson20Regular"; import { useState } from "react"; import { useMount } from "../../hook"; @@ -103,15 +102,6 @@ function Nav() {
- {/*
onClickProfileItem("sub")} - > - 订阅 - - - -
*/}
{ - if (props.code) { - setView(table[props.code]); - } + if (props.code) setView(table[props.code]); }, [props.code]); return <>{view}; diff --git a/apps/web/src/router/index.tsx b/apps/web/src/router/index.tsx index 7b7d143..a484ccc 100644 --- a/apps/web/src/router/index.tsx +++ b/apps/web/src/router/index.tsx @@ -1,8 +1,7 @@ import { lazy } from "react"; import Course from "../view/Course"; -import CourseDetail from "../view/CourseDetail"; import Login from "../view/Login"; -import Subscribe from "../view/Subscribe"; +import ResultPage from "../view/ResultPage"; export interface IRouteMenuItem { path: string; @@ -26,6 +25,12 @@ export const commonRouters: IRoute[] = [ element: , name: "学习", }, + { + path: "/result", + element: , + name: "Ooops!", + invisible: true, + }, ]; export const lazyRouters: IRoute[] = [ diff --git a/apps/web/src/view/CourseDetail/index.tsx b/apps/web/src/view/CourseDetail/index.tsx index 7dcc7b5..b38223a 100644 --- a/apps/web/src/view/CourseDetail/index.tsx +++ b/apps/web/src/view/CourseDetail/index.tsx @@ -3,7 +3,7 @@ import "./index.less"; import Guide from "./components/Guide"; import { useMount } from "../../hook"; import Player from "./components/DPlayer"; -import { useParams } from "react-router-dom"; +import { useNavigate, useParams } from "react-router-dom"; import { getCourseDetailById } from "../../api"; import { ms2Time } from "./util"; import Result from "../../components/Result"; @@ -34,6 +34,7 @@ const defaultState = { function CourseDetail() { const { id: course_id = "" } = useParams(); const [state, setState] = useState(defaultState); + const navigate = useNavigate(); const chapters2toc = (chapterList: IChapter[]) => { return chapterList.map((item) => { @@ -93,7 +94,9 @@ function CourseDetail() { ], view: , }); + break; default: + navigate("/result"); break; } }); @@ -109,51 +112,43 @@ function CourseDetail() { return (
- {state.toc.length > 0 ? ( - <> - -
0 ? 300 : "0" }} - > - {state.view} -
- - ) : ( - - )} + +
0 ? 300 : "0" }} + > + {state.view} +
); } diff --git a/apps/web/src/view/ResultPage/index.tsx b/apps/web/src/view/ResultPage/index.tsx new file mode 100644 index 0000000..216f171 --- /dev/null +++ b/apps/web/src/view/ResultPage/index.tsx @@ -0,0 +1,7 @@ +import Result from "../../components/Result"; + +const ResultPage = () => { + return ; +}; + +export default ResultPage; diff --git a/apps/web/src/view/Subscribe/index.less b/apps/web/src/view/Subscribe/index.less index 4fb67a1..32c766d 100644 --- a/apps/web/src/view/Subscribe/index.less +++ b/apps/web/src/view/Subscribe/index.less @@ -17,6 +17,11 @@ // ); background: #e9e8e5; + .bg { + position: absolute; + bottom: 0; + } + h2 { font-size: 24px; } @@ -40,7 +45,7 @@ width: 35%; height: 120%; top: -10%; - background: #fff; + background: rgba(255, 255, 255, 0.7); box-shadow: 0 0.75rem 2rem 0 rgba(0, 0, 0, 0.1); border-radius: 10px; border: 1px solid rgba(255, 255, 255, 0.125); diff --git a/apps/web/src/view/Subscribe/index.tsx b/apps/web/src/view/Subscribe/index.tsx index d99ff34..2a8baf3 100644 --- a/apps/web/src/view/Subscribe/index.tsx +++ b/apps/web/src/view/Subscribe/index.tsx @@ -5,6 +5,39 @@ import "./index.less"; function Subscribe() { return (
+ + + + + + + + + + + + + + + +

订阅

订阅后,全站免费,无任何其他附加收费