fix contest conflict.
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ export interface User {
|
||||
id: number
|
||||
username: string
|
||||
email: string
|
||||
admin_type: string
|
||||
admin_type: "Regular User" | "Super Admin" | "Admin"
|
||||
problem_permission: string
|
||||
create_time: Date
|
||||
last_login: Date
|
||||
|
||||
Reference in New Issue
Block a user