const DEFAULT_CHANNEL = "c1"; const DEFAULT_TEMP_LABEL = "发布日期:2024-07-28,版本:3.1.31"; const DEFAULT_LABEL = { android: DEFAULT_TEMP_LABEL, ios: "版本自动更新", webapp: "版本自动更新", windows: "暂未上线", tv: "暂未上线", macos: DEFAULT_TEMP_LABEL, }; const DLURLS = { android: { major: [{ id: "android-lanzout", label: "", title: "Android版" }], minor: [{ id: "android-hk", label: "", title: "Android版" }], }, webapp: { major: [{ id: "pwa-lanzout", label: "", title: "iOS轻量版" }], minor: [{ id: "pwa-lanzout-1", label: "", title: "ios轻量版" }], }, windows: { major: [{ id: "win-lanzout", label: "", title: "Windows版" }], }, tv: { major: [{ id: "tv-lanzout", label: "", title: "TV 版本" }], // minor: [{ id: "tvd-lanzout", label: "", title: "TV Android4低版本" }], }, }; const DLA = { isApple: function () { var u = navigator.userAgent.toLowerCase(); return /iphone|ipad|ipod|ios/i.test(u); }, isAndroid: function () { var u = navigator.userAgent.toLowerCase(); return /android/i.test(u); }, getTypeKey: function (type) { return type && type === "webapp" ? "i" : "a"; }, dlchanel: function () { const queryString = window.location.search; const urlParams = new URLSearchParams(queryString); const channelValue = urlParams.get("_c"); return channelValue ? channelValue : DEFAULT_CHANNEL; }, dlpackage: function (ostype) { const queryString = window.location.search; const urlParams = new URLSearchParams(queryString); return urlParams.get(this.getTypeKey(ostype)); }, adlh: function (item) { let html = []; Object.keys(item).forEach(ostype => { let majorArr = item[ostype].major; let minorArr = item[ostype].minor; for (const idx in majorArr) { html.push(this.dlHtmlItem(majorArr[idx], ostype, true)); } for (const idx in minorArr) { html.push(this.dlHtmlItem(minorArr[idx], ostype, false)); } }) return html; }, dlHtmlItem: function (item, ostype, isMajor = true) { let url = window.location.href; let cc = DLA.dlchanel(); let configItem = DLCONFIG[cc] || DLCONFIG.main(); if (configItem) { url = configItem[item.id]; } let sysIcon = 'img'; let guideBtnCls = 'guide-btn hidden'; if (ostype == "android") { guideBtnCls = "guide-btn android-guide-btn"; sysIcon = "img img_android"; } else if (ostype == "ios") { guideBtnCls = "guide-btn ios-guide-btn"; sysIcon = "img img_ios"; } else if (ostype == "webapp") { guideBtnCls = "guide-btn ios-guide-btn"; sysIcon = "img img_webapp"; } else if (ostype == "windows") { guideBtnCls = "guide-btn pc-guide-btn"; sysIcon = "img img_windows"; } else if (ostype == "macos") { guideBtnCls = "guide-btn pc-guide-btn"; sysIcon = "img img_macos"; } else if (ostype == "tv") { guideBtnCls = "guide-btn tv-guide-btn"; sysIcon = "img img_tv"; } else { } return `
${item.title}下载 ${isMajor ? '主用' : '备用'}
${item.label && item.label.length > 0 ? item.label : DEFAULT_LABEL[ostype]}

安装指引

`; }, downloadFile: function (url, ostype) { this.dlcallback(url, ostype); }, androidQrcodeUrl: function () { let href = window.location.href; if (!DLCONFIG) { return href; } let cc = DLA.dlchanel(); let item = DLCONFIG[cc] || DLCONFIG.main(); if (!item) { return href; } return item[DLURLS.android.major[0].id]; }, iosQrcodeUrl: function () { let href = window.location.href; if (!DLCONFIG) { return href; } let cc = DLA.dlchanel(); let item = DLCONFIG[cc] || DLCONFIG.main(); if (!item) { return href; } return item[DLURLS.webapp.major[0].id]; }, init: function () { if (!DLCONFIG) { return; } let wrapEle = document.getElementById("app-download-list"); if (wrapEle) { let htmlEle = DLA.adlh(DLURLS); for (const idx in htmlEle) { wrapEle.insertAdjacentHTML('beforeend', htmlEle[idx]); } if (htmlEle && htmlEle.length > 0) { let eles = document.querySelectorAll(".guide-btn"); eles.forEach(ele => { let os = ele.dataset.os; ele.addEventListener("click", () => { this.guideCallback(os); }); }) } } else { console.error("找不到容器"); } }, dlcallback: function (url) { }, guideCallback: function () { }, openUrl: function (url) { if (url) { this.dlcallback(); setTimeout(() => { // window.open(url, '_blank'); window.location.href = url; }, 500); } else { console.error("download fail: url is null."); } }, isSafariBrowser: function () { return /^((?!chrome|android).)*safari/i.test(navigator.userAgent); }, copyToClipboard: function (text) { // Check if the Clipboard API is available if (!navigator.clipboard) { // Clipboard API not available, fallback to execCommand const input = document.createElement('input'); input.setAttribute('type', 'text'); input.setAttribute('value', text); document.body.appendChild(input); input.select(); document.execCommand('copy'); document.body.removeChild(input); return; } // Use the Clipboard API to copy the text to the clipboard navigator.clipboard.writeText(text) .then(() => { console.log('Text copied to clipboard'); }) .catch((error) => { console.error('Failed to copy text: ', error); }); }, };