🎈 perf(升级react18):

This commit is contained in:
czm 2022-09-05 13:17:29 +08:00
parent 76dca1ef45
commit 25aff4f481
8 changed files with 14836 additions and 51571 deletions

View File

@ -42,7 +42,10 @@ const config = {
}, },
sourceRoot: 'src', sourceRoot: 'src',
outputRoot: 'dist', outputRoot: 'dist',
plugins: [['@tarojs/plugin-mini-ci', CIPluginOpt]], plugins: [
['@tarojs/plugin-mini-ci', CIPluginOpt],
['@tarojs/plugin-framework-react', { reactMode: 'concurrent' }],
],
defineConstants: { defineConstants: {
CURRENT_VERSION: JSON.stringify(CURRENT_VERSION), CURRENT_VERSION: JSON.stringify(CURRENT_VERSION),
CURRENT_GITHASH: JSON.stringify(CURRENT_GITHASH), CURRENT_GITHASH: JSON.stringify(CURRENT_GITHASH),
@ -91,6 +94,17 @@ const config = {
}, },
}, },
}, },
compiler: {
type: 'webpack5',
// 依赖预编译配置
prebundle: {
enable: true,
},
},
// 持久化缓存配置
// cache: {
// enable: true,
// },
} }
module.exports = function (merge) { module.exports = function (merge) {

35876
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -41,16 +41,17 @@
"author": "", "author": "",
"dependencies": { "dependencies": {
"@babel/runtime": "^7.7.7", "@babel/runtime": "^7.7.7",
"@tarojs/components": "3.3.10", "@tarojs/components": "3.5.5",
"@tarojs/plugin-framework-react": "^3.4.12", "@tarojs/mini-runner": "3.5.5",
"@tarojs/react": "3.3.10", "@tarojs/plugin-framework-react": "3.5.5",
"@tarojs/runtime": "3.3.10", "@tarojs/react": "3.5.5",
"@tarojs/taro": "3.3.10", "@tarojs/runtime": "3.5.5",
"@tarojs/taro": "3.5.5",
"big.js": "^6.1.1", "big.js": "^6.1.1",
"dayjs": "^1.11.3", "dayjs": "^1.11.3",
"qs": "^6.10.3", "qs": "^6.10.3",
"react": "^17.0.0", "react": "^18.2.0",
"react-dom": "^17.0.0", "react-dom": "^18.2.0",
"react-redux": "^8.0.1", "react-redux": "^8.0.1",
"redux": "^4.2.0", "redux": "^4.2.0",
"redux-logger": "^3.0.6", "redux-logger": "^3.0.6",
@ -59,23 +60,25 @@
}, },
"devDependencies": { "devDependencies": {
"@babel/core": "^7.8.0", "@babel/core": "^7.8.0",
"@tarojs/mini-runner": "3.3.10", "@pmmmwh/react-refresh-webpack-plugin": "0.5.5",
"@tarojs/plugin-mini-ci": "^3.5.1", "@tarojs/plugin-mini-ci": "^3.5.1",
"@tarojs/plugin-react-devtools": "^3.4.13", "@tarojs/plugin-react-devtools": "^3.4.13",
"@tarojs/webpack-runner": "3.3.10", "@tarojs/webpack5-runner": "^3.5.5",
"@types/qs": "^6.9.7", "@types/qs": "^6.9.7",
"@types/react": "^17.0.2", "@types/react": "^18.0.0",
"@types/webpack-env": "^1.13.6", "@types/webpack-env": "^1.13.6",
"@typescript-eslint/eslint-plugin": "^4.15.1", "@typescript-eslint/eslint-plugin": "^4.15.1",
"@typescript-eslint/parser": "^4.15.1", "@typescript-eslint/parser": "^4.15.1",
"babel-preset-taro": "3.3.10", "babel-preset-taro": "3.5.5",
"cross-env": "^7.0.3", "cross-env": "^7.0.3",
"eslint": "^6.8.0", "eslint": "^6.8.0",
"eslint-config-taro": "3.3.10", "eslint-config-taro": "3.5.5",
"eslint-plugin-import": "^2.12.0", "eslint-plugin-import": "^2.12.0",
"eslint-plugin-react": "^7.8.2", "eslint-plugin-react": "^7.8.2",
"eslint-plugin-react-hooks": "^4.2.0", "eslint-plugin-react-hooks": "^4.2.0",
"react-refresh": "0.11.0",
"stylelint": "9.3.0", "stylelint": "9.3.0",
"typescript": "^4.1.0" "typescript": "^4.1.0",
"webpack": "^5.74.0"
} }
} }

