refactor axios.

This commit is contained in:
2023-01-08 14:42:54 +08:00
parent 7bea386dbc
commit e306e6b463
16 changed files with 270 additions and 113 deletions

View File

@@ -196,8 +196,6 @@ export const LANGUAGE_LABEL = {
Golang: "Go",
}
export type LANGUAGE = keyof typeof LANGUAGE_LABEL
export const LANGUAGE_VALUE = {
C: "c",
"C++": "cpp",

View File

@@ -1,3 +1,4 @@
import { useDateFormat } from "@vueuse/core"
import { STORAGE_KEY } from "./constants"
export function getACRate(acCount: number, totalCount: number) {
@@ -32,3 +33,8 @@ export function getTagColor(tag: string) {
: "danger",
}[tag]
}
export function parseTime(utc: Date, format = "YYYY年M月D日") {
const time = useDateFormat(utc, format, { locales: "zh-CN" })
return time.value
}

51
src/utils/types.ts Normal file
View File

@@ -0,0 +1,51 @@
export type LANGUAGE =
| "C"
| "C++"
| "Python2"
| "Python3"
| "Java"
| "JavaScript"
| "Golang"
export interface Problem {
_id: string
id: number
tags: string[]
created_by: {
id: number
username: string
real_name: null
}
template: { [key in LANGUAGE]?: string }
title: string
description: string
input_description: string
output_description: string
samples: {
input: string
output: string
}[]
hint: string
languages: Array<LANGUAGE>
create_time: Date
last_update_time: null
time_limit: number
memory_limit: number
io_mode: {
input: string
output: string
io_mode: string
}
spj: boolean
spj_language: null
rule_type: string
difficulty: "Low" | "Mid" | "High"
source: string
total_score: number
submission_number: number
accepted_number: number
statistic_info: {}
share_submission: boolean
contest: null
my_status: number
}