You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
866 B
TypeScript
29 lines
866 B
TypeScript
2 years ago
|
import { AutoloadPage } from 'vj/misc/Page';
|
||
|
import i18n from 'vj/utils/i18n';
|
||
|
import tpl from 'vj/utils/tpl';
|
||
|
import { InfoDialog } from './dialog';
|
||
|
|
||
|
function isSupported() {
|
||
|
try {
|
||
|
if (!navigator.userAgent.includes('Chrome/')) return false;
|
||
|
const ver = +navigator.userAgent.split('Chrome/')[1].split('.')[0];
|
||
|
if (!Number.isSafeInteger(ver)) return false;
|
||
|
if (ver < 80) return false;
|
||
|
return true;
|
||
|
} catch (e) {
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
export default new AutoloadPage('browser-update', () => {
|
||
|
if (UserContext.priv !== -1) return; // Only warn superadmins
|
||
|
if (sessionStorage.getItem('su-browser-warn')) return;
|
||
|
const key = 'warn::admin:unsupportedbrowser';
|
||
|
if (!isSupported() && i18n(key) !== key) {
|
||
|
new InfoDialog({
|
||
|
$body: tpl.typoMsg(i18n(key)),
|
||
|
}).open();
|
||
|
sessionStorage.setItem('su-browser-warn', 'on');
|
||
|
}
|
||
|
});
|