View File

@ -13,7 +13,7 @@ export const BASE_URL = CURRENT_BASE_URL
// export const BASE_URL = `https://www.zzfzyc.com/lymarket` // 正式环境 // export const BASE_URL = `https://www.zzfzyc.com/lymarket` // 正式环境
// export const BASE_URL = `http://192.168.1.5:40001/lymarket` // 王霞 // export const BASE_URL = `http://192.168.1.5:40001/lymarket` // 王霞
// export const BASE_URL = `http://192.168.1.7:50002/lymarket` // 添 // export const BASE_URL = `http://192.168.1.7:50002/lymarket` // 添
// export const BASE_URL = `http://192.168.1.42:50001/lymarket` // 杰 // export const BASE_URL = `http://192.168.1.42:50002/lymarket` // 杰
// CDN // CDN
// 生成密钥 // 生成密钥

View File

@ -3,7 +3,6 @@ import Preview from '@/pages/details/components/preview'
import { Image, View } from '@tarojs/components' import { Image, View } from '@tarojs/components'
import { memo, useCallback, useEffect, useMemo, useState } from 'react' import { memo, useCallback, useEffect, useMemo, useState } from 'react'
import styles from './index.module.scss' import styles from './index.module.scss'
import Taro from '@tarojs/taro'
import LabAndImgShow from '../LabAndImgShow' import LabAndImgShow from '../LabAndImgShow'
//该组件宽高为100%需调整外层元素宽高 //该组件宽高为100%需调整外层元素宽高

View File

@ -1,65 +1,64 @@
import { formatImgUrl } from "@/common/fotmat" import { formatImgUrl } from '@/common/fotmat'
import { View } from "@tarojs/components" import { View } from '@tarojs/components'
import { useEffect, useMemo, useState } from "react" import { useEffect, useMemo, useState } from 'react'
import styles from './index.module.scss' import styles from './index.module.scss'
import Taro from '@tarojs/taro' import Taro from '@tarojs/taro'
export type colorParams = { export type colorParams = {
value?: { value?: {
texture_url?: string, //纹理图路径 texture_url?: string //纹理图路径
lab?: {l:number, a:number, b:number}, //lab lab?: { l: number; a: number; b: number } //lab
rgb?: {r:number, g:number, b:number} //rgb rgb?: { r: number; g: number; b: number } //rgb
title?: string //标题 title?: string //标题
}, }
show?: false|true show?: false | true
onClose?: () => void, onClose?: () => void
showNumber?: number, //图片显示张数0不限制 showNumber?: number //图片显示张数0不限制
} }
export default ({value, show = false, onClose, showNumber = 1}: colorParams) => { export default ({ value, show = false, onClose, showNumber = 1 }: colorParams) => {
useEffect(() => { useEffect(() => {
if(show&&rgbStyle) setLabShow(() => true) if (show && rgbStyle) setLabShow(() => true)
if(show&&value?.texture_url) onShowImage() if (show && value?.texture_url) onShowImage()
if(!show) setLabShow(() => false) if (!show) setLabShow(() => false)
}, [show]) }, [show])
//显示颜色 //显示颜色
const [labShow, setLabShow] = useState(false) const [labShow, setLabShow] = useState(false)
//lab是否都是0 //lab是否都是0
const rgbStyle = useMemo(() => { const rgbStyle = useMemo(() => {
if(value?.lab&&(value.lab.l||value.lab.a||value.lab.b)) { if (value?.lab && (value.lab.l || value.lab.a || value.lab.b)) {
return {'backgroundColor':`rgb(${value.rgb?.r} ${value.rgb?.g} ${value.rgb?.b})`} return { backgroundColor: `rgb(${value.rgb?.r} ${value.rgb?.g} ${value.rgb?.b})` }
} else { } else {
return null return null
} }
}, [value]) }, [value])
//显示图片 //显示图片
const onShowImage = () => { const onShowImage = () => {
onClose?.() onClose?.()
let res: string[] = [] let res: string[] = []
if(value?.texture_url) { if (value?.texture_url) {
res = value?.texture_url?.split(',').map(item => { res = value?.texture_url?.split(',').map((item) => {
return formatImgUrl(item) return formatImgUrl(item)
}) })
} }
let n_res = showNumber == 0? res : res?.splice(0, showNumber) let n_res = showNumber == 0 ? res : res?.splice(0, showNumber)
Taro.previewImage({ Taro.previewImage({
current: n_res[0], current: n_res[0],
urls: n_res urls: n_res,
}) })
} }
return ( return (
<> <>
{labShow&&<View className={styles.main} catch-move="true" onClick={() => onClose?.()}> {labShow && (
<View className={styles.main} catch-move='true' onClick={() => onClose?.()}>
<View className={styles.con}> <View className={styles.con}>
<View className={styles.rgb} style={rgbStyle!}></View> <View className={styles.rgb} style={rgbStyle!}></View>
<View className={styles.name}>{value?.title}</View> <View className={styles.name}>{value?.title}</View>
</View> </View>
</View>} </View>
)}
</> </>
) )
} }

