ui: fix icon display

pull/388/head
undefined 2 years ago
parent baab7bb68c
commit 3edc425a52

@ -17,6 +17,8 @@ ignorePatterns:
- public/
- '*.spec.ts'
rules:
'@typescript-eslint/no-shadow': 1
function-call-argument-newline: 0
react/function-component-definition: 0
'@typescript-eslint/dot-notation': 0
@ -106,6 +108,7 @@ rules:
no-plusplus: 0
no-restricted-syntax: 0
no-return-await: 0
no-shadow: 0
no-underscore-dangle: 0
prefer-destructuring: 0
function-paren-newline: 0

@ -53,6 +53,8 @@ module.exports = {
'@typescript-eslint/no-implied-eval': 'off',
'@typescript-eslint/no-throw-literal': 'off',
'@typescript-eslint/return-await': 'off',
'@typescript-eslint/no-shadow': 'warn',
'no-shadow': 'off',
// FIXME A bug with eslint-parser
'template-curly-spacing': 'off',

@ -13,6 +13,7 @@ import problem from 'hydrooj/src/model/problem';
import * as setting from 'hydrooj/src/model/setting';
import esbuild from 'esbuild';
import { tmpdir } from 'os';
import { UiContextBase } from 'hydrooj/src/service/layers/base';
import markdown from './backendlib/markdown';
declare module 'hydrooj/src/interface' {
@ -24,6 +25,13 @@ declare module 'hydrooj/src/interface' {
'ui-default.nav_logo_dark_2x': string;
}
}
declare module 'hydrooj/src/service/layers/base' {
interface UiContextBase {
nav_logo_dark: string;
nav_logo_dark_2x: string;
constantVersion: string;
}
}
let constant = '';
let hash = '';
@ -46,27 +54,18 @@ async function run() {
if (build.errors.length) console.error(build.errors);
if (build.warnings.length) console.warn(build.warnings);
const pages = build.outputFiles.map((i) => i.text);
const payload = [...pages];
const [logo, logo2x] = system.getMany([
'ui-default.nav_logo_dark', 'ui-default.nav_logo_dark_2x',
]);
const res = [];
res.push(`window.LANGS=${JSON.stringify(setting.langs)};`);
if (logo) res.push(`UiContext.nav_logo_dark="${logo}";`);
if (logo2x) res.push(`UiContext.nav_logo_dark_2x="${logo2x}";`);
payload.unshift(res.join('\n'));
const payload = [`window.LANGS=${JSON.stringify(setting.langs)};`, ...pages];
const c = crypto.createHash('sha1');
c.update(JSON.stringify(payload));
const version = c.digest('hex');
constant = JSON.stringify(payload);
hash = version;
UiContextBase.constantVersion = hash = version;
[UiContextBase.nav_logo_dark, UiContextBase.nav_logo_dark_2x] = system.getMany([
'ui-default.nav_logo_dark', 'ui-default.nav_logo_dark_2x',
]);
}
const versionHandler = (that) => {
that.UiContext.constantVersion = hash;
};
bus.on('handler/after', versionHandler);
bus.on('handler/error', versionHandler);
bus.on('app/started', run);
bus.on('system/setting', run);

Loading…
Cancel
Save