Ví dụ cấu hình mã nguồn cục bộ lưu trữ thông tin danh mục trò chơi của 99OK.
{ } catalogConfig.js{ } catalogConfig.json
Sao chép mã
JavaScript
// Cau hinh danh muc tro choi cuc bo 99OK
const localCatalogConfig = {
brand: "99OK" ,
country: "vn" ,
defaultCategory: "Tro choi dien tu" ,
featuredGames: [
{ id: "191" , name: "Perfect Strike" },
{ id: "020" , name: "Hotpot" },
{ id: "169" , name: "Fortune Snake" },
{ id: "081" , name: "Galactic Gems" },
{ id: "145" , name: "Mafia Mayhem" }
],
preference: {
audio: true ,
language: "Tieng Viet"
}
};
function getGameTitle(gameId) {
const target = localCatalogConfig.featuredGames.find(item => item.id === gameId);
return target ? target.name : "Khong tim thay" ;
}
// Kiem tra thu nghiem
console.log("Kiem tra tro choi:" , getGameTitle("020" )); JSON
{
"brand" : "99OK" ,
"country" : "vn" ,
"defaultCategory" : "Tro choi dien tu" ,
"featuredGames" : [
{ "id" : "191" , "name" : "Perfect Strike" },
{ "id" : "020" , "name" : "Hotpot" },
{ "id" : "169" , "name" : "Fortune Snake" },
{ "id" : "081" , "name" : "Galactic Gems" },
{ "id" : "145" , "name" : "Mafia Mayhem" }
],
"preference" : {
"audio" : true ,
"language" : "Tieng Viet"
}
}