fix: 暂时解决首页在切换语言时可能导致无法正常载入的问题
All checks were successful
deploy to server / build-and-deploy (push) Successful in 2m59s
All checks were successful
deploy to server / build-and-deploy (push) Successful in 2m59s
- 当首页获取相关条目时,Translations未找到对应语言条目的情况下Fallback为默认值 ISSUE: resolve #55
This commit is contained in:
@ -19,10 +19,15 @@ export function toHomepageView(raw: Homepage): HomepageView {
|
|||||||
const cover = isObject<DirectusFile>(item.cover)
|
const cover = isObject<DirectusFile>(item.cover)
|
||||||
? item.cover.id
|
? item.cover.id
|
||||||
: item.cover;
|
: item.cover;
|
||||||
|
console.log(
|
||||||
|
'Has empty array in product translations:',
|
||||||
|
item.translations.length === 0
|
||||||
|
);
|
||||||
|
const trans = item.translations?.[0] ?? { name: '', summary: '' };
|
||||||
return {
|
return {
|
||||||
id: item.id,
|
id: item.id,
|
||||||
name: item.translations?.[0].name,
|
name: trans.name,
|
||||||
summary: item.translations?.[0].summary,
|
summary: trans.summary,
|
||||||
cover: cover,
|
cover: cover,
|
||||||
} satisfies HomepageProductView;
|
} satisfies HomepageProductView;
|
||||||
});
|
});
|
||||||
@ -33,11 +38,12 @@ export function toHomepageView(raw: Homepage): HomepageView {
|
|||||||
const cover = isObject<DirectusFile>(item.cover)
|
const cover = isObject<DirectusFile>(item.cover)
|
||||||
? item.cover.id
|
? item.cover.id
|
||||||
: item.cover;
|
: item.cover;
|
||||||
|
const trans = item.translations?.[0] ?? { title: '', summary: '' };
|
||||||
|
|
||||||
return {
|
return {
|
||||||
id: item.id,
|
id: item.id,
|
||||||
title: item.translations?.[0].title,
|
title: trans.title,
|
||||||
summary: item.translations?.[0].summary,
|
summary: trans.summary,
|
||||||
cover: cover,
|
cover: cover,
|
||||||
} satisfies HomepageSolutionView;
|
} satisfies HomepageSolutionView;
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user