problem list.
This commit is contained in:
3
components.d.ts
vendored
3
components.d.ts
vendored
@@ -18,6 +18,7 @@ declare module '@vue/runtime-core' {
|
|||||||
ElForm: typeof import('element-plus/es')['ElForm']
|
ElForm: typeof import('element-plus/es')['ElForm']
|
||||||
ElFormItem: typeof import('element-plus/es')['ElFormItem']
|
ElFormItem: typeof import('element-plus/es')['ElFormItem']
|
||||||
ElHeader: typeof import('element-plus/es')['ElHeader']
|
ElHeader: typeof import('element-plus/es')['ElHeader']
|
||||||
|
ElIcon: typeof import('element-plus/es')['ElIcon']
|
||||||
ElInput: typeof import('element-plus/es')['ElInput']
|
ElInput: typeof import('element-plus/es')['ElInput']
|
||||||
ElMain: typeof import('element-plus/es')['ElMain']
|
ElMain: typeof import('element-plus/es')['ElMain']
|
||||||
ElMenu: typeof import('element-plus/es')['ElMenu']
|
ElMenu: typeof import('element-plus/es')['ElMenu']
|
||||||
@@ -29,6 +30,8 @@ declare module '@vue/runtime-core' {
|
|||||||
ElTable: typeof import('element-plus/es')['ElTable']
|
ElTable: typeof import('element-plus/es')['ElTable']
|
||||||
ElTableColumn: typeof import('element-plus/es')['ElTableColumn']
|
ElTableColumn: typeof import('element-plus/es')['ElTableColumn']
|
||||||
ElTag: typeof import('element-plus/es')['ElTag']
|
ElTag: typeof import('element-plus/es')['ElTag']
|
||||||
|
IEpSelect: typeof import('~icons/ep/select')['default']
|
||||||
|
IEpSemiSelect: typeof import('~icons/ep/semi-select')['default']
|
||||||
RouterLink: typeof import('vue-router')['RouterLink']
|
RouterLink: typeof import('vue-router')['RouterLink']
|
||||||
RouterView: typeof import('vue-router')['RouterView']
|
RouterView: typeof import('vue-router')['RouterView']
|
||||||
}
|
}
|
||||||
|
|||||||
690
package-lock.json
generated
690
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
13
package.json
13
package.json
@@ -6,9 +6,11 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "vite",
|
"start": "vite",
|
||||||
"build": "vue-tsc && vite build",
|
"build": "vue-tsc && vite build",
|
||||||
"preview": "vite preview"
|
"preview": "vite preview",
|
||||||
|
"fmt": "prettier --write src *.d.ts *.ts"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@element-plus/icons-vue": "^2.0.10",
|
||||||
"axios": "^1.2.2",
|
"axios": "^1.2.2",
|
||||||
"element-plus": "^2.2.28",
|
"element-plus": "^2.2.28",
|
||||||
"pinia": "^2.0.28",
|
"pinia": "^2.0.28",
|
||||||
@@ -16,11 +18,14 @@
|
|||||||
"vue-router": "^4.1.6"
|
"vue-router": "^4.1.6"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@iconify-json/ep": "^1.1.8",
|
||||||
"@vitejs/plugin-vue": "^4.0.0",
|
"@vitejs/plugin-vue": "^4.0.0",
|
||||||
"typescript": "^4.9.3",
|
"prettier": "^2.8.1",
|
||||||
|
"typescript": "^4.9.4",
|
||||||
"unplugin-auto-import": "^0.12.1",
|
"unplugin-auto-import": "^0.12.1",
|
||||||
|
"unplugin-icons": "^0.15.0",
|
||||||
"unplugin-vue-components": "^0.22.12",
|
"unplugin-vue-components": "^0.22.12",
|
||||||
"vite": "^4.0.0",
|
"vite": "^4.0.4",
|
||||||
"vue-tsc": "^1.0.11"
|
"vue-tsc": "^1.0.20"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
1
src/.prettierrc.toml
Normal file
1
src/.prettierrc.toml
Normal file
@@ -0,0 +1 @@
|
|||||||
|
semi=false
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import zhCn from "element-plus/dist/locale/zh-cn.mjs";
|
import zhCn from "element-plus/dist/locale/zh-cn.mjs"
|
||||||
|
|
||||||
const locale = zhCn;
|
const locale = zhCn
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|||||||
@@ -1,10 +1,7 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts"></script>
|
||||||
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<router-view></router-view>
|
<router-view></router-view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped></style>
|
||||||
</style>
|
|
||||||
|
|||||||
46
src/main.ts
46
src/main.ts
@@ -1,14 +1,14 @@
|
|||||||
import { createApp } from "vue";
|
import { createApp } from "vue"
|
||||||
import { createRouter, createWebHistory } from "vue-router";
|
import { createRouter, createWebHistory } from "vue-router"
|
||||||
import { createPinia } from "pinia";
|
import { createPinia } from "pinia"
|
||||||
import "element-plus/theme-chalk/display.css";
|
import "element-plus/theme-chalk/display.css"
|
||||||
import App from "./App.vue";
|
import App from "./App.vue"
|
||||||
|
|
||||||
import Home from "./oj/index.vue";
|
import Home from "./oj/index.vue"
|
||||||
import Problems from "./oj/problem/list.vue";
|
import Problems from "./oj/problem/list.vue"
|
||||||
import storage from "./utils/storage";
|
import storage from "./utils/storage"
|
||||||
import { STORAGE_KEY } from "./utils/constants";
|
import { STORAGE_KEY } from "./utils/constants"
|
||||||
import { useLoginStore } from "./shared/stores/login";
|
import { useLoginStore } from "./shared/stores/login"
|
||||||
|
|
||||||
const routes = [
|
const routes = [
|
||||||
{
|
{
|
||||||
@@ -45,30 +45,30 @@ const routes = [
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
{ path: "/admin", component: () => import("./admin/index.vue") },
|
{ path: "/admin", component: () => import("./admin/index.vue") },
|
||||||
];
|
]
|
||||||
|
|
||||||
const router = createRouter({
|
const router = createRouter({
|
||||||
history: createWebHistory(),
|
history: createWebHistory(),
|
||||||
routes,
|
routes,
|
||||||
});
|
})
|
||||||
|
|
||||||
router.beforeEach((to, from, next) => {
|
router.beforeEach((to, from, next) => {
|
||||||
if (to.matched.some((record) => record.meta.requiresAuth)) {
|
if (to.matched.some((record) => record.meta.requiresAuth)) {
|
||||||
if (!storage.get(STORAGE_KEY.AUTHED)) {
|
if (!storage.get(STORAGE_KEY.AUTHED)) {
|
||||||
const login = useLoginStore();
|
const login = useLoginStore()
|
||||||
login.show();
|
login.show()
|
||||||
next("/");
|
next("/")
|
||||||
} else {
|
} else {
|
||||||
next();
|
next()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
next();
|
next()
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
|
|
||||||
const pinia = createPinia();
|
const pinia = createPinia()
|
||||||
|
|
||||||
const app = createApp(App);
|
const app = createApp(App)
|
||||||
app.use(router);
|
app.use(router)
|
||||||
app.use(pinia);
|
app.use(pinia)
|
||||||
app.mount("#app");
|
app.mount("#app")
|
||||||
|
|||||||
@@ -1,22 +1,29 @@
|
|||||||
import { getACRate } from "./../utils/functions";
|
import { getACRate } from "./../utils/functions"
|
||||||
import http from "./../utils/http";
|
import http from "./../utils/http"
|
||||||
|
|
||||||
const difficultDict = {
|
const difficultDict = {
|
||||||
Low: "简单",
|
Low: "简单",
|
||||||
Mid: "中等",
|
Mid: "中等",
|
||||||
High: "困难",
|
High: "困难",
|
||||||
};
|
}
|
||||||
|
|
||||||
function filterResult(result: any) {
|
function filterResult(result: any) {
|
||||||
const newResult = {
|
const newResult: any = {
|
||||||
displayID: result._id,
|
displayID: result._id,
|
||||||
title: result.title,
|
title: result.title,
|
||||||
difficulty: difficultDict[<"Low" | "Mid" | "High">result.difficulty],
|
difficulty: difficultDict[<"Low" | "Mid" | "High">result.difficulty],
|
||||||
tags: result.tags,
|
tags: result.tags,
|
||||||
submission: result.submission_number,
|
submission: result.submission_number,
|
||||||
rate: getACRate(result.accepted_number, result.submission_number),
|
rate: getACRate(result.accepted_number, result.submission_number),
|
||||||
};
|
}
|
||||||
return newResult;
|
if (result.my_status === null || result.my_status === undefined) {
|
||||||
|
newResult.status = "none"
|
||||||
|
} else if (result.my_status === 0) {
|
||||||
|
newResult.status = "done"
|
||||||
|
} else {
|
||||||
|
newResult.status = "tried"
|
||||||
|
}
|
||||||
|
return newResult
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getProblemList(
|
export async function getProblemList(
|
||||||
@@ -28,31 +35,35 @@ export async function getProblemList(
|
|||||||
paging: true,
|
paging: true,
|
||||||
offset,
|
offset,
|
||||||
limit,
|
limit,
|
||||||
};
|
}
|
||||||
Object.keys(searchParams).forEach((element) => {
|
Object.keys(searchParams).forEach((element) => {
|
||||||
if (searchParams[element]) {
|
if (searchParams[element]) {
|
||||||
params[element] = searchParams[element];
|
params[element] = searchParams[element]
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
const res = await http.get("problem", {
|
const res = await http.get("problem", {
|
||||||
params,
|
params,
|
||||||
});
|
})
|
||||||
return {
|
return {
|
||||||
results: res.data.results.map(filterResult),
|
results: res.data.results.map(filterResult),
|
||||||
total: res.data.total,
|
total: res.data.total,
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getProblemTagList() {
|
export function getProblemTagList() {
|
||||||
return http.get("problem/tags");
|
return http.get("problem/tags")
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getRandomProblemID() {
|
||||||
|
return http.get("pickone")
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getProblem(id: number) {
|
export function getProblem(id: number) {
|
||||||
return http.get("problem", {
|
return http.get("problem", {
|
||||||
params: { problem_id: id },
|
params: { problem_id: id },
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getWebsite() {
|
export function getWebsite() {
|
||||||
return http.get("website");
|
return http.get("website")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,31 +1,31 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { useLoginStore } from "../../shared/stores/login";
|
import { useLoginStore } from "../../shared/stores/login"
|
||||||
import { useSignupStore } from "../stores/signup";
|
import { useSignupStore } from "../stores/signup"
|
||||||
import { useUserStore } from "../../shared/stores/user";
|
import { useUserStore } from "../../shared/stores/user"
|
||||||
import { onMounted } from "vue";
|
import { onMounted } from "vue"
|
||||||
import { logout } from "../../shared/api";
|
import { logout } from "../../shared/api"
|
||||||
import { useRouter } from "vue-router";
|
import { useRouter } from "vue-router"
|
||||||
|
|
||||||
const loginStore = useLoginStore();
|
const loginStore = useLoginStore()
|
||||||
const signupStore = useSignupStore();
|
const signupStore = useSignupStore()
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore()
|
||||||
const router = useRouter();
|
const router = useRouter()
|
||||||
|
|
||||||
async function handleLogout() {
|
async function handleLogout() {
|
||||||
await logout();
|
await logout()
|
||||||
userStore.clearMyProfile();
|
userStore.clearMyProfile()
|
||||||
router.replace("/");
|
router.replace("/")
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleDropdown(command: string) {
|
function handleDropdown(command: string) {
|
||||||
switch (command) {
|
switch (command) {
|
||||||
case "logout":
|
case "logout":
|
||||||
handleLogout();
|
handleLogout()
|
||||||
break;
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(userStore.getMyProfile);
|
onMounted(userStore.getMyProfile)
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -41,7 +41,7 @@ onMounted(userStore.getMyProfile);
|
|||||||
</div>
|
</div>
|
||||||
<div v-if="userStore.isLoaded && userStore.isAuthed" class="actions">
|
<div v-if="userStore.isLoaded && userStore.isAuthed" class="actions">
|
||||||
<el-dropdown @command="handleDropdown">
|
<el-dropdown @command="handleDropdown">
|
||||||
<h3>{{ userStore.user.username }}</h3>
|
<el-button>{{ userStore.user.username }}</el-button>
|
||||||
<template #dropdown>
|
<template #dropdown>
|
||||||
<el-dropdown-menu>
|
<el-dropdown-menu>
|
||||||
<el-dropdown-item>我的主页</el-dropdown-item>
|
<el-dropdown-item>我的主页</el-dropdown-item>
|
||||||
@@ -64,5 +64,6 @@ onMounted(userStore.getMyProfile);
|
|||||||
.actions {
|
.actions {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
border-bottom: solid 1px var(--el-menu-border-color);
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -1,10 +1,5 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts"></script>
|
||||||
|
|
||||||
</script>
|
<template>contest list</template>
|
||||||
|
|
||||||
<template>
|
<style scoped></style>
|
||||||
contest list
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
</style>
|
|
||||||
|
|||||||
@@ -1,10 +0,0 @@
|
|||||||
<script setup lang="ts">
|
|
||||||
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
contests
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
</style>
|
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import Login from "../shared/user/login.vue";
|
import Login from "../shared/user/login.vue"
|
||||||
import Signup from "./user/signup.vue";
|
import Signup from "./user/signup.vue"
|
||||||
import Header from "./components/header.vue";
|
import Header from "./components/header.vue"
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|||||||
@@ -1,10 +1,5 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts"></script>
|
||||||
|
|
||||||
</script>
|
<template>problem id</template>
|
||||||
|
|
||||||
<template>
|
<style scoped></style>
|
||||||
problem id
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
</style>
|
|
||||||
|
|||||||
@@ -1,21 +1,23 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { onMounted, ref, reactive, watch, VueElement } from "vue";
|
import { onMounted, ref, reactive, watch, VueElement } from "vue"
|
||||||
import { useRoute, useRouter } from "vue-router";
|
import { useRoute, useRouter } from "vue-router"
|
||||||
import { filterEmptyValue } from "../../utils/functions";
|
import { useUserStore } from "../../shared/stores/user"
|
||||||
import { getProblemList, getProblemTagList } from "../api";
|
import { filterEmptyValue } from "../../utils/functions"
|
||||||
|
import { getProblemList, getProblemTagList, getRandomProblemID } from "../api"
|
||||||
|
|
||||||
const difficultyOptions = [
|
const difficultyOptions = [
|
||||||
{ label: "全部", value: "" },
|
{ label: "全部", value: "" },
|
||||||
{ label: "简单", value: "Low" },
|
{ label: "简单", value: "Low" },
|
||||||
{ label: "中等", value: "Mid" },
|
{ label: "中等", value: "Mid" },
|
||||||
{ label: "困难", value: "High" },
|
{ label: "困难", value: "High" },
|
||||||
];
|
]
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter()
|
||||||
const route = useRoute();
|
const route = useRoute()
|
||||||
const problems = ref([]);
|
const userStore = useUserStore()
|
||||||
const tags = ref(<{ id: number; name: string }[]>[]);
|
const problems = ref([])
|
||||||
const total = ref(0);
|
const tags = ref(<{ id: number; name: string }[]>[])
|
||||||
|
const total = ref(0)
|
||||||
|
|
||||||
const query = reactive({
|
const query = reactive({
|
||||||
keyword: route.query.keyword || "",
|
keyword: route.query.keyword || "",
|
||||||
@@ -23,75 +25,92 @@ const query = reactive({
|
|||||||
tag: route.query.tag || "",
|
tag: route.query.tag || "",
|
||||||
page: parseInt(<string>route.query.page) || 1,
|
page: parseInt(<string>route.query.page) || 1,
|
||||||
limit: parseInt(<string>route.query.limit) || 10,
|
limit: parseInt(<string>route.query.limit) || 10,
|
||||||
});
|
})
|
||||||
|
|
||||||
function getTagColor(tag: string) {
|
function getTagColor(tag: string) {
|
||||||
return {
|
return {
|
||||||
简单: "success",
|
简单: "success",
|
||||||
中等: "",
|
中等: "",
|
||||||
困难: "danger",
|
困难: "danger",
|
||||||
}[tag];
|
}[tag]
|
||||||
}
|
}
|
||||||
|
|
||||||
async function listTags() {
|
async function listTags() {
|
||||||
const res = await getProblemTagList();
|
const res = await getProblemTagList()
|
||||||
tags.value = res.data;
|
tags.value = res.data
|
||||||
}
|
}
|
||||||
|
|
||||||
async function listProblems() {
|
async function listProblems() {
|
||||||
query.keyword = route.query.keyword || "";
|
query.keyword = route.query.keyword || ""
|
||||||
query.difficulty = route.query.difficulty || "";
|
query.difficulty = route.query.difficulty || ""
|
||||||
query.tag = route.query.tag || "";
|
query.tag = route.query.tag || ""
|
||||||
query.page = parseInt(<string>route.query.page) || 1;
|
query.page = parseInt(<string>route.query.page) || 1
|
||||||
query.limit = parseInt(<string>route.query.limit) || 10;
|
query.limit = parseInt(<string>route.query.limit) || 10
|
||||||
|
|
||||||
if (query.page < 1) query.page = 1;
|
if (query.page < 1) query.page = 1
|
||||||
const offset = (query.page - 1) * query.limit;
|
const offset = (query.page - 1) * query.limit
|
||||||
const res = await getProblemList(offset, query.limit, {
|
const res = await getProblemList(offset, query.limit, {
|
||||||
keyword: query.keyword,
|
keyword: query.keyword,
|
||||||
tag: query.tag,
|
tag: query.tag,
|
||||||
difficulty: query.difficulty,
|
difficulty: query.difficulty,
|
||||||
});
|
})
|
||||||
total.value = res.total;
|
total.value = res.total
|
||||||
problems.value = res.results;
|
problems.value = res.results
|
||||||
}
|
}
|
||||||
|
|
||||||
function routePush() {
|
function routePush() {
|
||||||
router.push({
|
router.push({
|
||||||
path: "/",
|
path: "/",
|
||||||
query: filterEmptyValue(query),
|
query: filterEmptyValue(query),
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function search() {
|
function search() {
|
||||||
query.page = 1;
|
query.page = 1
|
||||||
routePush();
|
routePush()
|
||||||
}
|
}
|
||||||
|
|
||||||
function clear() {
|
function clear() {
|
||||||
query.keyword = "";
|
query.keyword = ""
|
||||||
query.tag = "";
|
query.tag = ""
|
||||||
query.difficulty = "";
|
query.difficulty = ""
|
||||||
query.page = 1;
|
query.page = 1
|
||||||
routePush();
|
routePush()
|
||||||
}
|
}
|
||||||
|
|
||||||
watch(() => query.page, routePush);
|
async function getRandom() {
|
||||||
|
const res = await getRandomProblemID()
|
||||||
|
router.push("/problem/" + res.data)
|
||||||
|
}
|
||||||
|
|
||||||
|
function goProblem(row: any) {
|
||||||
|
router.push("/problem/" + row.displayID)
|
||||||
|
}
|
||||||
|
|
||||||
|
watch(() => query.page, routePush)
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => query.tag || query.difficulty || query.limit,
|
() => query.tag || query.difficulty || query.limit,
|
||||||
() => {
|
() => {
|
||||||
query.page = 1;
|
query.page = 1
|
||||||
routePush();
|
routePush()
|
||||||
}
|
}
|
||||||
);
|
)
|
||||||
|
|
||||||
watch(() => route.query, listProblems);
|
watch(
|
||||||
|
() => route.path === "/" && route.query,
|
||||||
|
(newVal) => {
|
||||||
|
if (newVal) listProblems()
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
// TODO: 这里会在登录时候执行两次,有BUG
|
||||||
|
watch(() => userStore.isLoaded && userStore.isAuthed, listProblems)
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
listTags();
|
listTags()
|
||||||
listProblems();
|
listProblems()
|
||||||
});
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -128,9 +147,15 @@ onMounted(() => {
|
|||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
<el-button type="" @click="clear">重置</el-button>
|
<el-button type="" @click="clear">重置</el-button>
|
||||||
|
<el-button type="" @click="getRandom">随机一题</el-button>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
<el-table class="hidden-md-and-up" :data="problems" stripe>
|
<el-table
|
||||||
|
class="hidden-md-and-up"
|
||||||
|
:data="problems"
|
||||||
|
stripe
|
||||||
|
@row-click="goProblem"
|
||||||
|
>
|
||||||
<el-table-column prop="displayID" label="ID" width="80" />
|
<el-table-column prop="displayID" label="ID" width="80" />
|
||||||
<el-table-column prop="title" label="标题" />
|
<el-table-column prop="title" label="标题" />
|
||||||
<el-table-column label="难度" width="100">
|
<el-table-column label="难度" width="100">
|
||||||
@@ -141,8 +166,25 @@ onMounted(() => {
|
|||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
<el-table class="hidden-sm-and-down pointer" :data="problems" stripe>
|
<el-table
|
||||||
<el-table-column prop="my_status" label="状态" width="80">
|
class="hidden-sm-and-down pointer"
|
||||||
|
:data="problems"
|
||||||
|
stripe
|
||||||
|
@row-click="goProblem"
|
||||||
|
>
|
||||||
|
<el-table-column label="状态" width="80">
|
||||||
|
<template #default="scope">
|
||||||
|
<el-icon
|
||||||
|
v-if="scope.row.status === 'done'"
|
||||||
|
color="var(--el-color-success)"
|
||||||
|
><i-ep-select
|
||||||
|
/></el-icon>
|
||||||
|
<el-icon
|
||||||
|
v-if="scope.row.status === 'tried'"
|
||||||
|
color="var(--el-color-error)"
|
||||||
|
><i-ep-semi-select
|
||||||
|
/></el-icon>
|
||||||
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column prop="displayID" label="编号" width="100" />
|
<el-table-column prop="displayID" label="编号" width="100" />
|
||||||
<el-table-column prop="title" label="标题" />
|
<el-table-column prop="title" label="标题" />
|
||||||
@@ -171,19 +213,20 @@ onMounted(() => {
|
|||||||
</el-table>
|
</el-table>
|
||||||
<el-pagination
|
<el-pagination
|
||||||
class="right hidden-md-and-up margin"
|
class="right hidden-md-and-up margin"
|
||||||
layout="sizes,prev,next"
|
layout="prev,next,sizes"
|
||||||
background
|
background
|
||||||
:total="total"
|
:total="total"
|
||||||
:page-sizes="[10, 30, 50, 100]"
|
:page-sizes="[10, 20, 30]"
|
||||||
v-model:page-size="query.limit"
|
v-model:page-size="query.limit"
|
||||||
v-model:current-page="query.page"
|
v-model:current-page="query.page"
|
||||||
/>
|
/>
|
||||||
<el-pagination
|
<el-pagination
|
||||||
class="right margin hidden-sm-and-down"
|
class="right margin hidden-sm-and-down"
|
||||||
layout="sizes,prev,pager,next"
|
layout="prev,pager,next,sizes"
|
||||||
background
|
background
|
||||||
:total="total"
|
:total="total"
|
||||||
:page-sizes="[10, 30, 50, 100]"
|
:page-sizes="[10, 20, 30]"
|
||||||
|
:pager-count="5"
|
||||||
v-model:page-size="query.limit"
|
v-model:page-size="query.limit"
|
||||||
v-model:current-page="query.page"
|
v-model:current-page="query.page"
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -1,10 +1,5 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts"></script>
|
||||||
|
|
||||||
</script>
|
<template>rank list</template>
|
||||||
|
|
||||||
<template>
|
<style scoped></style>
|
||||||
rank list
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
</style>
|
|
||||||
|
|||||||
@@ -1,10 +1,5 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts"></script>
|
||||||
|
|
||||||
</script>
|
<template>status list</template>
|
||||||
|
|
||||||
<template>
|
<style scoped></style>
|
||||||
status list
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
</style>
|
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
import { defineStore } from "pinia";
|
import { defineStore } from "pinia"
|
||||||
import { ref } from "vue";
|
import { ref } from "vue"
|
||||||
|
|
||||||
export const useSignupStore = defineStore("signup", () => {
|
export const useSignupStore = defineStore("signup", () => {
|
||||||
const visible = ref(false);
|
const visible = ref(false)
|
||||||
|
|
||||||
function show() {
|
function show() {
|
||||||
visible.value = true;
|
visible.value = true
|
||||||
}
|
}
|
||||||
|
|
||||||
function hide() {
|
function hide() {
|
||||||
visible.value = false;
|
visible.value = false
|
||||||
}
|
}
|
||||||
|
|
||||||
return { visible, show, hide };
|
return { visible, show, hide }
|
||||||
});
|
})
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { useSignupStore } from "../stores/signup";
|
import { useSignupStore } from "../stores/signup"
|
||||||
const store = useSignupStore();
|
const store = useSignupStore()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
import http from "../utils/http";
|
import http from "../utils/http"
|
||||||
|
|
||||||
export function login(data: { username: string; password: string }) {
|
export function login(data: { username: string; password: string }) {
|
||||||
return http.post("login", data);
|
return http.post("login", data)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function logout() {
|
export function logout() {
|
||||||
return http.get("logout");
|
return http.get("logout")
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getUserInfo(username: string) {
|
export function getUserInfo(username: string) {
|
||||||
return http.get("profile", {
|
return http.get("profile", {
|
||||||
params: { username },
|
params: { username },
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
import { defineStore } from "pinia";
|
import { defineStore } from "pinia"
|
||||||
import { ref } from "vue";
|
import { ref } from "vue"
|
||||||
|
|
||||||
export const useLoginStore = defineStore("login", () => {
|
export const useLoginStore = defineStore("login", () => {
|
||||||
const visible = ref(false);
|
const visible = ref(false)
|
||||||
|
|
||||||
function show() {
|
function show() {
|
||||||
visible.value = true;
|
visible.value = true
|
||||||
}
|
}
|
||||||
|
|
||||||
function hide() {
|
function hide() {
|
||||||
visible.value = false;
|
visible.value = false
|
||||||
}
|
}
|
||||||
|
|
||||||
return { visible, show, hide };
|
return { visible, show, hide }
|
||||||
});
|
})
|
||||||
|
|||||||
@@ -1,41 +1,41 @@
|
|||||||
import { defineStore } from "pinia";
|
import { defineStore } from "pinia"
|
||||||
import { computed, ref } from "vue";
|
import { computed, ref } from "vue"
|
||||||
import {
|
import {
|
||||||
PROBLEM_PERMISSION,
|
PROBLEM_PERMISSION,
|
||||||
STORAGE_KEY,
|
STORAGE_KEY,
|
||||||
USER_TYPE,
|
USER_TYPE,
|
||||||
} from "../../utils/constants";
|
} from "../../utils/constants"
|
||||||
import storage from "../../utils/storage";
|
import storage from "../../utils/storage"
|
||||||
import { getUserInfo } from "../api";
|
import { getUserInfo } from "../api"
|
||||||
|
|
||||||
export const useUserStore = defineStore("user", () => {
|
export const useUserStore = defineStore("user", () => {
|
||||||
const profile = ref<any>({});
|
const profile = ref<any>({})
|
||||||
const isLoaded = ref(false);
|
const isLoaded = ref(false)
|
||||||
const user = computed(() => profile.value.user || {});
|
const user = computed(() => profile.value.user || {})
|
||||||
const isAuthed = computed(() => !!user.value.email);
|
const isAuthed = computed(() => !!user.value.email)
|
||||||
const isAdminRole = computed(
|
const isAdminRole = computed(
|
||||||
() =>
|
() =>
|
||||||
user.value.admin_type === USER_TYPE.ADMIN ||
|
user.value.admin_type === USER_TYPE.ADMIN ||
|
||||||
user.value.admin_type === USER_TYPE.SUPER_ADMIN
|
user.value.admin_type === USER_TYPE.SUPER_ADMIN
|
||||||
);
|
)
|
||||||
const isSuperAdmin = computed(
|
const isSuperAdmin = computed(
|
||||||
() => user.value.admin_type === USER_TYPE.SUPER_ADMIN
|
() => user.value.admin_type === USER_TYPE.SUPER_ADMIN
|
||||||
);
|
)
|
||||||
const hasProblemPermission = computed(
|
const hasProblemPermission = computed(
|
||||||
() => user.value.problem_permission !== PROBLEM_PERMISSION.NONE
|
() => user.value.problem_permission !== PROBLEM_PERMISSION.NONE
|
||||||
);
|
)
|
||||||
|
|
||||||
async function getMyProfile() {
|
async function getMyProfile() {
|
||||||
isLoaded.value = false;
|
isLoaded.value = false
|
||||||
const res = await getUserInfo("");
|
const res = await getUserInfo("")
|
||||||
isLoaded.value = true;
|
isLoaded.value = true
|
||||||
profile.value = res.data || {};
|
profile.value = res.data || {}
|
||||||
storage.set(STORAGE_KEY.AUTHED, !!user.value.email);
|
storage.set(STORAGE_KEY.AUTHED, !!user.value.email)
|
||||||
}
|
}
|
||||||
|
|
||||||
function clearMyProfile() {
|
function clearMyProfile() {
|
||||||
profile.value = {};
|
profile.value = {}
|
||||||
storage.clear();
|
storage.clear()
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
profile,
|
profile,
|
||||||
@@ -47,5 +47,5 @@ export const useUserStore = defineStore("user", () => {
|
|||||||
isAuthed,
|
isAuthed,
|
||||||
getMyProfile,
|
getMyProfile,
|
||||||
clearMyProfile,
|
clearMyProfile,
|
||||||
};
|
}
|
||||||
});
|
})
|
||||||
|
|||||||
@@ -1,50 +1,50 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { FormInstance } from "element-plus";
|
import { FormInstance } from "element-plus"
|
||||||
import { reactive, ref } from "vue";
|
import { reactive, ref } from "vue"
|
||||||
import { useSignupStore } from "../../oj/stores/signup";
|
import { useSignupStore } from "../../oj/stores/signup"
|
||||||
import { login } from "../../shared/api";
|
import { login } from "../../shared/api"
|
||||||
import { useLoginStore } from "../stores/login";
|
import { useLoginStore } from "../stores/login"
|
||||||
import { useUserStore } from "../stores/user";
|
import { useUserStore } from "../stores/user"
|
||||||
|
|
||||||
const loginStore = useLoginStore();
|
const loginStore = useLoginStore()
|
||||||
const signupStore = useSignupStore();
|
const signupStore = useSignupStore()
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore()
|
||||||
const loading = ref(false);
|
const loading = ref(false)
|
||||||
const errorMessage = ref("");
|
const errorMessage = ref("")
|
||||||
const loginRef = ref<FormInstance>();
|
const loginRef = ref<FormInstance>()
|
||||||
const form = reactive({
|
const form = reactive({
|
||||||
username: "",
|
username: "",
|
||||||
password: "",
|
password: "",
|
||||||
});
|
})
|
||||||
const rules = reactive({
|
const rules = reactive({
|
||||||
username: [{ required: true, message: "用户名必填", trigger: "blur" }],
|
username: [{ required: true, message: "用户名必填", trigger: "blur" }],
|
||||||
password: [
|
password: [
|
||||||
{ required: true, message: "密码必填", trigger: "blur" },
|
{ required: true, message: "密码必填", trigger: "blur" },
|
||||||
{ min: 6, max: 20, message: "长度在6到20位之间", trigger: "change" },
|
{ min: 6, max: 20, message: "长度在6到20位之间", trigger: "change" },
|
||||||
],
|
],
|
||||||
});
|
})
|
||||||
|
|
||||||
async function submit() {
|
async function submit() {
|
||||||
if (!loginRef.value) return;
|
if (!loginRef.value) return
|
||||||
await loginRef.value.validate(async (valid) => {
|
await loginRef.value.validate(async (valid) => {
|
||||||
if (valid) {
|
if (valid) {
|
||||||
loading.value = true;
|
loading.value = true
|
||||||
errorMessage.value = "";
|
errorMessage.value = ""
|
||||||
try {
|
try {
|
||||||
await login(form);
|
await login(form)
|
||||||
loginStore.hide();
|
loginStore.hide()
|
||||||
await userStore.getMyProfile();
|
await userStore.getMyProfile()
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
errorMessage.value = "用户名或密码不正确";
|
errorMessage.value = "用户名或密码不正确"
|
||||||
}
|
}
|
||||||
loading.value = false;
|
loading.value = false
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function goSignup() {
|
function goSignup() {
|
||||||
loginStore.hide();
|
loginStore.hide()
|
||||||
signupStore.show();
|
signupStore.show()
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -68,13 +68,13 @@ export const JUDGE_STATUS = {
|
|||||||
color: "yellow",
|
color: "yellow",
|
||||||
type: "warning",
|
type: "warning",
|
||||||
},
|
},
|
||||||
};
|
}
|
||||||
|
|
||||||
export const CONTEST_STATUS = {
|
export const CONTEST_STATUS = {
|
||||||
NOT_START: "1",
|
NOT_START: "1",
|
||||||
UNDERWAY: "0",
|
UNDERWAY: "0",
|
||||||
ENDED: "-1",
|
ENDED: "-1",
|
||||||
};
|
}
|
||||||
|
|
||||||
export const CONTEST_STATUS_REVERSE = {
|
export const CONTEST_STATUS_REVERSE = {
|
||||||
"1": {
|
"1": {
|
||||||
@@ -89,41 +89,41 @@ export const CONTEST_STATUS_REVERSE = {
|
|||||||
name: "Ended",
|
name: "Ended",
|
||||||
color: "red",
|
color: "red",
|
||||||
},
|
},
|
||||||
};
|
}
|
||||||
|
|
||||||
export const RULE_TYPE = {
|
export const RULE_TYPE = {
|
||||||
ACM: "ACM",
|
ACM: "ACM",
|
||||||
OI: "OI",
|
OI: "OI",
|
||||||
};
|
}
|
||||||
|
|
||||||
export const CONTEST_TYPE = {
|
export const CONTEST_TYPE = {
|
||||||
PUBLIC: "Public",
|
PUBLIC: "Public",
|
||||||
PRIVATE: "Password Protected",
|
PRIVATE: "Password Protected",
|
||||||
};
|
}
|
||||||
|
|
||||||
export const USER_TYPE = {
|
export const USER_TYPE = {
|
||||||
REGULAR_USER: "Regular User",
|
REGULAR_USER: "Regular User",
|
||||||
ADMIN: "Admin",
|
ADMIN: "Admin",
|
||||||
SUPER_ADMIN: "Super Admin",
|
SUPER_ADMIN: "Super Admin",
|
||||||
};
|
}
|
||||||
|
|
||||||
export const PROBLEM_PERMISSION = {
|
export const PROBLEM_PERMISSION = {
|
||||||
NONE: "None",
|
NONE: "None",
|
||||||
OWN: "Own",
|
OWN: "Own",
|
||||||
ALL: "All",
|
ALL: "All",
|
||||||
};
|
}
|
||||||
|
|
||||||
export const STORAGE_KEY = {
|
export const STORAGE_KEY = {
|
||||||
AUTHED: "authed",
|
AUTHED: "authed",
|
||||||
PROBLEM_CODE: "problemCode",
|
PROBLEM_CODE: "problemCode",
|
||||||
USER: "user",
|
USER: "user",
|
||||||
};
|
}
|
||||||
|
|
||||||
export function buildProblemCodeKey(problemID: number, contestID = null) {
|
export function buildProblemCodeKey(problemID: number, contestID = null) {
|
||||||
if (contestID) {
|
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) {
|
export function getACRate(acCount: number, totalCount: number) {
|
||||||
let rate = totalCount === 0 ? 0.0 : ((acCount / totalCount) * 100).toFixed(2);
|
let rate = totalCount === 0 ? 0.0 : ((acCount / totalCount) * 100).toFixed(2)
|
||||||
return `${rate}%`;
|
return `${rate}%`
|
||||||
}
|
}
|
||||||
|
|
||||||
export function filterEmptyValue(object: any) {
|
export function filterEmptyValue(object: any) {
|
||||||
let query: any = {};
|
let query: any = {}
|
||||||
Object.keys(object).forEach((key) => {
|
Object.keys(object).forEach((key) => {
|
||||||
if (object[key] || object[key] === 0 || object[key] === false) {
|
if (object[key] || object[key] === 0 || object[key] === false) {
|
||||||
query[key] = object[key];
|
query[key] = object[key]
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
return query;
|
return query
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import axios from "axios";
|
import axios from "axios"
|
||||||
|
|
||||||
const http = axios.create({
|
const http = axios.create({
|
||||||
baseURL: "/api",
|
baseURL: "/api",
|
||||||
xsrfHeaderName: "X-CSRFToken",
|
xsrfHeaderName: "X-CSRFToken",
|
||||||
xsrfCookieName: "csrftoken",
|
xsrfCookieName: "csrftoken",
|
||||||
});
|
})
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
http.interceptors.response.use(
|
http.interceptors.response.use(
|
||||||
@@ -13,14 +13,14 @@ http.interceptors.response.use(
|
|||||||
// 若后端返回为登录,则为session失效,应退出当前登录用户
|
// 若后端返回为登录,则为session失效,应退出当前登录用户
|
||||||
if (res.data.data.startsWith("Please login")) {
|
if (res.data.data.startsWith("Please login")) {
|
||||||
}
|
}
|
||||||
return Promise.reject(res.data);
|
return Promise.reject(res.data)
|
||||||
} else {
|
} else {
|
||||||
return Promise.resolve(res.data);
|
return Promise.resolve(res.data)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
(err) => {
|
(err) => {
|
||||||
return Promise.reject(err);
|
return Promise.reject(err)
|
||||||
}
|
}
|
||||||
);
|
)
|
||||||
|
|
||||||
export default http;
|
export default http
|
||||||
|
|||||||
@@ -1,21 +1,21 @@
|
|||||||
const localStorage = window.localStorage;
|
const localStorage = window.localStorage
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
set(key: string, value: any) {
|
set(key: string, value: any) {
|
||||||
localStorage.setItem(key, JSON.stringify(value));
|
localStorage.setItem(key, JSON.stringify(value))
|
||||||
},
|
},
|
||||||
get(key: string) {
|
get(key: string) {
|
||||||
const content = localStorage.getItem(key);
|
const content = localStorage.getItem(key)
|
||||||
if (content) {
|
if (content) {
|
||||||
return JSON.parse(content);
|
return JSON.parse(content)
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
remove(key: string) {
|
remove(key: string) {
|
||||||
localStorage.removeItem(key);
|
localStorage.removeItem(key)
|
||||||
},
|
},
|
||||||
clear() {
|
clear() {
|
||||||
localStorage.clear();
|
localStorage.clear()
|
||||||
},
|
},
|
||||||
};
|
}
|
||||||
|
|||||||
@@ -3,35 +3,35 @@ import vue from "@vitejs/plugin-vue";
|
|||||||
import AutoImport from "unplugin-auto-import/vite";
|
import AutoImport from "unplugin-auto-import/vite";
|
||||||
import Components from "unplugin-vue-components/vite";
|
import Components from "unplugin-vue-components/vite";
|
||||||
import { ElementPlusResolver } from "unplugin-vue-components/resolvers";
|
import { ElementPlusResolver } from "unplugin-vue-components/resolvers";
|
||||||
|
import IconsResolver from "unplugin-icons/resolver";
|
||||||
|
import Icons from "unplugin-icons/vite";
|
||||||
|
|
||||||
const url = "https://oj.hyyz.izhai.net";
|
const url = "https://oj.hyyz.izhai.net";
|
||||||
|
const proxyConfig = {
|
||||||
|
target: url,
|
||||||
|
changeOrigin: true,
|
||||||
|
headers: { Referer: url },
|
||||||
|
};
|
||||||
|
|
||||||
// https://vitejs.dev/config/
|
// https://vitejs.dev/config/
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
plugins: [
|
plugins: [
|
||||||
vue(),
|
vue(),
|
||||||
AutoImport({
|
AutoImport({
|
||||||
resolvers: [ElementPlusResolver()],
|
resolvers: [ElementPlusResolver(), IconsResolver()],
|
||||||
}),
|
}),
|
||||||
Components({
|
Components({
|
||||||
resolvers: [ElementPlusResolver()],
|
resolvers: [
|
||||||
|
ElementPlusResolver(),
|
||||||
|
IconsResolver({ enabledCollections: ["ep"] }),
|
||||||
|
],
|
||||||
}),
|
}),
|
||||||
|
Icons({ autoInstall: true }),
|
||||||
],
|
],
|
||||||
server: {
|
server: {
|
||||||
proxy: {
|
proxy: {
|
||||||
"/api": {
|
"/api": proxyConfig,
|
||||||
target: url,
|
"/public": proxyConfig,
|
||||||
changeOrigin: true,
|
|
||||||
headers: {
|
|
||||||
Referer: url,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"/public": {
|
|
||||||
target: url,
|
|
||||||
changeOrigin: true,
|
|
||||||
headers: {
|
|
||||||
Referer: url,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user