mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
ui: fix icon display
This commit is contained in:
1 parent
baab7bb68c
commit
3edc425a52
3 files changed
+19
-15
No files matched your search
@@ -17,6 +17,8 @@ ignorePatterns:
|
|||||||
- public/
|
- public/
|
||||||
- '*.spec.ts'
|
- '*.spec.ts'
|
||||||
rules:
|
rules:
|
||||||
|
'@typescript-eslint/no-shadow': 1
|
||||||
|
|
||||||
function-call-argument-newline: 0
|
function-call-argument-newline: 0
|
||||||
react/function-component-definition: 0
|
react/function-component-definition: 0
|
||||||
'@typescript-eslint/dot-notation': 0
|
'@typescript-eslint/dot-notation': 0
|
||||||
@@ -106,6 +108,7 @@ rules:
|
|||||||
no-plusplus: 0
|
no-plusplus: 0
|
||||||
no-restricted-syntax: 0
|
no-restricted-syntax: 0
|
||||||
no-return-await: 0
|
no-return-await: 0
|
||||||
|
no-shadow: 0
|
||||||
no-underscore-dangle: 0
|
no-underscore-dangle: 0
|
||||||
prefer-destructuring: 0
|
prefer-destructuring: 0
|
||||||
function-paren-newline: 0
|
function-paren-newline: 0
|
||||||
|
|||||||
@@ -53,6 +53,8 @@ module.exports = {
|
|||||||
'@typescript-eslint/no-implied-eval': 'off',
|
'@typescript-eslint/no-implied-eval': 'off',
|
||||||
'@typescript-eslint/no-throw-literal': 'off',
|
'@typescript-eslint/no-throw-literal': 'off',
|
||||||
'@typescript-eslint/return-await': 'off',
|
'@typescript-eslint/return-await': 'off',
|
||||||
|
'@typescript-eslint/no-shadow': 'warn',
|
||||||
|
'no-shadow': 'off',
|
||||||
|
|
||||||
// FIXME A bug with eslint-parser
|
// FIXME A bug with eslint-parser
|
||||||
'template-curly-spacing': 'off',
|
'template-curly-spacing': 'off',
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import problem from 'hydrooj/src/model/problem';
|
|||||||
import * as setting from 'hydrooj/src/model/setting';
|
import * as setting from 'hydrooj/src/model/setting';
|
||||||
import esbuild from 'esbuild';
|
import esbuild from 'esbuild';
|
||||||
import { tmpdir } from 'os';
|
import { tmpdir } from 'os';
|
||||||
|
import { UiContextBase } from 'hydrooj/src/service/layers/base';
|
||||||
import markdown from './backendlib/markdown';
|
import markdown from './backendlib/markdown';
|
||||||
|
|
||||||
declare module 'hydrooj/src/interface' {
|
declare module 'hydrooj/src/interface' {
|
||||||
@@ -24,6 +25,13 @@ declare module 'hydrooj/src/interface' {
|
|||||||
'ui-default.nav_logo_dark_2x': string;
|
'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 constant = '';
|
||||||
let hash = '';
|
let hash = '';
|
||||||
@@ -46,27 +54,18 @@ async function run() {
|
|||||||
if (build.errors.length) console.error(build.errors);
|
if (build.errors.length) console.error(build.errors);
|
||||||
if (build.warnings.length) console.warn(build.warnings);
|
if (build.warnings.length) console.warn(build.warnings);
|
||||||
const pages = build.outputFiles.map((i) => i.text);
|
const pages = build.outputFiles.map((i) => i.text);
|
||||||
const payload = [...pages];
|
const payload = [`window.LANGS=${JSON.stringify(setting.langs)};`, ...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 c = crypto.createHash('sha1');
|
const c = crypto.createHash('sha1');
|
||||||
c.update(JSON.stringify(payload));
|
c.update(JSON.stringify(payload));
|
||||||
const version = c.digest('hex');
|
const version = c.digest('hex');
|
||||||
constant = JSON.stringify(payload);
|
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('app/started', run);
|
||||||
bus.on('system/setting', run);
|
bus.on('system/setting', run);
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user