Skip to content

Commit 18068f7

Browse files
committed
update
1 parent a94effb commit 18068f7

3 files changed

Lines changed: 27 additions & 17 deletions

File tree

pages/dashboard/proxy.vue

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@
3333
</code>
3434
</div>
3535
<div>
36-
<p class="flex justify-between items-center">
36+
<p class="flex justify-between items-center min-w-64">
3737
<span>已被封禁IP:</span>
3838
<span class="text-xs text-gray-500">若存在误伤,请联系开发者</span>
3939
</p>
4040
<ul>
41-
<li v-for="ip in BLOCKED_IPS" :key="ip">
41+
<li v-for="ip in blockedIPS" :key="ip">
4242
<code class="text-rose-500">{{ ip }}</code>
4343
</li>
4444
</ul>
@@ -66,7 +66,6 @@ import { websiteName } from '~/config';
6666
import type { AccountMetric } from '~/types/proxy';
6767
import ProxyMetrics from '~/components/ProxyMetrics.vue';
6868
import { request } from '#shared/utils/request';
69-
import { BLOCKED_IPS } from '~/config/public-proxy';
7069
7170
useHead({
7271
title: `公共代理 | ${websiteName}`,
@@ -85,7 +84,11 @@ const totalFailure = computed(
8584
async function getMetricsData() {
8685
loading.value = true;
8786
try {
88-
metricsData.value = await fetch('/api/web/worker/overview-metrics').then(res => res.json());
87+
metricsData.value = await fetch('/api/web/worker/overview-metrics')
88+
.then(res => res.json())
89+
.catch(e => {
90+
throw e;
91+
});
8992
} catch (error) {
9093
console.error(error);
9194
} finally {
@@ -94,13 +97,20 @@ async function getMetricsData() {
9497
}
9598
9699
const currentIP = ref('');
97-
onMounted(async () => {
98-
await getMetricsData();
100+
const blockedIPS = ref<string[]>([]);
99101
100-
const data = await request('/api/web/misc/current-ip');
101-
currentIP.value = data.ip;
102+
onMounted(async () => {
103+
await Promise.all([
104+
getMetricsData(),
105+
request('/api/web/misc/current-ip').then(data => {
106+
currentIP.value = data.ip;
107+
}),
108+
request<string[]>('/api/web/worker/blocked-ip-list').then(data => {
109+
blockedIPS.value = data;
110+
}),
111+
]);
102112
});
103113
const hasBlocked = computed(() => {
104-
return BLOCKED_IPS.includes(currentIP.value);
114+
return blockedIPS.value.includes(currentIP.value);
105115
});
106116
</script>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/**
2+
* 查询 ip 黑名单
3+
*/
4+
import { EXTERNAL_API_SERVICE } from '~/config';
5+
6+
export default defineEventHandler(async event => {
7+
return await fetch(`${EXTERNAL_API_SERVICE}/api/cf-worker/blocked-ip-list`).then(res => res.json());
8+
});

server/api/web/worker/blocked.get.ts

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)