mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
vjudge: better vedict
This commit is contained in:
2 files changed
+10
-5
No files matched your search
@@ -44,10 +44,10 @@ export class BasicFetcher {
|
|||||||
return $dom.window as DOMWindow & { html: string, headers: any };
|
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);
|
this.logger.debug('post', url, this.cookie);
|
||||||
url = new URL(url, this.endpoint).toString();
|
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.headers) req = req.set(this.fetchOptions.headers);
|
||||||
if (this.fetchOptions.post?.headers) req = req.set(this.fetchOptions.post.headers);
|
if (this.fetchOptions.post?.headers) req = req.set(this.fetchOptions.post.headers);
|
||||||
return this.account.proxy ? req.proxy(this.account.proxy) : req;
|
return this.account.proxy ? req.proxy(this.account.proxy) : req;
|
||||||
|
|||||||
@@ -1,10 +1,15 @@
|
|||||||
import { STATUS } from '@hydrooj/common';
|
import { STATUS } from '@hydrooj/common';
|
||||||
|
|
||||||
export function normalize(key: string) {
|
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,
|
RUNTIME_ERROR: STATUS.STATUS_RUNTIME_ERROR,
|
||||||
WRONG_ANSWER: STATUS.STATUS_WRONG_ANSWER,
|
WRONG_ANSWER: STATUS.STATUS_WRONG_ANSWER,
|
||||||
OK: STATUS.STATUS_ACCEPTED,
|
OK: STATUS.STATUS_ACCEPTED,
|
||||||
@@ -75,7 +80,7 @@ export const VERDICT = new Proxy<Record<string, STATUS>>({
|
|||||||
SYSTEM_ERROR: STATUS.STATUS_SYSTEM_ERROR,
|
SYSTEM_ERROR: STATUS.STATUS_SYSTEM_ERROR,
|
||||||
SE: STATUS.STATUS_SYSTEM_ERROR,
|
SE: STATUS.STATUS_SYSTEM_ERROR,
|
||||||
未知错误: STATUS.STATUS_SYSTEM_ERROR,
|
未知错误: STATUS.STATUS_SYSTEM_ERROR,
|
||||||
}, {
|
}), {
|
||||||
get(self, key) {
|
get(self, key) {
|
||||||
if (typeof key === 'symbol') return null;
|
if (typeof key === 'symbol') return null;
|
||||||
key = normalize(key);
|
key = normalize(key);
|
||||||
|
|||||||
Reference in new issue
Block a user