diff --git a/components.d.ts b/components.d.ts
index 8f4e3f15..842ae72d 100644
--- a/components.d.ts
+++ b/components.d.ts
@@ -13,6 +13,7 @@ declare module 'vue' {
MoreBtn: typeof import('./src/@core/components/MoreBtn.vue')['default']
RouterLink: typeof import('vue-router')['RouterLink']
RouterView: typeof import('vue-router')['RouterView']
+ StatIcon: typeof import('./src/@core/components/StatIcon.vue')['default']
ThemeSwitcher: typeof import('./src/@core/components/ThemeSwitcher.vue')['default']
}
}
diff --git a/src/@core/components/StatIcon.vue b/src/@core/components/StatIcon.vue
new file mode 100644
index 00000000..e5c82df3
--- /dev/null
+++ b/src/@core/components/StatIcon.vue
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/api/types.ts b/src/api/types.ts
index 32ab43f6..1d0efbe1 100644
--- a/src/api/types.ts
+++ b/src/api/types.ts
@@ -505,6 +505,33 @@ export interface Site {
is_active: boolean
}
+// 站点使用统计
+export interface SiteStatistic {
+
+ // 站点主域名Key
+ domain?: string
+
+ // 成功次数
+ success?: number
+
+ // 失败次数
+ fail?: number
+
+ // 平均耗时
+ seconds?: number
+
+ // 最后一次访问状态 0-成功 1-失败
+ lst_state?: number
+
+ // 最后访问时间
+ lst_mod_date?: string
+
+ // 耗时记录 JSON
+ note?: string
+
+
+}
+
// 正在下载
export interface DownloadingInfo {
diff --git a/src/components/cards/SiteCard.vue b/src/components/cards/SiteCard.vue
index 2b97b415..8fd8528a 100644
--- a/src/components/cards/SiteCard.vue
+++ b/src/components/cards/SiteCard.vue
@@ -5,7 +5,7 @@ import SiteAddEditForm from '../form/SiteAddEditForm.vue'
import SiteTorrentTable from '../table/SiteTorrentTable.vue'
import { requiredValidator } from '@/@validators'
import api from '@/api'
-import type { Site } from '@/api/types'
+import type { Site, SiteStatistic } from '@/api/types'
import ExistIcon from '@core/components/ExistIcon.vue'
// 输入参数
@@ -58,6 +58,9 @@ const userPwForm = ref({
code: '',
})
+// 站点使用统计
+const siteStats = ref({})
+
// 查询站点图标
async function getSiteIcon() {
try {
@@ -82,6 +85,18 @@ async function testSite() {
testButtonText.value = '测试'
testButtonDisable.value = false
+
+ getSiteStats()
+ }
+ catch (error) {
+ console.error(error)
+ }
+}
+
+// 查询站点使用统计
+async function getSiteStats() {
+ try {
+ siteStats.value = (await api.get(`site/statistic/${cardProps.site?.domain}`))
}
catch (error) {
console.error(error)
@@ -140,9 +155,24 @@ function openSitePage() {
window.open(cardProps.site?.url, '_blank')
}
+// 根据站点状态显示不同的状态图标
+const statColor = computed(() => {
+ if (siteStats.value?.lst_state == 1){
+ return 'error'
+ }
+ else if (siteStats.value?.lst_state == 0){
+ if (!siteStats.value?.seconds)
+ return 'secondary'
+ if (siteStats.value?.seconds >= 10)
+ return 'warning'
+ return 'success'
+ }
+})
+
// 装载时查询站点图标
onMounted(() => {
getSiteIcon()
+ getSiteStats()
})
@@ -163,16 +193,17 @@ onMounted(() => {
+
{{ cardProps.site?.name }}
- {{ cardProps.site?.url }}
+ {{ cardProps.site?.url }}
-
+