-
Notifications
You must be signed in to change notification settings - Fork 298
Feat v3.x cpp order #3451
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat v3.x cpp order #3451
Changes from all commits
ade3572
01180e6
ae7cf70
a13c9c8
fbc08c3
98071a1
8bd5499
c37d280
2c68438
c58fe8b
09a6a38
d6806ea
9053813
b2d3e88
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,44 +1,32 @@ | ||
| import React, { FC } from 'react' | ||
| import { Image, View } from '@tarojs/components' | ||
|
|
||
| let left = | ||
| 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxOCIgaGVpZ2h0PSIxOCIgdmlld0JveD0iMCAwIDE4IDE4Ij48cGF0aCBkPSJNNi42MDUgOS40OWEuNzcxLjc3MSAwIDAgMSAwLS45OGwzLjYtNC4zNzJhLjc3MS43NzEgMCAwIDEgMS4xOS45ODFMOC4yIDlsMy4xOTcgMy44ODFhLjc3MS43NzEgMCAxIDEtMS4xOTEuOThsLTMuNi00LjM3eiIvPjwvc3ZnPg==' | ||
|
|
||
| let right = | ||
| 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxOCIgaGVpZ2h0PSIxOCIgdmlld0JveD0iMCAwIDE4IDE4Ij48cGF0aCBkPSJNMTEuMzk2IDkuNDlhLjc3MS43NzEgMCAwIDAgMC0uOThsLTMuNi00LjM3MmEuNzcxLjc3MSAwIDAgMC0xLjE5MS45ODFMOS44IDlsLTMuMTk2IDMuODgxYS43NzEuNzcxIDAgMCAwIDEuMTkuOThsMy42LTQuMzd6Ii8+PC9zdmc+' | ||
|
|
||
|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Ljc3MS43NzEgMCAwIDEgMCAuOTY0bC0zLjQ5NyA0LjM3MWEuNzcxLjc3MSAwIDAgMS0xLjA4NS4xMnoiLz48L3N2Zz4=' | ||
| import { Image } from '@tarojs/components' | ||
|
|
||
| interface IconProps { | ||
| url: string | ||
| } | ||
|
|
||
| if (process.env.TARO_ENV === 'jdharmony_cpp') { | ||
| left = | ||
| 'https://img11.360buyimg.com/imagetools/jfs/t1/187031/35/51586/196/6731c464F9b9f8f00/5506e32bf15e29dc.png' | ||
| right = | ||
| 'https://img12.360buyimg.com/imagetools/jfs/t1/181006/25/51824/185/6731c452F9e252322/7493147dd6b4a88d.png' | ||
| doubleLeft = | ||
| 'https://img13.360buyimg.com/imagetools/jfs/t1/221244/29/45876/259/6731c6bdF515df0a2/624e8eee3c8494a2.png' | ||
| doubleRight = | ||
| 'https://img11.360buyimg.com/imagetools/jfs/t1/238382/25/24000/235/6731c6bdF0153286c/4a57e60b6e889af3.png' | ||
| } | ||
| const left = | ||
| 'https://storage.360buyimg.com/imgtools/6437a2b149-bb511b40-4942-11f1-b1e1-7158b9aae0a9.svg' | ||
| const right = | ||
| 'https://storage.360buyimg.com/imgtools/8aa060341d-baf78990-4942-11f1-9368-cd56fc5fadc6.svg' | ||
| const doubleLeft = | ||
| 'https://storage.360buyimg.com/imgtools/b5e798f4ed-bbe8c760-4942-11f1-b1e1-7158b9aae0a9.svg' | ||
| const doubleRight = | ||
| 'https://storage.360buyimg.com/imgtools/d6979fa16d-bbb4bf10-4942-11f1-9368-cd56fc5fadc6.svg' | ||
|
|
||
| const Icon: FC<IconProps> = ({ url }) => { | ||
| const style = { | ||
| background: `url('${url}') no-repeat center`, | ||
| backgroundSize: '100% 100%', | ||
| width: 18, | ||
| height: 18, | ||
| } | ||
| if (process.env.TARO_ENV === 'jdharmony_cpp') { | ||
| return <Image src={url} style={style} /> | ||
| const iconStyle = { | ||
| color: 'var(--nutui-color-text)', | ||
| } | ||
| return <View style={style} /> | ||
| return ( | ||
| <Image | ||
| className="nut-calendarcard-icon" | ||
| svg | ||
| src={url} | ||
| mode="aspectFit" | ||
| style={iconStyle} | ||
| /> | ||
| ) | ||
|
Comment on lines
+18
to
+29
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. CSS const iconStyle = {
color: 'var(--nutui-color-text)', // ← 对 <Image> 渲染的 SVG 不生效
}
建议:
🤖 Prompt for AI Agents |
||
| } | ||
|
|
||
| export const ArrowLeft: FC = () => <Icon url={left} /> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,6 +5,10 @@ import { ComponentDefaults } from '@/utils/typings' | |
| import { useRtl } from '@/packages/configprovider/index.taro' | ||
| import { TaroPriceProps, PriceColorEnum } from '@/types' | ||
| import { harmony } from '@/utils/taro/platform' | ||
| import { | ||
| shouldRenderPriceAsRaw, | ||
| hasNonPriceChars, | ||
| } from '@/utils/should-render-price-raw' | ||
|
|
||
| const defaultProps = { | ||
| ...ComponentDefaults, | ||
|
|
@@ -16,6 +20,7 @@ const defaultProps = { | |
| position: 'before', | ||
| size: 'normal', | ||
| line: false, | ||
| raw: false, | ||
| } as TaroPriceProps | ||
| export const Price: FunctionComponent<Partial<TaroPriceProps>> = (props) => { | ||
| const { | ||
|
|
@@ -27,6 +32,7 @@ export const Price: FunctionComponent<Partial<TaroPriceProps>> = (props) => { | |
| position, | ||
| size, | ||
| line, | ||
| raw, | ||
| className, | ||
| style, | ||
| } = { | ||
|
|
@@ -38,9 +44,20 @@ export const Price: FunctionComponent<Partial<TaroPriceProps>> = (props) => { | |
|
|
||
| const rtl = useRtl() | ||
|
|
||
| const isRenderPriceRaw = useMemo( | ||
| () => | ||
| (typeof originalPrice === 'string' && | ||
| shouldRenderPriceAsRaw(originalPrice)) || | ||
| (raw && | ||
| typeof originalPrice === 'string' && | ||
| hasNonPriceChars(originalPrice)), | ||
| [originalPrice, raw] | ||
| ) | ||
|
|
||
| const price = useMemo(() => { | ||
| if (isRenderPriceRaw) return '' | ||
| return originalPrice.toString().replace(/[^\d.]/g, '') | ||
| }, [originalPrice]) | ||
| }, [originalPrice, isRenderPriceRaw]) | ||
|
|
||
| const isCustomPriceColor = useMemo(() => { | ||
| const specificPriceColor = Object.values(PriceColorEnum) | ||
|
|
@@ -86,7 +103,7 @@ export const Price: FunctionComponent<Partial<TaroPriceProps>> = (props) => { | |
| } | ||
|
|
||
| const formatDecimal = (decimalNum: any) => { | ||
| if (Number(decimalNum) === 0) { | ||
| if (Number(decimalNum) === 0 && !checkPoint(decimalNum)) { | ||
| decimalNum = 0 | ||
| } | ||
|
|
||
|
|
@@ -164,21 +181,23 @@ export const Price: FunctionComponent<Partial<TaroPriceProps>> = (props) => { | |
| ) | ||
| } | ||
|
|
||
| const renderRawContent = () => <>{originalPrice}</> | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
const renderRawContent = () => <>{originalPrice}</>当 🛠️ 建议修复- const renderRawContent = () => <>{originalPrice}</>
+ const renderRawContent = () => (
+ <Text style={priceColorStyle}>{originalPrice}</Text>
+ )或将 <Text
className={`${classPrefix} ${classPrefix}-${color} ${className}`}
- style={style}
+ style={{ ...priceColorStyle, ...style }}
>
{isRenderPriceRaw ? renderRawContent() : renderInner()}
</Text>(View 分支同理) 🤖 Prompt for AI Agents |
||
|
|
||
| return ( | ||
| <> | ||
| {harmony() || process.env.TARO_ENV === 'dynamic' ? ( | ||
| <Text | ||
| className={`${classPrefix} ${classPrefix}-${color} ${className}`} | ||
| style={style} | ||
| > | ||
| {renderInner()} | ||
| {isRenderPriceRaw ? renderRawContent() : renderInner()} | ||
| </Text> | ||
| ) : ( | ||
| <View | ||
| className={`${classPrefix} ${classPrefix}-${color} ${className}`} | ||
| style={style} | ||
| > | ||
| {renderInner()} | ||
| {isRenderPriceRaw ? renderRawContent() : renderInner()} | ||
| </View> | ||
| )} | ||
| </> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,4 +19,5 @@ export interface BasePrice extends BaseProps { | |
| position: string | ||
| size: PriceSize | ||
| line: boolean | ||
| raw: boolean | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| const RE_NUM = /\d+(?:\.\d+)?/g | ||
|
|
||
| // 价格合法字符:数字、小数点、负号、大写货币代码(HK USD EUR 等)、常见货币符号 Unicode 区块(含全角 ¥) | ||
| const PRICE_CHARS = /^[\d.\-A-Z¥¥$€£₩₹₽₺₴₪฿\u20A0-\u20CF\uFE69\uFF04\uFFE5]*$/ | ||
|
|
||
| function hasNoExtractablePrice(s: string) { | ||
| const t = s.trim() | ||
| if (!t) return true | ||
| if (!/\d/.test(t)) return true | ||
| if (t.replace(/[^\d.]/g, '') === '') return true | ||
| return false | ||
| } | ||
|
|
||
| export function shouldRenderPriceAsRaw(s: string) { | ||
| if (hasNoExtractablePrice(s)) { | ||
| return true | ||
| } | ||
| const t = s.trim() | ||
| const matches = Array.from(t.matchAll(RE_NUM)) | ||
| if (matches.length < 2) return false | ||
| const a = matches[0] | ||
| const b = matches[1] | ||
| const i0 = a.index! | ||
| const i1 = b.index! | ||
| const between = t.slice(i0 + a[0].length, i1) | ||
| return !PRICE_CHARS.test(between) | ||
| } | ||
|
|
||
| export function hasNonPriceChars(s: string): boolean { | ||
| return !PRICE_CHARS.test(s) | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
图标 URL 强依赖外部 CDN,在小程序环境中需确认域名白名单并评估可用性风险。
四个图标地址均托管在
storage.360buyimg.com,存在以下问题:storage.360buyimg.com加入合法域名(downloadFile或request白名单),否则图片将静默加载失败,导致图标区域空白。onError回调,网络不可用时无任何 fallback 渲染。建议确认以下几点:
app.json中networkTimeout/ 合法域名是否已覆盖该 CDN;onError降级(例如渲染文字箭头‹ › ‹‹ ››);require本地文件)以彻底规避网络依赖。🤖 Prompt for AI Agents