mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
ui: add browser warning for superadmin
This commit is contained in:
1 parent
05f47e5515
commit
6acd1fed9f
4 files changed
+37
-10
No files matched your search
@@ -0,0 +1,28 @@
|
||||
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');
|
||||
}
|
||||
});
|
||||
Reference in new issue
Block a user