feat(product-center): implement Figma-designed UI, upload module, and website tests
- Redesign website homepage & product-center per Figma (fonts, logos, hero/footer/customer cases) - Add API upload module (multer) with static serving for uploads/public assets - Add OriginGood.delisted flag and SDS request retry logic - Add admin ImageUpload component and goods import/upload flows - Add vitest suite for website components and composables (32 tests) - Add skills, docs, plans and PRODUCT.md
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
const countryIcons: Record<string, string> = {
|
||||
美国: '/assets/product-center/countries/us.png',
|
||||
日本: '/assets/product-center/countries/jp.png',
|
||||
墨西哥: '/assets/product-center/countries/mx.png',
|
||||
巴西: '/assets/product-center/countries/br.png',
|
||||
中东: '/assets/product-center/countries/middle-east.png',
|
||||
波兰: '/assets/product-center/countries/pl.png',
|
||||
西班牙: '/assets/product-center/countries/es.png',
|
||||
德国: '/assets/product-center/countries/de.png',
|
||||
意大利: '/assets/product-center/countries/it.png',
|
||||
英国: '/assets/product-center/countries/gb.png',
|
||||
加拿大: '/assets/product-center/countries/ca.png',
|
||||
澳大利亚: '/assets/product-center/countries/au.png',
|
||||
韩国: '/assets/product-center/countries/kr.png',
|
||||
};
|
||||
|
||||
const categoryIcons: Record<string, string> = {
|
||||
男士服装: '/assets/product-center/categories/men.svg',
|
||||
女士服装: '/assets/product-center/categories/women.svg',
|
||||
儿童服装: '/assets/product-center/categories/children.svg',
|
||||
家居配饰: '/assets/product-center/categories/home.svg',
|
||||
};
|
||||
|
||||
async function updateExistingIcons(
|
||||
entries: Record<string, string>,
|
||||
update: (name: string, icon: string) => Promise<{ count: number }>,
|
||||
): Promise<number> {
|
||||
let updated = 0;
|
||||
for (const [name, icon] of Object.entries(entries)) {
|
||||
const result = await update(name, icon);
|
||||
updated += result.count;
|
||||
}
|
||||
return updated;
|
||||
}
|
||||
|
||||
async function main(): Promise<void> {
|
||||
const countries = await updateExistingIcons(countryIcons, (countryName, countryIcon) =>
|
||||
prisma.country.updateMany({ where: { countryName }, data: { countryIcon } }),
|
||||
);
|
||||
const categories = await updateExistingIcons(categoryIcons, (categoryName, categoryIcon) =>
|
||||
prisma.category.updateMany({
|
||||
where: { categoryName, parentCategoryId: null },
|
||||
data: { categoryIcon },
|
||||
}),
|
||||
);
|
||||
console.log(`Configured ${countries} countries and ${categories} root categories.`);
|
||||
}
|
||||
|
||||
main()
|
||||
.finally(async () => prisma.$disconnect());
|
||||
Reference in New Issue
Block a user