From db2bbd5d4ddd1e0cbb85666145bd50058eb61b56 Mon Sep 17 00:00:00 2001 From: engigu Date: Wed, 11 Mar 2026 11:50:06 +0800 Subject: [PATCH] chore: add vs dist server for monaco -- change path --- internal/router/static_routes.go | 5 ----- web/src/main.ts | 2 +- web/vite.config.ts | 7 ++++++- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/internal/router/static_routes.go b/internal/router/static_routes.go index ecb005f..b3c0c1c 100644 --- a/internal/router/static_routes.go +++ b/internal/router/static_routes.go @@ -37,11 +37,6 @@ func initStaticRoutes(root *gin.RouterGroup) { assetsGroup.Use(cacheControl("public, max-age=31536000, immutable")) // 带哈希的资源缓存 assetsGroup.StaticFS("/", http.FS(mustSubFS(staticFS, "assets"))) - // Monaco Editor (vs) 静态资源 - vsGroup := root.Group("/vs") - vsGroup.Use(cacheControl("public, max-age=31536000, immutable")) - vsGroup.StaticFS("/", http.FS(mustSubFS(staticFS, "vs"))) - // logo.svg 短缓存实现 root.GET("/logo.svg", func(ctx *gin.Context) { data, err := static.ReadFile("logo.svg") diff --git a/web/src/main.ts b/web/src/main.ts index 5a04f2c..aa1870a 100644 --- a/web/src/main.ts +++ b/web/src/main.ts @@ -16,7 +16,7 @@ createApp(App) .use(router) .use(VueMonacoEditorPlugin, { paths: { - vs: BASE_URL + '/vs' + vs: BASE_URL + '/assets/vs' } }) .mount('#app') diff --git a/web/vite.config.ts b/web/vite.config.ts index 7c6432c..cebc39e 100644 --- a/web/vite.config.ts +++ b/web/vite.config.ts @@ -12,7 +12,7 @@ export default defineConfig({ targets: [ { src: 'node_modules/monaco-editor/min/vs', - dest: '.' + dest: 'assets' } ] }) @@ -53,5 +53,10 @@ export default defineConfig({ } } } + }, + define: { + // Define MONACO_BASE_URL for monaco-editor to correctly load its workers and assets + // This path should match the destination of viteStaticCopy for monaco-editor's 'vs' folder + MONACO_BASE_URL: JSON.stringify('./assets/vs') } })