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) => {
ctx.body = await getSub()
ctx.body = await getSub(ctx.query.state)
})
/**

View File

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

View File

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

View File

@ -1,12 +1,18 @@
<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="item" v-for="i in list">
<el-card :body-style="{ padding: '0px' }">
<img :src="i.img" class="image" />
<div style="padding: 14px">
<span>{{i.name}}</span>
<span>{{ i.name }}</span>
<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>
</div>
</div>
@ -17,16 +23,21 @@
</template>
<script lang="ts" setup>
import {onMounted, ref} from "vue";
import {delSubscribe, getSubscribe} from '../../api/Video.js'
import {ElMessage, ElMessageBox} from "element-plus";
import { onMounted, ref, watch } from "vue";
import { delSubscribe, getSubscribe } from '../../api/Video.js'
import { ElMessage, ElMessageBox } from "element-plus";
const list = ref<any>([])
onMounted(async ()=>{
const res = await getSubscribe()
const labelPosition = ref("1")
watch(labelPosition, async () => {
const res = await getSubscribe(labelPosition.value)
list.value = res.data
})
function del(id){
onMounted(async () => {
const res = await getSubscribe(labelPosition.value)
list.value = res.data
})
function del(id) {
ElMessageBox.confirm(
'确认删除?',
'Warning',
@ -43,17 +54,17 @@ function del(id){
})
}
async function del2(id){
async function del2(id) {
let res = await delSubscribe(id)
if(res.data == "删除成功"){
if (res.data == "删除成功") {
ElMessage({
message: '删除成功',
type: 'success',
})
}else{
} else {
ElMessage({
message:"删除失败",
type:"error"
message: "删除失败",
type: "error"
})
}
const res2 = await getSubscribe()