public with sharing class RecordLastCtl { public RecordLastCtl() { } @AuraEnabled(cacheable=false) public static List getRecentlyViewedListView(){ List rvList = new List(); Map iconMap = new Map(); List resultList = [SELECT Id, Name, Type, LastViewedDate, LastReferencedDate FROM RecentlyViewed WHERE NOT Name like '%主页用%' order by LastViewedDate desc limit 20]; List tabList = [SELECT (SELECT ContentType, Url FROM Icons WHERE ContentType LIKE 'image/svg%'),SobjectName FROM TabDefinition]; if (resultList!=null && resultList.size() > 0) { if (tabList.size() > 0) { for (TabDefinition tab : tabList) { if (tab.Icons.size() > 0) { iconMap.put(tab.SobjectName, tab.Icons[0].Url.split('35/')[1].split('.svg')[0].replace('/',':')); } } } for (RecentlyViewed rv : resultList) { RecentlyViewedStr rvStr = new RecentlyViewedStr(); rvStr.id = rv.Id; rvStr.name = rv.Name; rvStr.type = rv.Type; SObjectType sObj = Schema.getGlobalDescribe().get(rv.Type); rvStr.type = sObj.getDescribe().getLabel(); rvStr.amount = '/lightning/r/'+ rv.Id+'/view'; if (String.isNotBlank(iconMap.get(rv.Type))) { rvStr.ico = iconMap.get(rv.Type); } else { rvStr.ico = 'custom:custom100'; } rvList.add(rvStr); } } return rvList; } public class RecentlyViewedStr { @AuraEnabled public String id; @AuraEnabled public String name; @AuraEnabled public String type; @AuraEnabled public String expectedRevenue; @AuraEnabled public String amount; @AuraEnabled public String ico; } }