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,4 +1,10 @@
<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' }">
@ -17,13 +23,18 @@
</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>([])
const labelPosition = ref("1")
watch(labelPosition, async () => {
const res = await getSubscribe(labelPosition.value)
list.value = res.data
})
onMounted(async () => { onMounted(async () => {
const res = await getSubscribe() const res = await getSubscribe(labelPosition.value)
list.value = res.data list.value = res.data
}) })
function del(id) { function del(id) {