From f14d8ee6953f68f6c944f03c6061961f66541974 Mon Sep 17 00:00:00 2001 From: mubai <1609539827@qq.com> Date: Sat, 10 Aug 2024 22:49:35 +0800 Subject: [PATCH] ui and sql optimize --- client/vite.config.ts | 34 +++++++++++++------------- server/config/DataConfig.go | 3 +++ server/main.go | 3 +-- server/model/system/Search.go | 11 +++++---- server/plugin/SystemInit/SpiderInit.go | 13 +++++++--- server/plugin/spider/SpiderCore.go | 10 ++++++++ 6 files changed, 46 insertions(+), 28 deletions(-) diff --git a/client/vite.config.ts b/client/vite.config.ts index 7ec509e..679b7f8 100644 --- a/client/vite.config.ts +++ b/client/vite.config.ts @@ -7,32 +7,32 @@ import {ElementPlusResolver} from "unplugin-vue-components/resolvers"; export default defineConfig({ // 本地测试环境 - // server: { - // host: '0.0.0.0', - // port: 3600, - // proxy: { - // "/api": { - // target: `http://127.0.0.1:3601`, - // // target: `http://1.94.30.26:3601`, - // changeOrigin: true, // 允许跨域 - // rewrite: path => path.replace(/^\/api/, '') - // } - // }, - // }, - - // nginx发布构建时使用此配置 server: { - host: 'localhost', + host: '0.0.0.0', port: 3600, proxy: { "/api": { - target: `http://localhost`, + target: `http://127.0.0.1:3601`, + // target: `http://1.94.30.26:3601`, changeOrigin: true, // 允许跨域 - rewrite: path => path.replace(/^\/api/,'') + rewrite: path => path.replace(/^\/api/, '') } }, }, + // nginx发布构建时使用此配置 + // server: { + // host: 'localhost', + // port: 3600, + // proxy: { + // "/api": { + // target: `http://localhost`, + // changeOrigin: true, // 允许跨域 + // rewrite: path => path.replace(/^\/api/,'') + // } + // }, + // }, + plugins: [ vue(), AutoImport({ diff --git a/server/config/DataConfig.go b/server/config/DataConfig.go index 9054b72..c1e8150 100644 --- a/server/config/DataConfig.go +++ b/server/config/DataConfig.go @@ -88,6 +88,7 @@ const ( //mysql服务配置信息 root:root 设置mysql账户的用户名和密码 MysqlDsn = "root:root@(192.168.20.5:3306)/FilmSite?charset=utf8mb4&parseTime=True&loc=Local" + //MysqlDsn = "root:MuBai0916$@(1.94.30.26:3610)/FilmSite?charset=utf8mb4&parseTime=True&loc=Local" // MysqlDsn docker compose 环境下的链接信息 mysql:3306 为 docker compose 中 mysql服务对应的网络名称和端口 //MysqlDsn = "root:root@(mysql:3306)/FilmSite?charset=utf8mb4&parseTime=True&loc=Local" @@ -98,6 +99,8 @@ const ( RedisPassword redis访问密码 RedisDBNo 使用第几号库 */ + //RedisAddr = `1.94.30.26:3620` + //RedisPassword = `MuBai0916$` RedisAddr = `192.168.20.5:6379` RedisPassword = `root` RedisDBNo = 0 diff --git a/server/main.go b/server/main.go index d9e8905..d18150a 100644 --- a/server/main.go +++ b/server/main.go @@ -7,12 +7,11 @@ import ( "server/plugin/SystemInit" "server/plugin/db" "server/router" - "time" ) func init() { // 执行初始化前等待20s , 让mysql服务完成初始化指令 - time.Sleep(time.Second * 20) + //time.Sleep(time.Second * 20) //初始化redis客户端 err := db.InitRedisConn() if err != nil { diff --git a/server/model/system/Search.go b/server/model/system/Search.go index daac38d..aad2b0b 100644 --- a/server/model/system/Search.go +++ b/server/model/system/Search.go @@ -437,10 +437,10 @@ func GetMovieListByCid(cid int64, page *Page) []MovieBasicInfo { // GetHotMovieByPid 获取指定类别的热门影片 func GetHotMovieByPid(pid int64, page *Page) []SearchInfo { // 返回分页参数 - var count int64 - db.Mdb.Model(&SearchInfo{}).Where("pid", pid).Count(&count) - page.Total = int(count) - page.PageCount = int((page.Total + page.PageSize - 1) / page.PageSize) + //var count int64 + //db.Mdb.Model(&SearchInfo{}).Where("pid", pid).Count(&count) + //page.Total = int(count) + //page.PageCount = int((page.Total + page.PageSize - 1) / page.PageSize) // 进行具体的信息查询 var s []SearchInfo // 当前时间偏移一个月 @@ -513,7 +513,8 @@ func GetRelateMovieBasicInfo(search SearchInfo, page *Page) []MovieBasicInfo { sql = fmt.Sprintf(`%s class_tag like "%%%s%%"`, sql, search.ClassTag) } // 除名称外的相似影片使用随机排序 - sql = fmt.Sprintf("%s ORDER BY RAND() limit %d,%d)", sql, page.Current, page.PageSize) + //sql = fmt.Sprintf("%s ORDER BY RAND() limit %d,%d)", sql, page.Current, page.PageSize) + sql = fmt.Sprintf("%s limit %d,%d)", sql, page.Current, page.PageSize) // 条件拼接完成后加上limit参数 sql = fmt.Sprintf("(%s) limit %d,%d", sql, page.Current, page.PageSize) // 执行sql diff --git a/server/plugin/SystemInit/SpiderInit.go b/server/plugin/SystemInit/SpiderInit.go index 69c05d4..1c81069 100644 --- a/server/plugin/SystemInit/SpiderInit.go +++ b/server/plugin/SystemInit/SpiderInit.go @@ -21,11 +21,16 @@ func FilmSourceInit() { return } var l []system.FilmSource = []system.FilmSource{ - {Id: util.GenerateSalt(), Name: "HD(lz)", Uri: `https://cj.lziapi.com/api.php/provide/vod/`, ResultModel: system.JsonResult, Grade: system.SlaveCollect, SyncPictures: false, CollectType: system.CollectVideo, State: true}, - {Id: util.GenerateSalt(), Name: "HD(sn)", Uri: `https://suoniapi.com/api.php/provide/vod/from/snm3u8/`, ResultModel: system.JsonResult, Grade: system.SlaveCollect, SyncPictures: false, CollectType: system.CollectVideo, State: true, Interval: 2000}, - {Id: util.GenerateSalt(), Name: "HD(bf)", Uri: `https://bfzyapi.com/api.php/provide/vod/`, ResultModel: system.JsonResult, Grade: system.SlaveCollect, SyncPictures: false, CollectType: system.CollectVideo, State: true, Interval: 2500}, - {Id: util.GenerateSalt(), Name: "HD(ff)", Uri: `http://cj.ffzyapi.com/api.php/provide/vod/`, ResultModel: system.JsonResult, Grade: system.SlaveCollect, SyncPictures: false, CollectType: system.CollectVideo, State: true}, + {Id: util.GenerateSalt(), Name: "HD(LZ)", Uri: `https://cj.lzcaiji.com/api.php/provide/vod/`, ResultModel: system.JsonResult, Grade: system.SlaveCollect, SyncPictures: false, CollectType: system.CollectVideo, State: true}, + {Id: util.GenerateSalt(), Name: "HD(BF)", Uri: `https://bfzyapi.com/api.php/provide/vod/`, ResultModel: system.JsonResult, Grade: system.SlaveCollect, SyncPictures: false, CollectType: system.CollectVideo, State: true, Interval: 2500}, + {Id: util.GenerateSalt(), Name: "HD(FF)", Uri: `http://cj.ffzyapi.com/api.php/provide/vod/`, ResultModel: system.JsonResult, Grade: system.SlaveCollect, SyncPictures: false, CollectType: system.CollectVideo, State: true}, + {Id: util.GenerateSalt(), Name: "HD(OK)", Uri: `https://okzyapi.com/api.php/provide/vod/`, ResultModel: system.JsonResult, Grade: system.SlaveCollect, SyncPictures: false, CollectType: system.CollectVideo, State: true}, + {Id: util.GenerateSalt(), Name: "HD(HM)", Uri: `https://json.heimuer.xyz/api.php/provide/vod/`, ResultModel: system.JsonResult, Grade: system.SlaveCollect, SyncPictures: false, CollectType: system.CollectVideo, State: true}, + {Id: util.GenerateSalt(), Name: "HD(LY)", Uri: `https://360zy.com/api.php/provide/vod/at/json`, ResultModel: system.JsonResult, Grade: system.SlaveCollect, SyncPictures: false, CollectType: system.CollectVideo, State: true}, + {Id: util.GenerateSalt(), Name: "HD(YZ)", Uri: `https://api.1080zyku.com/inc/apijson.php`, ResultModel: system.JsonResult, Grade: system.SlaveCollect, SyncPictures: false, CollectType: system.CollectVideo, State: true}, {Id: util.GenerateSalt(), Name: "HD(kk)", Uri: `https://kuaikan-api.com/api.php/provide/vod/from/kuaikan/`, ResultModel: system.JsonResult, Grade: system.SlaveCollect, SyncPictures: false, CollectType: system.CollectVideo, State: true}, + {Id: util.GenerateSalt(), Name: "HD(SN)", Uri: `https://suoniapi.com/api.php/provide/vod/from/snm3u8/`, ResultModel: system.JsonResult, Grade: system.SlaveCollect, SyncPictures: false, CollectType: system.CollectVideo, State: true, Interval: 2000}, + //{Id: util.GenerateSalt(), Name: "HD(LZ)", Uri: `https://cj.lziapi.com/api.php/provide/vod/`, ResultModel: system.JsonResult, Grade: system.SlaveCollect, SyncPictures: false, CollectType: system.CollectVideo, State: true}, //{Id: util.GenerateSalt(), Name: "HD(lzBk)", Uri: `https://cj.lzcaiji.com/api.php/provide/vod/`, ResultModel: system.JsonResult, Grade: system.SlaveCollect, SyncPictures: false, CollectType: system.CollectVideo, State: true}, //{Id: util.GenerateSalt(), Name: "HD(fs)", Uri: `https://www.feisuzyapi.com/api.php/provide/vod/`, ResultModel: system.JsonResult, Grade: system.SlaveCollect, SyncPictures: false, CollectType: system.CollectVideo, State: true}, //{Id: util.GenerateSalt(), Name: "HD(bfApp)", Uri: `http://app.bfzyapi.com/api.php/provide/vod/`, ResultModel: system.JsonResult, Grade: system.SlaveCollect, SyncPictures: false, CollectType: system.CollectVideo, State: true}, diff --git a/server/plugin/spider/SpiderCore.go b/server/plugin/spider/SpiderCore.go index 50331ef..8155e2e 100644 --- a/server/plugin/spider/SpiderCore.go +++ b/server/plugin/spider/SpiderCore.go @@ -113,6 +113,16 @@ func (jc *JsonCollect) GetFilmDetail(r util.RequestInfo) (list []system.MovieDet return } +// CustomSearch 自定义搜索, 通过特定的搜索参数获取满足条件的影片数据 +func (jc *JsonCollect) CustomSearch(r util.RequestInfo) { + // 设置固定参数 ac 请求类型 pg 页数 + if len(r.Params.Get("ac")) <= 0 { + r.Params.Set("ac", "detail") + } + r.Params.Set("pg", "1") + // 设置搜索参数 wd (影片名模糊搜索) +} + // ------------------------------------------------- XML Collect ------------------------------------------------- // XmlCollect 处理返回值为XML格式的采集数据