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

View File

@ -1,7 +1,7 @@
const axios = require("axios")
const puppeteer = require("puppeteer")
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}`, {
proxy: false,
})
@ -212,6 +212,6 @@ async function gen_douban(sid) {
}
module.exports = {
serach,
serach: search,
gen_douban
}

View File

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

View File

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

View File

@ -8,16 +8,23 @@ import {
CollectionTag,
VideoCamera,
VideoPlay,
SwitchButton
SwitchButton, House
} from "@element-plus/icons-vue";
import {router} from "../router/index.js";
</script>
<template>
<el-scrollbar>
<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>
<el-icon>
<CollectionTag/>
@ -25,12 +32,6 @@ import {router} from "../router/index.js";
订阅管理
</template>
<el-menu-item-group>
<el-menu-item index="/addSubscribe">
<el-icon>
<VideoCamera/>
</el-icon>
添加订阅
</el-menu-item>
<el-menu-item index="/subscribe">
<el-icon>
<VideoCamera/>

View File

@ -1,13 +1,5 @@
<template>
<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="item" v-for="i in list">
<el-card :body-style="{ padding: '0px' }">
@ -16,7 +8,7 @@
<span>{{ i.title }}({{ i.year }})</span>
<div class="bottom">
<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>
</el-card>
@ -38,20 +30,29 @@
<script setup>
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([])
const info = ref("")
async function onSubmit() {
let res = await serchVideo(formInline.value.name)
const route = useRoute()
async function onSubmit(name) {
let res = await searchVideo(name)
list.value = res.data.data
}
onSubmit(route.query.name)
onBeforeRouteUpdate(next => {
onSubmit(next.query.name)
})
let vid = "";
const dialogFormVisible = ref(false)
async function getinfo(id) {
async function getInfo(id) {
vid = id
let res = await getVideoInfo(id)
info.value = res.data.format