use rsbuild instead of vite
This commit is contained in:
8
.env
8
.env
@@ -1,4 +1,4 @@
|
|||||||
VITE_MAXKB_URL=https://maxkb.xuyue.cc/chat/api/embed?protocol=https&host=maxkb.xuyue.cc&token=2e801f7d6efdcc99
|
PUBLIC_MAXKB_URL=https://maxkb.xuyue.cc/chat/api/embed?protocol=https&host=maxkb.xuyue.cc&token=2e801f7d6efdcc99
|
||||||
VITE_OJ_URL=http://localhost:8000
|
PUBLIC_OJ_URL=http://localhost:8000
|
||||||
VITE_CODE_URL=https://code.xuyue.cc
|
PUBLIC_CODE_URL=https://code.xuyue.cc
|
||||||
VITE_JUDGE0_URL=https://judge0api.xuyue.cc
|
PUBLIC_JUDGE0_URL=https://judge0api.xuyue.cc
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
VITE_MAXKB_URL=https://maxkb.xuyue.cc/chat/api/embed?protocol=https&host=maxkb.xuyue.cc&token=2e801f7d6efdcc99
|
PUBLIC_MAXKB_URL=https://maxkb.xuyue.cc/chat/api/embed?protocol=https&host=maxkb.xuyue.cc&token=2e801f7d6efdcc99
|
||||||
VITE_OJ_URL=https://oj.xuyue.cc
|
PUBLIC_OJ_URL=https://oj.xuyue.cc
|
||||||
VITE_CODE_URL=https://code.xuyue.cc
|
PUBLIC_CODE_URL=https://code.xuyue.cc
|
||||||
VITE_JUDGE0_URL=https://judge0api.xuyue.cc
|
PUBLIC_JUDGE0_URL=https://judge0api.xuyue.cc
|
||||||
10
.env.staging
10
.env.staging
@@ -1,5 +1,5 @@
|
|||||||
VITE_MAXKB_URL=http://10.13.114.114:92/chat/api/embed?protocol=http&host=10.13.114.114:92&token=dd37457027c40b39
|
PUBLIC_MAXKB_URL=http://10.13.114.114:92/chat/api/embed?protocol=http&host=10.13.114.114:92&token=dd37457027c40b39
|
||||||
VITE_OJ_URL=http://10.13.114.114:81
|
PUBLIC_OJ_URL=http://10.13.114.114:81
|
||||||
VITE_CODE_URL=http://10.13.114.114:82
|
PUBLIC_CODE_URL=http://10.13.114.114:82
|
||||||
VITE_JUDGE0_URL=http://10.13.114.114:8082
|
PUBLIC_JUDGE0_URL=http://10.13.114.114:8082
|
||||||
VITE_ICONIFY_URL=http://10.13.114.114:8098
|
PUBLIC_ICONIFY_URL=http://10.13.114.114:8098
|
||||||
@@ -12,11 +12,10 @@
|
|||||||
<script
|
<script
|
||||||
async
|
async
|
||||||
defer
|
defer
|
||||||
src="%VITE_MAXKB_URL%"
|
src="<%= process.env.PUBLIC_MAXKB_URL %>"
|
||||||
></script>
|
></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="app"></div>
|
<div id="app"></div>
|
||||||
<script type="module" src="/src/main.ts"></script>
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
2145
package-lock.json
generated
2145
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
16
package.json
16
package.json
@@ -1,12 +1,11 @@
|
|||||||
{
|
{
|
||||||
"name": "oj-next",
|
"name": "oj-next",
|
||||||
"version": "1.7.0",
|
"version": "1.8.0",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "vite",
|
"start": "rsbuild dev",
|
||||||
"build": "vue-tsc && vite build",
|
"build": "rsbuild build",
|
||||||
"build:staging": "vue-tsc && vite build --mode=staging",
|
"build:staging": "rsbuild build --env-mode=staging",
|
||||||
"preview": "vite preview",
|
|
||||||
"fmt": "prettier --write src *.ts"
|
"fmt": "prettier --write src *.ts"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -33,14 +32,13 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@iconify/vue": "^5.0.0",
|
"@iconify/vue": "^5.0.0",
|
||||||
|
"@rsbuild/core": "^1.5.3",
|
||||||
|
"@rsbuild/plugin-vue": "^1.1.2",
|
||||||
"@types/canvas-confetti": "^1.9.0",
|
"@types/canvas-confetti": "^1.9.0",
|
||||||
"@types/node": "^24.3.0",
|
"@types/node": "^24.3.0",
|
||||||
"@vitejs/plugin-vue": "^6.0.1",
|
|
||||||
"prettier": "^3.6.2",
|
"prettier": "^3.6.2",
|
||||||
"typescript": "^5.9.2",
|
"typescript": "^5.9.2",
|
||||||
"unplugin-auto-import": "^20.0.0",
|
"unplugin-auto-import": "^20.0.0",
|
||||||
"unplugin-vue-components": "^29.0.0",
|
"unplugin-vue-components": "^29.0.0"
|
||||||
"vite": "^7.1.3",
|
|
||||||
"vue-tsc": "^3.0.6"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
93
rsbuild.config.ts
Normal file
93
rsbuild.config.ts
Normal file
@@ -0,0 +1,93 @@
|
|||||||
|
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"
|
||||||
|
|
||||||
|
export default defineConfig(({ envMode }) => {
|
||||||
|
const { publicVars, rawPublicVars } = loadEnv({
|
||||||
|
cwd: process.cwd(),
|
||||||
|
mode: envMode,
|
||||||
|
})
|
||||||
|
|
||||||
|
const url = rawPublicVars["PUBLIC_OJ_URL"]
|
||||||
|
const proxyConfig = {
|
||||||
|
target: url,
|
||||||
|
headers: { Referer: url },
|
||||||
|
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,
|
||||||
|
},
|
||||||
|
performance: {
|
||||||
|
chunkSplit: {
|
||||||
|
strategy: "split-by-module",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
resolve: {
|
||||||
|
alias: {
|
||||||
|
"~": "./src",
|
||||||
|
utils: "./src/utils",
|
||||||
|
oj: "./src/oj",
|
||||||
|
admin: "./src/admin",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
server: {
|
||||||
|
port: 5173,
|
||||||
|
proxy: {
|
||||||
|
"/api": proxyConfig,
|
||||||
|
"/public": proxyConfig,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
})
|
||||||
@@ -99,7 +99,7 @@ const abnormalServers = computed(() =>
|
|||||||
)
|
)
|
||||||
|
|
||||||
const websiteConfig = reactive({
|
const websiteConfig = reactive({
|
||||||
website_base_url: import.meta.env.VITE_OJ_URL,
|
website_base_url: import.meta.env.PUBLIC_OJ_URL,
|
||||||
website_name: "判题狗",
|
website_name: "判题狗",
|
||||||
website_name_shortcut: "判题狗",
|
website_name_shortcut: "判题狗",
|
||||||
website_footer: "所有权归属于徐越,感谢青岛大学开源 OJ 系统,感谢开源社区",
|
website_footer: "所有权归属于徐越,感谢青岛大学开源 OJ 系统,感谢开源社区",
|
||||||
|
|||||||
@@ -87,7 +87,11 @@ onMounted(init)
|
|||||||
/>
|
/>
|
||||||
</n-form-item>
|
</n-form-item>
|
||||||
<n-form-item label="顺序">
|
<n-form-item label="顺序">
|
||||||
<n-input-number style="width: 100px" v-model:value="tutorial.order" :min="0" />
|
<n-input-number
|
||||||
|
style="width: 100px"
|
||||||
|
v-model:value="tutorial.order"
|
||||||
|
:min="0"
|
||||||
|
/>
|
||||||
</n-form-item>
|
</n-form-item>
|
||||||
<n-form-item label="可见">
|
<n-form-item label="可见">
|
||||||
<n-switch v-model:value="tutorial.is_public" />
|
<n-switch v-model:value="tutorial.is_public" />
|
||||||
|
|||||||
13
src/env.d.ts
vendored
Normal file
13
src/env.d.ts
vendored
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
/// <reference types="@rsbuild/core/types" />
|
||||||
|
|
||||||
|
interface ImportMetaEnv {
|
||||||
|
readonly PUBLIC_MAXKB_URL: string
|
||||||
|
readonly PUBLIC_OJ_URL: string
|
||||||
|
readonly PUBLIC_CODE_URL: string
|
||||||
|
readonly PUBLIC_JUDGE0_URL: string
|
||||||
|
readonly PUBLIC_ICONIFY_URL: string
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ImportMeta {
|
||||||
|
readonly env: ImportMetaEnv
|
||||||
|
}
|
||||||
@@ -34,8 +34,8 @@ app.use(router)
|
|||||||
app.use(pinia)
|
app.use(pinia)
|
||||||
app.mount("#app")
|
app.mount("#app")
|
||||||
|
|
||||||
if (!!import.meta.env.VITE_ICONIFY_URL) {
|
if (!!import.meta.env.PUBLIC_ICONIFY_URL) {
|
||||||
addAPIProvider("", {
|
addAPIProvider("", {
|
||||||
resources: [import.meta.env.VITE_ICONIFY_URL],
|
resources: [import.meta.env.PUBLIC_ICONIFY_URL],
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ async function select(key: string) {
|
|||||||
copy()
|
copy()
|
||||||
break
|
break
|
||||||
case "test":
|
case "test":
|
||||||
window.open(import.meta.env.VITE_CODE_URL, "_blank")
|
window.open(import.meta.env.PUBLIC_CODE_URL, "_blank")
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -103,7 +103,7 @@ function changeLanguage(v: LANGUAGE) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function gotoTestCat() {
|
function gotoTestCat() {
|
||||||
const url = import.meta.env.VITE_CODE_URL
|
const url = import.meta.env.PUBLIC_CODE_URL
|
||||||
window.open(url, "_blank")
|
window.open(url, "_blank")
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
5
src/shims.d.ts
vendored
5
src/shims.d.ts
vendored
@@ -1,5 +0,0 @@
|
|||||||
declare module "*.md" {
|
|
||||||
import type { ComponentOptions } from "vue"
|
|
||||||
const Component: ComponentOptions
|
|
||||||
export default Component
|
|
||||||
}
|
|
||||||
@@ -2,7 +2,7 @@ import axios from "axios"
|
|||||||
import { decode, encode } from "./functions"
|
import { decode, encode } from "./functions"
|
||||||
import { Code } from "./types"
|
import { Code } from "./types"
|
||||||
|
|
||||||
const http = axios.create({ baseURL: import.meta.env.VITE_JUDGE0_URL })
|
const http = axios.create({ baseURL: import.meta.env.PUBLIC_JUDGE0_URL })
|
||||||
|
|
||||||
export async function createTestSubmission(code: Code, input: string) {
|
export async function createTestSubmission(code: Code, input: string) {
|
||||||
const encodedCode = encode(code.value)
|
const encodedCode = encode(code.value)
|
||||||
|
|||||||
13
src/vite-env.d.ts
vendored
13
src/vite-env.d.ts
vendored
@@ -1,13 +0,0 @@
|
|||||||
/// <reference types="vite/client" />
|
|
||||||
|
|
||||||
interface ImportMetaEnv {
|
|
||||||
readonly VITE_MAXKB_URL: string
|
|
||||||
readonly VITE_OJ_URL: string
|
|
||||||
readonly VITE_CODE_URL: string
|
|
||||||
readonly VITE_JUDGE0_URL: string
|
|
||||||
readonly VITE_ICONIFY_URL: string
|
|
||||||
}
|
|
||||||
|
|
||||||
interface ImportMeta {
|
|
||||||
readonly env: ImportMetaEnv
|
|
||||||
}
|
|
||||||
@@ -5,5 +5,5 @@
|
|||||||
"moduleResolution": "Node",
|
"moduleResolution": "Node",
|
||||||
"allowSyntheticDefaultImports": true
|
"allowSyntheticDefaultImports": true
|
||||||
},
|
},
|
||||||
"include": ["vite.config.ts"]
|
"include": ["rsbuild.config.ts"]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,96 +0,0 @@
|
|||||||
import Vue from "@vitejs/plugin-vue"
|
|
||||||
import path from "path"
|
|
||||||
import AutoImport from "unplugin-auto-import/vite"
|
|
||||||
import { NaiveUiResolver } from "unplugin-vue-components/resolvers"
|
|
||||||
import Components from "unplugin-vue-components/vite"
|
|
||||||
import { defineConfig, loadEnv } from "vite"
|
|
||||||
|
|
||||||
export default defineConfig(({ mode }) => {
|
|
||||||
const env = loadEnv(mode, process.cwd())
|
|
||||||
const url = env.VITE_OJ_URL
|
|
||||||
|
|
||||||
const proxyConfig = {
|
|
||||||
target: url,
|
|
||||||
changeOrigin: true,
|
|
||||||
headers: { Referer: url },
|
|
||||||
}
|
|
||||||
return {
|
|
||||||
build: {
|
|
||||||
rollupOptions: {
|
|
||||||
output: {
|
|
||||||
manualChunks: {
|
|
||||||
chart: ["vue-chartjs", "chart.js"],
|
|
||||||
editor: [
|
|
||||||
"@wangeditor-next/editor",
|
|
||||||
"@wangeditor-next/editor-for-vue",
|
|
||||||
],
|
|
||||||
cm: [
|
|
||||||
"vue-codemirror",
|
|
||||||
"codemirror",
|
|
||||||
"@codemirror/lang-cpp",
|
|
||||||
"@codemirror/lang-python",
|
|
||||||
],
|
|
||||||
md: [
|
|
||||||
"md-editor-v3",
|
|
||||||
"md-editor-v3/lib/style.css",
|
|
||||||
"md-editor-v3/lib/preview.css",
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
resolve: {
|
|
||||||
alias: {
|
|
||||||
"~": path.resolve(__dirname, "./src"),
|
|
||||||
utils: path.resolve(__dirname, "./src/utils"),
|
|
||||||
oj: path.resolve(__dirname, "./src/oj"),
|
|
||||||
admin: path.resolve(__dirname, "./src/admin"),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
plugins: [
|
|
||||||
Vue(),
|
|
||||||
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",
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
server: {
|
|
||||||
proxy: {
|
|
||||||
"/api": proxyConfig,
|
|
||||||
"/public": proxyConfig,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
})
|
|
||||||
Reference in New Issue
Block a user