diff --git a/src/app.config.ts b/src/app.config.ts index 2f15ede..f4dcc05 100644 --- a/src/app.config.ts +++ b/src/app.config.ts @@ -62,9 +62,10 @@ export default defineAppConfig({ list: [ { pagePath: 'pages/main/index', - text: 'clock', + text: 'Home', }, - { pagePath: 'pages/personalPage/index', text: 'user' }, + { pagePath: 'pages/messageNotification/index', text: 'Massage' }, + { pagePath: 'pages/personalPage/index', text: 'Profile' }, ], }, window: { diff --git a/src/common/utils/keyGen.ts b/src/common/utils/keyGen.ts new file mode 100644 index 0000000..4938359 --- /dev/null +++ b/src/common/utils/keyGen.ts @@ -0,0 +1,15 @@ +const keyGen = function* () { + let count = 0; + while (true) { + yield count++; + } +}; + +const uniqueKeyUtil = (() => { + const generator = keyGen(); + return { + nextKey: () => generator.next().value, + }; +})(); + +export default uniqueKeyUtil; diff --git a/src/custom-tab-bar/index.scss b/src/custom-tab-bar/index.scss index 33c1ea3..4e4c0d8 100644 --- a/src/custom-tab-bar/index.scss +++ b/src/custom-tab-bar/index.scss @@ -6,7 +6,7 @@ position: fixed; bottom: 0; background-color: #f9f9f2; - box-shadow: 0 -1vh 0.5vh rgba(0, 0, 0, 0.1); + box-shadow: 0 -1vh 1vh rgba(0, 0, 0, 0.1); display: flex; justify-content: space-evenly; align-items: center; diff --git a/src/custom-tab-bar/index.tsx b/src/custom-tab-bar/index.tsx index c1752ac..e45d290 100644 --- a/src/custom-tab-bar/index.tsx +++ b/src/custom-tab-bar/index.tsx @@ -1,3 +1,4 @@ +/* eslint-disable import/first */ import { View } from '@tarojs/components'; import Taro from '@tarojs/taro'; import { memo } from 'react'; @@ -5,8 +6,8 @@ import { AtIcon } from 'taro-ui'; import './index.scss'; -// eslint-disable-next-line import/first import useActiveButtonStore, { ActiveButtonType } from '@/common/hooks/useActiveNav'; +import uniqueKeyUtil from '@/common/utils/keyGen'; interface TabBarProps {} @@ -14,7 +15,7 @@ const TAB_LIST: Array<{ pagePath: string; name: string; icon?: string }> = [ { pagePath: '/pages/main/index', name: 'Home', icon: 'streaming' }, { pagePath: '/pages/123/index', name: 'Download', icon: 'download-cloud' }, { pagePath: '/pages/456/index', name: '+' }, - { pagePath: '/pages/789/index', name: 'Massage', icon: 'message' }, + { pagePath: '/pages/messageNotification/index', name: 'Massage', icon: 'message' }, { pagePath: '/pages/personalPage/index', name: 'Profile', icon: 'user' }, ]; @@ -23,7 +24,7 @@ const TabBar: React.FC = memo(() => { return ( - {TAB_LIST.map((item, index) => ( + {TAB_LIST.map((item) => ( <> {item.name === '+' ? ( @@ -31,7 +32,7 @@ const TabBar: React.FC = memo(() => { ) : ( = () => { - useLoad(() => { - console.log('Page loaded.'); - }); +interface MessageNotificationProps {} + +interface MessageProps extends Notification {} + +interface TabBarProps { + tab: string; + setTab: (tab: string) => void; +} - const [notificationEventType] = useState(true); - const [notificationUsername] = useState('昵称'); - const [notificationDescription] = useState('我正在回复你的评论'); - const [notificationComment] = useState('这里是原评论内容'); +const Tabs: { name: string; icon: string }[] = [ + { + name: '提问', + icon: 'clock', + }, + { + name: '点赞', + icon: 'clock', + }, + { + name: '官方', + icon: 'clock', + }, +]; + +const MessageNotification: React.FC = memo(() => { + const [tab, setTab] = useState('提问'); + const [notification, setNotification] = useState({ + username: '昵称', + eventType: true, + description: '我正在回复你的评论', + comment: '这里是原评论内容', + timestamp: '2023年1月1日', + }); return ( - + + ); -}; +}); -const Message: React.FC = ({ - username, - eventType, - description, - comment, -}) => { - return ( - - - - {username} - - - {eventType ? '回复:' : '赞了我'} - - {eventType && ( - {description} - )} +const TabBar: React.FC = memo(({ tab, setTab }) => ( + + {Tabs.map((item) => ( + + + { + setTab(item.name); + }} + > + + {item.name} + + ))} + +)); + +const Message: React.FC = memo( + ({ username, eventType, description, comment, timestamp }) => ( + + + + + {username} + {timestamp} + + + {eventType ? '回复:' : '赞了我'} + {eventType && {description}} + + + {comment} - {comment} {eventType && ( - - 回复TA: + + 回复TA: )} - ); -}; + ) +); export default MessageNotification; diff --git a/src/pages/personalPage/index.tsx b/src/pages/personalPage/index.tsx index 8f18127..5bd241d 100644 --- a/src/pages/personalPage/index.tsx +++ b/src/pages/personalPage/index.tsx @@ -13,7 +13,6 @@ import { BookIcon, ClockIcon, MailIcon, - MessageIcon, StarIcon, TopBackground, } from '@/common/assets/img/personalPage'; @@ -170,22 +169,6 @@ const List = () => { void Taro.navigateTo({ url: '/pages/evaluateCourseHistory/index' }); }} /> - { - void Taro.navigateTo({ url: '/pages/messageNotification/index' }); - }} - /> - { - void Taro.navigateTo({ url: '/pages/officialNotification/index' }); - }} - />