use composables.
This commit is contained in:
@@ -27,7 +27,7 @@
|
|||||||
"@types/node": "^18.11.18",
|
"@types/node": "^18.11.18",
|
||||||
"@vitejs/plugin-vue": "^4.0.0",
|
"@vitejs/plugin-vue": "^4.0.0",
|
||||||
"monaco-editor": "^0.34.1",
|
"monaco-editor": "^0.34.1",
|
||||||
"prettier": "^2.8.2",
|
"prettier": "^2.8.3",
|
||||||
"typescript": "^4.9.4",
|
"typescript": "^4.9.4",
|
||||||
"unplugin-auto-import": "^0.12.1",
|
"unplugin-auto-import": "^0.12.1",
|
||||||
"unplugin-icons": "^0.15.1",
|
"unplugin-icons": "^0.15.1",
|
||||||
|
|||||||
8
pnpm-lock.yaml
generated
8
pnpm-lock.yaml
generated
@@ -14,7 +14,7 @@ specifiers:
|
|||||||
normalize.css: ^8.0.1
|
normalize.css: ^8.0.1
|
||||||
party-js: ^2.2.0
|
party-js: ^2.2.0
|
||||||
pinia: ^2.0.28
|
pinia: ^2.0.28
|
||||||
prettier: ^2.8.2
|
prettier: ^2.8.3
|
||||||
typescript: ^4.9.4
|
typescript: ^4.9.4
|
||||||
unplugin-auto-import: ^0.12.1
|
unplugin-auto-import: ^0.12.1
|
||||||
unplugin-icons: ^0.15.1
|
unplugin-icons: ^0.15.1
|
||||||
@@ -43,7 +43,7 @@ devDependencies:
|
|||||||
'@types/node': 18.11.18
|
'@types/node': 18.11.18
|
||||||
'@vitejs/plugin-vue': 4.0.0_vite@4.0.4+vue@3.2.45
|
'@vitejs/plugin-vue': 4.0.0_vite@4.0.4+vue@3.2.45
|
||||||
monaco-editor: 0.34.1
|
monaco-editor: 0.34.1
|
||||||
prettier: 2.8.2
|
prettier: 2.8.3
|
||||||
typescript: 4.9.4
|
typescript: 4.9.4
|
||||||
unplugin-auto-import: 0.12.1_@vueuse+core@9.10.0
|
unplugin-auto-import: 0.12.1_@vueuse+core@9.10.0
|
||||||
unplugin-icons: 0.15.1
|
unplugin-icons: 0.15.1
|
||||||
@@ -1266,8 +1266,8 @@ packages:
|
|||||||
picocolors: 1.0.0
|
picocolors: 1.0.0
|
||||||
source-map-js: 1.0.2
|
source-map-js: 1.0.2
|
||||||
|
|
||||||
/prettier/2.8.2:
|
/prettier/2.8.3:
|
||||||
resolution: {integrity: sha512-BtRV9BcncDyI2tsuS19zzhzoxD8Dh8LiCx7j7tHzrkz8GFXAexeWFdi22mjE1d16dftH2qNaytVxqiRTGlMfpw==}
|
resolution: {integrity: sha512-tJ/oJ4amDihPoufT5sM0Z1SKEuKay8LfVAMlbbhnnkvt6BUserZylqo2PN+p9KeljLr0OHa2rXHU1T8reeoTrw==}
|
||||||
engines: {node: '>=10.13.0'}
|
engines: {node: '>=10.13.0'}
|
||||||
hasBin: true
|
hasBin: true
|
||||||
dev: true
|
dev: true
|
||||||
|
|||||||
1
src/components.d.ts
vendored
1
src/components.d.ts
vendored
@@ -8,6 +8,7 @@ export {}
|
|||||||
declare module '@vue/runtime-core' {
|
declare module '@vue/runtime-core' {
|
||||||
export interface GlobalComponents {
|
export interface GlobalComponents {
|
||||||
ElAlert: typeof import('element-plus/es')['ElAlert']
|
ElAlert: typeof import('element-plus/es')['ElAlert']
|
||||||
|
ElAside: typeof import('element-plus/es')['ElAside']
|
||||||
ElButton: typeof import('element-plus/es')['ElButton']
|
ElButton: typeof import('element-plus/es')['ElButton']
|
||||||
ElCard: typeof import('element-plus/es')['ElCard']
|
ElCard: typeof import('element-plus/es')['ElCard']
|
||||||
ElCol: typeof import('element-plus/es')['ElCol']
|
ElCol: typeof import('element-plus/es')['ElCol']
|
||||||
|
|||||||
1
src/learn/components/Loading.vue
Normal file
1
src/learn/components/Loading.vue
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<template>loading...</template>
|
||||||
@@ -1,9 +1,14 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import Md from "./step-1/index.md"
|
import Loading from "./components/Loading.vue"
|
||||||
import Monaco from "../shared/monaco/index.vue"
|
import Monaco from "../shared/monaco/index.vue"
|
||||||
|
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
// console.log(route.params.step)
|
const step = route.hash.replace("#step-", "") || "1"
|
||||||
|
|
||||||
|
const Md = defineAsyncComponent({
|
||||||
|
loader: () => import(`./step-${step}/index.md`),
|
||||||
|
loadingComponent: Loading,
|
||||||
|
})
|
||||||
|
|
||||||
const code = ref("")
|
const code = ref("")
|
||||||
|
|
||||||
@@ -14,13 +19,10 @@ function change(value: string) {
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<el-row>
|
<el-row>
|
||||||
<el-col :span="4"> </el-col>
|
|
||||||
<el-col :span="12">
|
<el-col :span="12">
|
||||||
<Md />
|
<Md />
|
||||||
{{ code }}
|
|
||||||
</el-col>
|
</el-col>
|
||||||
<!-- TODO: 这里有BUG -->
|
<el-col :span="12">
|
||||||
<el-col :span="8">
|
|
||||||
<Monaco :value="code" @change="change" />
|
<Monaco :value="code" @change="change" />
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
|
|||||||
@@ -1 +1,9 @@
|
|||||||
ceshi
|
# 我的是第一步骤
|
||||||
|
|
||||||
|
```c
|
||||||
|
#include<stdio.h>
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { DIFFICULTY } from "utils/constants"
|
import { DIFFICULTY } from "utils/constants"
|
||||||
import { getACRate, getTagColor, parseTime } from "utils/functions"
|
import { getACRate, getTagColor, parseTime } from "utils/functions"
|
||||||
import { isDesktop } from "utils/breakpoints"
|
import { isDesktop } from "~/shared/composables/breakpoints"
|
||||||
import { Problem } from "utils/types"
|
import { Problem } from "utils/types"
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
|
|||||||
@@ -188,7 +188,7 @@ defineExpose({ submit })
|
|||||||
:title="JUDGE_STATUS[submission.result]['name']"
|
:title="JUDGE_STATUS[submission.result]['name']"
|
||||||
>
|
>
|
||||||
</el-alert>
|
</el-alert>
|
||||||
<el-scrollbar v-if="msg" height="354" class="result" noresize>
|
<el-scrollbar v-if="msg" height="354" class="result">
|
||||||
<div>{{ msg }}</div>
|
<div>{{ msg }}</div>
|
||||||
</el-scrollbar>
|
</el-scrollbar>
|
||||||
<el-table
|
<el-table
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import ProblemContent from "./components/ProblemContent.vue"
|
|||||||
import ProblemInfo from "./components/ProblemInfo.vue"
|
import ProblemInfo from "./components/ProblemInfo.vue"
|
||||||
import SubmissionList from "./components/SubmissionList.vue"
|
import SubmissionList from "./components/SubmissionList.vue"
|
||||||
import { getProblem } from "oj/api"
|
import { getProblem } from "oj/api"
|
||||||
import { isDesktop, isMobile } from "utils/breakpoints"
|
import { isDesktop, isMobile } from "~/shared/composables/breakpoints"
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
problemID: string
|
problemID: string
|
||||||
@@ -25,7 +25,7 @@ provide("problem", readonly(problem))
|
|||||||
<el-col :span="isDesktop ? 12 : 24">
|
<el-col :span="isDesktop ? 12 : 24">
|
||||||
<el-tabs type="border-card">
|
<el-tabs type="border-card">
|
||||||
<el-tab-pane label="题目描述">
|
<el-tab-pane label="题目描述">
|
||||||
<el-scrollbar v-if="isDesktop" height="calc(100vh - 171px)" noresize>
|
<el-scrollbar v-if="isDesktop" height="calc(100vh - 171px)">
|
||||||
<ProblemContent :problem="problem" />
|
<ProblemContent :problem="problem" />
|
||||||
</el-scrollbar>
|
</el-scrollbar>
|
||||||
<ProblemContent v-else :problem="problem" />
|
<ProblemContent v-else :problem="problem" />
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { useUserStore } from "~/shared/store/user"
|
import { useUserStore } from "~/shared/store/user"
|
||||||
import { filterEmptyValue, getTagColor } from "utils/functions"
|
import { filterEmptyValue, getTagColor } from "utils/functions"
|
||||||
import { isDesktop } from "utils/breakpoints"
|
import { isDesktop } from "~/shared/composables/breakpoints"
|
||||||
import { getProblemList, getProblemTagList, getRandomProblemID } from "oj/api"
|
import { getProblemList, getProblemTagList, getRandomProblemID } from "oj/api"
|
||||||
|
|
||||||
import Pagination from "~/shared/Pagination/index.vue"
|
import Pagination from "~/shared/Pagination/index.vue"
|
||||||
|
|||||||
@@ -40,13 +40,12 @@ export const routes = [
|
|||||||
path: "rank",
|
path: "rank",
|
||||||
component: () => import("oj/rank/list.vue"),
|
component: () => import("oj/rank/list.vue"),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: "learn",
|
||||||
|
component: () => import("learn/index.vue"),
|
||||||
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
|
||||||
path: "/learn",
|
|
||||||
component: () => import("~/shared/layout/default.vue"),
|
|
||||||
children: [{ path: "", component: () => import("learn/index.vue") }],
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
path: "/admin",
|
path: "/admin",
|
||||||
component: () => import("~/shared/layout/admin.vue"),
|
component: () => import("~/shared/layout/admin.vue"),
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { logout } from "../api"
|
|||||||
import { useUserStore } from "../store/user"
|
import { useUserStore } from "../store/user"
|
||||||
import { isDark, toggleDark } from "~/shared/composables/dark"
|
import { isDark, toggleDark } from "~/shared/composables/dark"
|
||||||
import { toggleLogin, toggleSignup } from "~/shared/composables/modal"
|
import { toggleLogin, toggleSignup } from "~/shared/composables/modal"
|
||||||
|
import { isDesktop } from "../composables/breakpoints"
|
||||||
|
|
||||||
const userStore = useUserStore()
|
const userStore = useUserStore()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
@@ -26,14 +27,19 @@ onMounted(userStore.getMyProfile)
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<el-menu router mode="horizontal" :default-active="$route.path">
|
<el-menu
|
||||||
<el-menu-item index="/learn">自学</el-menu-item>
|
v-if="isDesktop"
|
||||||
|
router
|
||||||
|
mode="horizontal"
|
||||||
|
:default-active="$route.path"
|
||||||
|
>
|
||||||
|
<el-menu-item index="/learn#step-1">自学</el-menu-item>
|
||||||
<el-menu-item index="/">题库</el-menu-item>
|
<el-menu-item index="/">题库</el-menu-item>
|
||||||
<el-menu-item index="/contest">比赛</el-menu-item>
|
<el-menu-item index="/contest">比赛</el-menu-item>
|
||||||
<el-menu-item index="/status">提交</el-menu-item>
|
<el-menu-item index="/status">提交</el-menu-item>
|
||||||
<el-menu-item index="/rank">排名</el-menu-item>
|
<el-menu-item index="/rank">排名</el-menu-item>
|
||||||
</el-menu>
|
</el-menu>
|
||||||
<el-space class="actions">
|
<el-space v-if="isDesktop" class="actions">
|
||||||
<el-button
|
<el-button
|
||||||
circle
|
circle
|
||||||
:icon="isDark ? Sunny : Moon"
|
:icon="isDark ? Sunny : Moon"
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
import type * as Monaco from "monaco-editor"
|
import type * as Monaco from "monaco-editor"
|
||||||
import { LANGUAGE_VALUE } from "utils/constants"
|
import { LANGUAGE_VALUE } from "utils/constants"
|
||||||
import { LANGUAGE } from "utils/types"
|
import { LANGUAGE } from "utils/types"
|
||||||
import { isMobile } from "utils/breakpoints"
|
import { isMobile } from "~/shared/composables/breakpoints"
|
||||||
import { isDark } from "../composables/dark"
|
import { isDark } from "../composables/dark"
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
@@ -30,8 +30,7 @@ let editor: Monaco.editor.IStandaloneCodeEditor
|
|||||||
onMounted(function () {
|
onMounted(function () {
|
||||||
const model = window.monaco.editor.createModel(
|
const model = window.monaco.editor.createModel(
|
||||||
props.value,
|
props.value,
|
||||||
LANGUAGE_VALUE[props.language],
|
LANGUAGE_VALUE[props.language]
|
||||||
window.monaco.Uri.parse(`file:///root/${Date.now()}.${ext()}`)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
editor = window.monaco.editor.create(monacoEditorRef.value, {
|
editor = window.monaco.editor.create(monacoEditorRef.value, {
|
||||||
@@ -88,25 +87,6 @@ onMounted(function () {
|
|||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
editor && editor.dispose()
|
editor && editor.dispose()
|
||||||
})
|
})
|
||||||
|
|
||||||
function ext() {
|
|
||||||
switch (props.language) {
|
|
||||||
case "C":
|
|
||||||
return "c"
|
|
||||||
case "C++":
|
|
||||||
return "cpp"
|
|
||||||
case "Java":
|
|
||||||
return "java"
|
|
||||||
case "JavaScript":
|
|
||||||
return "js"
|
|
||||||
case "Python2":
|
|
||||||
return "py"
|
|
||||||
case "Python3":
|
|
||||||
return "py"
|
|
||||||
case "Golang":
|
|
||||||
return "go"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<div
|
<div
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { isDesktop } from "utils/breakpoints"
|
import { isDesktop } from "~/shared/composables/breakpoints"
|
||||||
interface Props {
|
interface Props {
|
||||||
total: number
|
total: number
|
||||||
limit: number
|
limit: number
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
import type * as Monaco from "monaco-editor"
|
import type * as Monaco from "monaco-editor"
|
||||||
import { LANGUAGE_VALUE } from "utils/constants"
|
import { LANGUAGE_VALUE } from "utils/constants"
|
||||||
import { LANGUAGE } from "utils/types"
|
import { LANGUAGE } from "utils/types"
|
||||||
import { isMobile } from "utils/breakpoints"
|
import { isMobile } from "~/shared/composables/breakpoints"
|
||||||
import { isDark } from "../composables/dark"
|
import { isDark } from "../composables/dark"
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
@@ -30,8 +30,7 @@ let editor: Monaco.editor.IStandaloneCodeEditor
|
|||||||
onMounted(function () {
|
onMounted(function () {
|
||||||
const model = window.monaco.editor.createModel(
|
const model = window.monaco.editor.createModel(
|
||||||
props.value,
|
props.value,
|
||||||
LANGUAGE_VALUE[props.language],
|
LANGUAGE_VALUE[props.language]
|
||||||
window.monaco.Uri.parse(`file:///root/${Date.now()}.${ext()}`)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
editor = window.monaco.editor.create(monacoEditorRef.value, {
|
editor = window.monaco.editor.create(monacoEditorRef.value, {
|
||||||
@@ -88,25 +87,6 @@ onMounted(function () {
|
|||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
editor && editor.dispose()
|
editor && editor.dispose()
|
||||||
})
|
})
|
||||||
|
|
||||||
function ext() {
|
|
||||||
switch (props.language) {
|
|
||||||
case "C":
|
|
||||||
return "c"
|
|
||||||
case "C++":
|
|
||||||
return "cpp"
|
|
||||||
case "Java":
|
|
||||||
return "java"
|
|
||||||
case "JavaScript":
|
|
||||||
return "js"
|
|
||||||
case "Python2":
|
|
||||||
return "py"
|
|
||||||
case "Python3":
|
|
||||||
return "py"
|
|
||||||
case "Golang":
|
|
||||||
return "go"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<div
|
<div
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ const proxyConfig = {
|
|||||||
headers: { Referer: url },
|
headers: { Referer: url },
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://vitejs.dev/config/
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
resolve: {
|
resolve: {
|
||||||
alias: {
|
alias: {
|
||||||
|
|||||||
Reference in New Issue
Block a user