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,99 +1,100 @@
<template> <template>
<div> <div>
<el-form :inline="true" :model="formInline" class="demo-form-inline"> <div class="list">
<el-form-item label="名称"> <div class="item" v-for="i in list">
<el-input v-model="formInline.name" placeholder="Approved by" clearable /> <el-card :body-style="{ padding: '0px' }">
</el-form-item> <img :src="i.img" class="image"/>
<el-form-item> <div style="padding: 14px">
<el-button type="primary" @click="onSubmit">搜索</el-button> <span>{{ i.title }}({{ i.year }})</span>
</el-form-item> <div class="bottom">
</el-form> <time class="time">类型{{ i.type }}</time>
<div class="list"> <el-button text class="button" @click="getInfo(i.id)">详情</el-button>
<div class="item" v-for="i in list">
<el-card :body-style="{ padding: '0px' }">
<img :src="i.img" class="image" />
<div style="padding: 14px">
<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>
</div>
</div>
</el-card>
</div> </div>
</div> </div>
<el-dialog v-model="dialogFormVisible" title="详情"> </el-card>
<textarea style="width: 95%;height: 400px;" v-model="info"></textarea> </div>
<template #footer> </div>
<el-dialog v-model="dialogFormVisible" title="详情">
<textarea style="width: 95%;height: 400px;" v-model="info"></textarea>
<template #footer>
<span class="dialog-footer"> <span class="dialog-footer">
<el-button @click="dialogFormVisible = false">Cancel</el-button> <el-button @click="dialogFormVisible = false">Cancel</el-button>
<el-button type="primary" @click="dialogFormVisible = false"> <el-button type="primary" @click="dialogFormVisible = false">
Confirm Confirm
</el-button> </el-button>
</span> </span>
</template> </template>
</el-dialog> </el-dialog>
</div> </div>
</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)
list.value = res.data.data 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 = ""; let vid = "";
const dialogFormVisible = ref(false) const dialogFormVisible = ref(false)
async function getinfo(id) {
vid = id async function getInfo(id) {
let res = await getVideoInfo(id) vid = id
info.value = res.data.format let res = await getVideoInfo(id)
dialogFormVisible.value = true info.value = res.data.format
dialogFormVisible.value = true
} }
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.list { .list {
display: flex; display: flex;
flex-wrap: wrap; flex-wrap: wrap;
.item { .item {
width: 200px; width: 200px;
margin: 20px; margin: 20px;
& img { & img {
height: 300px; height: 300px;
}
} }
}
} }
.time { .time {
font-size: 12px; font-size: 12px;
color: #999; color: #999;
} }
.bottom { .bottom {
margin-top: 13px; margin-top: 13px;
line-height: 12px; line-height: 12px;
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
align-items: center; align-items: center;
} }
.button { .button {
padding: 0; padding: 0;
min-height: auto; min-height: auto;
min-width: 40px; min-width: 40px;
} }
.image { .image {
width: 100%; width: 100%;
display: block; display: block;
}</style> }</style>