refactor(claim): 删除自建皮肤领取页,路径式 /claim/<token> 复用现成领取页 + 物品图片
**删掉上一轮自建的领取页** - `pages/claim-skin/*`、`services/claim-skin.ts`、`types/claim-skin.ts`、`tests/claim-skin.test.ts` 及其样式(client.css 里 `.claim-skin-*` 整段 254 行) - 后台我加的展示项:「皮肤自动发货」筛选项、执行器标签、「买家提交信息」卡片 **路径式链接复用现成领取页** - `utils/claim-path.ts`(中性命名 `isClaimPath` / `resolveClaimToken`)+ 单测 - `App.tsx`:pathname 命中 `/claim/<token>` → 独立 BrowserRouter 渲染**现成的 `ClaimPage`** (页面零复制零改动:它只用 `useParams`,不读 hash);`#/claim/:token` 仍走主站 HashRouter, 两者互不影响,且有用例断言 hash 入口不命中路径判定 **物品图片** - 后端领取详情的 `product.imageUrl` 接上(内部 SKU 在 `spec_json.code` / `sku_code` / `sku_name` 哪个字段都能回退找到图,映射不到返回空串) - 领取页新增 `ClaimProductImage`:居中大图(宽度 min(220px,62%)、圆角 16px), 空值或加载失败都降级虚线占位块,不出现破图 `npm run check`:前端 128 / 128 全绿(去掉旧用例 17 个、新增路径与图片用例)
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { Card } from 'antd'
|
||||
import type { ClaimOrderInfo, ClaimProductInfo } from '@/types/claim'
|
||||
import { ClaimProductItems } from './claim-shared'
|
||||
import { ClaimProductImage, ClaimProductItems } from './claim-shared'
|
||||
|
||||
export function ClaimHeaderCard({
|
||||
order,
|
||||
@@ -25,6 +25,9 @@ export function ClaimHeaderCard({
|
||||
<ClaimProductItems product={product} compact />
|
||||
</div>
|
||||
|
||||
{/* 物品图放在文案块下方:步骤指示器是绝对定位在右上角的,窄屏时不会与它重叠 */}
|
||||
<ClaimProductImage imageUrl={product?.imageUrl || ''} title={product?.title || ''} />
|
||||
|
||||
<div className="claim-step-indicator">
|
||||
<div className="claim-step-dots" aria-label={`当前第 ${currentStep} 步`}>
|
||||
{[1, 2, 3, 4].map((step) => (
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import { PictureOutlined } from '@ant-design/icons'
|
||||
import { Button, Input, Space, Tooltip } from 'antd'
|
||||
import { useState } from 'react'
|
||||
import type { ClaimProductInfo } from '@/types/claim'
|
||||
|
||||
export function ClaimProductItems({
|
||||
@@ -34,6 +36,39 @@ export function ClaimProductItems({
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 待领取物品主图:居中、圆角、大图。
|
||||
*
|
||||
* `imageUrl` 为空串、或图片加载失败时,降级成同尺寸的虚线占位块(不会出现破图)。
|
||||
* 记录的是**失败的 src**:接口刷新后换新链接会自动重试,不需要额外重置状态。
|
||||
*/
|
||||
export function ClaimProductImage({ imageUrl, title }: { imageUrl: string; title: string }) {
|
||||
const src = String(imageUrl || '').trim()
|
||||
const [failedSrc, setFailedSrc] = useState('')
|
||||
|
||||
if (!src || failedSrc === src) {
|
||||
return (
|
||||
<div className="claim-product-image-wrap">
|
||||
<div className="claim-product-image claim-product-image-fallback" aria-label="物品图片">
|
||||
<PictureOutlined />
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="claim-product-image-wrap">
|
||||
<img
|
||||
className="claim-product-image"
|
||||
src={src}
|
||||
alt={title ? `${title} 物品图片` : '物品图片'}
|
||||
loading="lazy"
|
||||
onError={() => setFailedSrc(src)}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export function UidEditRow({
|
||||
uidInput,
|
||||
submitting,
|
||||
|
||||
Reference in New Issue
Block a user