🐛 fix(config): Bugs

This commit is contained in:
web@ppanel 2024-12-15 23:18:50 +07:00
parent bbc2da05f0
commit f57e40cd3d
12 changed files with 100 additions and 16 deletions

View File

@ -7,7 +7,7 @@ NEXT_PUBLIC_API_URL=https://api.ppanel.dev
# Default Login User # Default Login User
NEXT_PUBLIC_DEFAULT_USER_EMAIL=admin@ppanel.dev NEXT_PUBLIC_DEFAULT_USER_EMAIL=admin@ppanel.dev
NEXT_PUBLIC_DEFAULT_USER_PASSWORD=admin-password NEXT_PUBLIC_DEFAULT_USER_PASSWORD=password
# Please put in the .env file, otherwise the i18n command will not work # Please put in the .env file, otherwise the i18n command will not work
# OpenAI API key and proxy URL required for i18n command (optional) # OpenAI API key and proxy URL required for i18n command (optional)

View File

@ -37,7 +37,7 @@ export default function AlipayF2F() {
await updateAlipayF2FPaymentConfig({ await updateAlipayF2FPaymentConfig({
...data, ...data,
[key]: value, [key]: value,
} as API.PaymentConfig); } as API.UpdateAlipayF2fRequest);
toast.success(t('saveSuccess')); toast.success(t('saveSuccess'));
refetch(); refetch();
} catch (error) { } catch (error) {
@ -62,6 +62,23 @@ export default function AlipayF2F() {
/> />
</TableCell> </TableCell>
</TableRow> </TableRow>
<TableRow>
<TableCell>
<Label>{t('alipayf2f.sandbox')}</Label>
<p className='text-muted-foreground text-xs'>{t('alipayf2f.sandboxDescription')}</p>
</TableCell>
<TableCell className='text-right'>
<Switch
checked={data?.config.sandbox}
onCheckedChange={(checked) => {
updateConfig('config', {
...data?.config,
sandbox: checked,
});
}}
/>
</TableCell>
</TableRow>
<TableRow> <TableRow>
<TableCell> <TableCell>
<Label>{t('showName')}</Label> <Label>{t('showName')}</Label>

View File

@ -5,7 +5,9 @@
"invoiceName": "Custom Product Name", "invoiceName": "Custom Product Name",
"invoiceNameDescription": "Will be displayed on Alipay bill", "invoiceNameDescription": "Will be displayed on Alipay bill",
"privateKey": "Alipay Private Key", "privateKey": "Alipay Private Key",
"publicKey": "Alipay Public Key" "publicKey": "Alipay Public Key",
"sandbox": "Sandbox Mode",
"sandboxDescription": "Enable sandbox mode to test payments"
}, },
"enable": "Enable", "enable": "Enable",
"enableDescription": "Enable this payment method", "enableDescription": "Enable this payment method",

View File

@ -5,7 +5,9 @@
"invoiceName": "自定义产品名称", "invoiceName": "自定义产品名称",
"invoiceNameDescription": "将显示在支付宝账单中", "invoiceNameDescription": "将显示在支付宝账单中",
"privateKey": "支付宝私钥", "privateKey": "支付宝私钥",
"publicKey": "支付宝公钥" "publicKey": "支付宝公钥",
"sandbox": "沙箱模式",
"sandboxDescription": "启用沙箱模式以测试支付"
}, },
"enable": "启用", "enable": "启用",
"enableDescription": "启用此支付方式", "enableDescription": "启用此支付方式",

View File

