From 4a7bd5b7f9a380678595ba3c109f9ce849477c14 Mon Sep 17 00:00:00 2001 From: Wangjunqi123 Date: Mon, 17 Jun 2024 15:15:10 +0800 Subject: [PATCH] template/server: modify static router path and add .gitignore --- template/server/.gitignore | 11 ++++++++++- template/server/handler/static.go | 2 +- template/server/handler/staticPro.go | 4 ++-- template/web/vite.config.ts | 1 + 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/template/server/.gitignore b/template/server/.gitignore index 46daa72e..f9d96451 100644 --- a/template/server/.gitignore +++ b/template/server/.gitignore @@ -1 +1,10 @@ -template.yaml \ No newline at end of file +template.yaml + +server/handler/assets/ +server/handler/index.html + +web/node_modules +web/dist/ + +handler/index.html +handler/assets \ No newline at end of file diff --git a/template/server/handler/static.go b/template/server/handler/static.go index 0eeb2e54..c93a8f53 100644 --- a/template/server/handler/static.go +++ b/template/server/handler/static.go @@ -13,7 +13,7 @@ import ( func StaticRouter(router *gin.Engine) { static := router.Group("/plugin/template") { - static.Static("/static", "../web/dist/static") + static.Static("/assets", "../web/dist/assets") static.StaticFile("/", "../web/dist/index.html") // 解决页面刷新404的问题 diff --git a/template/server/handler/staticPro.go b/template/server/handler/staticPro.go index 9489c804..9f7d8d34 100644 --- a/template/server/handler/staticPro.go +++ b/template/server/handler/staticPro.go @@ -14,7 +14,7 @@ import ( "github.com/gin-gonic/gin" ) -//go:embed static index.html +//go:embed assets index.html var StaticFiles embed.FS func StaticRouter(router *gin.Engine) { @@ -27,7 +27,7 @@ func StaticRouter(router *gin.Engine) { mime.AddExtensionType(".js", "application/javascript") static := router.Group("/plugin/template") { - static.StaticFS("/static", http.FS(sf)) + static.StaticFS("/assets", http.FS(sf)) static.GET("/", func(c *gin.Context) { c.FileFromFS("/", http.FS(StaticFiles)) }) diff --git a/template/web/vite.config.ts b/template/web/vite.config.ts index bd0d1650..72a5deaa 100644 --- a/template/web/vite.config.ts +++ b/template/web/vite.config.ts @@ -3,6 +3,7 @@ import vue from '@vitejs/plugin-vue' // https://vitejs.dev/config/ export default defineConfig({ + base: "/plugin/template", plugins: [vue()], server: { proxy: { -- Gitee