Electron: Add /get page
This commit is contained in:
parent
193a0c60f8
commit
cd4e124fbb
@ -1,6 +1,6 @@
|
||||
src/lib/rlottie/rlottie-wasm.js
|
||||
src/lib/video-preview/libav*
|
||||
src/lib/video-preview/polyfill/*
|
||||
src/lib/video-preview/polyfill
|
||||
src/lib/webp/webp_wasm.js
|
||||
src/lib/fasttextweb/fasttext-wasm.js
|
||||
|
||||
@ -17,6 +17,7 @@ jest.config.js
|
||||
src/lib/secret-sauce/
|
||||
playwright.config.ts
|
||||
|
||||
dist/*
|
||||
dist
|
||||
public
|
||||
|
||||
deploy/update_version.js
|
||||
|
||||
4
public/get/apple-logo.svg
Normal file
4
public/get/apple-logo.svg
Normal file
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="842.32007" height="1000.0001">
|
||||
<path fill="#b3b3b3" d="M824.66636 779.30363c-15.12299 34.93724-33.02368 67.09674-53.7638 96.66374-28.27076 40.3074-51.4182 68.2078-69.25717 83.7012-27.65347 25.4313-57.2822 38.4556-89.00964 39.1963-22.77708 0-50.24539-6.4813-82.21973-19.629-32.07926-13.0861-61.55985-19.5673-88.51583-19.5673-28.27075 0-58.59083 6.4812-91.02193 19.5673-32.48053 13.1477-58.64639 19.9994-78.65196 20.6784-30.42501 1.29623-60.75123-12.0985-91.02193-40.2457-19.32039-16.8514-43.48632-45.7394-72.43607-86.6641-31.060778-43.7024-56.597041-94.37983-76.602609-152.15586C10.740416 658.44309 0 598.01283 0 539.50845c0-67.01648 14.481044-124.8172 43.486336-173.25401C66.28194 327.34823 96.60818 296.6578 134.5638 274.1276c37.95566-22.53016 78.96676-34.01129 123.1321-34.74585 24.16591 0 55.85633 7.47508 95.23784 22.166 39.27042 14.74029 64.48571 22.21538 75.54091 22.21538 8.26518 0 36.27668-8.7405 83.7629-26.16587 44.90607-16.16001 82.80614-22.85118 113.85458-20.21546 84.13326 6.78992 147.34122 39.95559 189.37699 99.70686-75.24463 45.59122-112.46573 109.4473-111.72502 191.36456.67899 63.8067 23.82643 116.90384 69.31888 159.06309 20.61664 19.56727 43.64066 34.69027 69.2571 45.4307-5.55531 16.11062-11.41933 31.54225-17.65372 46.35662zM631.70926 20.0057c0 50.01141-18.27108 96.70693-54.6897 139.92782-43.94932 51.38118-97.10817 81.07162-154.75459 76.38659-.73454-5.99983-1.16045-12.31444-1.16045-18.95003 0-48.01091 20.9006-99.39207 58.01678-141.40314 18.53027-21.27094 42.09746-38.95744 70.67685-53.0663C578.3158 9.00229 605.2903 1.31621 630.65988 0c.74076 6.68575 1.04938 13.37191 1.04938 20.00505z"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.7 KiB |
BIN
public/get/icon-electron-macos.png
Normal file
BIN
public/get/icon-electron-macos.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 9.2 KiB |
137
public/get/index.css
Normal file
137
public/get/index.css
Normal file
@ -0,0 +1,137 @@
|
||||
body {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
height: 100vh;
|
||||
margin: 0;
|
||||
|
||||
font-family: 'Arial', sans-serif;
|
||||
color: #222222;
|
||||
|
||||
background-color: white;
|
||||
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
}
|
||||
|
||||
.container {
|
||||
min-width: 200px;
|
||||
max-width: 330px;
|
||||
padding: 40px 40px 16px 40px;
|
||||
|
||||
text-align: center;
|
||||
|
||||
background-color: rgba(255, 255, 255, 0.95);
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
.logo-container {
|
||||
display: flex;
|
||||
gap: 5px;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.logo {
|
||||
width: 90px;
|
||||
height: 90px;
|
||||
|
||||
background-repeat: no-repeat;
|
||||
background-position: center;
|
||||
background-size: cover;
|
||||
}
|
||||
|
||||
.telegram-logo {
|
||||
background-image: url('./icon-electron-macos.png');
|
||||
}
|
||||
|
||||
.apple-logo {
|
||||
background-image: url('./apple-logo.svg');
|
||||
background-size: auto 80%;
|
||||
}
|
||||
|
||||
.container h1 {
|
||||
margin-bottom: 10px;
|
||||
|
||||
font-size: 24px;
|
||||
}
|
||||
|
||||
.select-model {
|
||||
margin-top: 36px;
|
||||
margin-bottom: 16px;
|
||||
|
||||
color: #444444;
|
||||
}
|
||||
|
||||
.info {
|
||||
margin-top: 28px;
|
||||
margin-bottom: 36px;
|
||||
|
||||
line-height: 1.25rem;
|
||||
color: #444444;
|
||||
}
|
||||
|
||||
.download-container {
|
||||
display: flex;
|
||||
gap: 20px;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.download-block {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
margin-bottom: 36px;
|
||||
}
|
||||
|
||||
.caption {
|
||||
font-size: 14px;
|
||||
color: #777;
|
||||
}
|
||||
|
||||
.download-btn {
|
||||
display: inline-block;
|
||||
|
||||
margin: 10px;
|
||||
padding: 8px 20px;
|
||||
|
||||
font-size: 16px;
|
||||
color: #FFF;
|
||||
text-decoration: none;
|
||||
|
||||
background-color: #007BFF;
|
||||
border-radius: 5px;
|
||||
|
||||
transition: background-color 150ms;
|
||||
}
|
||||
|
||||
.download-btn:hover {
|
||||
background-color: rgba(0, 123, 255, 0.9);
|
||||
}
|
||||
|
||||
.download-btn.single {
|
||||
display: block;
|
||||
|
||||
margin: 32px 0;
|
||||
}
|
||||
|
||||
.footer {
|
||||
font-size: small;
|
||||
color: #A9A9A9;
|
||||
}
|
||||
|
||||
.footer a {
|
||||
display: inline-block;
|
||||
|
||||
color: #A9A9A9;
|
||||
}
|
||||
|
||||
a:hover {
|
||||
text-decoration: none;
|
||||
}
|
||||
23
public/get/index.html
Normal file
23
public/get/index.html
Normal file
@ -0,0 +1,23 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Telegram A Desktop</title>
|
||||
<script src="./index.js"></script>
|
||||
<link rel="stylesheet" href="./index.css">
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class="logo-container">
|
||||
<div class="logo telegram-logo"></div>
|
||||
</div>
|
||||
<h1>Telegram A</h1>
|
||||
<a href="javascript:downloadDefault();" class="download-btn single">Download</a>
|
||||
<div class="footer">
|
||||
<span class="version"></span>
|
||||
<a href="javascript:redirectToFullList();" class="other-platforms">Other platforms</a>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
131
public/get/index.js
Normal file
131
public/get/index.js
Normal file
@ -0,0 +1,131 @@
|
||||
const REPO = 'Ajaxy/telegram-tt';
|
||||
const LATEST_RELEASE_API_URL = `https://api.github.com/repos/${REPO}/releases/latest`;
|
||||
const LATEST_RELEASE_WEB_URL = `https://github.com/${REPO}/releases/latest`;
|
||||
const WEB_APP_URL = location.pathname.startsWith('/a/') ? '/a/' : '/';
|
||||
|
||||
const platform = getPlatform();
|
||||
const currentPage = location.href.includes('mac.html')
|
||||
? 'mac'
|
||||
: location.href.includes('unsupported.html')
|
||||
? 'unsupported'
|
||||
: 'index';
|
||||
|
||||
// Request the latest release information from GitHub
|
||||
const packagesPromise = fetch(LATEST_RELEASE_API_URL)
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
return data.assets.reduce((acc, {
|
||||
name,
|
||||
browser_download_url,
|
||||
}) => {
|
||||
if (name.endsWith('.exe')) {
|
||||
acc['win'] = browser_download_url;
|
||||
} else if (name.endsWith('.AppImage')) {
|
||||
acc['linux'] = browser_download_url;
|
||||
} else if (name.endsWith('.dmg')) {
|
||||
acc[`mac-${name.includes('arm') ? 'arm' : 'x64'}`] = browser_download_url;
|
||||
}
|
||||
|
||||
return acc;
|
||||
}, {
|
||||
$version: data.name,
|
||||
});
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error('Error:', error);
|
||||
});
|
||||
|
||||
(function init() {
|
||||
if (platform === 'Windows' || platform === 'Linux') {
|
||||
if (currentPage === 'index') {
|
||||
setupDownloadButton();
|
||||
setupVersion();
|
||||
}
|
||||
} else if (platform === 'macOS') {
|
||||
if (currentPage !== 'mac') {
|
||||
redirectToMac();
|
||||
} else {
|
||||
setupVersion();
|
||||
}
|
||||
} else if (currentPage !== 'unsupported') {
|
||||
redirectToUnsupported();
|
||||
}
|
||||
}());
|
||||
|
||||
function getPlatform() {
|
||||
const {
|
||||
userAgent,
|
||||
platform,
|
||||
} = window.navigator;
|
||||
|
||||
const iosPlatforms = ['iPhone', 'iPad', 'iPod'];
|
||||
if (
|
||||
iosPlatforms.indexOf(platform) !== -1
|
||||
// For new IPads with M1 chip and IPadOS platform returns "MacIntel"
|
||||
|| (platform === 'MacIntel' && ('maxTouchPoints' in navigator && navigator.maxTouchPoints > 2))
|
||||
) {
|
||||
return 'iOS';
|
||||
}
|
||||
|
||||
const macosPlatforms = ['Macintosh', 'MacIntel', 'MacPPC', 'Mac68K'];
|
||||
if (macosPlatforms.indexOf(platform) !== -1) return 'macOS';
|
||||
|
||||
const windowsPlatforms = ['Win32', 'Win64', 'Windows', 'WinCE'];
|
||||
if (windowsPlatforms.indexOf(platform) !== -1) return 'Windows';
|
||||
|
||||
if (/Android/.test(userAgent)) return 'Android';
|
||||
|
||||
if (/Linux/.test(platform)) return 'Linux';
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function setupDownloadButton() {
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
const downloadBtn = document.querySelector('.download-btn');
|
||||
downloadBtn.innerHTML += ` for ${platform}`;
|
||||
});
|
||||
}
|
||||
|
||||
function setupVersion() {
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
packagesPromise.then((packages) => {
|
||||
const versionEl = document.querySelector('.version');
|
||||
versionEl.innerHTML = `v. ${packages.$version} · `;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function redirectToMac() {
|
||||
location.href = './mac.html';
|
||||
}
|
||||
|
||||
function redirectToUnsupported() {
|
||||
location.href = './unsupported.html';
|
||||
}
|
||||
|
||||
function redirectToWeb() {
|
||||
location.href = WEB_APP_URL;
|
||||
}
|
||||
|
||||
function redirectToFullList() {
|
||||
location.href = LATEST_RELEASE_WEB_URL;
|
||||
}
|
||||
|
||||
function downloadDefault() {
|
||||
if (platform === 'Windows') {
|
||||
download('win');
|
||||
} else if (platform === 'Linux') {
|
||||
download('linux');
|
||||
} else if (platform === 'macOS') {
|
||||
redirectToMac();
|
||||
} else {
|
||||
redirectToUnsupported();
|
||||
}
|
||||
}
|
||||
|
||||
function download(platform) {
|
||||
packagesPromise.then((packages) => {
|
||||
location.href = packages[platform];
|
||||
});
|
||||
}
|
||||
34
public/get/mac.html
Normal file
34
public/get/mac.html
Normal file
@ -0,0 +1,34 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Telegram A for Mac</title>
|
||||
<script src="./index.js"></script>
|
||||
<link rel="stylesheet" href="./index.css">
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class="logo-container">
|
||||
<div class="logo telegram-logo"></div>
|
||||
<div class="logo apple-logo"></div>
|
||||
</div>
|
||||
<h1>Telegram A for your Mac</h1>
|
||||
<div class="select-model">Select your device model</div>
|
||||
<div class="download-container">
|
||||
<div class="download-block">
|
||||
<a href="javascript:download('mac-arm');" class="download-btn">Newer Mac</a>
|
||||
<div class="caption">M1 and later</div>
|
||||
</div>
|
||||
<div class="download-block">
|
||||
<a href="javascript:download('mac-x64');" class="download-btn">Older Mac</a>
|
||||
<div class="caption">2019 and earlier</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="footer">
|
||||
<span class="version"></span>
|
||||
<a href="javascript:redirectToFullList();" class="other-platforms">Other platforms</a>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
24
public/get/unsupported.html
Normal file
24
public/get/unsupported.html
Normal file
@ -0,0 +1,24 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Telegram A Desktop</title>
|
||||
<script src="./index.js"></script>
|
||||
<link rel="stylesheet" href="./index.css">
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class="logo-container">
|
||||
<div class="logo telegram-logo"></div>
|
||||
</div>
|
||||
<h1>Telegram A for Desktop</h1>
|
||||
<div class="info">Open this page from Mac, PC or Linux<br/>to install Telegram A.</div>
|
||||
<a href="javascript:redirectToWeb();" class="download-btn single">Open Web Version</a>
|
||||
<div class="footer">
|
||||
<span class="version"></span>
|
||||
<a href="javascript:redirectToFullList();" class="other-platforms">Other platforms</a>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@ -11,26 +11,25 @@ export * from './environmentWebp';
|
||||
|
||||
export function getPlatform() {
|
||||
const { userAgent, platform } = window.navigator;
|
||||
const macosPlatforms = ['Macintosh', 'MacIntel', 'MacPPC', 'Mac68K'];
|
||||
const windowsPlatforms = ['Win32', 'Win64', 'Windows', 'WinCE'];
|
||||
|
||||
const iosPlatforms = ['iPhone', 'iPad', 'iPod'];
|
||||
let os: 'macOS' | 'iOS' | 'Windows' | 'Android' | 'Linux' | undefined;
|
||||
|
||||
if (iosPlatforms.indexOf(platform) !== -1
|
||||
if (
|
||||
iosPlatforms.indexOf(platform) !== -1
|
||||
// For new IPads with M1 chip and IPadOS platform returns "MacIntel"
|
||||
|| (platform === 'MacIntel' && ('maxTouchPoints' in navigator && navigator.maxTouchPoints > 2))) {
|
||||
os = 'iOS';
|
||||
} else if (macosPlatforms.indexOf(platform) !== -1) {
|
||||
os = 'macOS';
|
||||
} else if (windowsPlatforms.indexOf(platform) !== -1) {
|
||||
os = 'Windows';
|
||||
} else if (/Android/.test(userAgent)) {
|
||||
os = 'Android';
|
||||
} else if (/Linux/.test(platform)) {
|
||||
os = 'Linux';
|
||||
}
|
||||
|| (platform === 'MacIntel' && ('maxTouchPoints' in navigator && navigator.maxTouchPoints > 2))
|
||||
) return 'iOS';
|
||||
|
||||
return os;
|
||||
const macosPlatforms = ['Macintosh', 'MacIntel', 'MacPPC', 'Mac68K'];
|
||||
if (macosPlatforms.indexOf(platform) !== -1) return 'macOS';
|
||||
|
||||
const windowsPlatforms = ['Win32', 'Win64', 'Windows', 'WinCE'];
|
||||
if (windowsPlatforms.indexOf(platform) !== -1) return 'Windows';
|
||||
|
||||
if (/Android/.test(userAgent)) return 'Android';
|
||||
|
||||
if (/Linux/.test(platform)) return 'Linux';
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
export const IS_PRODUCTION_HOST = window.location.host === PRODUCTION_HOSTNAME;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user