Forráskód Böngészése

部分数据修改和调整

Administrator 1 éve
szülő
commit
15245f5f5b

+ 0 - 10
file/resources/17170534845679.png

@@ -1,10 +0,0 @@
-<!DOCTYPE html>
-<html>
-    <head>
-        <meta charset="UTF-8" />
-        <title>404</title>
-    </head>
-    <body>
-        <script type="text/javascript" charset="utf-8" src="//qzonestyle.gtimg.cn/qzone/hybrid/app/404/search_children.js" homePageUrl="https://www.zuhaohao.com/" homePageName="回到我的主页"></script>
-    </body>
-</html>

BIN
file/resources/20240423094145微信图片_20240416170543.jpg


BIN
file/resources/202407021003542.jpg


BIN
file/resources/20240702153418微信图片_20240416170543.jpg


BIN
file/resources/20240702161158微信图片_20240416170543.jpg


BIN
file/resources/202407021613112 - 副本.jpg


BIN
file/resources/202407021613312 - 副本.jpg


+ 0 - 1
file/static/detail.html

@@ -313,7 +313,6 @@
             </div>
         </div>
     </div>
-
 </div>
 
 {{template "BottomBar.tmpl" .}}

+ 12 - 3
router/FileRouter.go

@@ -7,6 +7,7 @@ import (
 	"github.com/gin-gonic/gin"
 	"github.com/spf13/cast"
 	"os"
+	"strings"
 	"time"
 )
 
@@ -22,7 +23,7 @@ func FileRouter(engine *gin.RouterGroup) {
 		//文章上传
 		//user.POST("/upload", uploadHandler)
 		PushRouter(user, "POST", "/upload", uploadHandler)
-		PushRouter(user, "DELETE", "", DeleteFile)
+		PushRouter(user, "PUT", "", DeleteFile)
 	}
 }
 
@@ -61,7 +62,15 @@ func uploadHandler(c *gin.Context) {
 func DeleteFile(c *gin.Context) {
 	data := share.GetJsonAnyParam(c)
 	fileUrl, _ := data("fileUrl")
-	s, err := os.Stat(cast.ToString(fileUrl))
+
+	url := cast.ToString(fileUrl)
+
+	if strings.Index(url, "/api/static/") != 0 {
+		c.JSON(200, CreateResultError(400, "文件路径错误"))
+	}
+	url = fmt.Sprint("file/resources/", strings.Replace(url, "/api/static/", "", 1))
+
+	s, err := os.Stat(url)
 	if os.IsNotExist(err) {
 		c.JSON(200, CreateResultError(400, "文件不存在"))
 		return
@@ -70,7 +79,7 @@ func DeleteFile(c *gin.Context) {
 		c.JSON(200, CreateResultError(400, "路径不存在"))
 		return
 	}
-	err = os.Remove(cast.ToString(fileUrl))
+	err = os.Remove(url)
 	if err != nil {
 		c.JSON(200, CreateResultError(400, "删除失败"))
 		return