contest list.
This commit is contained in:
@@ -70,32 +70,26 @@ export const JUDGE_STATUS: {
|
||||
},
|
||||
}
|
||||
|
||||
export const CONTEST_STATUS = {
|
||||
NOT_START: "1",
|
||||
UNDERWAY: "0",
|
||||
ENDED: "-1",
|
||||
}
|
||||
|
||||
export const CONTEST_STATUS_REVERSE = {
|
||||
export const CONTEST_STATUS: {
|
||||
[key in "1" | "-1" | "0"]: {
|
||||
name: string
|
||||
type: "error" | "success" | "warning"
|
||||
}
|
||||
} = {
|
||||
"1": {
|
||||
name: "Not Started",
|
||||
color: "yellow",
|
||||
name: "未开始",
|
||||
type: "warning",
|
||||
},
|
||||
"0": {
|
||||
name: "Underway",
|
||||
color: "green",
|
||||
name: "进行中",
|
||||
type: "success",
|
||||
},
|
||||
"-1": {
|
||||
name: "Ended",
|
||||
color: "red",
|
||||
name: "已结束",
|
||||
type: "error",
|
||||
},
|
||||
}
|
||||
|
||||
export const RULE_TYPE = {
|
||||
ACM: "ACM",
|
||||
OI: "OI",
|
||||
}
|
||||
|
||||
export const CONTEST_TYPE = {
|
||||
PUBLIC: "Public",
|
||||
PRIVATE: "Password Protected",
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { intervalToDuration } from "date-fns"
|
||||
import { STORAGE_KEY } from "./constants"
|
||||
|
||||
export function getACRate(acCount: number, totalCount: number) {
|
||||
@@ -40,6 +41,30 @@ export function parseTime(utc: Date, format = "YYYY年M月D日") {
|
||||
return time.value
|
||||
}
|
||||
|
||||
export function duration(start: Date, end: Date): string {
|
||||
const duration = intervalToDuration({
|
||||
start: Date.parse(start.toString()),
|
||||
end: Date.parse(end.toString()),
|
||||
})
|
||||
let result = ""
|
||||
if (duration.years) {
|
||||
result += duration.years + "年"
|
||||
}
|
||||
if (duration.months) {
|
||||
result += duration.months + "月"
|
||||
}
|
||||
if (duration.days) {
|
||||
result += duration.days + "天"
|
||||
}
|
||||
if (duration.hours) {
|
||||
result += duration.hours + "小时"
|
||||
}
|
||||
if (duration.minutes) {
|
||||
result += duration.minutes + "分钟"
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
export function submissionMemoryFormat(memory: number | string | undefined) {
|
||||
if (memory === undefined) return "--"
|
||||
// 1048576 = 1024 * 1024
|
||||
|
||||
@@ -115,3 +115,59 @@ export interface SubmissionListPayload {
|
||||
limit: number
|
||||
offset: number
|
||||
}
|
||||
|
||||
export interface Rank {
|
||||
id: number
|
||||
user: {
|
||||
id: number
|
||||
username: string
|
||||
real_name: null
|
||||
}
|
||||
acm_problems_status: {
|
||||
problems: {
|
||||
[key: string]: {
|
||||
_id: string
|
||||
status: number
|
||||
}
|
||||
}
|
||||
contest_problems?: {
|
||||
[key: string]: {
|
||||
[key: string]: {
|
||||
_id: string
|
||||
status: number
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
oi_problems_status: {}
|
||||
real_name: null | string
|
||||
avatar: string
|
||||
blog: null
|
||||
mood: null | string
|
||||
github: null
|
||||
school: null | string
|
||||
major: null | string
|
||||
language: null | string
|
||||
accepted_number: number
|
||||
total_score: number
|
||||
submission_number: number
|
||||
}
|
||||
|
||||
export interface Contest {
|
||||
id: number
|
||||
created_by: {
|
||||
id: number
|
||||
username: string
|
||||
real_name: null
|
||||
}
|
||||
status: "-1" | "0" | "1"
|
||||
contest_type: "Password Protected" | "Public"
|
||||
title: string
|
||||
description: string
|
||||
real_time_rank: boolean
|
||||
rule_type: "ACM"
|
||||
start_time: Date
|
||||
end_time: Date
|
||||
create_time: Date
|
||||
last_update_time: Date
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user