problem list.
This commit is contained in:
@@ -68,13 +68,13 @@ export const JUDGE_STATUS = {
|
||||
color: "yellow",
|
||||
type: "warning",
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
export const CONTEST_STATUS = {
|
||||
NOT_START: "1",
|
||||
UNDERWAY: "0",
|
||||
ENDED: "-1",
|
||||
};
|
||||
}
|
||||
|
||||
export const CONTEST_STATUS_REVERSE = {
|
||||
"1": {
|
||||
@@ -89,41 +89,41 @@ export const CONTEST_STATUS_REVERSE = {
|
||||
name: "Ended",
|
||||
color: "red",
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
export const RULE_TYPE = {
|
||||
ACM: "ACM",
|
||||
OI: "OI",
|
||||
};
|
||||
}
|
||||
|
||||
export const CONTEST_TYPE = {
|
||||
PUBLIC: "Public",
|
||||
PRIVATE: "Password Protected",
|
||||
};
|
||||
}
|
||||
|
||||
export const USER_TYPE = {
|
||||
REGULAR_USER: "Regular User",
|
||||
ADMIN: "Admin",
|
||||
SUPER_ADMIN: "Super Admin",
|
||||
};
|
||||
}
|
||||
|
||||
export const PROBLEM_PERMISSION = {
|
||||
NONE: "None",
|
||||
OWN: "Own",
|
||||
ALL: "All",
|
||||
};
|
||||
}
|
||||
|
||||
export const STORAGE_KEY = {
|
||||
AUTHED: "authed",
|
||||
PROBLEM_CODE: "problemCode",
|
||||
USER: "user",
|
||||
};
|
||||
}
|
||||
|
||||
export function buildProblemCodeKey(problemID: number, contestID = null) {
|
||||
if (contestID) {
|
||||
return `${STORAGE_KEY.PROBLEM_CODE}_${contestID}_${problemID}`;
|
||||
return `${STORAGE_KEY.PROBLEM_CODE}_${contestID}_${problemID}`
|
||||
}
|
||||
return `${STORAGE_KEY.PROBLEM_CODE}_NaN_${problemID}`;
|
||||
return `${STORAGE_KEY.PROBLEM_CODE}_NaN_${problemID}`
|
||||
}
|
||||
|
||||
export const GOOGLE_ANALYTICS_ID = "UA-111499601-1";
|
||||
export const GOOGLE_ANALYTICS_ID = "UA-111499601-1"
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
export function getACRate(acCount: number, totalCount: number) {
|
||||
let rate = totalCount === 0 ? 0.0 : ((acCount / totalCount) * 100).toFixed(2);
|
||||
return `${rate}%`;
|
||||
}
|
||||
|
||||
export function filterEmptyValue(object: any) {
|
||||
let query: any = {};
|
||||
Object.keys(object).forEach((key) => {
|
||||
if (object[key] || object[key] === 0 || object[key] === false) {
|
||||
query[key] = object[key];
|
||||
}
|
||||
});
|
||||
return query;
|
||||
}
|
||||
export function getACRate(acCount: number, totalCount: number) {
|
||||
let rate = totalCount === 0 ? 0.0 : ((acCount / totalCount) * 100).toFixed(2)
|
||||
return `${rate}%`
|
||||
}
|
||||
|
||||
export function filterEmptyValue(object: any) {
|
||||
let query: any = {}
|
||||
Object.keys(object).forEach((key) => {
|
||||
if (object[key] || object[key] === 0 || object[key] === false) {
|
||||
query[key] = object[key]
|
||||
}
|
||||
})
|
||||
return query
|
||||
}
|
||||
|
||||
@@ -1,26 +1,26 @@
|
||||
import axios from "axios";
|
||||
|
||||
const http = axios.create({
|
||||
baseURL: "/api",
|
||||
xsrfHeaderName: "X-CSRFToken",
|
||||
xsrfCookieName: "csrftoken",
|
||||
});
|
||||
|
||||
// TODO
|
||||
http.interceptors.response.use(
|
||||
(res) => {
|
||||
if (res.data.error) {
|
||||
// 若后端返回为登录,则为session失效,应退出当前登录用户
|
||||
if (res.data.data.startsWith("Please login")) {
|
||||
}
|
||||
return Promise.reject(res.data);
|
||||
} else {
|
||||
return Promise.resolve(res.data);
|
||||
}
|
||||
},
|
||||
(err) => {
|
||||
return Promise.reject(err);
|
||||
}
|
||||
);
|
||||
|
||||
export default http;
|
||||
import axios from "axios"
|
||||
|
||||
const http = axios.create({
|
||||
baseURL: "/api",
|
||||
xsrfHeaderName: "X-CSRFToken",
|
||||
xsrfCookieName: "csrftoken",
|
||||
})
|
||||
|
||||
// TODO
|
||||
http.interceptors.response.use(
|
||||
(res) => {
|
||||
if (res.data.error) {
|
||||
// 若后端返回为登录,则为session失效,应退出当前登录用户
|
||||
if (res.data.data.startsWith("Please login")) {
|
||||
}
|
||||
return Promise.reject(res.data)
|
||||
} else {
|
||||
return Promise.resolve(res.data)
|
||||
}
|
||||
},
|
||||
(err) => {
|
||||
return Promise.reject(err)
|
||||
}
|
||||
)
|
||||
|
||||
export default http
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
const localStorage = window.localStorage;
|
||||
const localStorage = window.localStorage
|
||||
|
||||
export default {
|
||||
set(key: string, value: any) {
|
||||
localStorage.setItem(key, JSON.stringify(value));
|
||||
localStorage.setItem(key, JSON.stringify(value))
|
||||
},
|
||||
get(key: string) {
|
||||
const content = localStorage.getItem(key);
|
||||
const content = localStorage.getItem(key)
|
||||
if (content) {
|
||||
return JSON.parse(content);
|
||||
return JSON.parse(content)
|
||||
} else {
|
||||
return null;
|
||||
return null
|
||||
}
|
||||
},
|
||||
remove(key: string) {
|
||||
localStorage.removeItem(key);
|
||||
localStorage.removeItem(key)
|
||||
},
|
||||
clear() {
|
||||
localStorage.clear();
|
||||
localStorage.clear()
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user