Commit dc082867 authored by hewenhao's avatar hewenhao

Merge branch 'master' of dev.jiuaoedu.com:hewenhao/GeekLearnMathWeapp

parents bc96f194 e55d14af
{
"miniprogramRoot": "./dist",
"miniprogramRoot": "dist/",
"projectname": "GeekLearnMathWeapp",
"description": "",
"appid": "wx8f25def587982a19",
......@@ -9,7 +9,13 @@
"enhance": false,
"compileHotReLoad": false,
"postcss": false,
"minified": false
"minified": false,
"babelSetting": {
"ignore": [],
"disablePlugins": [],
"outputPath": ""
},
"condition": false
},
"libVersion": "2.30.2",
"condition": {
......@@ -25,5 +31,14 @@
]
}
},
"compileType": "miniprogram"
"compileType": "miniprogram",
"srcMiniprogramRoot": "dist/",
"packOptions": {
"ignore": [],
"include": []
},
"editorSetting": {
"tabIndent": "insertSpaces",
"tabSize": 2
}
}
......@@ -7,6 +7,8 @@
export default {
pages: [
'pages/main/main',
'pages/prepare/index',
'pages/study-market/index',
'pages/group/index',
'pages/game/play/index',
],
......
.wrapper {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
background-color: rgba(0, 0, 0, 0.5);
opacity: 0;
transition: opacity 0.3s ease-in-out;
z-index: 100;
pointer-events: none;
}
.visible {
opacity: 1;
z-index: 999;
pointer-events: auto;
}
.inner {
background-color: #ffffff;
padding: 16px;
border-radius: 4px;
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}
\ No newline at end of file
/** simple modal component */
import { View } from '@tarojs/components'
import classNames from 'classnames'
import styles from './index.module.scss'
interface ModalProps {
isVisible: boolean;
wrapClassName?: string;
children: React.ReactNode;
maskClosable?: boolean;
onClose: () => void;
}
const Modal: React.FC<ModalProps> = ({
isVisible,
onClose,
children,
wrapClassName,
maskClosable = true
}) => {
const wrapClass = classNames(
styles.wrapper,
wrapClassName,
isVisible ? styles.visible : ''
)
return (
<View className={wrapClass} onClick={() => maskClosable && onClose()}>
<View className={classNames(styles.inner)} onClick={(e) => e.stopPropagation()}>
{children}
</View>
</View>
)
}
export default Modal
import { Image } from '@tarojs/components'
import classNames from 'classnames'
export interface SkeletonAvatarProps {
animate?: boolean;
shape?: 'circle' | 'square';
size?: number;
}
const SkeletonAvatar: React.FC<SkeletonAvatarProps> = ({
animate = true,
shape = 'circle',
size = 48,
}) => {
const avatarClass = classNames(
'skeleton-avatar',
animate ? 'skeleton-loading' : null,
shape === 'circle' ? 'circle' : 'square'
)
return (
<Image
src=""
defaultSource="https://cdn.jkwljy.com/pbb/6gkGHSsPmxc_coeGYahBkelo_2w_/96x96"
className={avatarClass}
style={{ width: size, height: size }}
/>
)
}
export default SkeletonAvatar
import { View } from '@tarojs/components'
import classNames from 'classnames'
export interface SkeletonParagraphProps {
animate?: boolean;
rows?: number;
gap?: number;
height?: number;
width?: string | number | (string | number)[];
}
const SkeletonParagraph: React.FC<SkeletonParagraphProps> = ({
animate = true,
rows = 3,
gap = 8,
height = 16,
width = '100%',
}) => {
const paragraphRows = Array.from({ length: rows }, (_, i) => {
const rowWidth = Array.isArray(width)
? width[i] ?? width[width.length - 1]
: width
return (
<View
key={i}
className={classNames('skeleton-paragraph-row', animate ? 'skeleton-loading' : null,)}
style={{ width: rowWidth, height }}
/>
)
})
return (
<View className="skeleton-paragraph" style={{ gap: `${gap}px` }}>
{paragraphRows}
</View>
)
}
export default SkeletonParagraph
import { View } from '@tarojs/components'
import classNames from 'classnames'
export interface SkeletonTitleProps {
animate?: boolean;
height?: number;
width?: string | number;
}
const SkeletonTitle: React.FC<SkeletonTitleProps> = ({
animate = true,
height = 16,
width = '30%',
}) => {
return (
<View
className={classNames('skeleton-title', animate ? 'skeleton-loading' : null)}
style={{ width, height }}
/>
)
}
export default SkeletonTitle
.skeleton {
display: flex;
flex-direction: row;
margin: 8px 16px;
gap: 16px;
&-avatar {
width: 48px;
height: 48px;
border-radius: 50%;
background-color: #f0f0f0;
&.circle {
border-radius: 50%;
}
&.square {
border-radius: 4px;
}
}
&-content {
flex: 1;
}
&-title {
margin: 12px 0;
background-color: #f0f0f0;
}
&-paragraph {
display: flex;
flex-direction: column;
width: 100%;
margin: 12px 0;
&-row {
height: 32px;
background-color: #f0f0f0;
}
}
}
@keyframes loading {
0% {
background-position: 100% 50%;
}
100% {
background-position: 0 50%;
}
}
.skeleton-loading {
background-image: linear-gradient(
90deg,
rgba(255, 255, 255, 0) 25%,
rgba(255, 255, 255, 0.5) 50%,
rgba(255, 255, 255, 0) 75%
);
background-size: 200% 100%;
animation: loading 1.5s infinite;
}
.skeleton-avatar.skeleton-loading {
background-color: #f0f0f0;
}
.skeleton-title.skeleton-loading {
background-color: #f0f0f0;
}
.skeleton-paragraph.skeleton-loading {
background-color: #f0f0f0;
}
import React from 'react'
import { View } from '@tarojs/components'
import SkeletonAvatar, { type SkeletonAvatarProps } from './components/avatar'
import SkeletonTitle, { type SkeletonTitleProps } from './components/title'
import SkeletonParagraph, { type SkeletonParagraphProps } from './components/paragraph'
import './index.scss'
interface SkeletonProps {
loading: boolean;
animate?: boolean;
avatar?: SkeletonAvatarProps | boolean;
title?: SkeletonTitleProps | boolean;
paragraph?: SkeletonParagraphProps | boolean;
children?: React.ReactNode;
}
export default class Skeleton extends React.Component<SkeletonProps> {
static Avatar: typeof SkeletonAvatar
static Title: typeof SkeletonTitle
static Paragraph: typeof SkeletonParagraph
render () {
const {
loading,
avatar,
children,
animate = true,
title = true,
paragraph = true,
} = this.props
if (!loading) {
return children
}
return (
<View className="skeleton">
{avatar && <SkeletonAvatar animate={(avatar as SkeletonAvatarProps).animate || animate} {...avatar as SkeletonAvatarProps} />}
<View className="skeleton-content">
{title && <SkeletonTitle animate={(title as SkeletonTitleProps).animate || animate} {...title as SkeletonTitleProps} />}
{paragraph && <SkeletonParagraph animate={(paragraph as SkeletonTitleProps).animate || animate} {...paragraph as SkeletonParagraphProps} />}
</View>
</View>
)
}
}
Skeleton.Avatar = SkeletonAvatar
Skeleton.Title = SkeletonTitle
Skeleton.Paragraph = SkeletonParagraph
.tabs {
display: flex;
width: 100%;
flex-direction: column;
}
.tabBar {
display: flex;
border-bottom: 1px solid #ccc;
}
.tab {
padding: 12px 16px;
color: #888;
border-bottom: 2px solid transparent;
transition: border-color 0.3s ease-in-out, color 0.3s ease-in-out;
&.active {
color: #333;
border-color: #333;
}
&.disabled {
opacity: 0.5;
}
}
.tabPanes {
display: flex;
flex-direction: column;
padding: 12px 16px;
margin-top: 16px;
}
.tabPane {
display: none;
&.active {
display: block;
}
}
import { useState, useEffect, useCallback, CSSProperties, ReactNode } from 'react'
import { View } from '@tarojs/components'
import classNames from 'classnames'
import styles from './index.module.scss'
export interface TabItem {
label: string | ReactNode;
children: ReactNode;
disabled?: boolean;
hidden?: boolean;
keepAlive?: boolean;
}
interface TabsProps {
items: TabItem[];
initialIndex?: number;
tabBarStyle?: CSSProperties;
tabBarGutter?: number;
onChange?: (index: number) => void;
}
const Tabs: React.FC<TabsProps> = ({
items,
initialIndex = 0,
tabBarStyle = {},
tabBarGutter = 16,
onChange,
}) => {
const [activeIndex, setActiveIndex] = useState(initialIndex)
useEffect(() => {
if (items[activeIndex].hidden) {
const newIndex = items.findIndex((tab, index) => !tab.hidden && index !== activeIndex)
setActiveIndex(newIndex)
}
}, [items, activeIndex])
const handleClick = useCallback((index: number) => {
if (!items[index].disabled && index !== activeIndex) {
setActiveIndex(index)
onChange?.(index)
}
}, [items, activeIndex, onChange])
const renderTabs = () => {
return items.map((tab, index) => {
if (tab.hidden) return null
const cls = classNames(styles.tab, {
[styles.active]: index === activeIndex,
[styles.disabled]: tab.disabled,
})
return (
<View
key={index}
className={cls}
style={{ marginRight: index < items.length - 1 ? tabBarGutter : undefined }}
onClick={() => handleClick(index)}
>
{tab.label}
</View>
)
})
}
const renderTabPanes = () => {
return items.map((tab, index) => {
if (tab.hidden && !tab.keepAlive) return null
const isActive = activeIndex === index
const isHidden = tab.hidden || !isActive
const cls = classNames(styles.tabPane, {
[styles.active]: isActive,
})
return (
<View key={index} className={cls} hidden={isHidden}>
{tab.children}
</View>
)
})
}
return (
<View className={styles.tabs}>
<View className={styles.tabBar} style={tabBarStyle}>
{renderTabs()}
</View>
<View className={styles.tabPanes}>
{renderTabPanes()}
</View>
</View>
)
}
export default Tabs
import { useCallback, useEffect, useRef, useState } from 'react'
import Taro from '@tarojs/taro'
import type { RequestResult } from '@/types'
interface Options<T, P> {
immediate?: boolean;
params?: P;
pollInterval?: number;
pollRetryCount?: number;
trigger?: unknown[];
debounceDelay?: number;
throttleDelay?: number;
retryCount?: number;
onError?: (error: Error & RequestResult<T>) => void;
onSuccess?: (result: T) => void;
onComplete?: () => void;
}
interface Result<T, P> {
data: T | null;
loading: boolean;
error: Error & RequestResult<T> | null;
run: (params?: P) => Promise<void>;
refresh: () => Promise<void>;
cancel: () => void;
updateData: (newData: T) => void;
}
export default function useRequest<T = unknown, P = unknown> (
service: (params?: P) => Promise<T>,
options: Options<T, P>
): Result<T, P> {
const [data, updateData] = useState<T | null>(null)
const [error, setError] = useState<Error & RequestResult<T> | null>(null)
const [loading, setLoading] = useState<boolean>(false)
const paramsRef = useRef<P | undefined>(options.params)
const pollRetryCountRef = useRef<number>(0)
const debounceTimerRef = useRef<NodeJS.Timeout | null>(null)
const throttleTimerRef = useRef<NodeJS.Timeout | null>(null)
const cancelSourceRef = useRef<Taro.RequestTask<RequestResult<T>> | null>(null)
const run = useCallback(async (params?: P) => {
if (params !== undefined) {
paramsRef.current = { ...paramsRef.current, ...params }
}
runConfig(paramsRef.current)
}, [service, options])
const refresh = useCallback(async () => run(paramsRef.current), [run])
const cancel = useCallback(() => cancelSourceRef.current?.abort(), [])
useEffect(() => {
if (options.immediate !== false) {
run(paramsRef.current)
}
}, [])
useEffect(() => {
if (options.trigger !== undefined) {
run(paramsRef.current)
}
}, [JSON.stringify(options.trigger)])
const runService = async (params?: P, retryCount: number = options.retryCount || 0) => {
try {
cancelSourceRef.current?.abort()
paramsRef.current = params
const res = await service(params)
updateData(res)
options.onSuccess?.(res)
} catch (err) {
if (retryCount > 0) {
runService(params, retryCount - 1)
} else {
setError(err)
options.onError?.(err)
}
} finally {
setLoading(false)
options.onComplete?.()
}
}
const executeWithPolling = (params?: P) => {
runService(params)
if (options.pollInterval && (!options.pollRetryCount || pollRetryCountRef.current < options.pollRetryCount)) {
setTimeout(() => runConfig(params), options.pollInterval)
pollRetryCountRef.current += 1
}
}
const executeWithDebounce = (params?: P) => {
if (debounceTimerRef.current) {
clearTimeout(debounceTimerRef.current)
}
debounceTimerRef.current = setTimeout(() => {
executeWithPolling(params)
}, options.debounceDelay)
}
const executeWithThrottle = (params?: P) => {
if (!throttleTimerRef.current) {
throttleTimerRef.current = setTimeout(() => {
throttleTimerRef.current = null
}, options.throttleDelay)
executeWithPolling(params)
}
}
const runConfig = (params?: P) => {
if (options.debounceDelay) {
executeWithDebounce(params)
} else if (options.throttleDelay) {
executeWithThrottle(params)
} else {
executeWithPolling(params)
}
}
return {
data,
error,
loading,
run,
refresh,
cancel,
updateData,
}
}
import { useState, useCallback, useRef } from 'react'
export type ToggleValue = boolean | string | number
interface UseToggleOptions {
initialValue?: ToggleValue;
reverseValue?: ToggleValue;
}
export default function useToggle ({
initialValue = false,
reverseValue = !initialValue,
}: UseToggleOptions = {}) {
const [value, setValue] = useState<ToggleValue>(initialValue)
const initialValueRef = useRef(initialValue)
const reverseValueRef = useRef(reverseValue)
const toggle = useCallback((newInitialValue?: ToggleValue, newReverseValue?: ToggleValue) => {
if (newInitialValue !== undefined) {
initialValueRef.current = newInitialValue
}
if (newReverseValue !== undefined) {
reverseValueRef.current = newReverseValue
}
if (reverseValue === undefined) {
setValue((prevValue) =>
typeof prevValue === 'boolean' ? !prevValue : initialValue
)
} else {
setValue((prevValue) =>
prevValue === initialValueRef.current
? reverseValueRef.current
: initialValueRef.current
)
}
}, [initialValue, reverseValue])
return [value, toggle] as const
}
......@@ -44,7 +44,7 @@ const MainPage = () => {
<SceneContext.Provider value={{ ready: isReady }}>
<MainScene />
</SceneContext.Provider>
<View className={styles.gap}></View>
{/* <View className={styles.gap}></View> */}
</View>
{isReady && (
<MainShortCut onClick={() => scrollToCurrent()} />
......
import { View, Text } from '@tarojs/components'
import styles from './index.module.scss'
const GloryBadge: React.FC = () => {
return (
<View className={styles.badge}>
<Text>TOP30%</Text>
<Text>升档成功</Text>
<Text>S级实力</Text>
</View>
)
}
export default GloryBadge
.wrapper {
display: flex;
flex-direction: column;
align-items: center;
margin-bottom: 60px;
}
.title {
font-weight: bold;
}
.totalQuestions {
margin-top: 24px;
}
.requirement {
display: flex;
justify-content: space-between;
width: 60%;
margin-top: 24px;
}
.duration {
}
.launchQuest {
position: relative;
margin-top: 48px;
z-index: 1;
width: 70%;
}
.tip {
position: absolute;
z-index: 10;
top: -32px;
right: -12%;
font-size: 24px;
color: #ff0000;
background-color: #fff;
border: 1px solid #ff0000;
border-radius: 8px;
padding: 8px 12px;
}
.topLeftInfo {
position: absolute;
top: 0;
left: 24px;
display: flex;
flex-direction: column;
gap: 16px;
font-size: 20px;
}
.calculation,
.enhancement {
background-color: #f5f5f5;
padding: 4px 8px;
border: 1px solid #ccc;
}
.badge {
display: flex;
align-items: center;
margin-top: 24px;
gap: 24px;
padding: 24px;
border: 1px solid #000;
Text {
border-radius: 8px;
padding: 12px;
display: flex;
align-items: center;
border: 1px dashed red;
}
}
\ No newline at end of file
import { memo } from 'react'
import { View, Text } from '@tarojs/components'
import Taro from '@tarojs/taro'
import useRequest from '@/hooks/useRequest'
import TopLeftInfo from './top-left-info'
import LaunchQuest from './launch-quest'
import GloryBadge from './glory-badge'
import { formatTime } from '../../utils'
import styles from './index.module.scss'
const getUserInfo = async ({ uid }: {uid: number}) => {
const response = await Taro.request({
url: `https://api.example.com/users/${uid}`,
method: 'GET',
})
return response.data
}
const Overview: React.FC = () => {
const levelInfo = {
title: '表内除法',
totalQuestions: 10,
duration: 80,
}
useRequest(getUserInfo, {
params: { uid: 100 },
})
return (
<>
<TopLeftInfo />
<View className={styles.wrapper}>
<Text className={styles.title}>
{levelInfo.title}
</Text>
<Text className={styles.totalQuestions}>
共{levelInfo.totalQuestions}题
</Text>
<View className={styles.requirement}>
<Text className={styles.passingRequirement}>
通过要求:全 √
</Text>
<Text className={styles.duration}>
时间:{formatTime(levelInfo.duration)}
</Text>
</View>
<LaunchQuest />
<GloryBadge />
</View>
</>
)
}
export default memo(Overview)
import React from 'react'
import { View, Text, Button } from '@tarojs/components'
import Modal from '@/components/Modal'
import useToggle from '@/hooks/useToggle'
import styles from './index.module.scss'
const LaunchQuest: React.FC = () => {
const [isVisible, toggleModal] = useToggle()
return (
<>
<View className={styles.launchQuest}>
<Button onClick={() => toggleModal(true)}>开始闯关</Button>
<Text className={styles.tip}>
首次免答题卡
{/* {hasFreePass ? '首次免答题卡' : '-1答题卡'} */}
</Text>
</View>
<Modal isVisible={isVisible as boolean} onClose={() => toggleModal(false)}>
<View>
<Text>你的答题卡已经用完了</Text>
<Button onClick={() => toggleModal(false)}>建设学习部落得更多答题卡</Button>
<Button onClick={() => toggleModal(false)}>购买</Button>
</View>
</Modal>
</>
)
}
export default LaunchQuest
import { View, Text } from '@tarojs/components'
import styles from './index.module.scss'
const TopLeftInfo = () => {
return (
<View className={styles.topLeftInfo}>
<Text className={styles.calculation}>计算达标</Text>
<Text className={styles.enhancement}>强化</Text>
</View>
)
}
export default TopLeftInfo
.wrapper {
display: flex;
flex-direction: column;
}
.head {
display: flex;
justify-content: flex-end;
Text {
width: 160px;
text-align: center;
}
}
.timing {
min-width: 320px;
display: flex;
align-items: center;
Text {
flex: 1;
text-align: center;
}
}
.list {
min-height: 300px;
max-height: 400px;
overflow: hidden;
overflow-y: auto;
display: flex;
flex-direction: column;
row-gap: 24px;
}
.item {
padding: 16px 0;
display: flex;
justify-content: space-between;
}
.highlight {
background-color: yellow;
}
.noTopThree {
border: 1px solid red;
margin: 24px 0;
}
.userInfo {
display: flex;
column-gap: 16px;
}
.avatar {
width: 60px;
height: 60px;
border-radius: 50%;
background-color: pink;
}
.userDetails {
display: flex;
flex-direction: column;
row-gap: 16px;
line-height: 1;
}
\ No newline at end of file
import { View, Button, Text, ScrollView } from '@tarojs/components'
import { memo, useMemo } from 'react'
import classNames from 'classnames'
import { useStoreState } from '@/store/hooks'
import useToggle from '@/hooks/useToggle'
import UserInfo from './user-info'
import Timing from './timing'
import { User } from '../../types'
import styles from './index.module.scss'
const ScrollRankList: React.FC<{ users: User[] }> = ({ users }) => {
const [showAll, toggleShowAll] = useToggle()
const { currentUser, currentUserInTopThree, topThreeUsers } = useStoreState((state) => state.prepareModel)
const renderItem = (user: User) => {
const isCurrentUser = currentUser && currentUser.nickname === user.nickname
return (
<View key={user.nickname} className={classNames(styles.item, isCurrentUser && styles.highlight)}>
<UserInfo {...user} />
<Timing time={user.time} />
</View >
)
}
const hasNextPage = true
const loading = false
const computedUsers = useMemo(() => {
if (showAll) {
return users
}
return topThreeUsers
}, [showAll, users, topThreeUsers])
const scrollStyle = {
height: '400px',
background: 'red'
}
const loadMore = () => {
console.log('loadMore')
}
return (
<View className={styles.wrapper}>
<View className={styles.header}>
<Text>首次</Text><Text>最佳</Text>
</View>
{!currentUserInTopThree && currentUser && (
<View key={currentUser.nickname} className={classNames(styles.item, styles.noTopThree)}>
<UserInfo {...currentUser} />
<Timing time={currentUser.time} />
</View >
)}
<ScrollView
scrollY
enableFlex
scrollWithAnimation
style={scrollStyle}
onScrollToLower={loadMore}
>
<View style={{ height: '300px' }}>A</View>
<View style={{ height: '300px' }}>B</View>
<View style={{ height: '300px' }}>C</View>
{hasNextPage && !loading && <Text>加载更多</Text>}
</ScrollView>
<View className={styles.list}>
{computedUsers.map(renderItem)}
</View>
{!showAll && (
<Button className={styles.loadMore} onClick={() => toggleShowAll()}>
查看更多
</Button>
)}
</View>
)
}
export default memo(ScrollRankList)
import React from 'react'
import { View, Text } from '@tarojs/components'
import { TimingProps } from '../../types'
// import { formatTime } from '../../utils'
import styles from './index.module.scss'
const Timing: React.FC<TimingProps> = ({ time = 0 }) => {
return (
<View className={styles.timing}>
<Text>34.23秒</Text>
<Text>21.23秒</Text>
</View>
)
}
export default Timing
import React from 'react'
import { View, Text } from '@tarojs/components'
import { UserInfoProps } from '../../types'
import styles from './index.module.scss'
const UserInfo: React.FC<UserInfoProps> = ({ avatar, nickname, schoolName }) => {
return (
<View className={styles.userInfo}>
<View className={styles.avatar} />
{/* <Image className='avatar' src={avatar} /> */}
<View className={styles.userDetails}>
<Text className="nickname">{nickname}</Text>
<Text className="school">{schoolName}</Text>
</View>
</View>
)
}
export default UserInfo
import { View, Text } from '@tarojs/components'
import ScrollRankList from './rank-list/index'
import { User } from '../types'
const StudyLeagueRank: React.FC<{ users: User[] }> = ({ users }) => {
return (
<View>
<ScrollRankList users={users} />
<Text>立即创建</Text>
</View>
)
}
export default StudyLeagueRank
import { useEffect } from 'react'
import Tabs, { type TabItem } from '@/components/Tabs'
import Skeleton from '@/components/Skeleton'
import { useStoreState, useStoreActions } from '@/store/hooks'
import Overview from './components/overview/index'
import ScrollRankList from './components/rank-list/index'
import StudyLeagueRank from './components/study-league-rank'
const Prepare: React.FC = () => {
const { list: users } = useStoreState((state) => state.prepareModel)
const refresh = useStoreActions((actions) => actions.prepareModel.refresh)
useEffect(() => {
refresh()
}, [refresh])
const tabs: TabItem[] = [
{ label: '成都排行榜', children: <ScrollRankList users={users} /> },
{ label: '学习部落排行榜', children: <StudyLeagueRank users={users} /> }
]
return (
<>
<Overview />
<Tabs items={tabs} />
</>
)
}
export default Prepare
export type UserInfoProps = {
avatar?: string;
nickname?: string;
schoolName?: string;
}
export type TimingProps = {
time?: number;
}
export type User = UserInfoProps & TimingProps
// export interface PanelView {
// title: string;
// totalQuestions: number;
// passingRequirement: string;
// duration: number;
// }
export const formatTime = (time: number) => {
const minutes = Math.floor(time / 60)
const seconds = time % 60
return `${minutes}分${seconds}秒`
}
export default definePageConfig({
navigationBarTitleText: 'pk-math',
navigationStyle: 'custom'
})
import { useState, useEffect } from 'react'
import Taro, { getMenuButtonBoundingClientRect } from '@tarojs/taro'
import { View } from '@tarojs/components'
import Skeleton from '@/components/Skeleton'
import MainHeader from '../main/components/header'
const StudyMarket: React.FC = () => {
const [nav] = useState(getMenuButtonBoundingClientRect())
Taro.showLoading({
title: '加载中',
mask: true
})
return (
<View>
<MainHeader />
<View style={{ paddingTop: `${nav.height + nav.top + 5}px` }}>
<Skeleton loading />
</View>
</View>
)
}
export default StudyMarket
import { computed, Action, Computed, action } from 'easy-peasy'
import WithPaging from '@/utils/with-paging'
import { PagingFn } from '@/types'
import { User } from '@/pages/prepare/types'
interface Model {
// setTitle: Action<PrepareModel, string>;
// setTotalQuestions: Action<PrepareModel, number>;
// setPassingRequirement: Action<PrepareModel, string>;
// setDuration: Action<PrepareModel, number>;
currentUser: User;
setCurrentUser: Action<PrepareModel, User>;
topThreeUsers: Computed<PrepareModel, User[]>;
currentUserInTopThree: Computed<PrepareModel, boolean>;
}
const api: PagingFn<any, {}> = async () => {
return {
code: 0,
sysTime: Date.now(),
data: {
list: [
{
nickname: 'index1',
schoolName: 'index1',
avatar: 'index1',
time: 10,
},
{
nickname: 'index2',
schoolName: 'index2',
avatar: 'index1',
time: 20,
},
{
nickname: 'index3',
schoolName: 'index3',
avatar: 'index1',
time: 30,
},
{
nickname: 'index4',
schoolName: 'index4',
avatar: 'index4',
time: 110,
},
{
nickname: 'index5',
schoolName: 'index5',
avatar: 'index1',
time: 30,
},
{
nickname: 'index6',
schoolName: 'inex6',
avatar: 'index6',
time: 110,
},
],
total: 400,
hasNextPage: true
}
}
}
const prepareModel = WithPaging<User, Model, {}>(api)({
currentUser: {
nickname: 'index4',
schoolName: 'index4',
avatar: 'index4',
time: 30,
},
// panelCard: {
// title: '表内除法',
// totalQuestions: 10,
// passingRequirement: '全√',
// duration: 80,
// },
topThreeUsers: computed((state) => state.list.slice(0, 3)),
currentUserInTopThree: computed(
(state) => state.topThreeUsers.some(
(user) => user.nickname === state.currentUser.nickname
),
),
setCurrentUser: action((state, user) => {
state.currentUser = user
}),
// setTitle: action((state, payload) => {
// state.levelInfo.title = payload;
// }),
// setTotalQuestions: action((state, payload) => {
// state.levelInfo.totalQuestions = payload;
// }),
// setPassingRequirement: action((state, payload) => {
// state.levelInfo.passingRequirement = payload;
// }),
// setDuration: action((state, payload) => {
// state.levelInfo.duration = payload;
// }),
})
export default prepareModel
export type PrepareModel = typeof prepareModel;
import gameModel from '@/pages/game/play/model'
import cartModel from './modules/cart'
import counterModel from './modules/counter'
import prepareModel from './modules/prepare'
const appStoreModel = {
cartModel,
counterModel,
prepareModel,
gameModel,
}
......
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