add breakpoints.
This commit is contained in:
@@ -7,6 +7,7 @@ import {
|
||||
LANGUAGE_VALUE,
|
||||
SOURCES,
|
||||
} from "../../../utils/constants"
|
||||
import { isDesktop } from "../../../utils/breakpoints"
|
||||
|
||||
const { problem } = defineProps<{
|
||||
problem: {
|
||||
@@ -61,11 +62,13 @@ async function init() {
|
||||
monaco.editor.create(monacoEditorRef.value, {
|
||||
value: state.values[state.language], // 编辑器初始显示文字
|
||||
language: LANGUAGE_VALUE[state.language],
|
||||
automaticLayout: true, // 自适应布局
|
||||
theme: "vs", // 官方自带三种主题vs, hc-black, or vs-dark
|
||||
minimap: {
|
||||
enabled: false,
|
||||
},
|
||||
lineNumbersMinChars: 3,
|
||||
automaticLayout: true, // 自适应布局
|
||||
tabSize: 4,
|
||||
fontSize: 24, // 字体大小
|
||||
scrollBeyondLastLine: false, // 取消代码后面一大段空白
|
||||
})
|
||||
@@ -92,7 +95,10 @@ async function init() {
|
||||
<el-button @click="reset">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div ref="monacoEditorRef" class="editor"></div>
|
||||
<div
|
||||
ref="monacoEditorRef"
|
||||
:class="isDesktop ? 'editor' : 'editorMobile'"
|
||||
></div>
|
||||
<el-tabs type="border-card">
|
||||
<el-tab-pane label="测试用例"> 1 </el-tab-pane>
|
||||
<el-tab-pane label="执行结果"> 2 </el-tab-pane>
|
||||
@@ -113,6 +119,11 @@ async function init() {
|
||||
.editor {
|
||||
height: 70%;
|
||||
}
|
||||
|
||||
.editorMobile {
|
||||
height: 500px;
|
||||
}
|
||||
|
||||
.actions {
|
||||
margin-top: 16px;
|
||||
float: right;
|
||||
|
||||
@@ -3,41 +3,39 @@ const { problem } = defineProps(["problem"])
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<el-scrollbar height="calc(100vh - 171px)" noresize>
|
||||
<h1>{{ problem.title }}</h1>
|
||||
<p class="title">描述</p>
|
||||
<div class="content" v-html="problem.description"></div>
|
||||
<h1>{{ problem.title }}</h1>
|
||||
<p class="title">描述</p>
|
||||
<div class="content" v-html="problem.description"></div>
|
||||
|
||||
<p class="title">输入</p>
|
||||
<div class="content" v-html="problem.input_description"></div>
|
||||
<p class="title">输入</p>
|
||||
<div class="content" v-html="problem.input_description"></div>
|
||||
|
||||
<p class="title">输出</p>
|
||||
<div class="content" v-html="problem.output_description"></div>
|
||||
<p class="title">输出</p>
|
||||
<div class="content" v-html="problem.output_description"></div>
|
||||
|
||||
<div v-if="problem.hint">
|
||||
<p class="title">提示</p>
|
||||
<el-card shadow="never">
|
||||
<div class="content" v-html="problem.hint"></div>
|
||||
</el-card>
|
||||
</div>
|
||||
<div v-if="problem.hint">
|
||||
<p class="title">提示</p>
|
||||
<el-card shadow="never">
|
||||
<div class="content" v-html="problem.hint"></div>
|
||||
</el-card>
|
||||
</div>
|
||||
|
||||
<div v-for="(sample, index) of problem.samples" :key="index">
|
||||
<p class="title">测试用例 {{ index + 1 }}</p>
|
||||
<el-descriptions border direction="vertical">
|
||||
<el-descriptions-item width="50%" label="输入">
|
||||
<div class="testcase">{{ sample.input }}</div>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item width="50%" label="输出">
|
||||
<div class="testcase">{{ sample.output }}</div>
|
||||
</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
</div>
|
||||
<div v-for="(sample, index) of problem.samples" :key="index">
|
||||
<p class="title">测试用例 {{ index + 1 }}</p>
|
||||
<el-descriptions border direction="vertical">
|
||||
<el-descriptions-item width="50%" label="输入">
|
||||
<div class="testcase">{{ sample.input }}</div>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item width="50%" label="输出">
|
||||
<div class="testcase">{{ sample.output }}</div>
|
||||
</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
</div>
|
||||
|
||||
<div v-if="problem.source">
|
||||
<p class="title">来源</p>
|
||||
<div class="content" v-html="problem.source"></div>
|
||||
</div>
|
||||
</el-scrollbar>
|
||||
<div v-if="problem.source">
|
||||
<p class="title">来源</p>
|
||||
<div class="content" v-html="problem.source"></div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
<script setup lang="ts">
|
||||
import { DIFFICULTY, getTagColor } from "../../../utils/constants"
|
||||
import { getACRate } from "../../../utils/functions"
|
||||
import { DIFFICULTY } from "../../../utils/constants"
|
||||
import { getACRate, getTagColor } from "../../../utils/functions"
|
||||
import { isDesktop } from "../../../utils/breakpoints"
|
||||
|
||||
const { problem } = defineProps(["problem"])
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<el-descriptions border>
|
||||
<el-descriptions border :column="isDesktop ? 3 : 1">
|
||||
<el-descriptions-item label="编号">
|
||||
{{ problem._id }}
|
||||
</el-descriptions-item>
|
||||
@@ -14,7 +15,7 @@ const { problem } = defineProps(["problem"])
|
||||
{{ problem.created_by.username }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="难度">
|
||||
<el-tag :type="getTagColor(problem.difficulty)">
|
||||
<el-tag disable-transitions :type="getTagColor(problem.difficulty)">
|
||||
{{ DIFFICULTY[<"Low" | "Mid" | "High">problem.difficulty] }}
|
||||
</el-tag>
|
||||
</el-descriptions-item>
|
||||
@@ -40,7 +41,12 @@ const { problem } = defineProps(["problem"])
|
||||
|
||||
<el-descriptions-item :span="3" label="标签">
|
||||
<el-space>
|
||||
<el-tag type="info" v-for="tag in problem.tags" :key="tag">
|
||||
<el-tag
|
||||
disable-transitions
|
||||
type="info"
|
||||
v-for="tag in problem.tags"
|
||||
:key="tag"
|
||||
>
|
||||
{{ tag }}
|
||||
</el-tag>
|
||||
</el-space>
|
||||
|
||||
@@ -2,9 +2,10 @@
|
||||
import { onMounted, ref } from "vue"
|
||||
import { useRoute } from "vue-router"
|
||||
import Editor from "./components/editor.vue"
|
||||
import { getProblem } from "../api"
|
||||
import ProblemContent from "./components/problem-content.vue"
|
||||
import ProblemInfo from "./components/problem-info.vue"
|
||||
import { getProblem } from "../api"
|
||||
import { isDesktop, isMobile } from "../../utils/breakpoints"
|
||||
|
||||
const route = useRoute()
|
||||
const contestID = route.params.contestID as string
|
||||
@@ -33,19 +34,25 @@ onMounted(() => {
|
||||
|
||||
<template>
|
||||
<el-row v-if="problem._id">
|
||||
<el-col :span="12">
|
||||
<el-col :span="isDesktop ? 12 : 24">
|
||||
<el-tabs type="border-card">
|
||||
<el-tab-pane label="题目描述">
|
||||
<ProblemContent :problem="problem" />
|
||||
<el-tab-pane label="题目描述" lazy>
|
||||
<el-scrollbar v-if="isDesktop" height="calc(100vh - 171px)" noresize>
|
||||
<ProblemContent :problem="problem" />
|
||||
</el-scrollbar>
|
||||
<ProblemContent v-else :problem="problem" />
|
||||
</el-tab-pane>
|
||||
<el-tab-pane label="比赛信息" v-if="contestID"></el-tab-pane>
|
||||
<el-tab-pane label="题目信息">
|
||||
<el-tab-pane v-if="isMobile" label="代码编辑" lazy>
|
||||
<Editor :problem="problem" />
|
||||
</el-tab-pane>
|
||||
<el-tab-pane label="比赛信息" v-if="contestID" lazy></el-tab-pane>
|
||||
<el-tab-pane label="题目信息" lazy>
|
||||
<ProblemInfo :problem="problem" />
|
||||
</el-tab-pane>
|
||||
<el-tab-pane label="提交情况">3</el-tab-pane>
|
||||
</el-tabs>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-col v-if="isDesktop" :span="12">
|
||||
<Editor :problem="problem" />
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
import { onMounted, ref, reactive, watch } from "vue"
|
||||
import { useRoute, useRouter } from "vue-router"
|
||||
import { useUserStore } from "../../shared/stores/user"
|
||||
import { filterEmptyValue } from "../../utils/functions"
|
||||
import { getTagColor } from "../../utils/constants"
|
||||
import { filterEmptyValue, getTagColor } from "../../utils/functions"
|
||||
import { isDesktop } from "../../utils/breakpoints"
|
||||
import { getProblemList, getProblemTagList, getRandomProblemID } from "../api"
|
||||
|
||||
const difficultyOptions = [
|
||||
@@ -143,29 +143,8 @@ onMounted(() => {
|
||||
<el-button type="" @click="getRandom">随机一题</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<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="title" label="标题" />
|
||||
<el-table-column label="难度" width="100">
|
||||
<template #default="scope">
|
||||
<el-tag disable-transitions :type="getTagColor(scope.row.difficulty)">
|
||||
{{ scope.row.difficulty }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<el-table
|
||||
class="hidden-sm-and-down pointer"
|
||||
:data="problems"
|
||||
stripe
|
||||
@row-click="goProblem"
|
||||
>
|
||||
<el-table-column label="状态" width="80">
|
||||
<el-table class="pointer" :data="problems" stripe @row-click="goProblem">
|
||||
<el-table-column v-if="isDesktop" label="状态" :width="80">
|
||||
<template #default="scope">
|
||||
<el-icon
|
||||
v-if="scope.row.status === 'done'"
|
||||
@@ -179,7 +158,11 @@ onMounted(() => {
|
||||
/></el-icon>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="displayID" label="编号" width="100" />
|
||||
<el-table-column
|
||||
prop="displayID"
|
||||
label="编号"
|
||||
:width="isDesktop ? 100 : 60"
|
||||
/>
|
||||
<el-table-column prop="title" label="标题" />
|
||||
<el-table-column label="难度" width="100">
|
||||
<template #default="scope">
|
||||
@@ -188,7 +171,7 @@ onMounted(() => {
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="标签" width="200">
|
||||
<el-table-column v-if="isDesktop" label="标签" :width="200">
|
||||
<template #default="scope">
|
||||
<el-space>
|
||||
<el-tag
|
||||
@@ -201,21 +184,17 @@ onMounted(() => {
|
||||
</el-space>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="submission" label="提交数" width="100" />
|
||||
<el-table-column prop="rate" label="通过率" width="100" />
|
||||
<el-table-column
|
||||
v-if="isDesktop"
|
||||
prop="submission"
|
||||
label="提交数"
|
||||
width="100"
|
||||
/>
|
||||
<el-table-column v-if="isDesktop" prop="rate" label="通过率" width="100" />
|
||||
</el-table>
|
||||
<el-pagination
|
||||
class="right hidden-md-and-up margin"
|
||||
layout="prev,next,sizes"
|
||||
background
|
||||
:total="total"
|
||||
:page-sizes="[10, 20, 30]"
|
||||
v-model:page-size="query.limit"
|
||||
v-model:current-page="query.page"
|
||||
/>
|
||||
<el-pagination
|
||||
class="right margin hidden-sm-and-down"
|
||||
layout="prev,pager,next,sizes"
|
||||
class="right margin"
|
||||
:layout="isDesktop ? 'prev,pager,next,sizes' : 'prev,next,sizes'"
|
||||
background
|
||||
:total="total"
|
||||
:page-sizes="[10, 20, 30]"
|
||||
|
||||
Reference in New Issue
Block a user