diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 24d864a..0afdfbb 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -5,6 +5,9 @@ on: branches: - main paths-ignore: + - '.github/patch_android.py' + - '.github/workflows/release.yml' + - 'package.json' - 'README.md' - 'README_zh.md' workflow_dispatch: diff --git a/en/index.html b/en/index.html index dd0b417..6f16593 100644 --- a/en/index.html +++ b/en/index.html @@ -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">

📱 EmbyX

- v1.1
@@ -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 = [ diff --git a/zh/index.html b/zh/index.html index 8f20824..9bc928d 100644 --- a/zh/index.html +++ b/zh/index.html @@ -377,7 +377,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">

📱 EmbyX

- v1.1
@@ -705,6 +705,9 @@ setTimeout(() => this.toggleModal('profilePage', true), 500); } + // 检查版本更新 (静默模式,仅修改个人中心胶囊颜色) + this.checkUpdate(); + // ─── 注入项目签名彩蛋 (Branding Egg) ─── console.log( "%c EmbyX %c 原创设计@谢週五 %c", @@ -714,6 +717,52 @@ ); } + /** + * 检查 GitHub 更新 + * 逻辑:对比本地版本与 GitHub 最新 Release + */ + async checkUpdate() { + const badge = document.getElementById('appVersionBadge'); + if (!badge) return; + + // 频率限制:24小时检查一次 + 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; // 例如 v1.2 + const latestVersion = latestTag.replace('v', '').trim(); + const currentVersion = this.config.appVersion; + + // 语义化版本对比函数 (支持 1.1 < 1.1.2 等) + 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)) { + // 发现新版本:变橙并激活点击 + 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 = '发现新版本,点击前往下载'; + badge.onclick = () => window.open('https://github.com/juneix/EmbyX/releases', '_blank'); + } + } catch (err) { + console.error('Update check failed:', err); + } + } + cacheDOM() { const ids = [