|
@@ -20,6 +20,7 @@ export class WebService {
|
|
|
) {}
|
|
|
|
|
|
async findMenuTree(locale?: string): Promise<Menu[]> {
|
|
|
+ const lang = this.sharedService.handleValidLang(locale);
|
|
|
const menus = await this.menuRepo.find({
|
|
|
where: {
|
|
|
enable: true,
|
|
@@ -33,6 +34,7 @@ export class WebService {
|
|
|
relations: {
|
|
|
children: true,
|
|
|
category: true,
|
|
|
+ translations: true,
|
|
|
},
|
|
|
select: {
|
|
|
category: {
|
|
@@ -41,14 +43,16 @@ export class WebService {
|
|
|
},
|
|
|
},
|
|
|
});
|
|
|
- return this.sharedService.handleTree(menus);
|
|
|
+ const allMenus = menus.map((menu) => (menu.translations?.length ? menu.translate(lang) : menu));
|
|
|
+ // console.log('menus', lang, allMenus);
|
|
|
+ return this.sharedService.handleTree(allMenus);
|
|
|
}
|
|
|
|
|
|
async findArticleDetail(id: number, locale?: string) {
|
|
|
const lang = this.sharedService.handleValidLang(locale);
|
|
|
const article = await this.articleRepo.findOne({
|
|
|
where: { id },
|
|
|
- relations: { user: true, translations: true, category: true },
|
|
|
+ relations: { user: true, translations: false, category: true },
|
|
|
select: {
|
|
|
user: {
|
|
|
id: true,
|