Commit bb78324f authored by hewenhao's avatar hewenhao

feat: 添加护眼模式

parent 28824dd9
.eye_protection {
filter: brightness(60%) sepia(40%);
}
import { View, type ViewProps } from '@tarojs/components'
import classNames from 'classnames'
import { useStoreState } from '@/store/hooks'
import styles from './index.module.scss'
type EyeProtectionViewProps = ViewProps
const EyeProtectionView = (props: EyeProtectionViewProps) => {
const { className, children, ...rest } = props
const isEyeProtectionMode = useStoreState(states => states.userModel.isEyeProtectionMode)
return (
<View className={classNames(isEyeProtectionMode && styles.eye_protection, className)} {...rest}>{children}</View>
)
}
export default EyeProtectionView
/** simple modal component */ /** simple modal component */
import { View, Text, RootPortal, Image } from '@tarojs/components' import { View, Text, RootPortal, Image } from '@tarojs/components'
import classNames from 'classnames' import classNames from 'classnames'
import EyeProtectionView from '../EyeProtectionView'
import styles from './index.module.scss' import styles from './index.module.scss'
interface ModalProps { interface ModalProps {
...@@ -30,7 +31,7 @@ const Modal = ({ ...@@ -30,7 +31,7 @@ const Modal = ({
return ( return (
<RootPortal enable={enable}> <RootPortal enable={enable}>
<View className={wrapClass} onClick={() => maskClosable && onClose()}> <EyeProtectionView className={wrapClass} onClick={() => maskClosable && onClose()}>
<View className={styles.content} onClick={(e) => e.stopPropagation()}> <View className={styles.content} onClick={(e) => e.stopPropagation()}>
<View className={styles.header}> <View className={styles.header}>
...@@ -44,7 +45,7 @@ const Modal = ({ ...@@ -44,7 +45,7 @@ const Modal = ({
{children} {children}
</View> </View>
</View> </View>
</View> </EyeProtectionView>
</RootPortal> </RootPortal>
) )
} }
......
export { default as EyeProtectionView } from './EyeProtectionView/index'
...@@ -7,6 +7,10 @@ ...@@ -7,6 +7,10 @@
bottom: 0; bottom: 0;
} }
.eye_protection {
filter: brightness(60%) sepia(40%);
}
@supports (padding-bottom: constant(safe-area-inset-bottom)) or (padding-bottom: env(safe-area-inset-bottom)) { @supports (padding-bottom: constant(safe-area-inset-bottom)) or (padding-bottom: env(safe-area-inset-bottom)) {
.wrap { .wrap {
padding-bottom: constant(safe-area-inset-bottom); padding-bottom: constant(safe-area-inset-bottom);
......
...@@ -14,6 +14,7 @@ const Tabbar: ForwardRefRenderFunction<TabbarRef, {}> = (_, ref) => { ...@@ -14,6 +14,7 @@ const Tabbar: ForwardRefRenderFunction<TabbarRef, {}> = (_, ref) => {
const [selected, setSelected] = useState(0) const [selected, setSelected] = useState(0)
const hasPoint = useStoreState(state => state.groupModel.hasPoint) const hasPoint = useStoreState(state => state.groupModel.hasPoint)
const userInfo = useStoreState(state => state.userModel.userInfo) const userInfo = useStoreState(state => state.userModel.userInfo)
const isEyeProtectionMode = useStoreState(states => states.userModel.isEyeProtectionMode)
const _switchTab = useCallback((index: number, url: string) => { const _switchTab = useCallback((index: number, url: string) => {
setSelected(index) setSelected(index)
...@@ -32,7 +33,7 @@ const Tabbar: ForwardRefRenderFunction<TabbarRef, {}> = (_, ref) => { ...@@ -32,7 +33,7 @@ const Tabbar: ForwardRefRenderFunction<TabbarRef, {}> = (_, ref) => {
} }
return ( return (
<View className={styles.wrap}> <View className={classNames(styles.wrap, isEyeProtectionMode && styles.eye_protection)}>
<View className={styles.inner}> <View className={styles.inner}>
<View className={styles.left} onClick={() => _switchTab(0, '/pages/main/main')}> <View className={styles.left} onClick={() => _switchTab(0, '/pages/main/main')}>
{selected === 0 && ( {selected === 0 && (
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
margin: -16px -10px; margin: -16px -10px;
display: flex; display: flex;
flex-wrap: wrap; flex-wrap: wrap;
background-color: #ffffff;
} }
.keyboard_item_wrap { .keyboard_item_wrap {
......
...@@ -164,6 +164,10 @@ ...@@ -164,6 +164,10 @@
} }
} }
.wrap {
background-color: #ffffff;
}
.fail_icon { .fail_icon {
width: 686px; width: 686px;
height: 320px; height: 320px;
......
.head { .head {
padding-bottom: 64px; padding-bottom: 64px;
position: relative; position: relative;
background-color: #ffffff;
&.S { &.S {
background-image: linear-gradient(to bottom, #FFE4A1 0%, #FFFEF3 87.0301573% , #FFFFFF 100%); background-image: linear-gradient(to bottom, #FFE4A1 0%, #FFFEF3 87.0301573% , #FFFFFF 100%);
} }
......
.container {
min-height: 100vh;
background-color: #fff;
}
import { EyeProtectionView } from '@/components'
import GameCompleteHead from './components/complete-head' import GameCompleteHead from './components/complete-head'
import GameCompleteAchieve from './components/complete-achieve' import GameCompleteAchieve from './components/complete-achieve'
// import styles from './index.module.scss' import styles from './index.module.scss'
const GameComplete = () => { const GameComplete = () => {
return ( return (
<> <EyeProtectionView className={styles.container}>
<GameCompleteHead /> <GameCompleteHead />
<GameCompleteAchieve /> <GameCompleteAchieve />
</> </EyeProtectionView>
) )
} }
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
padding: 40px 32px 100px 32px; padding: 40px 32px 100px 32px;
display: flex; display: flex;
align-items: center; align-items: center;
background-color: #fff;
&.is_stop { &.is_stop {
padding-bottom: 50px; padding-bottom: 50px;
......
...@@ -3,6 +3,7 @@ import { useCallback, useEffect, useRef } from 'react' ...@@ -3,6 +3,7 @@ import { useCallback, useEffect, useRef } from 'react'
import classNames from 'classnames' import classNames from 'classnames'
import { useStoreState, useStoreActions } from '@/store/hooks' import { useStoreState, useStoreActions } from '@/store/hooks'
import assets from '@/assets/oss/assets-complete' import assets from '@/assets/oss/assets-complete'
import { EyeProtectionView } from '@/components'
import styles from './modal-continue.module.scss' import styles from './modal-continue.module.scss'
...@@ -38,7 +39,7 @@ const ModalContinue = () => { ...@@ -38,7 +39,7 @@ const ModalContinue = () => {
<RootPortal> <RootPortal>
<View className={classNames(styles.mask, modalContinueVisible && styles.is_show)}> <View className={classNames(styles.mask, modalContinueVisible && styles.is_show)}>
</View> </View>
<View className={classNames(styles.modal, modalContinueVisible && styles.is_show)}> <EyeProtectionView className={classNames(styles.modal, modalContinueVisible && styles.is_show)}>
{modalContinueVisible && ( {modalContinueVisible && (
<Image src={assets['fail-ip.png'].u} className={styles.fail_icon} /> <Image src={assets['fail-ip.png'].u} className={styles.fail_icon} />
)} )}
...@@ -64,7 +65,7 @@ const ModalContinue = () => { ...@@ -64,7 +65,7 @@ const ModalContinue = () => {
<View className={styles.account_left}>剩余<Text className={styles.account_num}>{cardNum}</Text>张</View> <View className={styles.account_left}>剩余<Text className={styles.account_num}>{cardNum}</Text>张</View>
</View> </View>
</View> </View>
</View> </EyeProtectionView>
</RootPortal> </RootPortal>
) )
} }
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
flex: 1; flex: 1;
position: relative; position: relative;
min-height: 0; min-height: 0;
background-color: #fff;
} }
.body_inner { .body_inner {
......
import { View, ScrollView, Image } from '@tarojs/components' import { ScrollView, Image } from '@tarojs/components'
import { useStoreState, useStoreActions } from '@/store/hooks' import { useStoreState, useStoreActions } from '@/store/hooks'
import { preloadImage } from '@/utils/preload-image' import { preloadImage } from '@/utils/preload-image'
import { useEffect, useMemo } from 'react' import { useEffect, useMemo } from 'react'
import { useDidShow } from '@tarojs/taro' import { useDidShow } from '@tarojs/taro'
import assets from '@/assets/oss/assets-complete' import assets from '@/assets/oss/assets-complete'
import { EyeProtectionView } from '@/components'
import ModalContinue from './components/modal-continue' import ModalContinue from './components/modal-continue'
import PageHead from './components/page-head' import PageHead from './components/page-head'
...@@ -51,7 +52,7 @@ const GamePlay = () => { ...@@ -51,7 +52,7 @@ const GamePlay = () => {
return ( return (
<> <>
<View className={styles.viewport}> <EyeProtectionView className={styles.viewport}>
<PageHead /> <PageHead />
{currentQuestion && stageDetail && ( {currentQuestion && stageDetail && (
<> <>
...@@ -79,7 +80,7 @@ const GamePlay = () => { ...@@ -79,7 +80,7 @@ const GamePlay = () => {
/> />
</> </>
)} )}
</View> </EyeProtectionView>
<ModalContinue /> <ModalContinue />
</> </>
) )
......
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
white-space: nowrap; white-space: nowrap;
font-size: 14PX; font-size: 14PX;
font-weight: 500; font-weight: 500;
margin-left: 16PX; margin-left: 12PX;
color: #FFFFFF; color: #FFFFFF;
} }
} }
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
.score { .score {
display: flex; display: flex;
align-items: center; align-items: center;
margin-right: 18PX; margin-right: 12PX;
.icon { .icon {
width: 32PX; width: 32PX;
......
@import '@/styles/mixins.scss'; @import '@/styles/mixins.scss';
.container {
min-height: 100vh;
background-color: #ffffff;
}
.modal { .modal {
padding: 32px 32px 0; padding: 32px 32px 0;
......
...@@ -9,6 +9,7 @@ import { createTribe } from '@/api/group' ...@@ -9,6 +9,7 @@ import { createTribe } from '@/api/group'
import { useStoreActions, useStoreState } from '@/store/hooks' import { useStoreActions, useStoreState } from '@/store/hooks'
import type { TabbarRef } from '@/custom-tab-bar/index' import type { TabbarRef } from '@/custom-tab-bar/index'
import { getNickNameWords, type NickNameWord } from '@/api' import { getNickNameWords, type NickNameWord } from '@/api'
import { EyeProtectionView } from '@/components'
import assets from '@/assets/oss/assets-group' import assets from '@/assets/oss/assets-group'
...@@ -125,7 +126,7 @@ const Group = () => { ...@@ -125,7 +126,7 @@ const Group = () => {
} }
return ( return (
<View> <EyeProtectionView className={styles.container}>
<TopHeader /> <TopHeader />
<ScrollView <ScrollView
refresherEnabled={!!tribeInfo?.id} refresherEnabled={!!tribeInfo?.id}
...@@ -159,7 +160,7 @@ const Group = () => { ...@@ -159,7 +160,7 @@ const Group = () => {
</View> </View>
</View> </View>
</Modal> </Modal>
</View> </EyeProtectionView>
) )
} }
......
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
white-space: nowrap; white-space: nowrap;
font-size: 14PX; font-size: 14PX;
font-weight: 500; font-weight: 500;
margin-left: 16PX; margin-left: 12PX;
color: #FFFFFF; color: #FFFFFF;
} }
} }
...@@ -49,7 +49,7 @@ ...@@ -49,7 +49,7 @@
.score { .score {
display: flex; display: flex;
align-items: center; align-items: center;
margin-right: 18PX; margin-right: 12PX;
.icon { .icon {
width: 32PX; width: 32PX;
......
...@@ -2,6 +2,7 @@ import { View, Text, Image } from '@tarojs/components' ...@@ -2,6 +2,7 @@ import { View, Text, Image } from '@tarojs/components'
import { getMenuButtonBoundingClientRect, getSystemInfoSync, navigateTo } from '@tarojs/taro' import { getMenuButtonBoundingClientRect, getSystemInfoSync, navigateTo } from '@tarojs/taro'
import { useMemo } from 'react' import { useMemo } from 'react'
import classNames from 'classnames' import classNames from 'classnames'
import { EyeProtectionView } from '@/components'
import { useStoreState } from '@/store/hooks' import { useStoreState } from '@/store/hooks'
import { cs } from '@/styles' import { cs } from '@/styles'
...@@ -29,7 +30,7 @@ const MainHeader = () => { ...@@ -29,7 +30,7 @@ const MainHeader = () => {
const userInfo = useStoreState(state => state.userModel.userInfo) const userInfo = useStoreState(state => state.userModel.userInfo)
return ( return (
<View className={styles.header}> <EyeProtectionView className={styles.header}>
<Image src={require('../assets/head-bg.png')} className={styles.bg} mode="widthFix"></Image> <Image src={require('../assets/head-bg.png')} className={styles.bg} mode="widthFix"></Image>
<View <View
className={styles.headerContent} className={styles.headerContent}
...@@ -52,7 +53,7 @@ const MainHeader = () => { ...@@ -52,7 +53,7 @@ const MainHeader = () => {
</View> </View>
</View> </View>
</View> </View>
</View> </EyeProtectionView>
) )
} }
......
...@@ -8,6 +8,7 @@ import { ...@@ -8,6 +8,7 @@ import {
import { useMemo, useCallback, useEffect } from 'react' import { useMemo, useCallback, useEffect } from 'react'
import { useStoreActions, useStoreState } from '@/store/hooks' import { useStoreActions, useStoreState } from '@/store/hooks'
import { useFocus } from '@/hooks/use-focus' import { useFocus } from '@/hooks/use-focus'
import { EyeProtectionView } from '@/components'
import type { TabbarRef } from '../../../custom-tab-bar/index' import type { TabbarRef } from '../../../custom-tab-bar/index'
import { CurrentRoundId, StageStatus } from './scene/constants' import { CurrentRoundId, StageStatus } from './scene/constants'
...@@ -80,11 +81,11 @@ const MainPage = () => { ...@@ -80,11 +81,11 @@ const MainPage = () => {
return ( return (
<> <>
<MainHeader /> <MainHeader />
<View className={styles.body} style={{ paddingTop: `${nav.height + nav.top + 5}px` }}> <EyeProtectionView className={styles.body} style={{ paddingTop: `${nav.height + nav.top + 5}px` }}>
<MainChapter /> <MainChapter />
<MainScene stageList={stageList} /> <MainScene stageList={stageList} />
<View className={styles.gap}></View> <View className={styles.gap}></View>
</View> </EyeProtectionView>
{isReady && ( {isReady && (
<MainShortCut onClick={() => scrollToCurrent()} /> <MainShortCut onClick={() => scrollToCurrent()} />
)} )}
......
...@@ -4,6 +4,7 @@ import { useEffect, useState, useRef } from 'react' ...@@ -4,6 +4,7 @@ import { useEffect, useState, useRef } from 'react'
import { usePageScroll, createIntersectionObserver } from '@tarojs/taro' import { usePageScroll, createIntersectionObserver } from '@tarojs/taro'
import classNames from 'classnames' import classNames from 'classnames'
import { useStoreState } from '@/store/hooks' import { useStoreState } from '@/store/hooks'
import { EyeProtectionView } from '@/components'
import { CurrentRoundId, StageStatus } from './scene/constants' import { CurrentRoundId, StageStatus } from './scene/constants'
import styles from './short-cut.module.scss' import styles from './short-cut.module.scss'
...@@ -47,12 +48,12 @@ const ShortCut = (props: ShortCutProps) => { ...@@ -47,12 +48,12 @@ const ShortCut = (props: ShortCutProps) => {
}, [stageList]) }, [stageList])
return ( return (
<View className={styles.shortcut}> <EyeProtectionView className={styles.shortcut}>
<View className={classNames(styles.shortcutInner, isHide && styles.is_hide)} onClick={props.onClick}> <View className={classNames(styles.shortcutInner, isHide && styles.is_hide)} onClick={props.onClick}>
<Image src={assets['short-cut-bg.png'].u} className={styles.bg}></Image> <Image src={assets['short-cut-bg.png'].u} className={styles.bg}></Image>
<Image src={assets['short-cut-arrow.png'].u} className={classNames(styles.arrow, ((!isHide && isDown) || (isHide && !isDown)) && styles.isDown)}></Image> <Image src={assets['short-cut-arrow.png'].u} className={classNames(styles.arrow, ((!isHide && isDown) || (isHide && !isDown)) && styles.isDown)}></Image>
</View> </View>
</View> </EyeProtectionView>
) )
} }
......
@import '../../styles/mixins.scss'; @import '../../styles/mixins.scss';
.container {
min-height: 100vh;
background-color: #FFFFFF;
}
.card-body { .card-body {
display: flex; display: flex;
padding: 32px 28px; padding: 32px 28px;
......
...@@ -6,6 +6,7 @@ import { useDidShow } from '@tarojs/taro' ...@@ -6,6 +6,7 @@ import { useDidShow } from '@tarojs/taro'
import { useBoolean } from '@/hooks' import { useBoolean } from '@/hooks'
import Modal from '@/components/Modal' import Modal from '@/components/Modal'
import { useStoreState, useStoreActions } from '@/store/hooks' import { useStoreState, useStoreActions } from '@/store/hooks'
import { EyeProtectionView } from '@/components'
import ExchangeItem from './components/exchange-item' import ExchangeItem from './components/exchange-item'
import Card from './components/card' import Card from './components/card'
import CardMain from './components/card-main' import CardMain from './components/card-main'
...@@ -61,7 +62,7 @@ const StudyMarket = () => { ...@@ -61,7 +62,7 @@ const StudyMarket = () => {
}, [setTrue]) }, [setTrue])
return ( return (
<> <EyeProtectionView className={styles.container}>
<View className={styles.head}> <View className={styles.head}>
<View className={styles.score_text}>{point} <Text className={styles.unit}>水晶</Text></View> <View className={styles.score_text}>{point} <Text className={styles.unit}>水晶</Text></View>
<Image src={require('./assets/score.png')} className={styles.score_icon}></Image> <Image src={require('./assets/score.png')} className={styles.score_icon}></Image>
...@@ -108,7 +109,7 @@ const StudyMarket = () => { ...@@ -108,7 +109,7 @@ const StudyMarket = () => {
onCancel={setFalse} onCancel={setFalse}
/> />
</Modal> </Modal>
</> </EyeProtectionView>
) )
} }
......
...@@ -2,6 +2,9 @@ ...@@ -2,6 +2,9 @@
.wrapper { .wrapper {
padding-bottom: 105px; padding-bottom: 105px;
min-height: 100vh;
box-sizing: border-box;
background-color: #fff;
.inner { .inner {
position: relative; position: relative;
......
...@@ -13,6 +13,7 @@ import assets from '@/assets/oss/assets-prepare' ...@@ -13,6 +13,7 @@ import assets from '@/assets/oss/assets-prepare'
import assetsGroup from '@/assets/oss/assets-group' import assetsGroup from '@/assets/oss/assets-group'
import { palyAudio } from '@/utils/play-audio' import { palyAudio } from '@/utils/play-audio'
import audio from '@/assets/oss/assets-audio' import audio from '@/assets/oss/assets-audio'
import { EyeProtectionView } from '@/components'
import Tabs, { type TabItem } from './components/tabs' import Tabs, { type TabItem } from './components/tabs'
import TopBar from './components/top-bar' import TopBar from './components/top-bar'
...@@ -178,7 +179,7 @@ const Prepare = () => { ...@@ -178,7 +179,7 @@ const Prepare = () => {
} }
return ( return (
<View className={styles.wrapper}> <EyeProtectionView className={styles.wrapper}>
<TopBar /> <TopBar />
<View className={styles.inner} style={innerStyle}> <View className={styles.inner} style={innerStyle}>
...@@ -218,7 +219,7 @@ const Prepare = () => { ...@@ -218,7 +219,7 @@ const Prepare = () => {
</View> </View>
</View> </View>
</AnswerCardModal> </AnswerCardModal>
</View> </EyeProtectionView>
) )
} }
......
...@@ -12,6 +12,7 @@ export interface UserModel { ...@@ -12,6 +12,7 @@ export interface UserModel {
userInfo: UserInfo; userInfo: UserInfo;
cardNum: number; cardNum: number;
point: number; point: number;
isEyeProtectionMode: boolean;
updateState: Action<UserModel, Partial<State<UserModel>>>; updateState: Action<UserModel, Partial<State<UserModel>>>;
fetchAccount: Thunk<UserModel, void, void, AppStoreModel>; fetchAccount: Thunk<UserModel, void, void, AppStoreModel>;
setting: SettintType; setting: SettintType;
...@@ -25,6 +26,7 @@ export interface UserModel { ...@@ -25,6 +26,7 @@ export interface UserModel {
const userModel: UserModel = { const userModel: UserModel = {
userInfo: getStorage(StorageKeys.userInfo)!, userInfo: getStorage(StorageKeys.userInfo)!,
isEyeProtectionMode: false,
cardNum: 0, cardNum: 0,
point: 0, point: 0,
setting: { pointToCard: Infinity, aPoint: 0, bPoint: 0, sPoint: 0 }, setting: { pointToCard: Infinity, aPoint: 0, bPoint: 0, sPoint: 0 },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment