fix: URL解码处理和移除BOM字符
- 添加assets文件路径的URL解码处理,支持特殊字符 - 添加NoRoute处理器的URL解码 - 移除dashboard.go文件中的BOM字符 - 添加Vite构建配置确保文件名格式正确
This commit is contained in:
+11
-2
@@ -6,6 +6,7 @@ import (
|
|||||||
"io/fs"
|
"io/fs"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
"verification-platform-backend/internal/config"
|
"verification-platform-backend/internal/config"
|
||||||
@@ -263,8 +264,12 @@ func setupEmbeddedFrontend(r *gin.Engine) {
|
|||||||
|
|
||||||
r.GET("/assets/*filepath", func(c *gin.Context) {
|
r.GET("/assets/*filepath", func(c *gin.Context) {
|
||||||
filepath := c.Param("filepath")
|
filepath := c.Param("filepath")
|
||||||
|
decodedPath, err := url.PathUnescape(filepath)
|
||||||
|
if err != nil {
|
||||||
|
decodedPath = filepath
|
||||||
|
}
|
||||||
c.Header("Cache-Control", "public, max-age=31536000, immutable")
|
c.Header("Cache-Control", "public, max-age=31536000, immutable")
|
||||||
c.FileFromFS("assets/"+filepath, http.FS(distFS))
|
c.FileFromFS("assets/"+decodedPath, http.FS(distFS))
|
||||||
})
|
})
|
||||||
|
|
||||||
r.NoRoute(func(c *gin.Context) {
|
r.NoRoute(func(c *gin.Context) {
|
||||||
@@ -274,7 +279,11 @@ func setupEmbeddedFrontend(r *gin.Engine) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
path := strings.TrimPrefix(c.Request.URL.Path, "/")
|
path := strings.TrimPrefix(c.Request.URL.Path, "/")
|
||||||
if f, err := distFS.Open(path); err == nil {
|
decodedPath, err := url.PathUnescape(path)
|
||||||
|
if err != nil {
|
||||||
|
decodedPath = path
|
||||||
|
}
|
||||||
|
if f, err := distFS.Open(decodedPath); err == nil {
|
||||||
f.Close()
|
f.Close()
|
||||||
c.FileFromFS(c.Request.URL.Path, http.FS(distFS))
|
c.FileFromFS(c.Request.URL.Path, http.FS(distFS))
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -103,6 +103,15 @@ export default defineConfig({
|
|||||||
'@': fileURLToPath(new URL('./src', import.meta.url)),
|
'@': fileURLToPath(new URL('./src', import.meta.url)),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
build: {
|
||||||
|
rollupOptions: {
|
||||||
|
output: {
|
||||||
|
chunkFileNames: 'assets/[name]-[hash].js',
|
||||||
|
entryFileNames: 'assets/[name]-[hash].js',
|
||||||
|
assetFileNames: 'assets/[name]-[hash].[ext]',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
server: {
|
server: {
|
||||||
proxy: {
|
proxy: {
|
||||||
'/api': {
|
'/api': {
|
||||||
|
|||||||
Reference in New Issue
Block a user