mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 09:46:28 +08:00
bug fixes
This commit is contained in:
11 files changed
+45
-19
No files matched your search
@@ -59,7 +59,7 @@ const session: Session = {
|
||||
},
|
||||
};
|
||||
|
||||
export async function* apply(ctx: HydroContext) {
|
||||
export async function apply(ctx: HydroContext) {
|
||||
ctx.inject(['check'], (c) => {
|
||||
c.check.addChecker('Judge', async (_ctx, log, warn, error) => {
|
||||
await versionCheck(warn, error);
|
||||
@@ -75,9 +75,7 @@ export async function* apply(ctx: HydroContext) {
|
||||
}
|
||||
await (new JudgeTask(session, JSON.parse(JSON.stringify(Object.assign(rdoc, t))))).handle().catch(logger.error);
|
||||
};
|
||||
const parallelism = Math.max(getConfig('parallelism'), 2);
|
||||
const taskConsumer = TaskModel.consume({ type: 'judge' }, handle, true, parallelism);
|
||||
yield () => taskConsumer.destroy();
|
||||
const parallelism = getConfig('parallelism');
|
||||
async function collectInfo() {
|
||||
const coll = db.collection('status');
|
||||
const compilers = await compilerVersions(langs);
|
||||
@@ -93,11 +91,20 @@ export async function* apply(ctx: HydroContext) {
|
||||
{ upsert: true },
|
||||
);
|
||||
}
|
||||
yield ctx.on('system/setting', () => {
|
||||
taskConsumer.setConcurrency(Math.max(getConfig('parallelism'), 2));
|
||||
collectInfo();
|
||||
ctx.effect(() => {
|
||||
const taskConsumer = TaskModel.consume({ type: 'judge' }, handle, true, parallelism);
|
||||
const dispose = ctx.on('system/setting', () => {
|
||||
taskConsumer.setConcurrency(getConfig('parallelism'));
|
||||
collectInfo();
|
||||
});
|
||||
return () => {
|
||||
taskConsumer.destroy();
|
||||
dispose();
|
||||
};
|
||||
});
|
||||
ctx.effect(() => {
|
||||
const generateConsumer = TaskModel.consume({ type: 'generate' }, handle);
|
||||
return () => generateConsumer.destroy();
|
||||
});
|
||||
collectInfo();
|
||||
const generateConsumer = TaskModel.consume({ type: 'generate' }, handle);
|
||||
yield () => generateConsumer.destroy();
|
||||
}
|
||||
@@ -2,7 +2,6 @@
|
||||
/* eslint-disable no-await-in-loop */
|
||||
import '../lib/index';
|
||||
|
||||
import os from 'os';
|
||||
import path from 'path';
|
||||
import fs from 'fs-extra';
|
||||
import yaml from 'js-yaml';
|
||||
|
||||
@@ -181,7 +181,6 @@ export class HomeHandler extends Handler {
|
||||
class HomeSecurityHandler extends Handler {
|
||||
@requireSudo
|
||||
async get() {
|
||||
const geoip = this.ctx.get('geoip');
|
||||
// TODO(iceboy): pagination? or limit session count for uid?
|
||||
const sessions = await token.getSessionListByUid(this.user._id);
|
||||
for (const session of sessions) {
|
||||
@@ -189,7 +188,7 @@ class HomeSecurityHandler extends Handler {
|
||||
session._id = md5(session._id);
|
||||
const ua = session.updateUa || session.createUa;
|
||||
if (ua) session.updateUaInfo = UAParser(ua);
|
||||
session.updateGeoip = geoip?.lookup?.(
|
||||
session.updateGeoip = this.ctx.geoip?.lookup?.(
|
||||
session.updateIp || session.createIp,
|
||||
this.translate('geoip_locale'),
|
||||
);
|
||||
@@ -202,7 +201,7 @@ class HomeSecurityHandler extends Handler {
|
||||
'credentialID', 'name', 'credentialType', 'credentialDeviceType',
|
||||
'authenticatorAttachment', 'regat', 'fmt',
|
||||
])),
|
||||
geoipProvider: geoip?.provider,
|
||||
geoipProvider: this.ctx.geoip?.provider,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -610,6 +609,7 @@ class HomeMessagesConnectionHandler extends ConnectionHandler {
|
||||
}
|
||||
}
|
||||
|
||||
export const inject = { geoip: { required: false } };
|
||||
export function apply(ctx: Context) {
|
||||
ctx.Route('homepage', '/', HomeHandler);
|
||||
ctx.Route('home_security', '/home/security', HomeSecurityHandler, PRIV.PRIV_USER_PROFILE);
|
||||
|
||||
@@ -16,6 +16,7 @@ declare module '../service/bus' {
|
||||
class I18nService extends Service {
|
||||
constructor(ctx: Context) {
|
||||
super(ctx, 'i18n');
|
||||
this.translate = this.translate.bind(this);
|
||||
this.load('ja', { __flag: '🇯🇵', __id: 'ja', __langname: '日本語' });
|
||||
}
|
||||
|
||||
|
||||
@@ -304,6 +304,7 @@ export default async function (env: { watch?: boolean, production?: boolean, mea
|
||||
}),
|
||||
new webpack.NormalModuleReplacementPlugin(/\/(vscode-)?nls\.js/, require.resolve('../../components/monaco/nls')),
|
||||
new webpack.NormalModuleReplacementPlugin(/^prettier[$/]/, root('../../modules/nop.ts')),
|
||||
new webpack.NormalModuleReplacementPlugin(/^highlightjs[$/]/, root('../../modules/nop.ts')),
|
||||
new webpack.NormalModuleReplacementPlugin(/core-js\/stable/, root('__core-js.js')),
|
||||
new MonacoWebpackPlugin({
|
||||
filename: '[name].[hash:6].worker.js',
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
.decoration-hide
|
||||
color: grey !important
|
||||
background-color: grey !important
|
||||
|
||||
.md-editor-preview code
|
||||
background-color: unset !important
|
||||
color: unset !important
|
||||
|
||||
.md-editor-scrn pre.syntax-hl code
|
||||
padding-left: unset !important
|
||||
@@ -1,4 +1,5 @@
|
||||
import $ from 'jquery';
|
||||
import { debounce } from 'lodash';
|
||||
import { nanoid } from 'nanoid';
|
||||
import React from 'react';
|
||||
import ReactDOM from 'react-dom/client';
|
||||
@@ -156,8 +157,12 @@ export default class Editor extends DOMAttachedObject {
|
||||
const { onChange } = this.options;
|
||||
const { MdEditor } = await import('./mdeditor');
|
||||
|
||||
const debouncedTrigger = debounce(() => {
|
||||
$(document.querySelector('.md-editor-preview')).trigger('vjContentNew');
|
||||
}, 500, { trailing: true });
|
||||
const renderCallback = (ref) => {
|
||||
this.markdownEditor = ref;
|
||||
setTimeout(debouncedTrigger, 200);
|
||||
};
|
||||
|
||||
function EditorComponent() {
|
||||
@@ -169,10 +174,12 @@ export default class Editor extends DOMAttachedObject {
|
||||
codeTheme='github'
|
||||
codeStyleReverse={false}
|
||||
ref={renderCallback}
|
||||
modelValue={val}
|
||||
value={val}
|
||||
theme={getTheme()}
|
||||
noMermaid
|
||||
noPrettier
|
||||
noKatex
|
||||
noHighlight
|
||||
autoDetectCode
|
||||
toolbarsExclude={[
|
||||
// 'bold',
|
||||
@@ -214,6 +221,7 @@ export default class Editor extends DOMAttachedObject {
|
||||
$dom.val(v);
|
||||
$dom.text(v);
|
||||
onChange?.(v);
|
||||
setTimeout(debouncedTrigger, 100);
|
||||
}}
|
||||
onUploadImg={async (files, callback) => {
|
||||
let ext: string;
|
||||
|
||||
@@ -7,6 +7,7 @@ import MergeCells from 'markdown-it-merge-cells';
|
||||
import TOC from 'markdown-it-table-of-contents';
|
||||
import { config, MdEditor } from 'md-editor-rt';
|
||||
import Imsize from '../../backendlib/markdown-it-imsize';
|
||||
import katex from '../../backendlib/markdown-it-katex';
|
||||
import { Media } from '../../backendlib/markdown-it-media';
|
||||
import { xssProtector } from '../../backendlib/markdown-it-xss';
|
||||
|
||||
@@ -28,6 +29,7 @@ config({
|
||||
mdit.use(TOC);
|
||||
mdit.use(MergeCells);
|
||||
mdit.use(xssProtector);
|
||||
mdit.use(katex);
|
||||
if (isProblemPage) {
|
||||
mdit.core.ruler.before('normalize', 'xss', (state) => {
|
||||
state.src = state.src.replace(/file:\/\//g, pagename === 'problem_create' ? `/file/${UserContext._id}/` : './file/');
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
label:'Difficulty',
|
||||
help_text:'From 1-10',
|
||||
name:'difficulty',
|
||||
value:pdoc['difficulty']
|
||||
value:pdoc['difficulty'] or ''
|
||||
}) }}
|
||||
</div>
|
||||
<div class="section__tab-container nojs--hide">
|
||||
|
||||
Reference in new issue
Block a user