mirror of
https://github.com/perfect-panel/ppanel-web.git
synced 2026-02-15 21:01:10 -05:00
✨ feat(stats): Replace dynamic stat fetching with environment constants for user, server, and location counts
This commit is contained in:
parent
3547bb1596
commit
46ae1665be
@ -5,6 +5,11 @@ NEXT_PUBLIC_DEFAULT_LANGUAGE=en-US
|
|||||||
NEXT_PUBLIC_SITE_URL=https://user.ppanel.dev
|
NEXT_PUBLIC_SITE_URL=https://user.ppanel.dev
|
||||||
NEXT_PUBLIC_API_URL=https://api.ppanel.dev
|
NEXT_PUBLIC_API_URL=https://api.ppanel.dev
|
||||||
|
|
||||||
|
# Home Page Settings
|
||||||
|
NEXT_PUBLIC_HOME_USER_COUNT=999
|
||||||
|
NEXT_PUBLIC_HOME_SERVER_COUNT=999
|
||||||
|
NEXT_PUBLIC_HOME_LOCATION_COUNT=999
|
||||||
|
|
||||||
# Contact Email
|
# Contact Email
|
||||||
NEXT_PUBLIC_EMAIL=support@ppanel.dev
|
NEXT_PUBLIC_EMAIL=support@ppanel.dev
|
||||||
# Community Links
|
# Community Links
|
||||||
|
|||||||
@ -1,8 +1,11 @@
|
|||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import { getStat } from '@/services/common/common';
|
import {
|
||||||
|
NEXT_PUBLIC_HOME_LOCATION_COUNT,
|
||||||
|
NEXT_PUBLIC_HOME_SERVER_COUNT,
|
||||||
|
NEXT_PUBLIC_HOME_USER_COUNT,
|
||||||
|
} from '@/config/constants';
|
||||||
import { DotLottieReact } from '@lottiefiles/dotlottie-react';
|
import { DotLottieReact } from '@lottiefiles/dotlottie-react';
|
||||||
import { useQuery } from '@tanstack/react-query';
|
|
||||||
import LocationsLittie from '@workspace/ui/lotties/locations.json';
|
import LocationsLittie from '@workspace/ui/lotties/locations.json';
|
||||||
import ServersLottie from '@workspace/ui/lotties/servers.json';
|
import ServersLottie from '@workspace/ui/lotties/servers.json';
|
||||||
import UsersLottie from '@workspace/ui/lotties/users.json';
|
import UsersLottie from '@workspace/ui/lotties/users.json';
|
||||||
@ -13,31 +16,20 @@ import { useEffect, useState } from 'react';
|
|||||||
export function Stats() {
|
export function Stats() {
|
||||||
const t = useTranslations('index');
|
const t = useTranslations('index');
|
||||||
|
|
||||||
const { data } = useQuery({
|
|
||||||
queryKey: ['getStat'],
|
|
||||||
queryFn: async () => {
|
|
||||||
const { data } = await getStat({
|
|
||||||
skipErrorHandler: true,
|
|
||||||
});
|
|
||||||
return data.data;
|
|
||||||
},
|
|
||||||
refetchOnWindowFocus: false,
|
|
||||||
});
|
|
||||||
|
|
||||||
const list = [
|
const list = [
|
||||||
{
|
{
|
||||||
name: t('users'),
|
name: t('users'),
|
||||||
number: data?.user || 999,
|
number: NEXT_PUBLIC_HOME_USER_COUNT,
|
||||||
icon: <DotLottieReact className='size-24' data={UsersLottie} autoplay loop />,
|
icon: <DotLottieReact className='size-24' data={UsersLottie} autoplay loop />,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: t('servers'),
|
name: t('servers'),
|
||||||
number: data?.server || 30,
|
number: NEXT_PUBLIC_HOME_SERVER_COUNT,
|
||||||
icon: <DotLottieReact className='size-24' data={ServersLottie} autoplay loop />,
|
icon: <DotLottieReact className='size-24' data={ServersLottie} autoplay loop />,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: t('locations'),
|
name: t('locations'),
|
||||||
number: data?.country || 10,
|
number: NEXT_PUBLIC_HOME_LOCATION_COUNT,
|
||||||
icon: <DotLottieReact className='size-24' data={LocationsLittie} autoplay loop />,
|
icon: <DotLottieReact className='size-24' data={LocationsLittie} autoplay loop />,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user