From d383ab2e2eac4409081b7d1b75747a3321442e2e Mon Sep 17 00:00:00 2001 From: Hakadao Date: Sun, 19 Jan 2025 19:05:25 +0800 Subject: [PATCH] feat(history-popup, watch-later-popup): delete button (#1178) close #1178 --- .../TopBar/components/HistoryPop.vue | 32 ++++++++++++++++-- .../TopBar/components/WatchLaterPop.vue | 33 +++++++++++++++++-- 2 files changed, 61 insertions(+), 4 deletions(-) diff --git a/src/components/TopBar/components/HistoryPop.vue b/src/components/TopBar/components/HistoryPop.vue index 0e65149b..1cec7007 100644 --- a/src/components/TopBar/components/HistoryPop.vue +++ b/src/components/TopBar/components/HistoryPop.vue @@ -10,7 +10,7 @@ import type { HistoryResult, List as HistoryItem } from '~/models/history/histor import { Business } from '~/models/history/history' import api from '~/utils/api' import { calcCurrentTime } from '~/utils/dataFormatter' -import { removeHttpFromUrl, scrollToTop } from '~/utils/main' +import { getCSRF, removeHttpFromUrl, scrollToTop } from '~/utils/main' const { t } = useI18n() const historys = reactive>([]) @@ -165,6 +165,17 @@ function getHistoryList(type: Business, view_at = 0 as number) { isLoading.value = false }) } + +function deleteHistoryItem(index: number, historyItem: HistoryItem) { + api.history.deleteHistoryItem({ + kid: `${historyItem.history.business}_${historyItem.history.oid}`, + csrf: getCSRF(), + }) + .then((res) => { + if (res.code === 0) + historys.splice(index, 1) + }) +}