View File

@ -1,24 +1,24 @@
import { formatImgUrl } from "@/common/fotmat" import { formatImgUrl } from '@/common/fotmat'
import { Image, Swiper, SwiperItem, View } from "@tarojs/components" import { Image, Swiper, SwiperItem, View } from '@tarojs/components'
import { useMemo, useRef, useState } from "react" import { useMemo, useRef, useState } from 'react'
import Taro from '@tarojs/taro' import Taro from '@tarojs/taro'
import styles from './index.module.scss' import styles from './index.module.scss'
type item = {title:string, img:string, url:string, id:number} type item = { title: string; img: string; url: string; id: number }
type params = { type params = {
list?: item[] list?: item[]
} }
export default ({list = []}: params) => { export default ({ list = [] }: params) => {
const [pageIndex, setPageIndex] = useState(1) const [pageIndex, setPageIndex] = useState(1)
const pageRef = useRef<any>(null) const pageRef = useRef<any>(null)
const pageCount = useMemo(() => { const pageCount = useMemo(() => {
return list.length return list.length
},[list]) }, [list])
const formatImages = useMemo(() => { const formatImages = useMemo(() => {
return list?.map(item => formatImgUrl(item, '!w800')) return list?.map((item) => formatImgUrl(item, '!w800'))
}, [list]) }, [list])
const swiperChange = (e) => { const swiperChange = (e) => {
@ -28,22 +28,30 @@ export default ({list = []}: params) => {
const onShowImage = () => { const onShowImage = () => {
Taro.previewImage({ Taro.previewImage({
current: formatImages[0], current: formatImages[0],
urls: formatImages urls: formatImages,
}) })
} }
return ( return (
<View className={styles.swiper}> <View className={styles.swiper}>
{list.length > 0 && <Swiper className={styles.swiper_item} circular={true} onAnimationFinish={(e) => swiperChange(e)}> {list.length > 0 && (
<Swiper className={styles.swiper_item} circular={true} onAnimationFinish={(e) => swiperChange(e)}>
{list?.map((item) => { {list?.map((item) => {
return <SwiperItem > return (
<SwiperItem>
<View className={styles.image_item} onClick={onShowImage}> <View className={styles.image_item} onClick={onShowImage}>
<Image mode="aspectFill" src={formatImgUrl(item, '!w400')}></Image> <Image mode='aspectFill' src={formatImgUrl(item, '!w400')}></Image>
</View> </View>
</SwiperItem> </SwiperItem>
)
})} })}
</Swiper>} </Swiper>
{(list.length > 0)&&<View className={styles.page} ref={pageRef}>{pageIndex+'/'+pageCount}</View>} )}
{list.length > 0 && (
<View className={styles.page} ref={pageRef}>
{pageIndex + '/' + pageCount}
</View>
)}
</View> </View>
) )
} }

9056
yarn.lock

File diff suppressed because it is too large Load Diff