1const state = Vue.reactive({ 2 fixtures: [], // Dữ liá»u từ API fixtures 3 liveFixtures: [], // Dữ liá»u từ API live fixtures 4 leaguesFixtures: [],// Dữ liá»u từ API Giải Äấu 5 countType: [], 6 loading: true, 7 error: null, 8 leagueFiltered: null, 9 leagueFilteredCheckbox: null, 10 isLoadingFixtures: false, // Äang load API fixtures 11 isLoadingLiveFixtures: false, // Äang load API live fixtures 12 isFetched: false, // Äảm bảo chá» gá»i API má»t lần 13}); 14 15// Hà m fetchFixtures ÄÆ°á»£c gá»i má»t lần Äá» tải dữ liá»u ban Äầu 16async function fetchFixtures() { 17 // Nếu dữ liá»u Äã ÄÆ°á»£c tải hoặc Äang tải, không cần gá»i lại API 18 if (state.isFetched || state.isLoadingFixtures || state.isLoadingLiveFixtures) { 19 return; 20 } 21 22 state.loading = true; 23 state.isLoadingFixtures = true; 24 state.isLoadingLiveFixtures = true; 25 state.error = null; 26 const currentTime = Date.now(); 27 const fixturesLiveUrl = `https://live-api.keovip88.net/storage/livestream/live.json?t=${currentTime}`; 28 const fixturesUrl = `https://live-api.keovip88.net/storage/livestream/all.json?t=${currentTime}`; 29 try { 30 // Gá»i Äá»ng thá»i hai API 31 const [fixturesLiveResponse, fixturesResponse] = await Promise.all([ 32 fetch(fixturesLiveUrl), 33 fetch(fixturesUrl) 34 ]); 35 36 // Kiá»m tra phản há»i từ API 37 if (!fixturesLiveResponse.ok) { 38 throw new Error('Failed to fetch live fixtures'); 39 } 40 if (!fixturesResponse.ok) { 41 throw new Error('Failed to fetch fixtures'); 42 } 43 44 // Chuyá»n Äá»i kết quả sang JSON 45 const resultFixturesLiveData = await fixturesLiveResponse.json(); 46 const resultFixturesData = await fixturesResponse.json(); 47 // Cáºp nháºt state vá»i dữ liá»u má»i 48 state.fixtures = resultFixturesData.response; 49 state.liveFixtures = resultFixturesLiveData.response; 50 const combinedFixtures = [...resultFixturesData.response, ...resultFixturesLiveData.response]; 51 combinedFixtures.forEach((item) => { 52 const exists = state.leaguesFixtures.some((league) => league.title === item.league.title); 53 if (!exists) { 54 state.leaguesFixtures.push(item.league); 55 } 56 }); 57 // Äánh dấu rằng dữ liá»u Äã ÄÆ°á»£c tải xong 58 state.isFetched = true; 59 60 } catch (err) { 61 state.error = err.message; 62 } finally { 63 state.loading = false; 64 state.isLoadingFixtures = false; 65 state.isLoadingLiveFixtures = false; 66 } 67} 68 69// Hà m fetch API live fixtures (Äá» cáºp nháºt live fixtures má»i 10 giây) 70async function fetchLiveFixtures() { 71 if (state.isLoadingLiveFixtures) return; // Kiá»m tra xem Äã có má»t cuá»c gá»i nà o Äang diá» n ra chưa 72 state.isLoadingLiveFixtures = true; 73 74 try { 75 const currentTime = Date.now(); 76 const liveFixturesUrl = `https://live-api.keovip88.net/storage/livestream/live.json?t=${currentTime}`; 77 const response = await fetch(liveFixturesUrl); 78 if (!response.ok) { 79 throw new Error('Failed to fetch live fixtures'); 80 } 81 const data = await response.json(); 82 state.liveFixtures = data.response; 83 state.liveFixtures.forEach((item) => { 84 const exists = state.leaguesFixtures.some((league) => league.title === item.league.title); 85 if (!exists) { 86 state.leaguesFixtures.push(item.league); 87 } 88 }); 89 } catch (err) { 90 state.error = err.message; 91 } finally { 92 state.isLoadingLiveFixtures = false; 93 } 94} 95 96// Gá»i hà m fetchFixtures khi component ÄÆ°á»£c khá»i tạo 97fetchFixtures(); 98 99// Äặt interval Äá» gá»i fetchLiveFixtures má»i 10 giây 100setInterval(fetchLiveFixtures, 10000); // 10000ms = 10 giây
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.