This commit is contained in:
undefined committed 2021-04-23 22:19:05 +08:00
1 parent fa4b7b6f33
commit 3383f5529b
10 files changed
+35 -22

No files matched your search

+1 -1
View File
@@ -77,7 +77,7 @@ class FpsProblemImportHandler extends Handler {
const content = buf.toString(); const content = buf.toString();
const result = await xml2js.parseStringPromise(content); const result = await xml2js.parseStringPromise(content);
tasks.push(result); tasks.push(result);
} catch { } // eslint-disable-line no-empty } catch { }
} }
} }
if (!tasks.length) throw new ValidationError('file'); if (!tasks.length) throw new ValidationError('file');
+2 -2
View File
@@ -217,7 +217,7 @@ class DiscussionDetailHandler extends DiscussionHandler {
const replies: Drdoc[] = await discussion.getMultiReply(domainId, did).toArray(); const replies: Drdoc[] = await discussion.getMultiReply(domainId, did).toArray();
const uids = new Set(replies.map((drdoc) => drdoc.owner)); const uids = new Set(replies.map((drdoc) => drdoc.owner));
uids.delete(this.user._id); uids.delete(this.user._id);
const str = JSON.stringify({ message: '{0} replied to discussion {1}{2}.', params: [this.user._id, domainId, did] }); const str = JSON.stringify({ message: '{0} replied to discussion {1}/{2}.', params: [this.user._id, domainId, did] });
const tasks = Array.from(uids).map((uid) => message.send(1, uid, str)); const tasks = Array.from(uids).map((uid) => message.send(1, uid, str));
await Promise.all(tasks); await Promise.all(tasks);
this.back(); this.back();
@@ -229,7 +229,7 @@ class DiscussionDetailHandler extends DiscussionHandler {
this.checkPerm(PERM.PERM_REPLY_DISCUSSION); this.checkPerm(PERM.PERM_REPLY_DISCUSSION);
await this.limitRate('add_discussion', 3600, 60); await this.limitRate('add_discussion', 3600, 60);
await discussion.addTailReply(domainId, drid, this.user._id, content, this.request.ip); await discussion.addTailReply(domainId, drid, this.user._id, content, this.request.ip);
const str = JSON.stringify({ message: '{0} replied to discussion reply {1}{2}.', params: [this.user._id, domainId, drid] }); const str = JSON.stringify({ message: '{0} replied to discussion reply {1}/{2}.', params: [this.user._id, domainId, drid] });
if (this.drdoc.owner !== this.user._id) await message.send(1, this.drdoc.owner, str); if (this.drdoc.owner !== this.user._id) await message.send(1, this.drdoc.owner, str);
this.back(); this.back();
} }
-1
View File
@@ -1,4 +1,3 @@
/* eslint-disable no-empty */
import { ValidationError } from '../error'; import { ValidationError } from '../error';
const RE_UID = /^-?\d+$/i; const RE_UID = /^-?\d+$/i;
+1
View File
@@ -71,6 +71,7 @@ module.exports = {
'import/first': 'off', 'import/first': 'off',
'import/no-extraneous-dependencies': 'off', 'import/no-extraneous-dependencies': 'off',
'max-classes-per-file': 'off', 'max-classes-per-file': 'off',
'no-empty': ['warn', { allowEmptyCatch: true }],
'no-unused-vars': 'warn', 'no-unused-vars': 'warn',
'no-console': 'off', 'no-console': 'off',
'no-continue': 'off', 'no-continue': 'off',
+1 -1
View File
@@ -35,7 +35,7 @@ class Markdown extends MarkdownIt {
if (lang && Prism.languages[lang]) { if (lang && Prism.languages[lang]) {
try { try {
return Prism.highlight(str, Prism.languages[lang], lang); return Prism.highlight(str, Prism.languages[lang], lang);
} catch (__) { } // eslint-disable-line no-empty } catch (__) { }
} }
return ''; return '';
}, },
@@ -5,7 +5,6 @@ import TimeAgo from 'timeago-react';
import moment from 'moment'; import moment from 'moment';
import 'jquery-scroll-lock'; import 'jquery-scroll-lock';
import 'jquery.easing'; import 'jquery.easing';
import i18n from 'vj/utils/i18n'; import i18n from 'vj/utils/i18n';
import { parse as parseMongoId } from 'vj/utils/mongoId'; import { parse as parseMongoId } from 'vj/utils/mongoId';
import Message from './MessageComponent'; import Message from './MessageComponent';
@@ -17,7 +16,7 @@ const mapStateToProps = (state) => ({
: null, : null,
}); });
export default connect(mapStateToProps, null)(class MessagePadDialogueContentContainer extends React.PureComponent { export default connect(mapStateToProps)(class MessagePadDialogueContentContainer extends React.PureComponent {
componentDidMount() { componentDidMount() {
$(this.refs.list).scrollLock({ strict: true }); $(this.refs.list).scrollLock({ strict: true });
} }
@@ -42,23 +41,33 @@ export default connect(mapStateToProps, null)(class MessagePadDialogueContentCon
} }
} }
renderInner() { renderContent(msg) {
if (this.props.activeId === null) { if (msg.from === 1) {
return []; // Is system message
try {
const data = JSON.parse(msg.content);
return i18n(data.message, ...data.params);
} catch (e) { }
return i18n(msg.content);
} }
return _.map(this.props.item.messages, (reply) => ( return msg.content;
}
renderInner() {
if (this.props.activeId === null) return [];
return _.map(this.props.item.messages, (msg) => (
<Message <Message
key={reply._id} key={msg._id}
isSelf={reply.from === UserContext._id} isSelf={msg.from === UserContext._id}
faceUrl={ faceUrl={
reply.from === UserContext._id msg.from === UserContext._id
? UserContext.avatarUrl ? UserContext.avatarUrl
: this.props.item.udoc.avatarUrl : this.props.item.udoc.avatarUrl
} }
> >
<div>{reply.content}</div> <div>{this.renderContent(msg)}</div>
<time data-tooltip={moment(parseMongoId(reply._id).timestamp * 1000).format('YYYY-MM-DD HH:mm:ss')}> <time data-tooltip={moment(parseMongoId(msg._id).timestamp * 1000).format('YYYY-MM-DD HH:mm:ss')}>
<TimeAgo datetime={parseMongoId(reply._id).timestamp * 1000} locale={i18n('timeago_locale')} /> <TimeAgo datetime={parseMongoId(msg._id).timestamp * 1000} locale={i18n('timeago_locale')} />
</time> </time>
</Message> </Message>
)); ));
@@ -1,11 +1,14 @@
import React from 'react'; import React from 'react';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import AnsiUp from 'ansi_up';
import i18n from 'vj/utils/i18n'; import i18n from 'vj/utils/i18n';
import Icon from 'vj/components/react/IconComponent'; import Icon from 'vj/components/react/IconComponent';
import Panel from './PanelComponent'; import Panel from './PanelComponent';
import DataInput from './DataInputComponent'; import DataInput from './DataInputComponent';
const AU = new AnsiUp();
const mapStateToProps = (state) => ({ const mapStateToProps = (state) => ({
input: state.pretest.input, input: state.pretest.input,
output: state.pretest.output, output: state.pretest.output,
@@ -44,7 +47,7 @@ export default connect(mapStateToProps, mapDispatchToProps)(class ScratchpadPret
/> />
<DataInput <DataInput
title={i18n('Output')} title={i18n('Output')}
value={this.props.output} value={AU.ansi_to_html(this.props.output)}
html html
/> />
</div> </div>
+3 -2
View File
@@ -1,9 +1,10 @@
{ {
"exclude": [ "exclude": [
"node_modules" "./node_modules",
"./public",
"../../node_modules"
], ],
"compilerOptions": { "compilerOptions": {
"experimentalDecorators": true,
"allowSyntheticDefaultImports": true, "allowSyntheticDefaultImports": true,
"target": "ES6", "target": "ES6",
"baseUrl": ".", "baseUrl": ".",
+2 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "@hydrooj/ui-default", "name": "@hydrooj/ui-default",
"version": "4.6.12", "version": "4.6.13",
"author": "undefined <i@undefined.moe>", "author": "undefined <i@undefined.moe>",
"license": "AGPL-3.0", "license": "AGPL-3.0",
"main": "hydro.js", "main": "hydro.js",
@@ -23,6 +23,7 @@
"@babel/register": "^7.13.14", "@babel/register": "^7.13.14",
"@babel/runtime-corejs2": "^7.13.10", "@babel/runtime-corejs2": "^7.13.10",
"@hydrooj/utils": "^1.0.7", "@hydrooj/utils": "^1.0.7",
"ansi_up": "^5.0.1",
"autoprefixer": "^9.8.6", "autoprefixer": "^9.8.6",
"babel-loader": "^8.2.2", "babel-loader": "^8.2.2",
"babel-plugin-lodash": "^3.3.4", "babel-plugin-lodash": "^3.3.4",
@@ -229,7 +229,6 @@ const page = new NamedPage(['problem_detail', 'contest_detail_problem', 'homewor
$('.problem-content').get(0), $('.problem-content').get(0),
); );
$('.outer-loader-container').hide(); $('.outer-loader-container').hide();
// eslint-disable-next-line no-empty
} catch (e) { } } catch (e) { }
} }