fix contest conflict.

This commit is contained in:
2023-03-16 14:49:34 +08:00
parent 51328770c6
commit 0fa885d892
15 changed files with 290 additions and 148 deletions

View File

@@ -1,5 +1,6 @@
import { getTime, intervalToDuration, parseISO } from "date-fns"
import { STORAGE_KEY } from "./constants"
import { User } from "./types"
export function getACRate(acCount: number, totalCount: number) {
let rate = totalCount === 0 ? 0.0 : ((acCount / totalCount) * 100).toFixed(2)
@@ -103,3 +104,28 @@ export function debounce(fn: Function, n = 100) {
}, n)
}
}
export function getUserRole(role: User["admin_type"]): {
type: "default" | "info" | "error"
tagString: "普通" | "管理员" | "超管"
} {
const obj: {
type: "default" | "info" | "error"
tagString: "普通" | "管理员" | "超管"
} = { type: "default", tagString: "普通" }
switch (role) {
case "Regular User":
obj.type = "default"
obj.tagString = "普通"
break
case "Admin":
obj.type = "info"
obj.tagString = "管理员"
break
case "Super Admin":
obj.type = "error"
obj.tagString = "超管"
break
}
return obj
}