add 订阅历史

This commit is contained in:
theluyuan 2023-09-03 21:10:55 +08:00
parent 637e2799f2
commit c0c122e9ca
4 changed files with 59 additions and 44 deletions

View File

@ -53,7 +53,7 @@ router.post("/addSubscribe", async (ctx) => {
* 获取订阅列表 * 获取订阅列表
*/ */
router.get("/getSubscribe", async (ctx) => { router.get("/getSubscribe", async (ctx) => {
ctx.body = await getSub() ctx.body = await getSub(ctx.query.state)
}) })
/** /**

View File

@ -13,8 +13,8 @@ async function addSub(info){
} }
// 获取所有订阅 (不包括已完成) // 获取所有订阅 (不包括已完成)
async function getSub(){ async function getSub(state){
let sql = `select * from VideoInfo where enable=1` let sql = `select * from VideoInfo where enable=${state}`
let list = await getAll(sql) let list = await getAll(sql)
return list return list
} }

View File

@ -28,8 +28,12 @@ export async function addSubscribe(data) {
return await base.post("/videoInfo/addSubscribe", data) return await base.post("/videoInfo/addSubscribe", data)
} }
export async function getSubscribe(){ export async function getSubscribe(state){
return await base.get("/videoInfo/getSubscribe") return await base.get("/videoInfo/getSubscribe",{
params:{
state
}
})
} }

View File

@ -1,12 +1,18 @@
<template> <template>
<div>
<el-radio-group v-model="labelPosition" label="label position">
<el-radio-button label="1">订阅中</el-radio-button>
<el-radio-button label="2">已完成</el-radio-button>
</el-radio-group>
</div>
<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.name}}</span> <span>{{ i.name }}</span>
<div class="bottom"> <div class="bottom">
<time class="time">正在订阅{{i.skip}}/{{i.count}}</time> <time class="time">正在订阅{{ i.skip }}/{{ i.count }}</time>
<el-button text class="button" @click="del(i.id)">删除</el-button> <el-button text class="button" @click="del(i.id)">删除</el-button>
</div> </div>
</div> </div>
@ -17,47 +23,52 @@
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import {onMounted, ref} from "vue"; import { onMounted, ref, watch } from "vue";
import {delSubscribe, getSubscribe} from '../../api/Video.js' import { delSubscribe, getSubscribe } from '../../api/Video.js'
import {ElMessage, ElMessageBox} from "element-plus"; import { ElMessage, ElMessageBox } from "element-plus";
const list = ref<any>([]) const list = ref<any>([])
onMounted(async ()=>{ const labelPosition = ref("1")
const res = await getSubscribe() watch(labelPosition, async () => {
list.value = res.data const res = await getSubscribe(labelPosition.value)
list.value = res.data
}) })
function del(id){ onMounted(async () => {
ElMessageBox.confirm( const res = await getSubscribe(labelPosition.value)
'确认删除?', list.value = res.data
'Warning', })
{ function del(id) {
confirmButtonText: '确认', ElMessageBox.confirm(
cancelButtonText: '取消', '确认删除?',
type: 'warning', 'Warning',
} {
) confirmButtonText: '确认',
.then(() => { cancelButtonText: '取消',
del2(id) type: 'warning',
})
.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 .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> </script>