From 9a88cbc30948b4b5299923a4b62f05d3eed66210 Mon Sep 17 00:00:00 2001 From: king <2229249788@qq.com> Date: Fri, 18 Aug 2023 11:12:52 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=99=BB=E5=BD=95=E9=80=BB?= =?UTF-8?q?=E8=BE=91=E5=92=8C=E6=9D=83=E9=99=90=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/request.ts | 16 ++++++++-------- src/app.config.ts | 10 ++++++++-- src/pages/home/home.config.ts | 4 ++++ src/pages/home/home.tsx | 10 ++++++++++ src/pages/index/components/videoList.tsx | 17 ++++++----------- src/pages/index/index.tsx | 7 +------ src/pages/login/login.tsx | 4 ++-- src/pages/preview/preview.config.ts | 4 ---- src/pages/preview/preview.tsx | 14 -------------- src/store/profile.ts | 12 ++++++------ 10 files changed, 45 insertions(+), 53 deletions(-) create mode 100644 src/pages/home/home.config.ts create mode 100644 src/pages/home/home.tsx delete mode 100644 src/pages/preview/preview.config.ts delete mode 100644 src/pages/preview/preview.tsx diff --git a/src/api/request.ts b/src/api/request.ts index 8778bc9..61b1757 100644 --- a/src/api/request.ts +++ b/src/api/request.ts @@ -83,14 +83,14 @@ export function request( if (data?.code === 0 && res?.statusCode === 200) { resolve(data?.data) } else if (res.statusCode === 401) { - Taro.showModal({ - title: "登录过期,需重新登陆", - showCancel: false, - success() { - Taro.clearStorageSync() - Taro.reLaunch({url: '/pages/login/login'}) - } - }) + // Taro.showModal({ + // title: "登录过期,需重新登陆", + // showCancel: false, + // success() { + Taro.clearStorageSync() + Taro.reLaunch({url: '/pages/login/login'}) + // } + // }) } else { reject(null) Taro.showToast({ diff --git a/src/app.config.ts b/src/app.config.ts index 9126b65..84acf9c 100644 --- a/src/app.config.ts +++ b/src/app.config.ts @@ -1,11 +1,11 @@ export default defineAppConfig({ pages: [ + 'pages/home/home', 'pages/index/index', 'pages/meeting/meeting', 'pages/login/login', 'pages/check/check', 'pages/my/my', - 'pages/preview/preview', ], window: { backgroundTextStyle: 'light', @@ -18,7 +18,13 @@ export default defineAppConfig({ selectedColor: '#45D4A8', list: [ { - text: '课题', + text: '首页', + pagePath: 'pages/home/home', + iconPath: "static/tabs/home-unselect.png", + selectedIconPath: "static/tabs/home-selected.png", + }, + { + text: '学习', pagePath: 'pages/index/index', iconPath: "static/tabs/home-unselect.png", selectedIconPath: "static/tabs/home-selected.png", diff --git a/src/pages/home/home.config.ts b/src/pages/home/home.config.ts new file mode 100644 index 0000000..d178761 --- /dev/null +++ b/src/pages/home/home.config.ts @@ -0,0 +1,4 @@ +export default definePageConfig({ + navigationBarTitleText: '首页', + navigationStyle: 'custom', +}) diff --git a/src/pages/home/home.tsx b/src/pages/home/home.tsx new file mode 100644 index 0000000..39eb775 --- /dev/null +++ b/src/pages/home/home.tsx @@ -0,0 +1,10 @@ +import {FC} from "react"; +import {View} from "@tarojs/components"; + +const Home: FC = () => { + return ( + 2 + ) +} + +export default Home diff --git a/src/pages/index/components/videoList.tsx b/src/pages/index/components/videoList.tsx index 5890586..10c422f 100644 --- a/src/pages/index/components/videoList.tsx +++ b/src/pages/index/components/videoList.tsx @@ -11,10 +11,9 @@ import eventsIndex from "@/hooks/eventsIndex"; interface Props { categoryKey: CoursesKey - ready: boolean } -export const VideoList: FC = ({categoryKey, ready}) => { +export const VideoList: FC = ({categoryKey}) => { const [data, setData] = useState({ is_finished: [], is_required: [], @@ -94,18 +93,14 @@ export const VideoList: FC = ({categoryKey, ready}) => { }) useDidShow(() => { - if (ready) { - getData().then() - getRecords().then() - } + getData().then() + getRecords().then() }) useEffect(() => { - if (ready) { - getData().then() - getRecords().then() - } - }, [page, ready]) + getData().then() + getRecords().then() + }, [page]) return ( {data?.[categoryKey]?.length ? data?.[categoryKey]?.map(c => diff --git a/src/pages/index/index.tsx b/src/pages/index/index.tsx index 0bb30bf..dc9c625 100644 --- a/src/pages/index/index.tsx +++ b/src/pages/index/index.tsx @@ -5,9 +5,6 @@ import {VideoList} from "@/pages/index/components/videoList"; import Tabs, {OnChangOpt, TabList} from "@/components/tabs/tabs"; import {CoursesKey} from "@/api/public"; import Taro from '@tarojs/taro' -import {Profile} from '@/store' -// import {Search} from "./components/search"; - const Index: FC = () => { const globalData = Taro.getApp().globalData @@ -18,7 +15,6 @@ const Index: FC = () => { {title: "未完成", value: 'is_not_finished'}, ] const [categoryKey, setCategoryKey] = useState('is_required') - const {token} = Profile.useContainer() function tabChange(data: OnChangOpt) { setCategoryKey(data.tab?.value as CoursesKey) @@ -28,9 +24,8 @@ const Index: FC = () => { <> {process.env.TARO_ENV !== "h5" && 医学道} - {/**/} - + ) diff --git a/src/pages/login/login.tsx b/src/pages/login/login.tsx index c4cff69..d16f495 100644 --- a/src/pages/login/login.tsx +++ b/src/pages/login/login.tsx @@ -61,7 +61,7 @@ const Login: FC = () => { setToken(token) setCompany(company) setLoading(false) - Taro.switchTab({url: '/pages/index/index'}) + Taro.switchTab({url: '/pages/home/home'}) } else { Taro.setStorageSync('openid', catch_key) Taro.reLaunch({url: '/pages/check/check'}) @@ -81,7 +81,7 @@ const Login: FC = () => { async function TESTLOGIN() { const res = await loginApi.testLogin() Taro.setStorageSync('profile', JSON.stringify(res)) - Taro.reLaunch({url: '/pages/index/index'}) + Taro.reLaunch({url: '/pages/home/home'}) } return ( diff --git a/src/pages/preview/preview.config.ts b/src/pages/preview/preview.config.ts deleted file mode 100644 index 767c5c8..0000000 --- a/src/pages/preview/preview.config.ts +++ /dev/null @@ -1,4 +0,0 @@ -export default definePageConfig({ - navigationBarTitleText:'医学道', - onReachBottomDistance: 30 -}) diff --git a/src/pages/preview/preview.tsx b/src/pages/preview/preview.tsx deleted file mode 100644 index 3d73d19..0000000 --- a/src/pages/preview/preview.tsx +++ /dev/null @@ -1,14 +0,0 @@ -import {FC} from "react"; -import {View, Navigator} from "@tarojs/components"; - -const Preview: FC = () => { - return ( - - 预览..... - - 登录 - - ) -} - -export default Preview diff --git a/src/store/profile.ts b/src/store/profile.ts index 7e3723d..b3d21d0 100644 --- a/src/store/profile.ts +++ b/src/store/profile.ts @@ -1,7 +1,7 @@ import {useEffect, useState} from "react"; import {createContainer} from "unstated-next"; import Taro from "@tarojs/taro"; -import {whiteList} from "@/config"; +// import {whiteList} from "@/config"; function DataKey(data: any) { @@ -40,11 +40,11 @@ function useProfile() { } } - if (data?.token == null) { - if (!whiteList.includes(Taro.getCurrentInstance().router?.path?.split('?')?.[0] || '')) { - Taro.reLaunch({url: '/pages/preview/preview'}) - } - } + // if (data?.token == null) { + // if (!whiteList.includes(Taro.getCurrentInstance().router?.path?.split('?')?.[0] || '')) { + // Taro.reLaunch({url: '/pages/login/login'}) + // } + // } const [role, setRole] = useState(data?.role || null) const [user, setUser] = useState(data?.user || null)