Skip to content

Commit ac151f3

Browse files
fix(launcher): corrigir caminho do executável no launcher
feat(translate): adicionar botões de aprovação e rejeição com estilos refactor(index): otimizar sistema de cache e carregamento de traduções recentes
1 parent c073b3f commit ac151f3

File tree

4 files changed

+328
-55
lines changed

4 files changed

+328
-55
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,4 @@ tools/config_ptbr.ini
5252
/.vs
5353
.history/
5454

55+
launcher/dist/wwm_ptbr_launcher.json

docs/index.html

Lines changed: 40 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -2548,8 +2548,8 @@ <h4>Comunidade</h4>
25482548

25492549
// ========== CACHE SYSTEM ==========
25502550
const CacheManager = {
2551-
CACHE_KEY: 'wwm_api_cache_index',
2552-
CACHE_TTL: 10 * 60 * 1000, // 10 minutos
2551+
CACHE_KEY: 'wwm_api_cache', // Compartilhado com translate.html
2552+
CACHE_TTL: 15 * 60 * 1000, // 15 minutos
25532553

25542554
get(key, allowExpired = false) {
25552555
try {
@@ -3023,25 +3023,30 @@ <h4>Comunidade</h4>
30233023
}
30243024
}
30253025

3026-
// Load Recent Translations (Issues com label "applied") - COM CACHE
3026+
// Load Recent Translations - Reutiliza cache do Hall da Fama
30273027
async function loadRecentTranslations() {
30283028
const grid = document.getElementById('recent-translations-grid');
30293029
if (!grid) return;
30303030

30313031
try {
3032-
// Buscar issues fechadas com label "applied" - COM CACHE
3033-
const issues = await cachedApiCall(
3034-
'recent_translations',
3035-
'https://api.github.com/repos/rodrigomiquilino/wwm_brasileiro/issues?state=closed&labels=applied&per_page=6&sort=updated&direction=desc'
3032+
// Reutiliza o mesmo cache do Hall (applied_issues) - economia de 1 chamada
3033+
const allIssues = await cachedApiCall(
3034+
'applied_issues',
3035+
'https://api.github.com/repos/rodrigomiquilino/wwm_brasileiro/issues?state=closed&labels=applied&per_page=100'
30363036
);
30373037

3038+
// Ordenar por data de fechamento e pegar os 6 mais recentes
3039+
const issues = [...allIssues]
3040+
.sort((a, b) => new Date(b.closed_at) - new Date(a.closed_at))
3041+
.slice(0, 6);
3042+
30383043
if (!issues || issues.length === 0) {
30393044
grid.innerHTML = '<div class="recent-translations-empty"><i class="fas fa-inbox"></i> Nenhuma tradução aprovada ainda. Seja o primeiro!</div>';
30403045
return;
30413046
}
30423047

3043-
// Processar cada issue para extrair dados
3044-
const cards = await Promise.all(issues.slice(0, 6).map(async issue => {
3048+
// Processar cada issue para extrair dados (SEM buscar eventos - economia de API)
3049+
const cards = issues.slice(0, 6).map(issue => {
30453050
// Extrair JSON do corpo da issue
30463051
let suggestions = [];
30473052
let firstSuggestion = null;
@@ -3057,24 +3062,6 @@ <h4>Comunidade</h4>
30573062
console.warn('Erro ao parsear JSON da issue:', issue.number);
30583063
}
30593064

3060-
// Buscar quem aprovou (último evento de label)
3061-
let reviewer = null;
3062-
try {
3063-
const events = await cachedApiCall(
3064-
`issue_events_${issue.number}`,
3065-
`https://api.github.com/repos/rodrigomiquilino/wwm_brasileiro/issues/${issue.number}/events?per_page=20`
3066-
);
3067-
// Procurar evento de adição da label "approved"
3068-
const approvalEvent = events.find(e =>
3069-
e.event === 'labeled' && e.label?.name === 'approved'
3070-
);
3071-
if (approvalEvent && approvalEvent.actor) {
3072-
reviewer = approvalEvent.actor;
3073-
}
3074-
} catch (e) {
3075-
console.warn('Erro ao buscar eventos:', issue.number);
3076-
}
3077-
30783065
const closedDate = new Date(issue.closed_at);
30793066
const dateStr = closedDate.toLocaleDateString('pt-BR', {
30803067
day: '2-digit',
@@ -3128,17 +3115,10 @@ <h4>Comunidade</h4>
31283115
<img src="${issue.user?.avatar_url || ''}" alt="${issue.user?.login || 'user'}">
31293116
<span>@${issue.user?.login || 'anônimo'}</span>
31303117
</div>
3131-
${reviewer ? `
3132-
<div class="recent-translation-reviewer">
3133-
<span class="recent-translation-label">Revisor</span>
3134-
<img src="${reviewer.avatar_url || ''}" alt="${reviewer.login || 'revisor'}">
3135-
<span>@${reviewer.login}</span>
3136-
</div>
3137-
` : ''}
31383118
</div>
31393119
</div>
31403120
`;
3141-
}));
3121+
});
31423122

31433123
grid.innerHTML = cards.join('');
31443124

@@ -3148,12 +3128,34 @@ <h4>Comunidade</h4>
31483128
}
31493129
}
31503130

3151-
// Initialize
3131+
// Initialize with Lazy Loading (só carrega quando visível)
31523132
document.addEventListener('DOMContentLoaded', () => {
3133+
// Releases e commits são importantes - carregar imediatamente
31533134
fetchReleases();
31543135
fetchCommits();
3155-
loadContributors();
3156-
loadRecentTranslations();
3136+
3137+
// Hall da Fama e Traduções Recentes - lazy load quando visível
3138+
const lazyLoadObserver = new IntersectionObserver((entries) => {
3139+
entries.forEach(entry => {
3140+
if (entry.isIntersecting) {
3141+
const id = entry.target.id;
3142+
if (id === 'hall-container' && !entry.target.dataset.loaded) {
3143+
entry.target.dataset.loaded = 'true';
3144+
loadContributors();
3145+
} else if (id === 'recent-translations-grid' && !entry.target.dataset.loaded) {
3146+
entry.target.dataset.loaded = 'true';
3147+
loadRecentTranslations();
3148+
}
3149+
lazyLoadObserver.unobserve(entry.target);
3150+
}
3151+
});
3152+
}, { rootMargin: '200px' }); // Carrega 200px antes de aparecer
3153+
3154+
const hallContainer = document.getElementById('hall-container');
3155+
const recentGrid = document.getElementById('recent-translations-grid');
3156+
3157+
if (hallContainer) lazyLoadObserver.observe(hallContainer);
3158+
if (recentGrid) lazyLoadObserver.observe(recentGrid);
31573159
});
31583160

31593161
// Smooth scroll for navigation

0 commit comments

Comments
 (0)