fix: 暂时解决首页在切换语言时可能导致无法正常载入的问题 #59
@ -19,10 +19,15 @@ export function toHomepageView(raw: Homepage): HomepageView {
|
||||
const cover = isObject<DirectusFile>(item.cover)
|
||||
? item.cover.id
|
||||
: item.cover;
|
||||
console.log(
|
||||
'Has empty array in product translations:',
|
||||
item.translations.length === 0
|
||||
);
|
||||
const trans = item.translations?.[0] ?? { name: '', summary: '' };
|
||||
return {
|
||||
id: item.id,
|
||||
name: item.translations?.[0].name,
|
||||
summary: item.translations?.[0].summary,
|
||||
name: trans.name,
|
||||
summary: trans.summary,
|
||||
cover: cover,
|
||||
} satisfies HomepageProductView;
|
||||
});
|
||||
@ -33,11 +38,12 @@ export function toHomepageView(raw: Homepage): HomepageView {
|
||||
const cover = isObject<DirectusFile>(item.cover)
|
||||
? item.cover.id
|
||||
: item.cover;
|
||||
const trans = item.translations?.[0] ?? { title: '', summary: '' };
|
||||
|
||||
return {
|
||||
id: item.id,
|
||||
title: item.translations?.[0].title,
|
||||
summary: item.translations?.[0].summary,
|
||||
title: trans.title,
|
||||
summary: trans.summary,
|
||||
cover: cover,
|
||||
} satisfies HomepageSolutionView;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user