|
@@ -80,25 +80,44 @@ func ForbiddenHandler(ctx *gin.Context) {
|
|
|
func StaticFilesHandler(url string, ctx *gin.Context) {
|
|
|
finf, err := StaticFileSystem.Open(path.Clean(url))
|
|
|
if os.IsNotExist(err) {
|
|
|
- NotFoundHandler(ctx)
|
|
|
- return
|
|
|
+ if ConfigData.CommonConfig.VueHistoryMode {
|
|
|
+ VueHistoryModeHandler(ctx)
|
|
|
+ return
|
|
|
+ } else {
|
|
|
+ NotFoundHandler(ctx)
|
|
|
+ return
|
|
|
+ }
|
|
|
}
|
|
|
fst, err := finf.Stat()
|
|
|
if err != nil {
|
|
|
- NotFoundHandler(ctx)
|
|
|
- return
|
|
|
+ if ConfigData.CommonConfig.VueHistoryMode {
|
|
|
+ VueHistoryModeHandler(ctx)
|
|
|
+ return
|
|
|
+ } else {
|
|
|
+ NotFoundHandler(ctx)
|
|
|
+ return
|
|
|
+ }
|
|
|
}
|
|
|
if fst.IsDir() {
|
|
|
_, err := StaticFileSystem.Open(path.Clean(path.Join(url, "index.html")))
|
|
|
if os.IsNotExist(err) {
|
|
|
- ForbiddenHandler(ctx)
|
|
|
- return
|
|
|
+ if ConfigData.CommonConfig.VueHistoryMode {
|
|
|
+ VueHistoryModeHandler(ctx)
|
|
|
+ return
|
|
|
+ } else {
|
|
|
+ ForbiddenHandler(ctx)
|
|
|
+ return
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
ctx.Request.URL.Path = url
|
|
|
FileServer.ServeHTTP(ctx.Writer, ctx.Request)
|
|
|
}
|
|
|
|
|
|
+func VueHistoryModeHandler(ctx *gin.Context) {
|
|
|
+ http.ServeFile(ctx.Writer, ctx.Request, path.Join(WWWRootPath, "index.html"))
|
|
|
+}
|
|
|
+
|
|
|
func APIReverseProxy(context *gin.Context) {
|
|
|
if !ConfigData.CommonConfig.IsBackendProxyEnable {
|
|
|
NotFoundHandler(context)
|