remove useless code.

This commit is contained in:
2023-12-11 13:38:20 +08:00
parent eb8dce2e4f
commit e3b2aded62
21 changed files with 30 additions and 233 deletions

4
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{
"name": "oj-next",
"version": "1.1.0",
"version": "1.2.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "oj-next",
"version": "1.1.0",
"version": "1.2.0",
"dependencies": {
"@codemirror/lang-cpp": "^6.0.2",
"@codemirror/lang-python": "^6.1.3",

View File

@@ -1,6 +1,6 @@
{
"name": "oj-next",
"version": "1.1.0",
"version": "1.2.0",
"type": "module",
"scripts": {
"start": "vite",

View File

@@ -26,5 +26,3 @@ hljs.registerLanguage("python", python)
</n-message-provider>
</n-config-provider>
</template>
<style scoped></style>

View File

@@ -1,103 +0,0 @@
<script setup lang="ts">
import { isDesktop } from "~/shared/composables/breakpoints"
import { code } from "~/shared/composables/learn"
import { useLearnStore } from "./store"
const CodeEditor = defineAsyncComponent(
() => import("~/shared/components/CodeEditor.vue"),
)
const route = useRoute()
const router = useRouter()
const learnStore = useLearnStore()
const Mds = Array.from({ length: learnStore.total }, (_, i) => i + 1).map((v) =>
defineAsyncComponent(() => import(`./step-${v}/index.md`)),
)
watch(
() => route.params.step,
async (value) => {
if (route.name !== "learn") return
try {
const raw = await import(`./${value[0]}/main.c?raw`)
code.value = raw.default
} catch (err) {
router.replace("/learn/step-1")
}
},
{ immediate: true },
)
</script>
<template>
<n-grid v-if="isDesktop" :cols="22">
<n-gi :span="2">
<n-scrollbar style="max-height: calc(100vh - 92px)">
<n-space vertical>
<span>目录</span>
<n-button
text
:type="learnStore.current === title.key ? 'primary' : 'default'"
v-for="title in learnStore.menu"
:key="title.key"
@click="title.props?.onClick"
>
{{ title.label }}
</n-button>
</n-space>
</n-scrollbar>
</n-gi>
<n-gi :span="10">
<n-scrollbar style="max-height: calc(100vh - 92px)">
<component :is="Mds[learnStore.current - 1]"></component>
</n-scrollbar>
</n-gi>
<n-gi :span="10">
<CodeEditor v-model="code" height="calc(100vh - 92px)" />
</n-gi>
</n-grid>
<div v-else>
<n-scrollbar style="height: calc(50vh - 42px)">
<component :is="Mds[learnStore.current - 1]"></component>
</n-scrollbar>
<CodeEditor v-model="code" height="calc(50vh - 42px)" />
</div>
</template>
<style>
.__layout-dark .vitesse-light {
display: none;
}
.__layout .vitesse-dark {
display: none;
}
.shiki .highlighted {
background: #7f7f7f20;
display: block;
margin: 0 -1rem;
padding: 0 1rem;
}
.markdown-body code[v-pre] {
font-size: 20px;
font-family: "SF Mono", Monaco, Menlo, Consolas, "Ubuntu Mono",
"Liberation Mono", "DejaVu Sans Mono", "Courier New", monospace;
display: flex;
flex-direction: column;
counter-reset: step;
counter-increment: step 0;
}
.markdown-body code[v-pre] .line:not(:last-child)::before {
content: counter(step);
counter-increment: step;
width: 1rem;
margin-right: 1.5rem;
display: inline-block;
text-align: right;
color: rgba(115, 138, 148, 0.4);
}
</style>

View File

@@ -1,3 +0,0 @@
我是第一步
我是第二步
我是第三步

View File

@@ -1,17 +0,0 @@
# 我是一级标题
## 我是二级标题
### 我是三级标题
我是代码
```c
#include<stdio.h>
int main()
{
printf("hello world");
return 0;
}
```

View File

@@ -1,7 +0,0 @@
#include <stdio.h>
int main()
{
printf("我是右侧的代码");
return 0;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 56 KiB

View File

@@ -1,7 +0,0 @@
随便写写
图片 1
![tupian](./WX20220628-084503@2x.png)
图片 2
<img src="./WX20220628-084503@2x.png" style="width: 100%"/>

View File

@@ -1 +0,0 @@
1212121212

View File

@@ -1,39 +0,0 @@
import sidebar from "./menu.md?raw"
export const useLearnStore = defineStore("learn", () => {
const route = useRoute()
const router = useRouter()
const current = computed(() => {
if (!route.params.step || !route.params.step.length) return 1
else {
return parseInt(route.params.step[0].split("-")[1])
}
})
const menu: DropdownOption[] = sidebar
.split("\n")
.filter((title) => !!title)
.map((title: string, index) => {
return {
key: index + 1,
label: title,
props: {
onClick: () => {
router.push(`/learn/step-${index + 1}`)
},
},
}
})
function go(step: number) {
router.push(`/learn/step-${step}`)
}
return {
total: menu.length,
current,
menu,
go,
}
})

View File

@@ -1,5 +1,5 @@
<script setup lang="ts">
import { ContestRank, ProblemFiltered } from "~/utils/types"
import { ContestRank } from "~/utils/types"
interface Props {
rank: ContestRank

View File

@@ -10,7 +10,7 @@
// input: "",
// })
function gotoTestCat() {
const url = "https://code.hyyz.izhai.net/"
const url = "https://code.xuyue.cc"
// let id = 50
// const lang = props.lang
// if (lang === "Python3") id = 71

View File

@@ -36,7 +36,7 @@ const query = reactive<Query>({
limit: parseInt(<string>route.query.limit) || 10,
username: <string>route.query.username ?? "",
myself: route.query.myself === "1",
problem: <string>route.query.problem ?? ""
problem: <string>route.query.problem ?? "",
})
const options: SelectOption[] = [
@@ -110,7 +110,13 @@ async function rejudge(submissionID: string) {
watch(() => query.page, routerPush)
watch(
() => [query.limit, query.myself, query.username, query.result, query.problem],
() => [
query.limit,
query.myself,
query.username,
query.result,
query.problem,
],
() => {
query.page = 1
routerPush()
@@ -269,7 +275,9 @@ const columns = computed(() => {
</n-form>
<n-form :show-feedback="false" inline label-placement="left">
<n-form-item>
<n-button @click="search(query.username, query.problem)">搜索</n-button>
<n-button @click="search(query.username, query.problem)">
搜索
</n-button>
</n-form-item>
<n-form-item>
<n-button @click="clear" quaternary>重置</n-button>

View File

@@ -80,15 +80,6 @@ export const ojs: RouteRecordRaw = {
component: () => import("oj/user/setting.vue"),
meta: { requiresAuth: true },
},
{
path: "learn",
redirect: "learn/step-1",
},
{
path: "learn/:step+",
component: () => import("learn/index.vue"),
name: "learn",
},
],
}

View File

@@ -10,22 +10,17 @@ import {
screenSwitchLabel,
switchScreenMode,
} from "~/shared/composables/switchScreen"
import { code } from "~/shared/composables/learn"
import { useLearnStore } from "~/learn/store"
import Play from "../icons/Play.vue"
import Sunny from "../icons/Sunny.vue"
import Moon from "../icons/Moon.vue"
const userStore = useUserStore()
const configStore = useConfigStore()
const learnStore = useLearnStore()
const route = useRoute()
const router = useRouter()
const active = computed(() => {
const path = route.path.split("/")[1] || "problem"
return !["user", "setting"].includes(path) ? path : ""
})
const hiddenTitle = computed(() => isMobile.value && route.name === "learn")
async function handleLogout() {
await logout()
@@ -39,12 +34,6 @@ onMounted(() => {
})
const menus = computed<MenuOption[]>(() => [
{
label: () =>
h(RouterLink, { to: "/learn/step-1" }, { default: () => "自学" }),
key: "learn",
show: false,
},
{
label: () => h(RouterLink, { to: "/" }, { default: () => "题库" }),
key: "problem",
@@ -95,10 +84,6 @@ const options: Array<DropdownOption | DropdownDividerOption> = [
{ label: "退出", key: "logout", props: { onClick: handleLogout } },
]
function run() {
console.log(code.value)
}
function goHome() {
router.push("/")
}
@@ -109,7 +94,7 @@ function switchScreen() {}
<template>
<n-space justify="space-between" align="center">
<n-space align="center">
<div v-if="!hiddenTitle" class="websiteTitle" @click="goHome">
<div class="websiteTitle" @click="goHome">
{{ configStore.config?.website_name }}
</div>
<n-menu
@@ -120,23 +105,6 @@ function switchScreen() {}
/>
</n-space>
<n-space align="center">
<n-dropdown
v-if="route.name === 'learn' && isMobile"
trigger="click"
:options="learnStore.menu"
>
<n-button>目录</n-button>
</n-dropdown>
<div v-if="route.name === 'learn'">
<n-button v-if="isDesktop" type="primary" @click="run">
运行代码
</n-button>
<n-button v-else circle @click="run">
<n-icon>
<Play />
</n-icon>
</n-button>
</div>
<n-dropdown v-if="isMobile" :options="menus" trigger="click">
<n-button>菜单</n-button>
</n-dropdown>

View File

@@ -0,0 +1,13 @@
<template>
<svg
xmlns="http://www.w3.org/2000/svg"
width="1em"
height="1em"
viewBox="0 0 24 24"
>
<path
fill="currentColor"
d="M15.5 14h-.79l-.28-.27a6.5 6.5 0 0 0 1.48-5.34c-.47-2.78-2.79-5-5.59-5.34a6.505 6.505 0 0 0-7.27 7.27c.34 2.8 2.56 5.12 5.34 5.59a6.5 6.5 0 0 0 5.34-1.48l.27.28v.79l4.25 4.25c.41.41 1.08.41 1.49 0c.41-.41.41-1.08 0-1.49L15.5 14zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5S14 7.01 14 9.5S11.99 14 9.5 14z"
></path>
</svg>
</template>

View File

@@ -17,8 +17,6 @@
"utils/*": ["./src/utils/*"],
"oj/*": ["./src/oj/*"],
"admin/*": ["./src/admin/*"],
"learn/*": ["./src/learn/*"],
"play/*": ["./src/play/*"],
},
"types": ["naive-ui/volar"]
},

View File

@@ -48,8 +48,6 @@ export default defineConfig({
utils: path.resolve(__dirname, "./src/utils"),
oj: path.resolve(__dirname, "./src/oj"),
admin: path.resolve(__dirname, "./src/admin"),
learn: path.resolve(__dirname, "./src/learn"),
play: path.relative(__dirname, "./src/play"),
},
},
plugins: [