mirror of
git://f0xx.org/ac/ac-be-hub
synced 2026-07-29 04:59:44 +03:00
feat(hub): add Downloads and Documentation landing pages
Wire hub-downloads.js for stable OTA APK resolution, expand nav i18n, and add Session Studio download slot for alpha hub FR. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
67
assets/hub-downloads.js
Normal file
67
assets/hub-downloads.js
Normal file
@@ -0,0 +1,67 @@
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
function setStatus(msg) {
|
||||
var el = document.getElementById('hub-download-apk-status');
|
||||
if (el) {
|
||||
el.textContent = msg;
|
||||
}
|
||||
}
|
||||
|
||||
function resolveStableApkUrl() {
|
||||
return fetch('/v0/ota/channel/stable.json', { cache: 'no-store' })
|
||||
.then(function (r) {
|
||||
if (!r.ok) {
|
||||
throw new Error('stable channel HTTP ' + r.status);
|
||||
}
|
||||
return r.json();
|
||||
})
|
||||
.then(function (channel) {
|
||||
var manifestUrl = channel && channel.manifestUrl;
|
||||
if (!manifestUrl) {
|
||||
throw new Error('stable.json missing manifestUrl');
|
||||
}
|
||||
return fetch(manifestUrl, { cache: 'no-store' }).then(function (r) {
|
||||
if (!r.ok) {
|
||||
throw new Error('manifest HTTP ' + r.status);
|
||||
}
|
||||
return r.json();
|
||||
});
|
||||
})
|
||||
.then(function (manifest) {
|
||||
var url = manifest && (manifest.apkUrl || manifest.bundleUrl);
|
||||
if (!url) {
|
||||
throw new Error('manifest missing apkUrl');
|
||||
}
|
||||
return url;
|
||||
});
|
||||
}
|
||||
|
||||
function wireApkButton() {
|
||||
var btn = document.getElementById('hub-download-apk');
|
||||
if (!btn) {
|
||||
return;
|
||||
}
|
||||
btn.addEventListener('click', function () {
|
||||
btn.disabled = true;
|
||||
setStatus('Resolving stable OTA channel…');
|
||||
resolveStableApkUrl()
|
||||
.then(function (url) {
|
||||
setStatus('Downloading…');
|
||||
window.location.href = url;
|
||||
})
|
||||
.catch(function (err) {
|
||||
setStatus('APK unavailable — run builder OTA publish (stable). ' + (err.message || err));
|
||||
})
|
||||
.finally(function () {
|
||||
btn.disabled = false;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
if (document.readyState === 'loading') {
|
||||
document.addEventListener('DOMContentLoaded', wireApkButton);
|
||||
} else {
|
||||
wireApkButton();
|
||||
}
|
||||
})();
|
||||
Reference in New Issue
Block a user