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';
6666import type { AccountMetric } from ' ~/types/proxy' ;
6767import ProxyMetrics from ' ~/components/ProxyMetrics.vue' ;
6868import { request } from ' #shared/utils/request' ;
69- import { BLOCKED_IPS } from ' ~/config/public-proxy' ;
7069
7170useHead ({
7271 title: ` 公共代理 | ${websiteName } ` ,
@@ -85,7 +84,11 @@ const totalFailure = computed(
8584async 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
9699const 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});
103113const hasBlocked = computed (() => {
104- return BLOCKED_IPS .includes (currentIP .value );
114+ return blockedIPS . value .includes (currentIP .value );
105115});
106116 </script >
0 commit comments