v1.1
This commit is contained in:
+49
-1
@@ -364,7 +364,7 @@
|
||||
class="bg-gray-800/40 p-5 rounded-xl border border-gray-700/50 space-y-5 text-sm text-gray-300 leading-relaxed">
|
||||
<div class="flex items-center">
|
||||
<h3 class="text-white font-bold text-2xl tracking-tight">📱 EmbyX</h3>
|
||||
<span
|
||||
<span id="appVersionBadge"
|
||||
class="ml-2 px-2 py-0.5 bg-primary/20 text-primary text-xs font-bold rounded-full border border-primary/30">v1.1</span>
|
||||
</div>
|
||||
|
||||
@@ -675,6 +675,9 @@
|
||||
setTimeout(() => this.toggleModal('profilePage', true), 500);
|
||||
}
|
||||
|
||||
// Check for updates (silent mode, only changes badge color)
|
||||
this.checkUpdate();
|
||||
|
||||
// ─── Branding Egg ───
|
||||
console.log(
|
||||
"%c EmbyX %c Designed by Juneix %c",
|
||||
@@ -684,6 +687,51 @@
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check GitHub for updates
|
||||
*/
|
||||
async checkUpdate() {
|
||||
const badge = document.getElementById('appVersionBadge');
|
||||
if (!badge) return;
|
||||
|
||||
// Rate limiting: check once every 24 hours
|
||||
const lastCheck = localStorage.getItem('embyx_last_update_check');
|
||||
const now = Date.now();
|
||||
if (lastCheck && now - parseInt(lastCheck) < 24 * 60 * 60 * 1000) return;
|
||||
|
||||
try {
|
||||
const response = await fetch('https://api.github.com/repos/juneix/EmbyX/releases/latest');
|
||||
if (!response.ok) return;
|
||||
const data = await response.json();
|
||||
localStorage.setItem('embyx_last_update_check', now.toString());
|
||||
|
||||
const latestTag = data.tag_name; // e.g. v1.2
|
||||
const latestVersion = latestTag.replace('v', '').trim();
|
||||
const currentVersion = this.config.appVersion;
|
||||
|
||||
// Semantic version comparison
|
||||
const isNewer = (latest, current) => {
|
||||
const l = latest.split('.').map(Number);
|
||||
const c = current.split('.').map(Number);
|
||||
for (let i = 0; i < Math.max(l.length, c.length); i++) {
|
||||
if ((l[i] || 0) > (c[i] || 0)) return true;
|
||||
if ((l[i] || 0) < (c[i] || 0)) return false;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
if (isNewer(latestVersion, currentVersion)) {
|
||||
// New version found: change to orange and enable click
|
||||
badge.classList.remove('bg-primary/20', 'text-primary', 'border-primary/30');
|
||||
badge.classList.add('bg-orange-500/20', 'text-orange-500', 'border-orange-500/30', 'cursor-pointer', 'transition-all', 'hover:opacity-80', 'active:scale-95');
|
||||
badge.title = 'New version available, click to download';
|
||||
badge.onclick = () => window.open('https://github.com/juneix/EmbyX/releases', '_blank');
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('Update check failed:', err);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
cacheDOM() {
|
||||
const ids = [
|
||||
|
||||
Reference in New Issue
Block a user