change to vite8
This commit is contained in:
@@ -4,7 +4,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
|
||||
|
||||
## Project Overview
|
||||
|
||||
**ojnext** is the frontend for an Online Judge platform. Built with Vue 3 + TypeScript using Rsbuild (Rust-based bundler), Naive UI component library, Pinia for state management, and Vue Router.
|
||||
**ojnext** is the frontend for an Online Judge platform. Built with Vue 3 + TypeScript using Vite (Rolldown-based bundler), Naive UI component library, Pinia for state management, and Vue Router.
|
||||
|
||||
## Commands
|
||||
|
||||
|
||||
@@ -9,16 +9,9 @@
|
||||
<script>
|
||||
window.localStorage.setItem("maxkbMaskTip", true)
|
||||
</script>
|
||||
|
||||
<% if (process.env.PUBLIC_MAXKB_URL) { %>
|
||||
<script
|
||||
async
|
||||
defer
|
||||
src="<%= process.env.PUBLIC_MAXKB_URL %>"
|
||||
></script>
|
||||
<% } %>
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
<script type="module" src="/src/main.ts"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
3678
package-lock.json
generated
3678
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
35
package.json
35
package.json
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "oj-next",
|
||||
"version": "1.8.0",
|
||||
"version": "1.9.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"start": "rsbuild dev",
|
||||
"build": "rsbuild build",
|
||||
"build:staging": "rsbuild build --env-mode=staging",
|
||||
"build:test": "rsbuild build --env-mode=test",
|
||||
"start": "vite",
|
||||
"build": "vite build",
|
||||
"build:staging": "vite build --mode staging",
|
||||
"build:test": "vite build --mode test",
|
||||
"fmt": "prettier --write src *.ts"
|
||||
},
|
||||
"dependencies": {
|
||||
@@ -22,9 +22,9 @@
|
||||
"@vue-flow/node-toolbar": "^1.1.1",
|
||||
"@vueuse/core": "^14.3.0",
|
||||
"@vueuse/router": "^14.3.0",
|
||||
"@wangeditor-next/editor": "^5.7.12",
|
||||
"@wangeditor-next/editor": "^5.7.13",
|
||||
"@wangeditor-next/editor-for-vue": "^5.1.14",
|
||||
"axios": "^1.18.0",
|
||||
"axios": "^1.18.1",
|
||||
"canvas-confetti": "^1.9.4",
|
||||
"chart.js": "^4.5.1",
|
||||
"chartjs-chart-wordcloud": "^4.4.5",
|
||||
@@ -34,15 +34,15 @@
|
||||
"date-fns": "^4.4.0",
|
||||
"fflate": "^0.8.3",
|
||||
"highlight.js": "^11.11.1",
|
||||
"md-editor-v3": "^6.5.1",
|
||||
"mermaid": "^11.15.0",
|
||||
"mermaid-legacy": "npm:mermaid@^9.1.7",
|
||||
"md-editor-v3": "^6.5.3",
|
||||
"mermaid": "^11.16.0",
|
||||
"mermaid-legacy": "npm:mermaid@^9.4.3",
|
||||
"naive-ui": "^2.44.1",
|
||||
"nanoid": "^5.1.15",
|
||||
"nanoid": "^5.1.16",
|
||||
"normalize.css": "^8.0.1",
|
||||
"pinia": "^3.0.4",
|
||||
"skulpt": "^1.2.0",
|
||||
"vue": "^3.5.38",
|
||||
"vue": "^3.5.39",
|
||||
"vue-chartjs": "^5.3.3",
|
||||
"vue-codemirror": "^6.1.1",
|
||||
"vue-router": "^5.1.0",
|
||||
@@ -52,14 +52,15 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@iconify/vue": "^5.0.1",
|
||||
"@rsbuild/core": "^1.7.5",
|
||||
"@rsbuild/plugin-vue": "^1.2.9",
|
||||
"@types/canvas-confetti": "^1.9.0",
|
||||
"@types/node": "^26.0.0",
|
||||
"@types/node": "^26.1.0",
|
||||
"@vitejs/plugin-legacy": "^8.1.0",
|
||||
"@vitejs/plugin-vue": "^6.0.7",
|
||||
"@vue/tsconfig": "^0.9.1",
|
||||
"prettier": "^3.8.4",
|
||||
"prettier": "^3.9.4",
|
||||
"typescript": "^6.0.3",
|
||||
"unplugin-auto-import": "^21.0.0",
|
||||
"unplugin-vue-components": "^32.1.0"
|
||||
"unplugin-vue-components": "^32.1.0",
|
||||
"vite": "^8.1.3"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,104 +0,0 @@
|
||||
import { defineConfig, loadEnv } from "@rsbuild/core"
|
||||
import { pluginVue } from "@rsbuild/plugin-vue"
|
||||
import AutoImport from "unplugin-auto-import/rspack"
|
||||
import Components from "unplugin-vue-components/rspack"
|
||||
import { NaiveUiResolver } from "unplugin-vue-components/resolvers"
|
||||
|
||||
const config: ReturnType<typeof defineConfig> = defineConfig(({ envMode }) => {
|
||||
const { publicVars, rawPublicVars } = loadEnv({
|
||||
cwd: process.cwd(),
|
||||
mode: envMode,
|
||||
})
|
||||
|
||||
const proxyConfig = {
|
||||
target: rawPublicVars["PUBLIC_OJ_URL"],
|
||||
changeOrigin: true,
|
||||
}
|
||||
|
||||
const wsProxyConfig = {
|
||||
target: rawPublicVars["PUBLIC_WS_URL"],
|
||||
ws: true,
|
||||
changeOrigin: true,
|
||||
}
|
||||
|
||||
return {
|
||||
plugins: [pluginVue()],
|
||||
tools: {
|
||||
rspack: {
|
||||
plugins: [
|
||||
AutoImport({
|
||||
imports: [
|
||||
"vue",
|
||||
"vue-router",
|
||||
"@vueuse/core",
|
||||
"pinia",
|
||||
{
|
||||
"naive-ui": [
|
||||
"useDialog",
|
||||
"useMessage",
|
||||
"useNotification",
|
||||
"useLoadingBar",
|
||||
],
|
||||
},
|
||||
{
|
||||
from: "naive-ui",
|
||||
imports: [
|
||||
"DataTableColumn",
|
||||
"FormRules",
|
||||
"FormItemRule",
|
||||
"SelectOption",
|
||||
"UploadCustomRequestOptions",
|
||||
"UploadFileInfo",
|
||||
"MenuOption",
|
||||
"DropdownDividerOption",
|
||||
"DropdownOption",
|
||||
],
|
||||
type: true,
|
||||
},
|
||||
],
|
||||
dts: "./src/auto-imports.d.ts",
|
||||
}),
|
||||
Components({
|
||||
resolvers: [NaiveUiResolver()],
|
||||
dts: "./src/components.d.ts",
|
||||
}),
|
||||
],
|
||||
},
|
||||
},
|
||||
html: {
|
||||
template: "./index.html",
|
||||
},
|
||||
source: {
|
||||
entry: {
|
||||
index: "./src/main.ts",
|
||||
},
|
||||
define: publicVars,
|
||||
},
|
||||
output: {
|
||||
polyfill: "usage",
|
||||
},
|
||||
performance: {
|
||||
chunkSplit: {
|
||||
strategy: "split-by-module",
|
||||
},
|
||||
},
|
||||
resolve: {
|
||||
alias: {
|
||||
utils: "./src/utils",
|
||||
oj: "./src/oj",
|
||||
admin: "./src/admin",
|
||||
shared: "./src/shared",
|
||||
},
|
||||
},
|
||||
server: {
|
||||
port: 5173,
|
||||
proxy: {
|
||||
"/api": proxyConfig,
|
||||
"/public": proxyConfig,
|
||||
"/ws": wsProxyConfig,
|
||||
},
|
||||
},
|
||||
}
|
||||
})
|
||||
|
||||
export default config
|
||||
@@ -1,6 +1,6 @@
|
||||
<script lang="ts" setup>
|
||||
import TextEditor from "shared/components/TextEditor.vue"
|
||||
import { AnnouncementEdit } from "utils/types"
|
||||
import type { AnnouncementEdit } from "utils/types"
|
||||
import { createAnnouncement, editAnnouncement, getAnnouncement } from "../api"
|
||||
|
||||
interface Props {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import { NSwitch } from "naive-ui"
|
||||
import Pagination from "shared/components/Pagination.vue"
|
||||
import { parseTime } from "utils/functions"
|
||||
import { Announcement } from "utils/types"
|
||||
import type { Announcement } from "utils/types"
|
||||
import { editAnnouncement, getAnnouncementList } from "../api"
|
||||
import Actions from "./components/Actions.vue"
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
import { NButton } from "naive-ui"
|
||||
import Pagination from "shared/components/Pagination.vue"
|
||||
import { parseTime } from "utils/functions"
|
||||
import { Comment } from "utils/types"
|
||||
import type { Comment } from "utils/types"
|
||||
import { getCommentList } from "../api"
|
||||
import CommentActions from "./components/CommentActions.vue"
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script lang="ts" setup>
|
||||
import { Contest } from "utils/types"
|
||||
import type { Contest } from "utils/types"
|
||||
import { cloneContest } from "../../api"
|
||||
|
||||
interface Props {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import { h } from "vue"
|
||||
import { ProblemSetBadge } from "utils/types"
|
||||
import type { ProblemSetBadge } from "utils/types"
|
||||
import { NButton, NImage } from "naive-ui"
|
||||
|
||||
interface Props {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { ProblemSetBadge } from "utils/types"
|
||||
import type { ProblemSetBadge } from "utils/types"
|
||||
|
||||
interface Props {
|
||||
show: boolean
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { ProblemSetProblem } from "utils/types"
|
||||
import type { ProblemSetProblem } from "utils/types"
|
||||
|
||||
interface Props {
|
||||
show: boolean
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<script setup lang="ts">
|
||||
import { h } from "vue"
|
||||
import { NDataTable, NButton, NFlex } from "naive-ui"
|
||||
import { ProblemSetProblem } from "utils/types"
|
||||
import type { ProblemSetProblem } from "utils/types"
|
||||
|
||||
interface Props {
|
||||
problems: ProblemSetProblem[]
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import { parseTime } from "utils/functions"
|
||||
import { ProblemSet } from "utils/types"
|
||||
import type { ProblemSet } from "utils/types"
|
||||
|
||||
interface Props {
|
||||
problemSet: ProblemSet
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import { h } from "vue"
|
||||
import { NDataTable, NButton, NFlex } from "naive-ui"
|
||||
import { parseTime } from "utils/functions"
|
||||
import { ProblemSetProgress } from "utils/types"
|
||||
import type { ProblemSetProgress } from "utils/types"
|
||||
|
||||
interface Props {
|
||||
progress: ProblemSetProgress[]
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import { NTabPane, NTabs, NButton, NFlex } from "naive-ui"
|
||||
import {
|
||||
import type {
|
||||
ProblemSet,
|
||||
ProblemSetProblem,
|
||||
ProblemSetBadge,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { CreateProblemSetData, EditProblemSetData } from "utils/types"
|
||||
import type { CreateProblemSetData, EditProblemSetData } from "utils/types"
|
||||
import { getProblemSetDetail, createProblemSet, editProblemSet } from "../api"
|
||||
|
||||
const route = useRoute()
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<script setup lang="ts">
|
||||
import { NButton, NTag } from "naive-ui"
|
||||
import { parseTime } from "utils/functions"
|
||||
import { Server } from "utils/types"
|
||||
import type { Server } from "utils/types"
|
||||
import { useConfigStore } from "shared/store/config"
|
||||
import { useConfigWebSocket } from "shared/composables/websocket"
|
||||
import {
|
||||
|
||||
@@ -6,7 +6,7 @@ import { getRank } from "oj/api"
|
||||
import Pagination from "shared/components/Pagination.vue"
|
||||
import { useUserStore } from "shared/store/user"
|
||||
import { getACRate } from "utils/functions"
|
||||
import { Rank } from "utils/types"
|
||||
import type { Rank } from "utils/types"
|
||||
import { getBaseInfo, randomUser10 } from "../api"
|
||||
|
||||
const userCount = ref(0)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
import type {
|
||||
Exercise,
|
||||
ExerciseType,
|
||||
ExerciseMcqData,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<script lang="ts" setup>
|
||||
import CodeEditor from "shared/components/CodeEditor.vue"
|
||||
import MarkdownEditor from "shared/components/MarkdownEditor.vue"
|
||||
import { Tutorial } from "utils/types"
|
||||
import type { Tutorial } from "utils/types"
|
||||
import { createTutorial, getTutorial, updateTutorial } from "../api"
|
||||
import ExerciseManager from "./components/ExerciseManager.vue"
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<script setup lang="ts">
|
||||
import { NSwitch } from "naive-ui"
|
||||
import { parseTime } from "utils/functions"
|
||||
import { Tutorial } from "utils/types"
|
||||
import type { Tutorial } from "utils/types"
|
||||
import { getTutorialList, setTutorialVisibility } from "../api"
|
||||
import Actions from "./components/Actions.vue"
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<script setup lang="ts">
|
||||
import { PROBLEM_PERMISSION, USER_TYPE } from "utils/constants"
|
||||
import { getUserRole } from "utils/functions"
|
||||
import { User } from "utils/types"
|
||||
import type { User } from "utils/types"
|
||||
import TextCopy from "shared/components/TextCopy.vue"
|
||||
|
||||
interface Props {
|
||||
|
||||
@@ -3,7 +3,7 @@ import { DataTableRowKey, SelectOption } from "naive-ui"
|
||||
import Pagination from "shared/components/Pagination.vue"
|
||||
import { usePagination } from "shared/composables/pagination"
|
||||
import { parseTime } from "utils/functions"
|
||||
import { User } from "utils/types"
|
||||
import type { User } from "utils/types"
|
||||
import {
|
||||
deleteUsers,
|
||||
editUser,
|
||||
|
||||
10
src/env.d.ts
vendored
10
src/env.d.ts
vendored
@@ -1,4 +1,4 @@
|
||||
/// <reference types="@rsbuild/core/types" />
|
||||
/// <reference types="vite/client" />
|
||||
|
||||
interface ImportMetaEnv {
|
||||
readonly PUBLIC_ENV: string
|
||||
@@ -14,11 +14,3 @@ interface ImportMetaEnv {
|
||||
interface ImportMeta {
|
||||
readonly env: ImportMetaEnv
|
||||
}
|
||||
|
||||
interface Document {
|
||||
startViewTransition?: (callback: () => void | Promise<void>) => {
|
||||
ready: Promise<void>
|
||||
finished: Promise<void>
|
||||
updateCallbackDone: Promise<void>
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
<script lang="ts" setup>
|
||||
import { NButton, NTooltip } from "naive-ui"
|
||||
import TagTitle from "./TagTitle.vue"
|
||||
import { FlowchartSummary, SolvedProblem } from "utils/types"
|
||||
import type { FlowchartSummary, SolvedProblem } from "utils/types"
|
||||
import { useAIStore } from "oj/store/ai"
|
||||
import { useBreakpoints } from "shared/composables/breakpoints"
|
||||
import { parseTime } from "utils/functions"
|
||||
|
||||
@@ -5,7 +5,7 @@ import Pagination from "shared/components/Pagination.vue"
|
||||
import { useBreakpoints } from "shared/composables/breakpoints"
|
||||
import { parseTime } from "utils/functions"
|
||||
import { renderTableTitle } from "utils/renders"
|
||||
import { Announcement } from "utils/types"
|
||||
import type { Announcement } from "utils/types"
|
||||
import TitleWithTag from "./components/TitleWithTag.vue"
|
||||
|
||||
const total = ref(0)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { ContestRank } from "utils/types"
|
||||
import type { ContestRank } from "utils/types"
|
||||
|
||||
interface Props {
|
||||
rank: ContestRank
|
||||
|
||||
@@ -15,7 +15,7 @@ import {
|
||||
Tooltip,
|
||||
Legend,
|
||||
} from "chart.js"
|
||||
import { ContestRank } from "utils/types"
|
||||
import type { ContestRank } from "utils/types"
|
||||
|
||||
ChartJS.register(
|
||||
CategoryScale,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { ProblemFiltered } from "utils/types"
|
||||
import type { ProblemFiltered } from "utils/types"
|
||||
import ProblemStatus from "oj/problem/components/ProblemStatus.vue"
|
||||
import { useContestStore } from "oj/store/contest"
|
||||
import { renderTableTitle } from "utils/renders"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { Exercise, ExerciseDebugData } from "utils/types"
|
||||
import type { Exercise, ExerciseDebugData } from "utils/types"
|
||||
import { highlightLines } from "../composables/useCodeHighlight"
|
||||
import "./exercise-highlight.css"
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { Exercise, ExerciseGroupData } from "utils/types"
|
||||
import type { Exercise, ExerciseGroupData } from "utils/types"
|
||||
|
||||
const props = defineProps<{ exercise: Exercise; lang?: string }>()
|
||||
const data = computed(() => props.exercise.data as ExerciseGroupData)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { Exercise, ExerciseMatchData } from "utils/types"
|
||||
import type { Exercise, ExerciseMatchData } from "utils/types"
|
||||
|
||||
const props = defineProps<{ exercise: Exercise; lang?: string }>()
|
||||
const data = computed(() => props.exercise.data as ExerciseMatchData)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { Exercise, ExerciseMcqData } from "utils/types"
|
||||
import type { Exercise, ExerciseMcqData } from "utils/types"
|
||||
|
||||
const props = defineProps<{ exercise: Exercise }>()
|
||||
const data = computed(() => props.exercise.data as ExerciseMcqData)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { Exercise, ExercisePredictData } from "utils/types"
|
||||
import type { Exercise, ExercisePredictData } from "utils/types"
|
||||
import { highlight } from "../composables/useCodeHighlight"
|
||||
import "./exercise-highlight.css"
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import hljs from "highlight.js/lib/core"
|
||||
import python from "highlight.js/lib/languages/python"
|
||||
import c from "highlight.js/lib/languages/c"
|
||||
import { Exercise, ExerciseSortData } from "utils/types"
|
||||
import type { Exercise, ExerciseSortData } from "utils/types"
|
||||
|
||||
hljs.registerLanguage("python", python)
|
||||
hljs.registerLanguage("c", c)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { Exercise } from "utils/types"
|
||||
import type { Exercise } from "utils/types"
|
||||
|
||||
const ExerciseMcq = defineAsyncComponent(() => import("./ExerciseMcq.vue"))
|
||||
const ExerciseSort = defineAsyncComponent(() => import("./ExerciseSort.vue"))
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Exercise } from "utils/types"
|
||||
import type { Exercise } from "utils/types"
|
||||
|
||||
type Segment =
|
||||
| { type: "md"; content: string }
|
||||
|
||||
@@ -7,7 +7,7 @@ import CodeEditor from "shared/components/CodeEditor.vue"
|
||||
import { useBreakpoints } from "shared/composables/breakpoints"
|
||||
import { provideSyncStatus } from "oj/composables/syncStatus"
|
||||
import storage from "utils/storage"
|
||||
import { LANGUAGE } from "utils/types"
|
||||
import type { LANGUAGE } from "utils/types"
|
||||
import Form from "./Form.vue"
|
||||
|
||||
const route = useRoute()
|
||||
|
||||
@@ -15,7 +15,7 @@ import {
|
||||
import { useBreakpoints } from "shared/composables/breakpoints"
|
||||
import { useUserStore } from "shared/store/user"
|
||||
import storage from "utils/storage"
|
||||
import { LANGUAGE } from "utils/types"
|
||||
import type { LANGUAGE } from "utils/types"
|
||||
import StatisticsPanel from "shared/components/StatisticsPanel.vue"
|
||||
import IconButton from "shared/components/IconButton.vue"
|
||||
import { Icon } from "@iconify/vue"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import { Icon } from "@iconify/vue"
|
||||
import { ProblemSet, UserBadge as UserBadgeType } from "utils/types"
|
||||
import type { ProblemSet, UserBadge as UserBadgeType } from "utils/types"
|
||||
import UserBadge from "shared/components/UserBadge.vue"
|
||||
import { useUserStore } from "shared/store/user"
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import { Icon } from "@iconify/vue"
|
||||
import { ProblemSetProblem } from "utils/types"
|
||||
import type { ProblemSetProblem } from "utils/types"
|
||||
import { DIFFICULTY } from "utils/constants"
|
||||
import { getTagColor } from "utils/functions"
|
||||
import { useBreakpoints } from "shared/composables/breakpoints"
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import { h, computed, ref, onMounted, watch } from "vue"
|
||||
import { watchDebounced } from "@vueuse/core"
|
||||
import { parseTime } from "utils/functions"
|
||||
import { ProblemSetProgress } from "utils/types"
|
||||
import type { ProblemSetProgress } from "utils/types"
|
||||
import { getProblemSetUserProgress } from "../../api"
|
||||
import { NFlex, NTag } from "naive-ui"
|
||||
import { usePagination } from "shared/composables/pagination"
|
||||
|
||||
@@ -5,7 +5,7 @@ import {
|
||||
joinProblemSet,
|
||||
getUserBadges,
|
||||
} from "../api"
|
||||
import {
|
||||
import type {
|
||||
ProblemSet,
|
||||
ProblemSetProblem,
|
||||
UserBadge as UserBadgeType,
|
||||
|
||||
@@ -11,7 +11,7 @@ import {
|
||||
Colors,
|
||||
} from "chart.js"
|
||||
import { ChartType } from "utils/constants"
|
||||
import { Rank } from "utils/types"
|
||||
import type { Rank } from "utils/types"
|
||||
|
||||
// 仅注册柱状图所需的 Chart.js 组件
|
||||
ChartJS.register(
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { DetailsData, DurationData } from "utils/types"
|
||||
import type { DetailsData, DurationData } from "utils/types"
|
||||
import { consumeJSONEventStream } from "utils/stream"
|
||||
import {
|
||||
getAIDetailData,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { defineStore } from "pinia"
|
||||
import { STORAGE_KEY } from "utils/constants"
|
||||
import storage from "utils/storage"
|
||||
import { Code, LANGUAGE } from "utils/types"
|
||||
import type { Code, LANGUAGE } from "utils/types"
|
||||
|
||||
/**
|
||||
* 代码编辑器状态管理 Store
|
||||
|
||||
@@ -2,7 +2,7 @@ import { formatISO, getTime, parseISO } from "date-fns"
|
||||
import { useUserStore } from "shared/store/user"
|
||||
import { ContestStatus, ContestType } from "utils/constants"
|
||||
import { duration } from "utils/functions"
|
||||
import { Contest, Problem } from "utils/types"
|
||||
import type { Contest, Problem } from "utils/types"
|
||||
import {
|
||||
checkContestPassword,
|
||||
getContest,
|
||||
|
||||
@@ -109,7 +109,7 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { Icon } from "@iconify/vue"
|
||||
import { FlowchartSubmission } from "utils/types"
|
||||
import type { FlowchartSubmission } from "utils/types"
|
||||
import { useMermaid } from "shared/composables/useMermaid"
|
||||
|
||||
interface Props {
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
</n-text>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { Grade } from "utils/types"
|
||||
import type { Grade } from "utils/types"
|
||||
defineProps<{
|
||||
score: number
|
||||
grade: Grade
|
||||
|
||||
@@ -11,7 +11,7 @@ import {
|
||||
submissionTimeFormat,
|
||||
utoa,
|
||||
} from "utils/functions"
|
||||
import { Submission } from "utils/types"
|
||||
import type { Submission } from "utils/types"
|
||||
import SubmissionResultTag from "shared/components/SubmissionResultTag.vue"
|
||||
import { useBreakpoints } from "shared/composables/breakpoints"
|
||||
import { useCodeStore } from "oj/store/code"
|
||||
|
||||
@@ -48,7 +48,7 @@ import { JUDGE_STATUS, LANGUAGE_FORMAT_VALUE } from "utils/constants"
|
||||
import Copy from "shared/components/Copy.vue"
|
||||
import Pagination from "shared/components/Pagination.vue"
|
||||
import { parseTime } from "utils/functions"
|
||||
import { Message } from "utils/types"
|
||||
import type { Message } from "utils/types"
|
||||
|
||||
const router = useRouter()
|
||||
const messages = ref<Message[]>([])
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import http from "utils/http"
|
||||
import { Profile, Tag } from "utils/types"
|
||||
import type { Profile, Tag } from "utils/types"
|
||||
|
||||
export function login(data: { username: string; password: string }) {
|
||||
return http.post("login", data)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<script setup lang="ts">
|
||||
import { Icon } from "@iconify/vue"
|
||||
import { ContestType } from "utils/constants"
|
||||
import { Contest } from "utils/types"
|
||||
import type { Contest } from "utils/types"
|
||||
|
||||
defineProps<{ contest: Contest }>()
|
||||
</script>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import { ContestType } from "utils/constants"
|
||||
import { Contest } from "utils/types"
|
||||
import type { Contest } from "utils/types"
|
||||
|
||||
interface Props {
|
||||
contest: Contest
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import { JUDGE_STATUS } from "utils/constants"
|
||||
import { SUBMISSION_RESULT } from "utils/types"
|
||||
import type { SUBMISSION_RESULT } from "utils/types"
|
||||
|
||||
interface Props {
|
||||
result: SUBMISSION_RESULT
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { UserBadge } from "utils/types"
|
||||
import type { UserBadge } from "utils/types"
|
||||
import { parseTime } from "utils/functions"
|
||||
interface Props {
|
||||
badge: UserBadge
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { getWebsiteConfig } from "oj/api"
|
||||
import { WebsiteConfig } from "utils/types"
|
||||
import type { WebsiteConfig } from "utils/types"
|
||||
|
||||
export const useConfigStore = defineStore("config", () => {
|
||||
const config = ref<WebsiteConfig>({
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { PROBLEM_PERMISSION, STORAGE_KEY, USER_TYPE } from "utils/constants"
|
||||
import storage from "utils/storage"
|
||||
import { Profile, User } from "utils/types"
|
||||
import type { Profile, User } from "utils/types"
|
||||
import { getProfile } from "../api"
|
||||
import { useConfigStore } from "./config"
|
||||
|
||||
|
||||
@@ -2,6 +2,9 @@
|
||||
"extends": "@vue/tsconfig/tsconfig.dom.json",
|
||||
"compilerOptions": {
|
||||
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
|
||||
// Vite(oxc) 遵守 verbatimModuleSyntax,会保留未写 type 的纯类型导入导致构建报错;
|
||||
// 关掉以让转换器自动消除类型导入(与原 Rsbuild 行为一致)
|
||||
"verbatimModuleSyntax": false,
|
||||
"paths": {
|
||||
"utils/*": ["./src/utils/*"],
|
||||
"oj/*": ["./src/oj/*"],
|
||||
|
||||
@@ -20,5 +20,5 @@
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"noUncheckedSideEffectImports": true
|
||||
},
|
||||
"include": ["rsbuild.config.ts"]
|
||||
"include": ["vite.config.ts"]
|
||||
}
|
||||
|
||||
112
vite.config.ts
Normal file
112
vite.config.ts
Normal file
@@ -0,0 +1,112 @@
|
||||
import { fileURLToPath, URL } from "node:url"
|
||||
import { defineConfig, loadEnv, type Plugin } from "vite"
|
||||
import vue from "@vitejs/plugin-vue"
|
||||
import legacy from "@vitejs/plugin-legacy"
|
||||
import AutoImport from "unplugin-auto-import/vite"
|
||||
import Components from "unplugin-vue-components/vite"
|
||||
import { NaiveUiResolver } from "unplugin-vue-components/resolvers"
|
||||
|
||||
// index.html 里按需注入 MaxKB 脚本(原 Rsbuild EJS 模板的等价实现)
|
||||
function injectMaxkb(maxkbUrl: string | undefined): Plugin {
|
||||
return {
|
||||
name: "inject-maxkb",
|
||||
transformIndexHtml(html) {
|
||||
if (!maxkbUrl) return html
|
||||
return {
|
||||
html,
|
||||
tags: [
|
||||
{
|
||||
tag: "script",
|
||||
attrs: { async: true, defer: true, src: maxkbUrl },
|
||||
injectTo: "head",
|
||||
},
|
||||
],
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
export default defineConfig(({ mode }) => {
|
||||
const env = loadEnv(mode, process.cwd(), "PUBLIC_")
|
||||
|
||||
const proxyConfig = {
|
||||
target: env["PUBLIC_OJ_URL"],
|
||||
changeOrigin: true,
|
||||
}
|
||||
|
||||
const wsProxyConfig = {
|
||||
target: env["PUBLIC_WS_URL"],
|
||||
ws: true,
|
||||
changeOrigin: true,
|
||||
}
|
||||
|
||||
return {
|
||||
plugins: [
|
||||
vue(),
|
||||
// 机房存在 Chrome 91 等旧浏览器:不做 SystemJS 双构建,
|
||||
// 只按使用情况给现代产物注入 core-js API polyfill(Array.at 等)
|
||||
legacy({
|
||||
renderLegacyChunks: false,
|
||||
modernTargets: "chrome>=90",
|
||||
modernPolyfills: true,
|
||||
}),
|
||||
AutoImport({
|
||||
imports: [
|
||||
"vue",
|
||||
"vue-router",
|
||||
"@vueuse/core",
|
||||
"pinia",
|
||||
{
|
||||
"naive-ui": [
|
||||
"useDialog",
|
||||
"useMessage",
|
||||
"useNotification",
|
||||
"useLoadingBar",
|
||||
],
|
||||
},
|
||||
{
|
||||
from: "naive-ui",
|
||||
imports: [
|
||||
"DataTableColumn",
|
||||
"FormRules",
|
||||
"FormItemRule",
|
||||
"SelectOption",
|
||||
"UploadCustomRequestOptions",
|
||||
"UploadFileInfo",
|
||||
"MenuOption",
|
||||
"DropdownDividerOption",
|
||||
"DropdownOption",
|
||||
],
|
||||
type: true,
|
||||
},
|
||||
],
|
||||
dts: "./src/auto-imports.d.ts",
|
||||
}),
|
||||
Components({
|
||||
resolvers: [NaiveUiResolver()],
|
||||
dts: "./src/components.d.ts",
|
||||
}),
|
||||
injectMaxkb(env["PUBLIC_MAXKB_URL"]),
|
||||
],
|
||||
envPrefix: "PUBLIC_",
|
||||
resolve: {
|
||||
alias: {
|
||||
// mermaid-legacy (mermaid@9) 写死了 UMD 路径,新版 cytoscape 的 exports
|
||||
// 不允许 import 条件访问它,转到 ESM 产物
|
||||
"cytoscape/dist/cytoscape.umd.js": "cytoscape/dist/cytoscape.esm.mjs",
|
||||
utils: fileURLToPath(new URL("./src/utils", import.meta.url)),
|
||||
oj: fileURLToPath(new URL("./src/oj", import.meta.url)),
|
||||
admin: fileURLToPath(new URL("./src/admin", import.meta.url)),
|
||||
shared: fileURLToPath(new URL("./src/shared", import.meta.url)),
|
||||
},
|
||||
},
|
||||
server: {
|
||||
port: 5173,
|
||||
proxy: {
|
||||
"/api": proxyConfig,
|
||||
"/public": proxyConfig,
|
||||
"/ws": wsProxyConfig,
|
||||
},
|
||||
},
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user