Commit 3190e1ec authored by hewenhao's avatar hewenhao

feat: update

parent 28579326
{
"A和B通关.wav": {
"u": "https://cdn.jkwljy.com/pk-math/4P1LV2HsBxu3yHnf8hWeR2FFdk5o.wav",
"ossName": "/pk-math/4P1LV2HsBxu3yHnf8hWeR2FFdk5o.wav"
},
"S通关.wav": {
"u": "https://cdn.jkwljy.com/pk-math/PPZySMdpZGhmSjMHofsLm911A2g.wav",
"ossName": "/pk-math/PPZySMdpZGhmSjMHofsLm911A2g.wav"
},
"最后10秒 一战到底.mp3": {
"u": "https://cdn.jkwljy.com/pk-math/4Li9G8xoEyenYFWcawvFELxkkLTG.mp3",
"ossName": "/pk-math/4Li9G8xoEyenYFWcawvFELxkkLTG.mp3"
},
"点领取水晶部落.wav": {
"u": "https://cdn.jkwljy.com/pk-math/3WyAatVWmvngZMv2Fp1qUpDQQFzG.wav",
"ossName": "/pk-math/3WyAatVWmvngZMv2Fp1qUpDQQFzG.wav"
},
"蹦蹦top出现首页.wav": {
"u": "https://cdn.jkwljy.com/pk-math/3xWyfMNzygvUMkpS3xiux7yTak97.wav",
"ossName": "/pk-math/3xWyfMNzygvUMkpS3xiux7yTak97.wav"
},
"部门排行榜出现.wav": {
"u": "https://cdn.jkwljy.com/pk-math/4Fc1xAi1LJqSVxnwyD3w3sYFXZz.wav",
"ossName": "/pk-math/4Fc1xAi1LJqSVxnwyD3w3sYFXZz.wav"
},
"闯关失败.wav": {
"u": "https://cdn.jkwljy.com/pk-math/4CHzoWjnHJDMzufZarfD5A75o8br.wav",
"ossName": "/pk-math/4CHzoWjnHJDMzufZarfD5A75o8br.wav"
},
"回答正确--一战到底.wav": {
"u": "https://cdn.jkwljy.com/pk-math/27VsNjau3bmrFjWf7kmGkh5z3eug.wav",
"ossName": "/pk-math/27VsNjau3bmrFjWf7kmGkh5z3eug.wav"
},
"错误.wav": {
"u": "https://cdn.jkwljy.com/pk-math/cqKDzvSN1Gh53GGfqkmURQiCSc6.wav",
"ossName": "/pk-math/cqKDzvSN1Gh53GGfqkmURQiCSc6.wav"
}
}
......@@ -78,7 +78,12 @@ async function uploadFolder ({ fileList, outputFileName, cachedOutputFileName })
}
const resultList = fileList.map(item => {
const dimensions = sizeOf(item.filePath)
let dimensions = null
try {
dimensions = sizeOf(item.filePath)
} catch (err) {
console.log(err)
}
const ossName = getFileName(item.relativePath, item.filePath, dimensions)
return {
ossName,
......@@ -141,8 +146,8 @@ function uploadFile ({ fileName, filePath, ContentType, ossName, dimensions }) {
resolve({
fileName,
filePath,
width: dimensions.width,
height: dimensions.height,
width: dimensions?.width,
height: dimensions?.height,
ossName,
// originPath,
url: `https://${data.Location}`.replace(`${config.Bucket}.cos.ap-chengdu.myqcloud.com`, 'cdn.jkwljy.com')
......@@ -161,5 +166,13 @@ function getFileName (relativePath, absolutPath, dimensions) {
.update(fs.readFileSync(absolutPath, { encoding: 'binary' }))
.digest()
const key = bs58.encode(buffer)
if (dimensions) {
return `/pk-math/${key}/${dimensions.width}x${dimensions.height}`
}
const dot = absolutPath.lastIndexOf('.')
if (dot < -1) {
throw Error('File name is not right!')
}
const suffix = absolutPath.substr(dot + 1)
return `/pk-math/${key}.${suffix}`
}
/* eslint-disable quotes */
/* eslint-disable quote-props */
export default {
"A和B通关.wav": {
"u": "https://cdn.jkwljy.com/pk-math/4P1LV2HsBxu3yHnf8hWeR2FFdk5o.wav"
},
"S通关.wav": {
"u": "https://cdn.jkwljy.com/pk-math/PPZySMdpZGhmSjMHofsLm911A2g.wav"
},
"最后10秒 一战到底.mp3": {
"u": "https://cdn.jkwljy.com/pk-math/4Li9G8xoEyenYFWcawvFELxkkLTG.mp3"
},
"点领取水晶部落.wav": {
"u": "https://cdn.jkwljy.com/pk-math/3WyAatVWmvngZMv2Fp1qUpDQQFzG.wav"
},
"蹦蹦top出现首页.wav": {
"u": "https://cdn.jkwljy.com/pk-math/3xWyfMNzygvUMkpS3xiux7yTak97.wav"
},
"部门排行榜出现.wav": {
"u": "https://cdn.jkwljy.com/pk-math/4Fc1xAi1LJqSVxnwyD3w3sYFXZz.wav"
},
"闯关失败.wav": {
"u": "https://cdn.jkwljy.com/pk-math/4CHzoWjnHJDMzufZarfD5A75o8br.wav"
},
"回答正确--一战到底.wav": {
"u": "https://cdn.jkwljy.com/pk-math/27VsNjau3bmrFjWf7kmGkh5z3eug.wav"
},
"错误.wav": {
"u": "https://cdn.jkwljy.com/pk-math/cqKDzvSN1Gh53GGfqkmURQiCSc6.wav"
}
} as const
import { View, Image } from '@tarojs/components'
import { useMemo } from 'react'
import { useMemo, useEffect } from 'react'
import { getMenuButtonBoundingClientRect } from '@tarojs/taro'
import classNames from 'classnames'
import assets from '@/assets/oss/assets-complete'
import { useFormatTick } from '@/hooks/use-format-tick'
import { StageLevel } from '@/api'
import { useStoreState } from '@/store/hooks'
import { palyAudio } from '@/utils/play-audio'
import audio from '@/assets/oss/assets-audio'
import styles from './complete-head.module.scss'
......@@ -25,6 +27,17 @@ const getLevelBigBg = (s?: StageLevel | null): string => {
return assets['level-big-fail.png'].u
}
const getAudioSrc = (s?: StageLevel | null) => {
if (!s) {
return audio['闯关失败.wav'].u
}
if (s === StageLevel.S) {
return audio['S通关.wav'].u
}
return audio['A和B通关.wav'].u
}
const getLevelText = (s?: StageLevel | null) => {
switch (s) {
case StageLevel.S: {
......@@ -76,6 +89,12 @@ const GameCompleteHead = () => {
const time = useFormatTick((gameResult?.resultTime ?? 0) * 1000)
const au = useMemo(() => getAudioSrc(gameResult?.level), [gameResult?.level])
useEffect(() => {
palyAudio(au)
}, [au])
const bonus = useMemo(() => {
if (!gameResult) return 0
return gameResult?.gearReward + gameResult?.levelReward + gameResult?.upGearReward
......
......@@ -5,6 +5,8 @@ import classNames from 'classnames'
import { useBoolean } from '@/hooks'
import { useStoreState, useStoreActions } from '@/store/hooks'
import { type StageDetail, StageType } from '@/api'
import audio from '@/assets/oss/assets-audio'
import { palyAudio } from '@/utils/play-audio'
import styles from './count-up.module.scss'
......@@ -74,6 +76,11 @@ const CountUp = (props: CountUpProps) => {
}
}, [submit, isOneStop])
const handleExceed = useCallback(() => {
exceedActions.setTrue()
palyAudio(audio['最后10秒 一战到底.mp3'].u)
}, [exceedActions])
return (
<View className={classNames(styles.count, isOneStop && styles.is_stop)}>
<View className={styles.process}>
......@@ -94,8 +101,8 @@ const CountUp = (props: CountUpProps) => {
: (<Image src={require('../assets/count-time.png')} className={styles.icon}></Image>)
}
<count-up-time
exceedTime={20}
onExceed={exceedActions.setTrue}
exceedTime={10}
onExceed={handleExceed}
maxValue={stageDetail.bTime}
startValue={startTick}
isDown={isOneStop}
......
......@@ -2,6 +2,8 @@ import { action, Action, computed, Computed, Thunk, thunk } from 'easy-peasy'
import { AppStoreModel } from '@/store/store-model'
import { getQuestionList, type StageDetail, getStageDetail, completeStage, StageType, type CompleteStageOut, resumeGame } from '@/api'
import { showLoading, hideLoading, showModal, redirectTo, vibrateShort, getCurrentInstance } from '@tarojs/taro'
import { palyAudio } from '@/utils/play-audio'
import audio from '@/assets/oss/assets-audio'
import {
QuestionType,
QuestionAnswer,
......@@ -174,10 +176,12 @@ const gameModel: GameModel = {
const { canGoNext, currentQuestionIndex, questionList, stageDetail, currentQuestion, isReborn } = helpers.getState()
if (!canGoNext) return
if (stageDetail?.type === StageType.OneStop && currentQuestion && !determinQuestion(currentQuestion)) {
if (stageDetail?.type === StageType.OneStop && currentQuestion) {
if (!determinQuestion(currentQuestion)) {
const cardNum = helpers.getStoreState().userModel.cardNum
/** 没有复活过并且有答题卡 */
if (!isReborn && cardNum > 0) {
palyAudio(audio['错误.wav'].u)
stopCounter()
actions.updateState({ modalContinueVisible: true, isReborn: true })
} else {
......@@ -185,6 +189,10 @@ const gameModel: GameModel = {
}
return
}
if (currentQuestionIndex > 0 && currentQuestionIndex % 3 === 0) {
palyAudio(audio['回答正确--一战到底.wav'].u)
}
}
if (questionList.length === currentQuestionIndex + 1) {
actions.submit()
......
......@@ -2,7 +2,12 @@ import { Image } from '@tarojs/components'
import { useEffect, useRef, useMemo, useState } from 'react'
import assets from '@/assets/oss/assets-round'
import { useFocus } from '@/hooks'
import { usePageScroll, createIntersectionObserver, getCurrentInstance, getMenuButtonBoundingClientRect, IntersectionObserver, nextTick } from '@tarojs/taro'
import {
usePageScroll, createIntersectionObserver, getCurrentInstance,
getMenuButtonBoundingClientRect, IntersectionObserver, nextTick
} from '@tarojs/taro'
import { palyAudio } from '@/utils/play-audio'
import audio from '@/assets/oss/assets-audio'
type StageTagProps = {
url?: string;
......@@ -47,6 +52,7 @@ const StageTag = (props: StageTagProps) => {
clearTimeout(timer)
}
timer = setTimeout(() => {
palyAudio(audio['蹦蹦top出现首页.wav'].u)
setIsAnimated(true)
page?.animate?.(`#${uid}`, [
{ opacity: 0, translateY: 50, scale: [1, 1] },
......
import { createInnerAudioContext } from '@tarojs/taro'
const innerAudioContext = createInnerAudioContext()
export function palyAudio (src: string) {
innerAudioContext.src = src
innerAudioContext.play()
return innerAudioContext
}
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