From 4caa3b061a4fc93cb8f093f5d3c3d7fe33572b0a Mon Sep 17 00:00:00 2001 From: yuetsh <517252939@qq.com> Date: Sun, 15 Jun 2025 21:53:50 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=B8=8A=E4=BC=A0=E5=9B=BE?= =?UTF-8?q?=E7=89=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env | 1 + .env.production | 1 + components.d.ts | 1 + rsbuild.config.ts | 10 +++++- src/api.ts | 11 +++++++ src/components/dashboard/MarkdownEditor.vue | 35 +++++++++++++++++++++ src/pages/Tutorial.vue | 9 +++--- 7 files changed, 63 insertions(+), 5 deletions(-) create mode 100644 .env create mode 100644 .env.production create mode 100644 src/components/dashboard/MarkdownEditor.vue diff --git a/.env b/.env new file mode 100644 index 0000000..9123a08 --- /dev/null +++ b/.env @@ -0,0 +1 @@ +WEB_URL=http://localhost:8000 \ No newline at end of file diff --git a/.env.production b/.env.production new file mode 100644 index 0000000..9c05eee --- /dev/null +++ b/.env.production @@ -0,0 +1 @@ +WEB_URL=https://web.xuyue.cc \ No newline at end of file diff --git a/components.d.ts b/components.d.ts index 0184acb..a95086a 100644 --- a/components.d.ts +++ b/components.d.ts @@ -13,6 +13,7 @@ declare module 'vue' { Editor: typeof import('./src/components/Editor.vue')['default'] Editors: typeof import('./src/components/Editors.vue')['default'] Login: typeof import('./src/components/Login.vue')['default'] + MarkdownEditor: typeof import('./src/components/dashboard/MarkdownEditor.vue')['default'] NAlert: typeof import('naive-ui')['NAlert'] NameWithFilter: typeof import('./src/components/submissions/NameWithFilter.vue')['default'] NButton: typeof import('naive-ui')['NButton'] diff --git a/rsbuild.config.ts b/rsbuild.config.ts index c6ec3b9..5e0ad12 100644 --- a/rsbuild.config.ts +++ b/rsbuild.config.ts @@ -15,7 +15,7 @@ export default defineConfig({ }, }, output: { - polyfill: "usage" + polyfill: "usage", }, tools: { rspack: { @@ -26,6 +26,14 @@ export default defineConfig({ ], }, }, + server: { + proxy: { + "/media": { + target: process.env.WEB_URL, + changeOrigin: true, + }, + }, + }, performance: { chunkSplit: { strategy: "split-by-experience", diff --git a/src/api.ts b/src/api.ts index 3fb156b..d63032b 100644 --- a/src/api.ts +++ b/src/api.ts @@ -131,3 +131,14 @@ export const Submission = { return res.data }, } + +export const Helper = { + async upload(file: File) { + const form = new window.FormData() + form.append("image", file) + const res = await http.post("/upload/", form, { + headers: { "content-type": "multipart/form-data" }, + }) + return !!res.data.url ? res.data.url : "" + }, +} diff --git a/src/components/dashboard/MarkdownEditor.vue b/src/components/dashboard/MarkdownEditor.vue new file mode 100644 index 0000000..19b632d --- /dev/null +++ b/src/components/dashboard/MarkdownEditor.vue @@ -0,0 +1,35 @@ + + diff --git a/src/pages/Tutorial.vue b/src/pages/Tutorial.vue index ba79fa6..9f940d8 100644 --- a/src/pages/Tutorial.vue +++ b/src/pages/Tutorial.vue @@ -58,7 +58,10 @@ - + @@ -70,9 +73,7 @@ import { Icon } from "@iconify/vue" import { Tutorial } from "../api" import type { TutorialSlim } from "../utils/type" import { useDialog, useMessage } from "naive-ui" -import { MdEditor } from "md-editor-v3" -//@ts-ignore -import "md-editor-v3/lib/style.css" +import MarkdownEditor from "../components/dashboard/MarkdownEditor.vue" const route = useRoute() const router = useRouter()