|
|
@@ -8,7 +8,7 @@
|
|
|
<el-table :data="proxyList" border stripe v-loading="loading">
|
|
|
<el-table-column prop="name" label="代理名称" width="100" />
|
|
|
<el-table-column prop="port" label="端口" width="100" align="center" />
|
|
|
- <el-table-column label="状态" width="120" align="center">
|
|
|
+ <el-table-column label="状态" width="80" align="center">
|
|
|
<template #default="{ row }">
|
|
|
<el-tag
|
|
|
:type="row.reachable ? 'success' : 'danger'"
|
|
|
@@ -19,7 +19,7 @@
|
|
|
</el-tag>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
- <el-table-column label="管理地址">
|
|
|
+ <el-table-column label="管理地址" width="90">
|
|
|
<template #default="{ row }">
|
|
|
<el-link v-if="row.reachable && row.mgr_url" :href="row.mgr_url || ''" target="_blank">
|
|
|
<el-icon><Link /></el-icon>访问
|
|
|
@@ -74,6 +74,9 @@
|
|
|
<script setup lang="ts">
|
|
|
import { ref } from 'vue'
|
|
|
import type { ProxyResponse, ProxyPostResponse } from '../api-types'
|
|
|
+import { useProxyStore } from '../stores/proxyStore'
|
|
|
+import { log } from 'console'
|
|
|
+const store = useProxyStore()
|
|
|
|
|
|
const apiBaseUrl = import.meta.env.VITE_API_BASE_URL || ''
|
|
|
const proxyList = ref<ProxyResponse[]>([])
|
|
|
@@ -82,13 +85,22 @@ const creating = ref(false)
|
|
|
const detailVisible = ref(false)
|
|
|
const selectedProxy = ref<ProxyResponse | null>(null)
|
|
|
|
|
|
-const fetchProxyList = async () => {
|
|
|
+const fetchProxyList = async (useCatch=true) => {
|
|
|
try {
|
|
|
loading.value = true
|
|
|
- const response = await fetch(`${apiBaseUrl}/proxy/proxies`)
|
|
|
- if (!response.ok) throw new Error('获取代理列表失败')
|
|
|
+ let response:Response
|
|
|
+ let data: ProxyResponse[]
|
|
|
+ if (useCatch) {
|
|
|
+ const cacheKey = 'fetchProxyList'
|
|
|
+ data = await store.cachedFetch(`${apiBaseUrl}/proxy/proxies`, cacheKey)
|
|
|
+ console.log(`useCatch ${cacheKey}: `, data)
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ response = await fetch(`${apiBaseUrl}/proxy/proxies`)
|
|
|
+ if (!response.ok) throw new Error('获取代理列表失败')
|
|
|
+ data = await response.json()
|
|
|
+ }
|
|
|
|
|
|
- const data = await response.json()
|
|
|
proxyList.value = data.map((proxy: ProxyResponse) => ({
|
|
|
...proxy,
|
|
|
isLoading: proxy.isLoading || false
|