update 修改添加订阅搜索方式,修正方法名称

This commit is contained in:
SummerTail 2023-07-07 15:54:38 +08:00
parent 2045da6ebe
commit 3edb0a645c
6 changed files with 109 additions and 97 deletions

View File

@ -8,8 +8,7 @@ const router = new Router({
router.get("/search",async (ctx)=>{ router.get("/search",async (ctx)=>{
let name = ctx.query.name let name = ctx.query.name
let info = await serach(name) ctx.body = await serach(name)
ctx.body = info
}) })
// router.get("/getinfo",async (ctx)=>{ // router.get("/getinfo",async (ctx)=>{
@ -18,10 +17,9 @@ router.get("/search",async (ctx)=>{
// ctx.body = info // ctx.body = info
// }) // })
router.get("/serchVideo",async (ctx)=>{ router.get("/searchVideo",async (ctx)=>{
let name = ctx.query.name let name = ctx.query.name
let info = await serach(name) ctx.body = await serach(name)
ctx.body = info
}) })
@ -31,8 +29,7 @@ router.get("/getVideoInfo",async (ctx)=>{
ctx.body = "请传递id" ctx.body = "请传递id"
return return
} }
let info = await gen_douban(id) ctx.body = await gen_douban(id)
ctx.body = info
}) })

View File

@ -1,7 +1,7 @@
const axios = require("axios") const axios = require("axios")
const puppeteer = require("puppeteer") const puppeteer = require("puppeteer")
const cheerio = require("cheerio"); // HTML页面解析 const cheerio = require("cheerio"); // HTML页面解析
async function serach(name) { async function search(name) {
const list = await axios.get(`https://movie.douban.com/j/subject_suggest?q=${name}`, { const list = await axios.get(`https://movie.douban.com/j/subject_suggest?q=${name}`, {
proxy: false, proxy: false,
}) })
@ -212,6 +212,6 @@ async function gen_douban(sid) {
} }
module.exports = { module.exports = {
serach, serach: search,
gen_douban gen_douban
} }

View File

@ -7,8 +7,8 @@ export async function getVideoInfo(id){
}) })
} }
export async function serchVideo(name){ export async function searchVideo(name){
return await base.get("/videoInfo/serchVideo",{ return await base.get("/videoInfo/searchVideo",{
params:{ params:{
name name
} }

View File

@ -1,28 +1,41 @@
<template> <template>
<el-menu <el-menu
:default-active="activeIndex"
class="el-menu-demo" class="el-menu-demo"
mode="horizontal" mode="horizontal"
@select="handleSelect" :ellipsis="false"
> >
<h3 style="width: 180px">WEB-DL发布工具</h3> <h3 style="width: 180px">WEB-DL发布工具</h3>
<el-menu-item index="1">首页</el-menu-item>
<el-sub-menu index="2"> <el-menu-item-group>
<template #title>设置</template> <el-input
<el-menu-item index="2-1">item one</el-menu-item> style="min-width: auto"
</el-sub-menu> v-model="searchInput"
<el-avatar style="position: absolute;right:0" :size="50" src="https://www.konfan.cn/img/favicon.png" /> placeholder="搜索资源"
:prefix-icon="Search"
@keydown.enter="search"
/>
</el-menu-item-group>
</el-menu> </el-menu>
<div class="h-6" /> <div class="h-6"/>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { ref } from 'vue' import {ref} from 'vue'
import {Search} from "@element-plus/icons-vue";
import {useRouter} from 'vue-router'
const activeIndex = ref('1') const router = useRouter()
const activeIndex2 = ref('1') const searchInput = ref('')
const handleSelect = (key: string, keyPath: string[]) => {
console.log(key, keyPath) function search() {
router.push({
path: '/addSubscribe',
query: {'name': searchInput.value}
})
} }
</script> </script>

View File

@ -8,16 +8,23 @@ import {
CollectionTag, CollectionTag,
VideoCamera, VideoCamera,
VideoPlay, VideoPlay,
SwitchButton SwitchButton, House
} from "@element-plus/icons-vue"; } from "@element-plus/icons-vue";
import {router} from "../router/index.js";
</script> </script>
<template> <template>
<el-scrollbar> <el-scrollbar>
<el-menu v-model="sel" :router="true"> <el-menu v-model="sel" :router="true">
<el-sub-menu index="1"> <el-menu-item index="1">
<el-icon>
<el-icon>
<House/>
</el-icon>
</el-icon>
<span>首页</span>
</el-menu-item>
<el-sub-menu index="2">
<template #title> <template #title>
<el-icon> <el-icon>
<CollectionTag/> <CollectionTag/>
@ -25,12 +32,6 @@ import {router} from "../router/index.js";
订阅管理 订阅管理
</template> </template>
<el-menu-item-group> <el-menu-item-group>
<el-menu-item index="/addSubscribe">
<el-icon>
<VideoCamera/>
</el-icon>
添加订阅
</el-menu-item>
<el-menu-item index="/subscribe"> <el-menu-item index="/subscribe">
<el-icon> <el-icon>
<VideoCamera/> <VideoCamera/>
@ -87,7 +88,7 @@ import {router} from "../router/index.js";
<script> <script>
import axios from "axios"; import axios from "axios";
import { ref } from "vue"; import {ref} from "vue";
const sel = ref('') const sel = ref('')

View File

@ -1,22 +1,14 @@
<template> <template>
<div> <div>
<el-form :inline="true" :model="formInline" class="demo-form-inline">
<el-form-item label="名称">
<el-input v-model="formInline.name" placeholder="Approved by" clearable />
</el-form-item>
<el-form-item>
<el-button type="primary" @click="onSubmit">搜索</el-button>
</el-form-item>
</el-form>
<div class="list"> <div class="list">
<div class="item" v-for="i in list"> <div class="item" v-for="i in list">
<el-card :body-style="{ padding: '0px' }"> <el-card :body-style="{ padding: '0px' }">
<img :src="i.img" class="image" /> <img :src="i.img" class="image"/>
<div style="padding: 14px"> <div style="padding: 14px">
<span>{{ i.title }}({{ i.year }})</span> <span>{{ i.title }}({{ i.year }})</span>
<div class="bottom"> <div class="bottom">
<time class="time">类型{{ i.type }}</time> <time class="time">类型{{ i.type }}</time>
<el-button text class="button" @click="getinfo(i.id)">详情</el-button> <el-button text class="button" @click="getInfo(i.id)">详情</el-button>
</div> </div>
</div> </div>
</el-card> </el-card>
@ -37,21 +29,30 @@
</template> </template>
<script setup> <script setup>
import { ref } from 'vue'; import {ref} from 'vue';
import { getVideoInfo, serchVideo } from '../../api/Video.js' import {getVideoInfo, searchVideo} from '../../api/Video.js'
import {onBeforeRouteUpdate, useRoute} from "vue-router";
const formInline = ref({
name: ""
})
let list = ref([]) let list = ref([])
const info = ref("") const info = ref("")
async function onSubmit() { const route = useRoute()
let res = await serchVideo(formInline.value.name)
async function onSubmit(name) {
let res = await searchVideo(name)
list.value = res.data.data list.value = res.data.data
} }
onSubmit(route.query.name)
onBeforeRouteUpdate(next => {
onSubmit(next.query.name)
})
let vid = ""; let vid = "";
const dialogFormVisible = ref(false) const dialogFormVisible = ref(false)
async function getinfo(id) {
async function getInfo(id) {
vid = id vid = id
let res = await getVideoInfo(id) let res = await getVideoInfo(id)
info.value = res.data.format info.value = res.data.format