add 删除订阅
This commit is contained in:
parent
54e6932dc2
commit
41d16c43b0
BIN
db/database.db
BIN
db/database.db
Binary file not shown.
@ -2,7 +2,7 @@ const Router = require("koa-router")
|
||||
const { serach, gen_douban } = require("../util/ptgen")
|
||||
const axios = require("axios")
|
||||
const cheerio = require("cheerio");
|
||||
const {addSub, getSub} = require("../util/sql/video"); // HTML页面解析
|
||||
const {addSub, getSub, delSub} = require("../util/sql/video"); // HTML页面解析
|
||||
|
||||
const router = new Router({
|
||||
prefix: "/videoInfo"
|
||||
@ -70,4 +70,13 @@ router.get("/getImdbName", async (ctx) => {
|
||||
ctx.body = $("h1").text()
|
||||
})
|
||||
|
||||
router.get("/delSubscribe",async (ctx)=>{
|
||||
try {
|
||||
await delSub(ctx.query.id)
|
||||
ctx.body = "删除成功"
|
||||
}catch {
|
||||
ctx.body = "删除失败"
|
||||
}
|
||||
})
|
||||
|
||||
module.exports = router
|
@ -18,8 +18,14 @@ async function getSub(){
|
||||
return list
|
||||
}
|
||||
|
||||
async function delSub(id){
|
||||
let sql = `delete from VideoInfo where id=${id}`
|
||||
await run(sql)
|
||||
}
|
||||
|
||||
|
||||
module.exports = {
|
||||
addSub,
|
||||
getSub
|
||||
getSub,
|
||||
delSub
|
||||
}
|
@ -32,3 +32,12 @@ export async function getSubscribe(){
|
||||
return await base.get("/videoInfo/getSubscribe")
|
||||
|
||||
}
|
||||
|
||||
export async function delSubscribe(id){
|
||||
return await base.get("/videoInfo/delSubscribe",{
|
||||
params:{
|
||||
id
|
||||
}
|
||||
})
|
||||
|
||||
}
|
@ -7,7 +7,7 @@
|
||||
<span>{{i.name}}</span>
|
||||
<div class="bottom">
|
||||
<time class="time">正在订阅:{{i.skip}}/{{i.count}}</time>
|
||||
<el-button text class="button">编辑</el-button>
|
||||
<el-button text class="button" @click="del(i.id)">删除</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</el-card>
|
||||
@ -18,13 +18,47 @@
|
||||
|
||||
<script lang="ts" setup>
|
||||
import {onMounted, ref} from "vue";
|
||||
import {getSubscribe} from '../../api/Video.js'
|
||||
import {delSubscribe, getSubscribe} from '../../api/Video.js'
|
||||
import {ElMessage, ElMessageBox} from "element-plus";
|
||||
|
||||
const list = ref([])
|
||||
onMounted(async ()=>{
|
||||
const res = await getSubscribe()
|
||||
list.value = res.data
|
||||
})
|
||||
function del(id){
|
||||
ElMessageBox.confirm(
|
||||
'确认删除?',
|
||||
'Warning',
|
||||
{
|
||||
confirmButtonText: '确认',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning',
|
||||
}
|
||||
)
|
||||
.then(() => {
|
||||
del2(id)
|
||||
})
|
||||
.catch(() => {
|
||||
|
||||
})
|
||||
}
|
||||
async function del2(id){
|
||||
let res = await delSubscribe(id)
|
||||
if(res.data == "删除成功"){
|
||||
ElMessage({
|
||||
message: '删除成功',
|
||||
type: 'success',
|
||||
})
|
||||
}else{
|
||||
ElMessage({
|
||||
message:"删除失败",
|
||||
type:"error"
|
||||
})
|
||||
}
|
||||
const res2 = await getSubscribe()
|
||||
list.value = res2.data
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user