feat(阶段1): 端到端串通,前端显示本地库真实题目
This commit is contained in:
31
apps/web/src/oj/dev-problems.vue
Normal file
31
apps/web/src/oj/dev-problems.vue
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import type { ProblemSummary } from "@oj2/contract"
|
||||||
|
import { onMounted, ref } from "vue"
|
||||||
|
|
||||||
|
const problems = ref<ProblemSummary[]>([])
|
||||||
|
const error = ref("")
|
||||||
|
|
||||||
|
onMounted(async () => {
|
||||||
|
try {
|
||||||
|
const response = await fetch("/api2/problems")
|
||||||
|
const body = await response.json()
|
||||||
|
problems.value = body.data
|
||||||
|
} catch (cause) {
|
||||||
|
error.value = String(cause)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div style="padding: 24px">
|
||||||
|
<h2>阶段 1 链路验证(临时页,阶段 3 删除)</h2>
|
||||||
|
<p v-if="error" style="color: red">{{ error }}</p>
|
||||||
|
<p>共 {{ problems.length }} 道题</p>
|
||||||
|
<ul>
|
||||||
|
<li v-for="problem in problems" :key="problem.id">
|
||||||
|
{{ problem._id }} — {{ problem.title }}({{ problem.difficulty }},通过
|
||||||
|
{{ problem.acceptedNumber }}/{{ problem.submissionNumber }})
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
@@ -5,6 +5,7 @@ export const ojs: RouteRecordRaw = {
|
|||||||
component: () => import("shared/layout/default.vue"),
|
component: () => import("shared/layout/default.vue"),
|
||||||
children: [
|
children: [
|
||||||
{ path: "", component: () => import("oj/problem/list.vue") },
|
{ path: "", component: () => import("oj/problem/list.vue") },
|
||||||
|
{ path: "dev-problems", component: () => import("oj/dev-problems.vue") },
|
||||||
{
|
{
|
||||||
path: "problem/:problemID",
|
path: "problem/:problemID",
|
||||||
component: () => import("oj/problem/detail.vue"),
|
component: () => import("oj/problem/detail.vue"),
|
||||||
|
|||||||
@@ -166,6 +166,11 @@ export default defineConfig(({ mode }) => {
|
|||||||
server: {
|
server: {
|
||||||
port: 5173,
|
port: 5173,
|
||||||
proxy: {
|
proxy: {
|
||||||
|
"/api2": {
|
||||||
|
target: "http://localhost:3000",
|
||||||
|
changeOrigin: true,
|
||||||
|
rewrite: (path: string) => path.replace(/^\/api2/, "/api"),
|
||||||
|
},
|
||||||
"/api": proxyConfig,
|
"/api": proxyConfig,
|
||||||
"/public": proxyConfig,
|
"/public": proxyConfig,
|
||||||
"/ws": wsProxyConfig,
|
"/ws": wsProxyConfig,
|
||||||
|
|||||||
Reference in New Issue
Block a user