diff --git a/src/api/request.ts b/src/api/request.ts index 2c15aa8..25a13d9 100644 --- a/src/api/request.ts +++ b/src/api/request.ts @@ -43,7 +43,12 @@ export const ERROR_STATUS: Record = { 'INVALID_DATA': '服务器响应异常~', 'OVERSTEP': '请求越界~' } -let isOverdue = false + +const whitelist = [ + '/api/v1/auth/login/code', + '/api/v1/auth/login/checkout', + '/api/v1/auth/login/wechat' +] export function request( url: string, @@ -63,6 +68,13 @@ export function request( if (token) { option.header ??= {} option.header['Authorization'] = `Bearer ${token}` + } else { + /** 登录页面白名单 */ + if (Taro.getCurrentInstance().router?.path === '/pages/login/login') { + if (!whitelist.includes(url)) { + return new Promise((_, reject) => reject()) + } + } } if (method === 'GET' && data) { let parameter = '' @@ -71,11 +83,10 @@ export function request( }) option.url += parameter } - if (isOverdue) { - isOverdue = false - } data && (option.data = data) return new Promise((resolve, reject) => { + + Taro.request({ ...option, success(res) { @@ -84,16 +95,13 @@ export function request( if (data?.code === 0 && res.statusCode === 200) { resolve(data.data || []) } else if (res.statusCode === 401) { - if (!isOverdue) { - isOverdue = true - Taro.showModal({ - title: "登录过期,需重新登陆", - showCancel: false, - success({confirm}) { - confirm && Taro.reLaunch({url: '/pages/login/login'}) - } - }) - } + Taro.showModal({ + title: "登录过期,需重新登陆", + showCancel: false, + success({confirm}) { + confirm && Taro.reLaunch({url: '/pages/login/login'}) + } + }) } else { Taro.showToast({title: data.msg || ERROR_STATUS[res.statusCode] || '请求错误~', icon: 'error'}) reject(null) diff --git a/src/app.scss b/src/app.scss index dd4ecb0..1b4a95c 100644 --- a/src/app.scss +++ b/src/app.scss @@ -249,8 +249,6 @@ .bg-gray{ background-color: gray;} .bg-transparent { background-color: transparent;} - - /* 文字颜色 */ .text-white {color: #ffffff } .text-primary {color: #007bff;} diff --git a/src/components/empty/empty.module.scss b/src/components/empty/empty.module.scss new file mode 100644 index 0000000..40f4e3d --- /dev/null +++ b/src/components/empty/empty.module.scss @@ -0,0 +1,21 @@ +.empty { + width: 750rpx; + text-align: center; + color: #6c757d; + position: relative; + + Image { + display: block; + margin: auto; + width: 400px; + margin-bottom: 10px; + } + + View { + position: absolute; + left: 0; + right: 0; + bottom: 40px; + margin: auto; + } +} diff --git a/src/components/empty/empty.tsx b/src/components/empty/empty.tsx new file mode 100644 index 0000000..05df872 --- /dev/null +++ b/src/components/empty/empty.tsx @@ -0,0 +1,19 @@ +import {FC} from "react"; +import {Image, View} from "@tarojs/components"; +import emptyImg from '@/static/img/empty.png' +import styles from './empty.module.scss' + +interface Props { + name: string +} + +const Empty: FC = ({name}) => { + return ( + + + {name} + + ) +} + +export default Empty diff --git a/src/components/topic/judge.tsx b/src/components/topic/judge.tsx index 47337dc..396b792 100644 --- a/src/components/topic/judge.tsx +++ b/src/components/topic/judge.tsx @@ -73,7 +73,8 @@ const Judge: FC = ({data, onAnswer, onUpAndDown, index, validate, frequen {error && frequency == 0 && - 错误答案解析 + 正确答案:{data.right_answer ? '正确' : '错误'} + 题目解析 {data.analysis} } diff --git a/src/components/topic/multi.tsx b/src/components/topic/multi.tsx index 0f2a3cc..71f8238 100644 --- a/src/components/topic/multi.tsx +++ b/src/components/topic/multi.tsx @@ -88,7 +88,8 @@ const Multi: FC = ({data, onAnswer, onUpAndDown, index, validate, frequen {error && frequency == 0 && - 错误答案解析 + 正确答案:{data.right_answer} + 题目解析 {data.analysis} } diff --git a/src/components/topic/shortAnswer.tsx b/src/components/topic/shortAnswer.tsx index 2f817ba..d3d2b1d 100644 --- a/src/components/topic/shortAnswer.tsx +++ b/src/components/topic/shortAnswer.tsx @@ -63,7 +63,7 @@ const ShortAnswer: FC = ({data, onAnswer, onUpAndDown, index, validate, f {frequency == 0 && - 解析 + 题目解析 {data.analysis} } diff --git a/src/components/topic/topic.scss b/src/components/topic/topic.scss index 1b1e306..ddf9069 100644 --- a/src/components/topic/topic.scss +++ b/src/components/topic/topic.scss @@ -1,10 +1,12 @@ .topic { padding: 40rpx; box-sizing: border-box; + background: #FFF; .option { display: block; margin-bottom: 10px; + line-height: 2; } } @@ -23,3 +25,11 @@ width: 40%; } } + + +.right_answer{ + font-weight: bold; + color: #FF9E5F; + line-height: 40rpx; + font-size: 32px; +} diff --git a/src/components/video/video.tsx b/src/components/video/video.tsx index d66dc1f..1e5fdd4 100644 --- a/src/components/video/video.tsx +++ b/src/components/video/video.tsx @@ -53,7 +53,8 @@ const HVideo: FC = (opt: HVideoOptions) => { return (