139 lines
3.6 KiB
JavaScript
139 lines
3.6 KiB
JavaScript
/** 铸爱 — 与网关 CreateMintOrderRequestDTO 对齐的本地表单快照(见 gateway/dto/asset_dto.go) */
|
||
|
||
export const CRAFT_LENTICULAR_CN = '光栅卡'
|
||
/** 工艺名:与 craft-select 卡片「镭射卡」一致 */
|
||
export const CRAFT_LASER_CARD_CN = '镭射卡'
|
||
/** 工艺标签:写入 tags[],便于检索与后端扩展 */
|
||
export const CRAFT_TAG_LENTICULAR = 'craft:lenticular'
|
||
|
||
const defaultBgBase =
|
||
'radial-gradient(ellipse at 50% 40%, #1a0a3b 0%, #0a0418 55%, #000 100%)'
|
||
const defaultBgMid =
|
||
'radial-gradient(ellipse 38% 28% at 50% 45%, rgba(255,212,255,0.9) 0%, rgba(183,109,255,0.55) 50%, rgba(26,10,59,0) 100%)'
|
||
|
||
export function defaultLenticularDots() {
|
||
return [
|
||
{ x: 18, y: 22, r: 1.4 },
|
||
{ x: 78, y: 30, r: 1.6 },
|
||
{ x: 28, y: 72, r: 1.3 },
|
||
{ x: 86, y: 78, r: 1.2 },
|
||
{ x: 58, y: 12, r: 1.1 },
|
||
{ x: 8, y: 50, r: 1.0 },
|
||
{ x: 92, y: 50, r: 1.2 },
|
||
{ x: 50, y: 88, r: 1.1 },
|
||
]
|
||
}
|
||
|
||
/** 进入光栅工作室前写入的临时数据(create → lenticular-studio) */
|
||
export const LENTICULAR_STUDIO_STORAGE_KEY = 'lenticular_studio_payload'
|
||
|
||
/** 单图工艺:create → 镭射工坊(Laser-Card 页)入口载荷 */
|
||
export const CASTLOVE_LASER_ENTRY_KEY = 'castlove_laser_entry_payload'
|
||
|
||
/**
|
||
* 仅背景 + 主体两图层(无高光层),与光栅卡工作室一致
|
||
* @param {string} bgSrc 背景图本地路径或 URL
|
||
* @param {string} subjectSrc 主体图本地路径或 URL
|
||
*/
|
||
export function buildLenticularLayersTwo(bgSrc, subjectSrc) {
|
||
return [
|
||
{
|
||
id: 'base',
|
||
label: '背景',
|
||
depth: 0,
|
||
opacity: 1,
|
||
blendMode: 'normal',
|
||
parallaxFactor: 0.35,
|
||
background: bgSrc ? undefined : defaultBgBase,
|
||
dots: bgSrc ? undefined : defaultLenticularDots(),
|
||
src: bgSrc || undefined,
|
||
},
|
||
{
|
||
id: 'mid',
|
||
label: '主体',
|
||
depth: 0.55,
|
||
opacity: 0.92,
|
||
blendMode: 'screen',
|
||
parallaxFactor: 0.7,
|
||
background: subjectSrc ? undefined : defaultBgMid,
|
||
src: subjectSrc || undefined,
|
||
},
|
||
]
|
||
}
|
||
|
||
/** 兼容旧预览:单图仅贴在主体层,仍带高光层 */
|
||
export function buildLenticularLayers(uploadSrc) {
|
||
const mid = {
|
||
id: 'mid',
|
||
label: '主体',
|
||
depth: 0.55,
|
||
opacity: 0.92,
|
||
blendMode: 'screen',
|
||
parallaxFactor: 0.7,
|
||
background: uploadSrc ? undefined : defaultBgMid,
|
||
src: uploadSrc || undefined,
|
||
}
|
||
return [
|
||
{
|
||
id: 'base',
|
||
label: '背景',
|
||
depth: 0.0,
|
||
opacity: 1,
|
||
blendMode: 'normal',
|
||
parallaxFactor: 0.35,
|
||
background: defaultBgBase,
|
||
dots: defaultLenticularDots(),
|
||
},
|
||
mid,
|
||
{
|
||
id: 'fx',
|
||
label: '高光',
|
||
depth: 0.9,
|
||
opacity: 0.85,
|
||
blendMode: 'lighten',
|
||
parallaxFactor: 1.15,
|
||
background: 'transparent',
|
||
dots: [
|
||
{ x: 20, y: 16, r: 3, color: '#ffffff' },
|
||
{ x: 82, y: 22, r: 2.4, color: '#ffffff' },
|
||
{ x: 14, y: 78, r: 3.2, color: '#4cd7f6' },
|
||
],
|
||
},
|
||
]
|
||
}
|
||
|
||
/**
|
||
* 构建与 POST /api/v1/assets/mints 一致的字段子集 + 本地预览所需字段
|
||
* DTO: order_id, name, material_url, description, grade, tags, material_type, info
|
||
*/
|
||
export function buildCastloveFormSnapshot({
|
||
nftInfo,
|
||
materialTypes,
|
||
materialTypeIndex,
|
||
pageName,
|
||
uploadedImage,
|
||
uploadedImageBase64,
|
||
}) {
|
||
const info = (nftInfo || '').trim()
|
||
const material_type = materialTypes[materialTypeIndex] || '粉丝自制'
|
||
const lines = info.split(/\n/).map((l) => l.trim()).filter(Boolean)
|
||
const name =
|
||
lines.length > 0
|
||
? lines[0].slice(0, 80)
|
||
: pageName === CRAFT_LENTICULAR_CN
|
||
? '光栅卡作品'
|
||
: pageName || '藏品'
|
||
const tags = pageName === CRAFT_LENTICULAR_CN ? [CRAFT_TAG_LENTICULAR] : []
|
||
return {
|
||
image: uploadedImage,
|
||
imageBase64: uploadedImageBase64,
|
||
info,
|
||
material_type,
|
||
name,
|
||
description: '',
|
||
tags,
|
||
craft_name: pageName || '',
|
||
grade: 0,
|
||
}
|
||
}
|