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()