ui: build enhancement

This commit is contained in:
undefined committed 2022-02-13 23:25:11 +08:00
1 parent af994325b5
commit 773cc34b6e
7 files changed
+43 -7

No files matched your search

+4 -2
View File
@@ -15,7 +15,6 @@ import mapWebpackUrlPrefix from '../utils/mapWebpackUrlPrefix';
import root from '../utils/root';
const beautifyOutputUrl = mapWebpackUrlPrefix([
{ prefix: 'node_modules/katex/dist/', replace: './katex/' },
{ prefix: 'misc/.iconfont', replace: './ui/iconfont' },
]);
const smp = new SpeedMeasurePlugin();
@@ -53,8 +52,11 @@ export default function (env = {}) {
name(resourcePath) {
if (resourcePath.includes('node_modules')) {
const extra = resourcePath.split('node_modules')[1];
const moduleName = extra.split('/')[0];
if (['katex', 'monaco-editor'].includes(moduleName)) return `modules/${moduleName}/[name].[ext]?[contenthash]`;
return `modules/${extra.substr(1, extra.length - 1).replace(/\\/g, '/')}?[contenthash]`;
}
if (resourcePath.includes('misc/.iconfont')) return 'modules/icon/[name].[ext]?[contenthash]';
return '[path][name].[ext]?[contenthash]';
},
},
@@ -197,7 +199,7 @@ export default function (env = {}) {
new CopyWebpackPlugin({
patterns: [
{ from: root('static') },
{ from: root(`${dirname(require.resolve('vditor/package.json'))}`), to: 'vditor/' },
{ from: root(`${dirname(require.resolve('vditor/package.json'))}/dist`), to: 'vditor/dist' },
{ from: `${dirname(require.resolve('monaco-themes/package.json'))}/themes`, to: 'monaco/themes/' },
{ from: root('.build/sharedworker.js'), to: 'sharedworker.js' },
],
@@ -25,7 +25,8 @@ export default connect(mapStateToProps, mapDispatchToProps)(class MonacoEditor e
const { language } = this.props;
const { load } = await import('vj/components/monaco/loader');
const { monaco, registerAction, customOptions } = await load([language]);
this.model = monaco.editor.createModel(value, language, monaco.Uri.parse(`file:///${UiContext.pdoc.pid || UiContext.pdoc.docId}.${language}`));
const uri = monaco.Uri.parse(`hydro://${UiContext.pdoc.pid || UiContext.pdoc.docId}.${language}`);
this.model = monaco.editor.createModel(value, language, uri);
if (this.containerElement) {
/** @type {monaco.editor.IStandaloneEditorConstructionOptions} */
const config = {
@@ -12,11 +12,13 @@ padding: 8px 0px; box-shadow: rgba(0, 0, 0, 0.1) 0px 4px 8px;" id="disconnect_no
const $el = $(notification);
$el.appendTo('body');
$el.hide();
function create() {
$el.show();
$el.animate({ bottom: 0 }, 100);
}
function remove() {
$el.animate({ bottom: -100 }, 100);
$el.animate({ bottom: -100 }, 100, () => $el.remove());
}
export default class Sock {
+1 -1
View File
@@ -215,7 +215,7 @@ Difficulty by algorithm: 알고리즘 난이도
Difficulty displayed: 난이도 표시
Difficulty: 난이도
Disabled: 비활성
Disconnected from the server. Reconnecting...: 서버 연결이 끊어졌습니다. 재시도 중입니다...
Disconnected from the server. trying to reconnect...: 서버 연결이 끊어졌습니다. 재시도 중입니다...
Discussion {1} not found.: 토론 {1}이(가) 없습니다.
Discussion category {1} already exists.: 토론 분류 {1}이(가) 이미 존재합니다.
Discussion category {1} not found.: 토론 분류 {1}을(를) 찾을 수 없습니다.
+1 -1
View File
@@ -226,7 +226,7 @@ Difficulty by algorithm: 算法计算的难度
Difficulty displayed: 显示的难度
Difficulty: 难度
Disabled: 关闭
Disconnected from the server. Reconnecting...: 到服务器的连接断开。正在重新连接...
Disconnected from the server. trying to reconnect...: 到服务器的连接断开。正在重新连接...
Discussion {1} not found.: 讨论 {1} 不存在。
Discussion category {1} already exists.: 讨论分类 {1} 已经存在。
Discussion category {1} not found.: 讨论分类 {1} 不存在。
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@hydrooj/ui-default",
"version": "4.31.17",
"version": "4.31.18",
"author": "undefined <i@undefined.moe>",
"license": "AGPL-3.0",
"main": "hydro.js",
+31
View File
@@ -0,0 +1,31 @@
const base = 'https://hydro.ac';
const target = [
'https://hydro.ac',
'https://us.hydro.ac',
'https://proxy1.hydro.workers.dev',
];
this.addEventListener('install', () => {
console.log('Service Worker installing');
});
async function get(url) {
let current = 0;
let response;
while (target[current]) {
response = fetch(url.replace(base, target[current]));
try {
await response;
if (current) console.log('From ', target[current]);
return response;
} catch (error) {
console.warn(target[current], ' Load fail ', error);
current++;
}
}
return response;
}
this.addEventListener('fetch', (event) => {
// eslint-disable-next-line no-restricted-globals
if (new URL(event.request.url).origin !== location.origin) return;
event.respondWith(get(event.request.url));
});