@ -12,7 +12,7 @@ export async function getAlipayF2FPaymentConfig(options?: { [key: string]: any }
/** Update alipay f2f payment config PUT /v1/admin/payment/alipay_f2f */ /** Update alipay f2f payment config PUT /v1/admin/payment/alipay_f2f */
export async function updateAlipayF2FPaymentConfig( export async function updateAlipayF2FPaymentConfig(
body: API.PaymentConfig, body: API.UpdateAlipayF2fRequest,
options?: { [key: string]: any }, options?: { [key: string]: any },
) { ) {
return request<API.Response & { data?: any }>('/v1/admin/payment/alipay_f2f', { return request<API.Response & { data?: any }>('/v1/admin/payment/alipay_f2f', {
@ -46,7 +46,7 @@ export async function getEpayPaymentConfig(options?: { [key: string]: any }) {
/** Update epay payment config PUT /v1/admin/payment/epay */ /** Update epay payment config PUT /v1/admin/payment/epay */
export async function updateEpayPaymentConfig( export async function updateEpayPaymentConfig(
body: API.PaymentConfig, body: API.UpdateEpayRequest,
options?: { [key: string]: any }, options?: { [key: string]: any },
) { ) {
return request<API.Response & { data?: any }>('/v1/admin/payment/epay', { return request<API.Response & { data?: any }>('/v1/admin/payment/epay', {
@ -69,7 +69,7 @@ export async function getStripeAlipayPaymentConfig(options?: { [key: string]: an
/** Update stripe alipay payment config PUT /v1/admin/payment/stripe_alipay */ /** Update stripe alipay payment config PUT /v1/admin/payment/stripe_alipay */
export async function updateStripeAlipayPaymentConfig( export async function updateStripeAlipayPaymentConfig(
body: API.PaymentConfig, body: API.UpdateStripeRequest,
options?: { [key: string]: any }, options?: { [key: string]: any },
) { ) {
return request<API.Response & { data?: any }>('/v1/admin/payment/stripe_alipay', { return request<API.Response & { data?: any }>('/v1/admin/payment/stripe_alipay', {
@ -95,7 +95,7 @@ export async function getStripeWeChatPayPaymentConfig(options?: { [key: string]:
/** Update stripe wechat pay payment config PUT /v1/admin/payment/stripe_wechat_pay */ /** Update stripe wechat pay payment config PUT /v1/admin/payment/stripe_wechat_pay */
export async function updateStripeWeChatPayPaymentConfig( export async function updateStripeWeChatPayPaymentConfig(
body: API.PaymentConfig, body: API.UpdateStripeRequest,
options?: { [key: string]: any }, options?: { [key: string]: any },
) { ) {
return request<API.Response & { data?: any }>('/v1/admin/payment/stripe_wechat_pay', { return request<API.Response & { data?: any }>('/v1/admin/payment/stripe_wechat_pay', {

View File

@ -1,4 +1,12 @@
declare namespace API { declare namespace API {
type AlipayF2FConfig = {
app_id: string;
private_key: string;
public_key: string;
invoice_name: string;
sandbox: boolean;
};
type Announcement = { type Announcement = {
id: number; id: number;
title: string; title: string;
@ -183,7 +191,6 @@ declare namespace API {
type CurrencyConfig = { type CurrencyConfig = {
currency_unit: string; currency_unit: string;
currency_symbol: string; currency_symbol: string;
access_key: string;
}; };
type DeleteAnnouncementRequest = { type DeleteAnnouncementRequest = {
@ -244,6 +251,12 @@ declare namespace API {
expiration_email_template: string; expiration_email_template: string;
}; };
type EpayConfig = {
pid: string;
url: string;
key: string;
};
type Follow = { type Follow = {
id: number; id: number;
ticket_id: number; ticket_id: number;
@ -576,6 +589,8 @@ declare namespace API {
sni: string; sni: string;
allow_insecure: boolean; allow_insecure: boolean;
fingerprint: string; fingerprint: string;
reality_server_addr: string;
reality_server_port: number;
reality_private_key: string; reality_private_key: string;
reality_public_key: string; reality_public_key: string;
reality_short_id: string; reality_short_id: string;
@ -627,6 +642,13 @@ declare namespace API {
site_logo: string; site_logo: string;
}; };
type StripeConfig = {
public_key: string;
secret_key: string;
webhook_secret: string;
payment: string;
};
type Subscribe = { type Subscribe = {
id: number; id: number;
name: string; name: string;
@ -716,6 +738,19 @@ declare namespace API {
security_config: SecurityConfig; security_config: SecurityConfig;
}; };
type UpdateAlipayF2fRequest = {
id: number;
name: string;
mark: string;
icon?: string;
domain?: string;
config: AlipayF2FConfig;
fee_mode: number;
fee_percent?: number;
fee_amount?: number;
enable: boolean;
};
type UpdateAnnouncementEnableRequest = { type UpdateAnnouncementEnableRequest = {
id: number; id: number;
enable: boolean; enable: boolean;
@ -759,6 +794,19 @@ declare namespace API {
show: boolean; show: boolean;
}; };
type UpdateEpayRequest = {
id: number;
name: string;
mark: string;
icon?: string;
domain?: string;
config: EpayConfig;
fee_mode: number;
fee_percent?: number;
fee_amount?: number;
enable: boolean;
};
type UpdateNodeGroupRequest = { type UpdateNodeGroupRequest = {
id: number; id: number;
name: string; name: string;
@ -787,6 +835,19 @@ declare namespace API {
trade_no?: string; trade_no?: string;
}; };
type UpdateStripeRequest = {
id: number;
name: string;
mark: string;
icon?: string;
domain?: string;
config: StripeConfig;
fee_mode: number;
fee_percent?: number;
fee_amount?: number;
enable: boolean;
};
type UpdateSubscribeGroupRequest = { type UpdateSubscribeGroupRequest = {
id: number; id: number;
name: string; name: string;

View File

@ -57,7 +57,6 @@ declare namespace API {
type CurrencyConfig = { type CurrencyConfig = {
currency_unit: string; currency_unit: string;
currency_symbol: string; currency_symbol: string;
access_key: string;
}; };
type Document = { type Document = {
@ -235,6 +234,8 @@ declare namespace API {
sni: string; sni: string;
allow_insecure: boolean; allow_insecure: boolean;
fingerprint: string; fingerprint: string;
reality_server_addr: string;
reality_server_port: number;
reality_private_key: string; reality_private_key: string;
reality_public_key: string; reality_public_key: string;
reality_short_id: string; reality_short_id: string;

View File

@ -7,10 +7,9 @@ import { getAuthorization, Logout } from './common';
async function handleError(response: any) { async function handleError(response: any) {
const code = response.data?.code; const code = response.data?.code;
if ([40002, 40003, 40004].includes(code)) return Logout();
if (response?.config?.skipErrorHandler) return; if (response?.config?.skipErrorHandler) return;
if (!isBrowser()) return; if (!isBrowser()) return;
if ([40002, 40003, 40004].includes(code)) return Logout();
const t = await getTranslations('common'); const t = await getTranslations('common');
const message = const message =
t(`request.${code}`) !== `request.${code}` t(`request.${code}`) !== `request.${code}`

View File

@ -18,7 +18,7 @@ NEXT_PUBLIC_GITHUB_LINK=https://github.com/perfect-panel/ppanel-user-web
# Default Login User # Default Login User
NEXT_PUBLIC_DEFAULT_USER_EMAIL=admin@ppanel.dev NEXT_PUBLIC_DEFAULT_USER_EMAIL=admin@ppanel.dev
NEXT_PUBLIC_DEFAULT_USER_PASSWORD=admin-password NEXT_PUBLIC_DEFAULT_USER_PASSWORD=password
# Please put in the .env file, otherwise the i18n command will not work # Please put in the .env file, otherwise the i18n command will not work
# OpenAI API key and proxy URL required for i18n command (optional) # OpenAI API key and proxy URL required for i18n command (optional)

View File

@ -57,7 +57,6 @@ declare namespace API {
type CurrencyConfig = { type CurrencyConfig = {
currency_unit: string; currency_unit: string;
currency_symbol: string; currency_symbol: string;
access_key: string;
}; };
type Document = { type Document = {
@ -235,6 +234,8 @@ declare namespace API {
sni: string; sni: string;
allow_insecure: boolean; allow_insecure: boolean;
fingerprint: string; fingerprint: string;
reality_server_addr: string;
reality_server_port: number;
reality_private_key: string; reality_private_key: string;
reality_public_key: string; reality_public_key: string;
reality_short_id: string; reality_short_id: string;

View File

@ -71,7 +71,6 @@ declare namespace API {
type CurrencyConfig = { type CurrencyConfig = {
currency_unit: string; currency_unit: string;
currency_symbol: string; currency_symbol: string;
access_key: string;
}; };
type Document = { type Document = {
@ -377,6 +376,8 @@ declare namespace API {
sni: string; sni: string;
allow_insecure: boolean; allow_insecure: boolean;
fingerprint: string; fingerprint: string;
reality_server_addr: string;
reality_server_port: number;
reality_private_key: string; reality_private_key: string;
reality_public_key: string; reality_public_key: string;
reality_short_id: string; reality_short_id: string;

View File

@ -7,9 +7,9 @@ import { getAuthorization, Logout } from './common';
async function handleError(response: any) { async function handleError(response: any) {
const code = response.data?.code; const code = response.data?.code;
if ([40002, 40003, 40004].includes(code)) return Logout();
if (response?.config?.skipErrorHandler) return; if (response?.config?.skipErrorHandler) return;
if (!isBrowser()) return; if (!isBrowser()) return;
if ([40002, 40003, 40004].includes(code)) return Logout();
const t = await getTranslations('common'); const t = await getTranslations('common');
const message = const message =