2 Commits

Author SHA1 Message Date
s
c94cdf679a fix: auto-install AppImage dans ~/.local/bin au premier lancement Linux
Au démarrage, si l'AppImage ne tourne pas depuis ~/.local/bin/farm-tracker.AppImage,
elle s'y copie automatiquement — plus besoin d'installation manuelle.
Les mises à jour suivantes y atterrissent toujours (fix update Linux).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-30 12:27:04 +02:00
s
a5d1725ee7 feat: stats historique enrichies en kills/min avec exp, kamas et top item
- Kills/h remplacé par kills/min partout (graphique + tableau)
- Hero : 3 nouvelles cartes (kills/min moyen + meilleur, exp totale, kamas totaux)
- Tableau : ajout colonnes exp/min, kamas, cols/min, top item droppé

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-30 12:14:02 +02:00
3 changed files with 78 additions and 17 deletions

31
main.js
View File

@@ -154,14 +154,23 @@ async function downloadAndInstall(downloadUrl, version) {
if (process.platform === 'linux') { if (process.platform === 'linux') {
fs.chmodSync(tmpPath, 0o755); fs.chmodSync(tmpPath, 0o755);
const stablePath = path.join(require('os').homedir(), '.local', 'bin', 'farm-tracker.AppImage'); const stablePath = path.join(require('os').homedir(), '.local', 'bin', 'farm-tracker.AppImage');
const target = fs.existsSync(stablePath) ? stablePath : process.env.APPIMAGE; try {
if (target) { fs.mkdirSync(path.dirname(stablePath), { recursive: true });
fs.copyFileSync(tmpPath, target); fs.copyFileSync(tmpPath, stablePath);
fs.chmodSync(stablePath, 0o755);
fs.unlinkSync(tmpPath); fs.unlinkSync(tmpPath);
app.relaunch({ execPath: target }); app.relaunch({ execPath: stablePath });
} catch (_) {
// fallback: remplace l'AppImage courant si la copie vers bin/ échoue
const fallback = process.env.APPIMAGE;
if (fallback) {
fs.copyFileSync(tmpPath, fallback);
fs.unlinkSync(tmpPath);
app.relaunch({ execPath: fallback });
} else { } else {
app.relaunch({ execPath: tmpPath }); app.relaunch({ execPath: tmpPath });
} }
}
app.exit(0); app.exit(0);
} else if (process.platform === 'win32') { } else if (process.platform === 'win32') {
const { spawn } = require('child_process'); const { spawn } = require('child_process');
@@ -251,7 +260,21 @@ function createWindow() {
mainWindow.loadFile(path.join(__dirname, 'renderer', 'index.html')); mainWindow.loadFile(path.join(__dirname, 'renderer', 'index.html'));
} }
function selfInstallLinux() {
if (process.platform !== 'linux' || !app.isPackaged) return;
const appImagePath = process.env.APPIMAGE;
if (!appImagePath) return;
const stablePath = path.join(require('os').homedir(), '.local', 'bin', 'farm-tracker.AppImage');
if (appImagePath === stablePath) return;
try {
fs.mkdirSync(path.dirname(stablePath), { recursive: true });
fs.copyFileSync(appImagePath, stablePath);
fs.chmodSync(stablePath, 0o755);
} catch (_) {}
}
app.whenReady().then(() => { app.whenReady().then(() => {
selfInstallLinux();
createWindow(); createWindow();
setTimeout(() => checkForUpdates(false), 5000); setTimeout(() => checkForUpdates(false), 5000);
}); });

View File

@@ -1,6 +1,6 @@
{ {
"name": "farm-tracker", "name": "farm-tracker",
"version": "1.0.3", "version": "1.0.5",
"description": "Suivi de loot Minecraft en direct, avec sauvegarde automatique des stats et des chances de drop.", "description": "Suivi de loot Minecraft en direct, avec sauvegarde automatique des stats et des chances de drop.",
"main": "main.js", "main": "main.js",
"scripts": { "scripts": {

View File

@@ -528,6 +528,21 @@
<p class="hero-number" id="histTotalTime">0h 00m</p> <p class="hero-number" id="histTotalTime">0h 00m</p>
<p class="hero-sub" id="histAvgTime">moy. 0h / session</p> <p class="hero-sub" id="histAvgTime">moy. 0h / session</p>
</div> </div>
<div class="hero-stat">
<p class="eyebrow">Kills/min moyen</p>
<p class="hero-number" id="histAvgRate">0</p>
<p class="hero-sub" id="histBestRate">meilleur 0/min</p>
</div>
<div class="hero-stat">
<p class="eyebrow">Exp totale</p>
<p class="hero-number" id="histTotalExp">0</p>
<p class="hero-sub" id="histAvgExp">moy. 0 / session</p>
</div>
<div class="hero-stat">
<p class="eyebrow">Kamas totaux</p>
<p class="hero-number" id="histTotalKamas">0</p>
<p class="hero-sub" id="histAvgKamas">moy. 0 / session</p>
</div>
</div> </div>
<div id="histEmptyState"> <div id="histEmptyState">
@@ -552,7 +567,7 @@
<div class="charts-2col" style="margin-bottom:14px;"> <div class="charts-2col" style="margin-bottom:14px;">
<div class="panel"> <div class="panel">
<h2>Kills / heure</h2> <h2>Kills / min</h2>
<div class="chart-wrap" id="chartRate"></div> <div class="chart-wrap" id="chartRate"></div>
<div class="chart-label-row" id="chartRateLabels"></div> <div class="chart-label-row" id="chartRateLabels"></div>
</div> </div>
@@ -577,10 +592,13 @@
<th>Date</th> <th>Date</th>
<th class="r">Durée</th> <th class="r">Durée</th>
<th class="r">Kills</th> <th class="r">Kills</th>
<th class="r">Kills/h</th> <th class="r">K/min</th>
<th class="r">Exp</th> <th class="r">Exp</th>
<th class="r">Cols kill</th> <th class="r">Exp/min</th>
<th class="r">Kamas</th>
<th class="r">Cols/min</th>
<th>Mob principal</th> <th>Mob principal</th>
<th>Top item</th>
</tr> </tr>
</thead> </thead>
<tbody id="histSessionsBody"></tbody> <tbody id="histSessionsBody"></tbody>
@@ -1834,8 +1852,15 @@
histEmpty.hidden=true; histHero.hidden=false; histCharts.hidden=false; histPanel.hidden=false; histEmpty.hidden=true; histHero.hidden=false; histCharts.hidden=false; histPanel.hidden=false;
const totalKills=sessions.reduce((s,x)=>s+x.totalKills,0); const totalKills=sessions.reduce((s,x)=>s+x.totalKills,0);
const totalMs=sessions.reduce((s,x)=>s+x.durationMs,0); const totalMs=sessions.reduce((s,x)=>s+x.durationMs,0);
const totalExp=sessions.reduce((s,x)=>s+(x.totalExp||0),0);
const totalKamas=sessions.reduce((s,x)=>s+(x.sellTotal||0),0);
const avgKills=Math.round(totalKills/sessions.length); const avgKills=Math.round(totalKills/sessions.length);
const avgMs=totalMs/sessions.length; const avgMs=totalMs/sessions.length;
const avgExp=Math.round(totalExp/sessions.length);
const avgKamas=Math.round(totalKamas/sessions.length);
const ratesPerMin=sessions.filter(s=>s.durationMs>0).map(s=>s.totalKills/(s.durationMs/60000));
const avgRate=ratesPerMin.length?ratesPerMin.reduce((a,b)=>a+b,0)/ratesPerMin.length:0;
const bestRate=ratesPerMin.length?Math.max(...ratesPerMin):0;
$('histTotalSessions').textContent=fmt(sessions.length); $('histTotalSessions').textContent=fmt(sessions.length);
$('histTotalKills').textContent=fmt(totalKills); $('histTotalKills').textContent=fmt(totalKills);
$('histAvgKills').textContent='moy. '+fmt(avgKills)+' / session'; $('histAvgKills').textContent='moy. '+fmt(avgKills)+' / session';
@@ -1843,12 +1868,18 @@
$('histTotalTime').textContent=tH+'h '+String(tM).padStart(2,'0')+'m'; $('histTotalTime').textContent=tH+'h '+String(tM).padStart(2,'0')+'m';
const aH=Math.floor(avgMs/3600000),aM=Math.floor((avgMs%3600000)/60000); const aH=Math.floor(avgMs/3600000),aM=Math.floor((avgMs%3600000)/60000);
$('histAvgTime').textContent='moy. '+(aH>0?aH+'h ':'')+String(aM).padStart(2,'0')+'m / session'; $('histAvgTime').textContent='moy. '+(aH>0?aH+'h ':'')+String(aM).padStart(2,'0')+'m / session';
$('histAvgRate').textContent=fmt(avgRate,1)+'/min';
$('histBestRate').textContent='meilleur '+fmt(bestRate,1)+'/min';
$('histTotalExp').textContent=fmtShort(totalExp);
$('histAvgExp').textContent='moy. '+fmtShort(avgExp)+' / session';
$('histTotalKamas').textContent=fmtShort(totalKamas);
$('histAvgKamas').textContent='moy. '+fmtShort(avgKamas)+' / session';
const kAvgEl=$('histKillsAvgLabel'); const kAvgEl=$('histKillsAvgLabel');
if (kAvgEl) kAvgEl.textContent='moy. '+fmt(avgKills)+' kills'; if (kAvgEl) kAvgEl.textContent='moy. '+fmt(avgKills)+' kills';
renderSvgChart($('chartKills'),sessions,s=>s.totalKills,'#9B5DE5',null,$('chartKillsLabels')); renderSvgChart($('chartKills'),sessions,s=>s.totalKills,'#9B5DE5',null,$('chartKillsLabels'));
renderSvgChart($('chartRate'),sessions,s=>{ renderSvgChart($('chartRate'),sessions,s=>{
const h=s.durationMs/3600000; return h>0?Math.round(s.totalKills/h):0; const min=s.durationMs/60000; return min>0?Math.round(s.totalKills/min*10)/10:0;
},'#5DB7E5',v=>fmtShort(v)+'/h',$('chartRateLabels')); },'#5DB7E5',v=>fmt(v,1)+'/min',$('chartRateLabels'));
renderSvgChart($('chartExp'),sessions,s=>s.totalExp,'#F2C94C',v=>fmtShort(v),$('chartExpLabels')); renderSvgChart($('chartExp'),sessions,s=>s.totalExp,'#F2C94C',v=>fmtShort(v),$('chartExpLabels'));
const tbody=$('histSessionsBody'); const tbody=$('histSessionsBody');
tbody.innerHTML=''; tbody.innerHTML='';
@@ -1859,16 +1890,23 @@
+' '+d.toLocaleTimeString('fr-FR',{hour:'2-digit',minute:'2-digit'}); +' '+d.toLocaleTimeString('fr-FR',{hour:'2-digit',minute:'2-digit'});
const dH=Math.floor(s.durationMs/3600000),dM=Math.floor((s.durationMs%3600000)/60000); const dH=Math.floor(s.durationMs/3600000),dM=Math.floor((s.durationMs%3600000)/60000);
const durStr=dH>0?dH+'h'+String(dM).padStart(2,'0')+'m':dM+'min'; const durStr=dH>0?dH+'h'+String(dM).padStart(2,'0')+'m':dM+'min';
const killsPerH=s.durationMs>0?Math.round(s.totalKills/(s.durationMs/3600000)):0; const minElapsed=s.durationMs/60000;
const killsPerMin=minElapsed>0?Math.round(s.totalKills/minElapsed*10)/10:0;
const expPerMin=minElapsed>0?Math.round(s.totalExp/minElapsed):0;
const colsPerMin=minElapsed>0?Math.round((s.killCols||0)/minElapsed*10)/10:0;
const topItemName=s.topItems&&s.topItems.length?s.topItems[0].name+' ×'+s.topItems[0].qty:'—';
const tr=document.createElement('tr'); const tr=document.createElement('tr');
tr.innerHTML= tr.innerHTML=
'<td>'+escHtml(dateStr)+'</td>'+ '<td>'+escHtml(dateStr)+'</td>'+
'<td class="r mono">'+escHtml(durStr)+'</td>'+ '<td class="r mono">'+escHtml(durStr)+'</td>'+
'<td class="r hl">'+fmt(s.totalKills)+'</td>'+ '<td class="r hl">'+fmt(s.totalKills)+'</td>'+
'<td class="r mono">'+fmt(killsPerH)+'/h</td>'+ '<td class="r mono">'+fmt(killsPerMin,1)+'/min</td>'+
'<td class="r mono">'+fmt(s.totalExp)+'</td>'+ '<td class="r mono">'+fmtShort(s.totalExp)+'</td>'+
'<td class="r mono">'+fmt(s.killCols)+'</td>'+ '<td class="r mono">'+fmtShort(expPerMin)+'/min</td>'+
'<td class="dim">'+escHtml(s.topMob||'—')+'</td>'; '<td class="r mono">'+(s.sellTotal?fmtShort(Math.round(s.sellTotal)):'—')+'</td>'+
'<td class="r mono">'+fmt(colsPerMin,1)+'/min</td>'+
'<td class="dim">'+escHtml(s.topMob||'—')+'</td>'+
'<td class="dim" title="'+escHtml(topItemName)+'">'+escHtml(topItemName.length>22?topItemName.slice(0,20)+'…':topItemName)+'</td>';
tbody.appendChild(tr); tbody.appendChild(tr);
} }
} }