This commit is contained in:
tamaina
2019-05-03 00:05:12 +09:00
committed by Satsuki Yanagi
parent 5afe96e15a
commit 788edd3622
3 changed files with 10 additions and 15 deletions

View File

@@ -35,12 +35,12 @@
const url = new URL(location.href);
//#region Detect app name
window.appType = null;
let app = null;
if (`${url.pathname}/`.startsWith('/docs/')) window.appType = 'docs';
if (`${url.pathname}/`.startsWith('/dev/')) window.appType = 'dev';
if (`${url.pathname}/`.startsWith('/auth/')) window.appType = 'auth';
if (`${url.pathname}/`.startsWith('/admin/')) window.appType = 'admin';
if (`${url.pathname}/`.startsWith('/docs/')) app = 'docs';
if (`${url.pathname}/`.startsWith('/dev/')) app = 'dev';
if (`${url.pathname}/`.startsWith('/auth/')) app = 'auth';
if (`${url.pathname}/`.startsWith('/admin/')) app = 'admin';
//#endregion
// Script version
@@ -105,15 +105,15 @@
}
// Switch desktop or mobile version
if (window.appType == null) {
window.appType = isMobile ? 'mobile' : 'desktop';
if (app == null) {
app = isMobile ? 'mobile' : 'desktop';
}
// Load an app script
// Note: 'async' make it possible to load the script asyncly.
// 'defer' make it possible to run the script when the dom loaded.
const script = document.createElement('script');
script.setAttribute('src', `/assets/${window.appType}.${ver}.js`);
script.setAttribute('src', `/assets/${app}.${ver}.js`);
script.setAttribute('async', 'true');
script.setAttribute('defer', 'true');
head.appendChild(script);