新增 `/movie/delete` 接口用于删除指定视频文件及其缩略图,并从全局电影列表中移除记录。 同时完善了前端删除交互,包括确认对话框、成功提示及错误处理。 - 后端: - 新增 `PostDelete` 处理函数,支持通过文件名删除视频 - 实现 `Movie.DeleteVideo()` 方法,用于删除视频文件和关联缩略图 - 更新路由注册,增加 `/delete` 接口 - 前端: - 新增删除确认弹窗与交互逻辑 - 添加删除成功的 Snackbar 提示 - 调整 MovieCard 按钮布局以容纳删除按钮 - 传递并使用 onDelete 回调函数处理删除操作 该功能增强了系统的文件管理能力,使用户能够安全地移除不需要的视频内容。
45 lines
972 B
Go
45 lines
972 B
Go
package main
|
|
|
|
import (
|
|
"net/http"
|
|
"path/filepath"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
func main() {
|
|
initMovie()
|
|
|
|
// 设置为发布模式
|
|
gin.SetMode(gin.ReleaseMode)
|
|
|
|
eg := gin.Default()
|
|
eg.Use(Cors())
|
|
eg.Static("/res", "movie/")
|
|
eg.Static("/static", "../build/static")
|
|
eg.StaticFile("/manifest.json", "../build/manifest.json")
|
|
eg.StaticFile("/favicon.ico", "../build/favicon.ico")
|
|
eg.StaticFile("/logo512.png", "../build/logo512.png")
|
|
eg.StaticFile("/logo192.png", "../build/logo192.png")
|
|
eg.NoRoute(func(c *gin.Context) {
|
|
path := c.Request.URL.Path
|
|
if filepath.Ext(path) == "" {
|
|
c.File("../build/index.html")
|
|
} else {
|
|
c.Status(http.StatusNotFound)
|
|
}
|
|
})
|
|
|
|
api := eg.Group("/api")
|
|
api.POST("/login", loginHandler)
|
|
|
|
movie := eg.Group("movie")
|
|
movie.Use(jwtMiddleware())
|
|
movie.GET("/list/category", GetCategoryList)
|
|
movie.GET("/list", MovieList)
|
|
movie.POST("/rename", PostRename)
|
|
movie.POST("/delete", PostDelete)
|
|
|
|
eg.Run("0.0.0.0:4444")
|
|
}
|