vjudge: better vedict

This commit is contained in:
undefined committed 2025-09-28 16:13:32 +08:00
1 parent 40b933e436
commit 186fcf0f34
2 files changed
+10 -5

No files matched your search

+2 -2
View File
@@ -44,10 +44,10 @@ export class BasicFetcher {
return $dom.window as DOMWindow & { html: string, headers: any };
}
post(url: string) {
post(url: string, type = this.formType) {
this.logger.debug('post', url, this.cookie);
url = new URL(url, this.endpoint).toString();
let req = superagent.post(url).set('Cookie', this.cookie).set('User-Agent', this.UA).type(this.formType);
let req = superagent.post(url).set('Cookie', this.cookie).set('User-Agent', this.UA).type(type);
if (this.fetchOptions.headers) req = req.set(this.fetchOptions.headers);
if (this.fetchOptions.post?.headers) req = req.set(this.fetchOptions.post.headers);
return this.account.proxy ? req.proxy(this.account.proxy) : req;
+8 -3
View File
@@ -1,10 +1,15 @@
import { STATUS } from '@hydrooj/common';
export function normalize(key: string) {
return key.toUpperCase().replace(/ /g, '_');
return key.toUpperCase().replace(/ _-/g, '');
}
export const VERDICT = new Proxy<Record<string, STATUS>>({
function removeSlash(src: Record<string, STATUS>) {
for (const key in Object.keys(src)) src[key.replace(/_/g, '')] = src[key];
return src;
}
export const VERDICT = new Proxy<Record<string, STATUS>>(removeSlash({
RUNTIME_ERROR: STATUS.STATUS_RUNTIME_ERROR,
WRONG_ANSWER: STATUS.STATUS_WRONG_ANSWER,
OK: STATUS.STATUS_ACCEPTED,
@@ -75,7 +80,7 @@ export const VERDICT = new Proxy<Record<string, STATUS>>({
SYSTEM_ERROR: STATUS.STATUS_SYSTEM_ERROR,
SE: STATUS.STATUS_SYSTEM_ERROR,
未知错误: STATUS.STATUS_SYSTEM_ERROR,
}, {
}), {
get(self, key) {
if (typeof key === 'symbol') return null;
key = normalize(key);