feat:健康检查

This commit is contained in:
jxxghp
2024-03-06 13:27:17 +08:00
parent 82904d956d
commit 6e4dbd912b
2 changed files with 132 additions and 25 deletions

View File

@@ -3,6 +3,7 @@ import NameTestView from '@/views/system/NameTestView.vue'
import NetTestView from '@/views/system/NetTestView.vue'
import LoggingView from '@/views/system/LoggingView.vue'
import RuleTestView from '@/views/system/RuleTestView.vue'
import ModuleTestView from '@/views/system/ModuleTestView.vue'
import store from '@/store'
// App捷径
@@ -20,6 +21,9 @@ const loggingDialog = ref(false)
// 过滤规则弹窗
const ruleTestDialog = ref(false)
// 系统健康检查弹窗
const systemTestDialog = ref(false)
// 拼接全部日志url
function allLoggingUrl() {
const token = store.state.auth.token
@@ -79,6 +83,50 @@ function allLoggingUrl() {
<span class="text-sm">名称识别测试</span>
</VListItem>
</VCol>
<VCol
cols="6"
class="text-center cursor-pointer pa-0 shortcut-icon border-e"
@click="() => {}"
>
<VListItem
class="pa-4"
@click="ruleTestDialog = true"
>
<VAvatar
size="48"
variant="tonal"
>
<VIcon icon="mdi-filter-cog-outline" />
</VAvatar>
<h6 class="text-base font-weight-medium mt-2 mb-0">
优先级
</h6>
<span class="text-sm">优先级规则测试</span>
</VListItem>
</VCol>
</VRow>
<VRow class="ma-0 mt-n1 border-t">
<VCol
cols="6"
class="text-center cursor-pointer pa-0 shortcut-icon border-e"
@click="() => {}"
>
<VListItem
class="pa-4"
@click="loggingDialog = true"
>
<VAvatar
size="48"
variant="tonal"
>
<VIcon icon="mdi-file-document-outline" />
</VAvatar>
<h6 class="text-base font-weight-medium mt-2 mb-0">
日志
</h6>
<span class="text-sm">查看实时日志</span>
</VListItem>
</VCol>
<VCol
cols="6"
class="text-center cursor-pointer pa-0 shortcut-icon"
@@ -109,39 +157,18 @@ function allLoggingUrl() {
>
<VListItem
class="pa-4"
@click="loggingDialog = true"
@click="systemTestDialog = true"
>
<VAvatar
size="48"
variant="tonal"
>
<VIcon icon="mdi-file-document-outline" />
<VIcon icon="mdi-cog-outline" />
</VAvatar>
<h6 class="text-base font-weight-medium mt-2 mb-0">
日志
系统
</h6>
<span class="text-sm">系统实时日志</span>
</VListItem>
</VCol>
<VCol
cols="6"
class="text-center cursor-pointer pa-0 shortcut-icon border-e"
@click="() => {}"
>
<VListItem
class="pa-4"
@click="ruleTestDialog = true"
>
<VAvatar
size="48"
variant="tonal"
>
<VIcon icon="mdi-filter-cog-outline" />
</VAvatar>
<h6 class="text-base font-weight-medium mt-2 mb-0">
优先级
</h6>
<span class="text-sm">优先级规则测试</span>
<span class="text-sm">系统健康检查</span>
</VListItem>
</VCol>
</VRow>
@@ -209,4 +236,17 @@ function allLoggingUrl() {
</VCardText>
</VCard>
</VDialog>
<!-- 系统健康检查弹窗 -->
<VDialog
v-model="systemTestDialog"
max-width="50rem"
scrollable
>
<VCard title="系统健康检查">
<DialogCloseBtn @click="systemTestDialog = false" />
<VCardText>
<ModuleTestView />
</VCardText>
</VCard>
</VDialog>
</template>

View File

@@ -0,0 +1,67 @@
<script setup lang="ts">
import api from '@/api'
// 定义所有的模块ID、名称列表
const modules = ref([
{ id: 'DoubanModule', name: '豆瓣', state: '', errmsg: '' },
{ id: 'TheMovieDbModule', name: 'TheMovieDb', state: '', errmsg: '' },
{ id: 'TheTvDbModule', name: 'TheTvDb', state: '', errmsg: '' },
{ id: 'FanartModule', name: 'Fanart', state: '', errmsg: '' },
{ id: 'EmbyModule', name: 'Emby', state: '', errmsg: '' },
{ id: 'JellyfinModule', name: 'Jellyfin', state: '', errmsg: '' },
{ id: 'PlexModule', name: 'Plex', state: '', errmsg: '' },
{ id: 'WechatModule', name: '微信', state: '', errmsg: '' },
{ id: 'TelegramModule', name: 'Telegram', state: '', errmsg: '' },
{ id: 'SlackModule', name: 'Slack', state: '', errmsg: '' },
{ id: 'SynologyChatModule', name: 'Synology Chat', state: '', errmsg: '' },
{ id: 'IndexerModule', name: '站点索引', state: '', errmsg: '' },
{ id: 'QbittorrentModule', name: 'Qbittorrent', state: '', errmsg: '' },
{ id: 'TransmissionModule', name: 'Transmission', state: '', errmsg: '' },
])
// 调用API测试模块
async function moduleTest(index: number) {
try {
const target = modules.value[index]
const moduleid = target.id
const result: { [key: string]: any } = await api.get(`system/moduletest/${moduleid}`)
if (result.success) {
target.state = 'success'
target.name = `${target.name} - 正常`
}
else if (result.message?.includes('模块未加载')) {
target.state = ''
target.name = `${target.name} - 未启用`
}
else {
target.state = 'error'
target.name = `${target.name} - 错误!`
target.errmsg = result.message
}
}
catch (error) {
console.error(error)
}
}
// 加载
onMounted(async () => {
// 逐个检查所有模块
for (let i = 0; i < modules.value.length; i++)
await moduleTest(i)
})
</script>
<template>
<VAlert
v-for="(module, index) in modules"
:key="index"
:type="module.state"
:title="module.name"
class="mb-2"
variant="tonal"
>
{{ module.errmsg }}
</VAlert>
</template>