🐛 fix: Fix bugs

This commit is contained in:
web 2025-10-21 04:10:34 -07:00
parent c2bfee1f31
commit a46657d5ef
15 changed files with 276 additions and 19 deletions

View File

@ -1,38 +1,35 @@
<a name="readme-top"></a> <a name="readme-top"></a>
# Changelog # Changelog
## [1.5.2](https://github.com/perfect-panel/ppanel-web/compare/v1.5.1...v1.5.2) (2025-09-29) ## [1.5.2](https://github.com/perfect-panel/ppanel-web/compare/v1.5.1...v1.5.2) (2025-09-29)
### 🐛 Bug Fixes ### 🐛 Bug Fixes
* Add step attribute to datetime-local inputs for precise time selection in forms ([32fd181](https://github.com/perfect-panel/ppanel-web/commit/32fd181)) - Add step attribute to datetime-local inputs for precise time selection in forms ([32fd181](https://github.com/perfect-panel/ppanel-web/commit/32fd181))
* Rename 'hysteria2' to 'hysteria' across protocol definitions and schemas for consistency ([5816dd5](https://github.com/perfect-panel/ppanel-web/commit/5816dd5)) - Rename 'hysteria2' to 'hysteria' across protocol definitions and schemas for consistency ([5816dd5](https://github.com/perfect-panel/ppanel-web/commit/5816dd5))
* Update protocol options in ServerConfig for accuracy and consistency ([9266529](https://github.com/perfect-panel/ppanel-web/commit/9266529)) - Update protocol options in ServerConfig for accuracy and consistency ([9266529](https://github.com/perfect-panel/ppanel-web/commit/9266529))
## [1.5.1](https://github.com/perfect-panel/ppanel-web/compare/v1.5.0...v1.5.1) (2025-09-28) ## [1.5.1](https://github.com/perfect-panel/ppanel-web/compare/v1.5.0...v1.5.1) (2025-09-28)
### 🐛 Bug Fixes ### 🐛 Bug Fixes
* Simplify protocol enable checks by removing unnecessary false comparisons ([4828700](https://github.com/perfect-panel/ppanel-web/commit/4828700)) - Simplify protocol enable checks by removing unnecessary false comparisons ([4828700](https://github.com/perfect-panel/ppanel-web/commit/4828700))
# [1.5.0](https://github.com/perfect-panel/ppanel-web/compare/v1.4.8...v1.5.0) (2025-09-28) # [1.5.0](https://github.com/perfect-panel/ppanel-web/compare/v1.4.8...v1.5.0) (2025-09-28)
### ✨ Features ### ✨ Features
* Update server configuration translations for multiple languages ([fc43de1](https://github.com/perfect-panel/ppanel-web/commit/fc43de1)) - Update server configuration translations for multiple languages ([fc43de1](https://github.com/perfect-panel/ppanel-web/commit/fc43de1))
### 🐛 Bug Fixes ### 🐛 Bug Fixes
* Add DynamicMultiplier component for managing node multipliers and update ServersPage layout ([bb6671c](https://github.com/perfect-panel/ppanel-web/commit/bb6671c)) - Add DynamicMultiplier component for managing node multipliers and update ServersPage layout ([bb6671c](https://github.com/perfect-panel/ppanel-web/commit/bb6671c))
* Remove unnecessary blank lines in multiple index files for cleaner code structure ([6a823b8](https://github.com/perfect-panel/ppanel-web/commit/6a823b8)) - Remove unnecessary blank lines in multiple index files for cleaner code structure ([6a823b8](https://github.com/perfect-panel/ppanel-web/commit/6a823b8))
* Remove unused ratio variable from server traffic log and server form for cleaner code ([55034dc](https://github.com/perfect-panel/ppanel-web/commit/55034dc)) - Remove unused ratio variable from server traffic log and server form for cleaner code ([55034dc](https://github.com/perfect-panel/ppanel-web/commit/55034dc))
* Update Badge variants and restructure traffic ratio display in ServersPage ([3d778e5](https://github.com/perfect-panel/ppanel-web/commit/3d778e5)) - Update Badge variants and restructure traffic ratio display in ServersPage ([3d778e5](https://github.com/perfect-panel/ppanel-web/commit/3d778e5))
* Update minimum ratio value to 0 in protocol fields and adjust related schemas; enhance unit conversion in ServerConfig ([3b6ef17](https://github.com/perfect-panel/ppanel-web/commit/3b6ef17)) - Update minimum ratio value to 0 in protocol fields and adjust related schemas; enhance unit conversion in ServerConfig ([3b6ef17](https://github.com/perfect-panel/ppanel-web/commit/3b6ef17))
* Update protocol fields to use 'obfs' instead of 'security' and adjust related configurations ([4abdd36](https://github.com/perfect-panel/ppanel-web/commit/4abdd36)) - Update protocol fields to use 'obfs' instead of 'security' and adjust related configurations ([4abdd36](https://github.com/perfect-panel/ppanel-web/commit/4abdd36))
<a name="readme-top"></a> <a name="readme-top"></a>

View File

@ -1,6 +1,7 @@
'use client'; 'use client';
import useGlobalStore, { GlobalStore } from '@/config/use-global'; import useGlobalStore, { GlobalStore } from '@/config/use-global';
import { useStatsStore } from '@/store/stats';
import { Logout } from '@/utils/common'; import { Logout } from '@/utils/common';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import { ReactQueryStreamedHydration } from '@tanstack/react-query-next-experimental'; import { ReactQueryStreamedHydration } from '@tanstack/react-query-next-experimental';
@ -42,6 +43,12 @@ export default function Providers({
setCommon(common); setCommon(common);
}, [setCommon, common]); }, [setCommon, common]);
const { stats } = useStatsStore();
useEffect(() => {
stats();
}, []);
return ( return (
<NextThemesProvider attribute='class' defaultTheme='system' enableSystem> <NextThemesProvider attribute='class' defaultTheme='system' enableSystem>
<QueryClientProvider client={queryClient}> <QueryClientProvider client={queryClient}>

View File

@ -76,6 +76,17 @@ export async function updateNodeConfig(body: API.NodeConfig, options?: { [key: s
}); });
} }
/** PreView Node Multiplier GET /v1/admin/system/node_multiplier/preview */
export async function preViewNodeMultiplier(options?: { [key: string]: any }) {
return request<API.Response & { data?: API.PreViewNodeMultiplierResponse }>(
'/v1/admin/system/node_multiplier/preview',
{
method: 'GET',
...(options || {}),
},
);
}
/** get Privacy Policy Config GET /v1/admin/system/privacy */ /** get Privacy Policy Config GET /v1/admin/system/privacy */
export async function getPrivacyPolicyConfig(options?: { [key: string]: any }) { export async function getPrivacyPolicyConfig(options?: { [key: string]: any }) {
return request<API.Response & { data?: API.PrivacyPolicyConfig }>('/v1/admin/system/privacy', { return request<API.Response & { data?: API.PrivacyPolicyConfig }>('/v1/admin/system/privacy', {

View File

@ -108,6 +108,7 @@ declare namespace API {
type AuthConfig = { type AuthConfig = {
mobile: MobileAuthenticateConfig; mobile: MobileAuthenticateConfig;
email: EmailAuthticateConfig; email: EmailAuthticateConfig;
device: DeviceAuthticateConfig;
register: PubilcRegisterConfig; register: PubilcRegisterConfig;
}; };
@ -456,6 +457,13 @@ declare namespace API {
user_subscribe_id: number; user_subscribe_id: number;
}; };
type DeviceAuthticateConfig = {
enable: boolean;
show_ads: boolean;
enable_security: boolean;
only_real_device: boolean;
};
type Document = { type Document = {
id: number; id: number;
title: string; title: string;
@ -1272,7 +1280,7 @@ declare namespace API {
has_migrate: boolean; has_migrate: boolean;
}; };
type Hysteria = { type Hysteria2 = {
port: number; port: number;
hop_ports: string; hop_ports: string;
hop_interval: number; hop_interval: number;
@ -1495,6 +1503,11 @@ declare namespace API {
orderNo: string; orderNo: string;
}; };
type PreViewNodeMultiplierResponse = {
current_time: string;
ratio: number;
};
type PreviewSubscribeTemplateParams = { type PreviewSubscribeTemplateParams = {
id: number; id: number;
}; };

View File

@ -47,6 +47,18 @@ export async function userLogin(body: API.UserLoginRequest, options?: { [key: st
}); });
} }
/** Device Login POST /v1/auth/login/device */
export async function deviceLogin(body: API.DeviceLoginRequest, options?: { [key: string]: any }) {
return request<API.Response & { data?: API.LoginResponse }>('/v1/auth/login/device', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
data: body,
...(options || {}),
});
}
/** User Telephone login POST /v1/auth/login/telephone */ /** User Telephone login POST /v1/auth/login/telephone */
export async function telephoneLogin( export async function telephoneLogin(
body: API.TelephoneLoginRequest, body: API.TelephoneLoginRequest,

View File

@ -114,6 +114,7 @@ declare namespace API {
type AuthConfig = { type AuthConfig = {
mobile: MobileAuthenticateConfig; mobile: MobileAuthenticateConfig;
email: EmailAuthticateConfig; email: EmailAuthticateConfig;
device: DeviceAuthticateConfig;
register: PubilcRegisterConfig; register: PubilcRegisterConfig;
}; };
@ -211,6 +212,19 @@ declare namespace API {
currency_symbol: string; currency_symbol: string;
}; };
type DeviceAuthticateConfig = {
enable: boolean;
show_ads: boolean;
enable_security: boolean;
only_real_device: boolean;
};
type DeviceLoginRequest = {
identifier: string;
user_agent: string;
cf_token?: string;
};
type Document = { type Document = {
id: number; id: number;
title: string; title: string;
@ -324,7 +338,7 @@ declare namespace API {
state: string; state: string;
}; };
type Hysteria = { type Hysteria2 = {
port: number; port: number;
hop_ports: string; hop_ports: string;
hop_interval: number; hop_interval: number;
@ -706,6 +720,7 @@ declare namespace API {
}; };
type ResetPasswordRequest = { type ResetPasswordRequest = {
identifier: string;
email: string; email: string;
password: string; password: string;
code?: string; code?: string;
@ -898,6 +913,7 @@ declare namespace API {
}; };
type TelephoneLoginRequest = { type TelephoneLoginRequest = {
identifier: string;
telephone: string; telephone: string;
telephone_code: string; telephone_code: string;
telephone_area_code: string; telephone_area_code: string;
@ -906,6 +922,7 @@ declare namespace API {
}; };
type TelephoneRegisterRequest = { type TelephoneRegisterRequest = {
identifier: string;
telephone: string; telephone: string;
telephone_area_code: string; telephone_area_code: string;
password: string; password: string;
@ -915,6 +932,7 @@ declare namespace API {
}; };
type TelephoneResetPasswordRequest = { type TelephoneResetPasswordRequest = {
identifier: string;
telephone: string; telephone: string;
telephone_area_code: string; telephone_area_code: string;
password: string; password: string;
@ -1035,12 +1053,14 @@ declare namespace API {
}; };
type UserLoginRequest = { type UserLoginRequest = {
identifier: string;
email: string; email: string;
password: string; password: string;
cf_token?: string; cf_token?: string;
}; };
type UserRegisterRequest = { type UserRegisterRequest = {
identifier: string;
email: string; email: string;
password: string; password: string;
invite?: string; invite?: string;

74
apps/admin/store/stats.ts Normal file
View File

@ -0,0 +1,74 @@
import { create } from 'zustand';
// Fixed remote stats endpoint and required header
export const REQUIRED_HEADER_NAME = 'stats';
export const REQUIRED_HEADER_VALUE = 'ppanel.dev';
const STATS_URL = 'https://stats.ppanel.dev';
const STATS_LOADED_KEY = 'ppanel:stats:loaded';
interface StatsState {
loading: boolean;
loaded: boolean;
stats: () => Promise<void>;
}
async function hashHostname(hostname: string): Promise<string> {
try {
const encoder = new TextEncoder();
const data = encoder.encode(hostname);
const hashBuffer = await crypto.subtle.digest('SHA-256', data);
const hashArray = Array.from(new Uint8Array(hashBuffer));
return hashArray.map((b) => b.toString(16).padStart(2, '0')).join('');
} catch (e) {
return '';
}
}
export const useStatsStore = create<StatsState>((set) => ({
loading: false,
loaded:
typeof window !== 'undefined' ? Boolean(window.localStorage.getItem(STATS_LOADED_KEY)) : false,
stats: async () => {
// if already recorded, skip
if (typeof window !== 'undefined') {
try {
if (window.localStorage.getItem(STATS_LOADED_KEY)) return;
} catch {}
}
set({ loading: true });
try {
const hostname =
typeof window !== 'undefined' && window.location ? window.location.hostname : '';
const domain = hostname ? await hashHostname(hostname) : '';
await fetch(STATS_URL, {
method: 'POST',
headers: {
[REQUIRED_HEADER_NAME]: REQUIRED_HEADER_VALUE,
'Content-Type': 'application/json',
},
body: JSON.stringify({
domain,
}),
});
set({ loaded: true });
if (typeof window !== 'undefined') {
try {
window.localStorage.setItem(STATS_LOADED_KEY, '1');
} catch {}
}
} catch (error) {
// treat as completed to avoid repeated attempts
set({ loaded: false });
if (typeof window !== 'undefined') {
try {
window.localStorage.setItem(STATS_LOADED_KEY, '0');
} catch {}
}
} finally {
set({ loading: false });
}
},
}));

View File

@ -20,6 +20,7 @@ export default function PhoneAuthForm() {
const [type, setType] = useState<'login' | 'register' | 'reset'>('login'); const [type, setType] = useState<'login' | 'register' | 'reset'>('login');
const [loading, startTransition] = useTransition(); const [loading, startTransition] = useTransition();
const [initialValues, setInitialValues] = useState<API.TelephoneLoginRequest>({ const [initialValues, setInitialValues] = useState<API.TelephoneLoginRequest>({
identifier: '',
telephone: '', telephone: '',
telephone_area_code: '1', telephone_area_code: '1',
password: '', password: '',

View File

@ -19,6 +19,8 @@ export default function Certification({ platform, children }: CertificationProps
oAuthLoginGetToken({ oAuthLoginGetToken({
method: platform, method: platform,
callback: searchParams, callback: searchParams,
// @ts-ignore
invite: localStorage.getItem('invite') || '',
}) })
.then((res) => { .then((res) => {
const token = res?.data?.data?.token; const token = res?.data?.data?.token;

View File

@ -47,6 +47,18 @@ export async function userLogin(body: API.UserLoginRequest, options?: { [key: st
}); });
} }
/** Device Login POST /v1/auth/login/device */
export async function deviceLogin(body: API.DeviceLoginRequest, options?: { [key: string]: any }) {
return request<API.Response & { data?: API.LoginResponse }>('/v1/auth/login/device', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
data: body,
...(options || {}),
});
}
/** User Telephone login POST /v1/auth/login/telephone */ /** User Telephone login POST /v1/auth/login/telephone */
export async function telephoneLogin( export async function telephoneLogin(
body: API.TelephoneLoginRequest, body: API.TelephoneLoginRequest,

View File

@ -114,6 +114,7 @@ declare namespace API {
type AuthConfig = { type AuthConfig = {
mobile: MobileAuthenticateConfig; mobile: MobileAuthenticateConfig;
email: EmailAuthticateConfig; email: EmailAuthticateConfig;
device: DeviceAuthticateConfig;
register: PubilcRegisterConfig; register: PubilcRegisterConfig;
}; };
@ -211,6 +212,19 @@ declare namespace API {
currency_symbol: string; currency_symbol: string;
}; };
type DeviceAuthticateConfig = {
enable: boolean;
show_ads: boolean;
enable_security: boolean;
only_real_device: boolean;
};
type DeviceLoginRequest = {
identifier: string;
user_agent: string;
cf_token?: string;
};
type Document = { type Document = {
id: number; id: number;
title: string; title: string;
@ -324,7 +338,7 @@ declare namespace API {
state: string; state: string;
}; };
type Hysteria = { type Hysteria2 = {
port: number; port: number;
hop_ports: string; hop_ports: string;
hop_interval: number; hop_interval: number;
@ -706,6 +720,7 @@ declare namespace API {
}; };
type ResetPasswordRequest = { type ResetPasswordRequest = {
identifier: string;
email: string; email: string;
password: string; password: string;
code?: string; code?: string;
@ -898,6 +913,7 @@ declare namespace API {
}; };
type TelephoneLoginRequest = { type TelephoneLoginRequest = {
identifier: string;
telephone: string; telephone: string;
telephone_code: string; telephone_code: string;
telephone_area_code: string; telephone_area_code: string;
@ -906,6 +922,7 @@ declare namespace API {
}; };
type TelephoneRegisterRequest = { type TelephoneRegisterRequest = {
identifier: string;
telephone: string; telephone: string;
telephone_area_code: string; telephone_area_code: string;
password: string; password: string;
@ -915,6 +932,7 @@ declare namespace API {
}; };
type TelephoneResetPasswordRequest = { type TelephoneResetPasswordRequest = {
identifier: string;
telephone: string; telephone: string;
telephone_area_code: string; telephone_area_code: string;
password: string; password: string;
@ -1035,12 +1053,14 @@ declare namespace API {
}; };
type UserLoginRequest = { type UserLoginRequest = {
identifier: string;
email: string; email: string;
password: string; password: string;
cf_token?: string; cf_token?: string;
}; };
type UserRegisterRequest = { type UserRegisterRequest = {
identifier: string;
email: string; email: string;
password: string; password: string;
invite?: string; invite?: string;

View File

@ -19,3 +19,14 @@ export async function querySubscribeList(
}, },
); );
} }
/** Get user subscribe node info GET /v1/public/subscribe/node/list */
export async function queryUserSubscribeNodeList(options?: { [key: string]: any }) {
return request<API.Response & { data?: API.QueryUserSubscribeNodeListResponse }>(
'/v1/public/subscribe/node/list',
{
method: 'GET',
...(options || {}),
},
);
}

View File

@ -108,6 +108,7 @@ declare namespace API {
type AuthConfig = { type AuthConfig = {
mobile: MobileAuthenticateConfig; mobile: MobileAuthenticateConfig;
email: EmailAuthticateConfig; email: EmailAuthticateConfig;
device: DeviceAuthticateConfig;
register: PubilcRegisterConfig; register: PubilcRegisterConfig;
}; };
@ -204,6 +205,13 @@ declare namespace API {
currency_symbol: string; currency_symbol: string;
}; };
type DeviceAuthticateConfig = {
enable: boolean;
show_ads: boolean;
enable_security: boolean;
only_real_device: boolean;
};
type Document = { type Document = {
id: number; id: number;
title: string; title: string;
@ -256,6 +264,11 @@ declare namespace API {
list: PaymentMethod[]; list: PaymentMethod[];
}; };
type GetDeviceListResponse = {
list: UserDevice[];
total: number;
};
type GetLoginLogParams = { type GetLoginLogParams = {
page: number; page: number;
size: number; size: number;
@ -343,7 +356,7 @@ declare namespace API {
list: Ticket[]; list: Ticket[];
}; };
type Hysteria = { type Hysteria2 = {
port: number; port: number;
hop_ports: string; hop_ports: string;
hop_interval: number; hop_interval: number;
@ -799,6 +812,10 @@ declare namespace API {
total: number; total: number;
}; };
type QueryUserSubscribeNodeListResponse = {
list: UserSubscribeInfo[];
};
type RechargeOrderRequest = { type RechargeOrderRequest = {
amount: number; amount: number;
payment: number; payment: number;
@ -1039,6 +1056,10 @@ declare namespace API {
security_config: SecurityConfig; security_config: SecurityConfig;
}; };
type UnbindDeviceRequest = {
id: number;
};
type UnbindOAuthRequest = { type UnbindOAuthRequest = {
method: string; method: string;
}; };
@ -1150,6 +1171,26 @@ declare namespace API {
updated_at: number; updated_at: number;
}; };
type UserSubscribeInfo = {
id: number;
user_id: number;
order_id: number;
subscribe_id: number;
start_time: number;
expire_time: number;
finished_at: number;
reset_time: number;
traffic: number;
download: number;
upload: number;
token: string;
status: number;
created_at: number;
updated_at: number;
is_try_out: boolean;
nodes: UserSubscribeNodeInfo[];
};
type UserSubscribeLog = { type UserSubscribeLog = {
id: number; id: number;
user_id: number; user_id: number;
@ -1160,6 +1201,19 @@ declare namespace API {
timestamp: number; timestamp: number;
}; };
type UserSubscribeNodeInfo = {
id: number;
name: string;
uuid: string;
protocol: string;
port: number;
address: string;
tags: string[];
country: string;
city: string;
created_at: number;
};
type VerifyCodeConfig = { type VerifyCodeConfig = {
verify_code_expire_time: number; verify_code_expire_time: number;
verify_code_limit: number; verify_code_limit: number;

View File

@ -128,6 +128,14 @@ export async function queryUserCommissionLog(
); );
} }
/** Get Device List GET /v1/public/user/devices */
export async function getDeviceList(options?: { [key: string]: any }) {
return request<API.Response & { data?: API.GetDeviceListResponse }>('/v1/public/user/devices', {
method: 'GET',
...(options || {}),
});
}
/** Query User Info GET /v1/public/user/info */ /** Query User Info GET /v1/public/user/info */
export async function queryUserInfo(options?: { [key: string]: any }) { export async function queryUserInfo(options?: { [key: string]: any }) {
return request<API.Response & { data?: API.User }>('/v1/public/user/info', { return request<API.Response & { data?: API.User }>('/v1/public/user/info', {
@ -236,6 +244,21 @@ export async function resetUserSubscribeToken(
}); });
} }
/** Unbind Device PUT /v1/public/user/unbind_device */
export async function unbindDevice(
body: API.UnbindDeviceRequest,
options?: { [key: string]: any },
) {
return request<API.Response & { data?: any }>('/v1/public/user/unbind_device', {
method: 'PUT',
headers: {
'Content-Type': 'application/json',
},
data: body,
...(options || {}),
});
}
/** Unbind OAuth POST /v1/public/user/unbind_oauth */ /** Unbind OAuth POST /v1/public/user/unbind_oauth */
export async function unbindOAuth(body: API.UnbindOAuthRequest, options?: { [key: string]: any }) { export async function unbindOAuth(body: API.UnbindOAuthRequest, options?: { [key: string]: any }) {
return request<API.Response & { data?: any }>('/v1/public/user/unbind_oauth', { return request<API.Response & { data?: any }>('/v1/public/user/unbind_oauth', {

BIN
bun.lockb

Binary file not shown.