import { useEffect } from "react"; import { Alert, Button, Form, Input, Space } from "antd"; import type { MiniAppReleaseSettings } from "@personal-brand/api-client"; import { AdminSection } from "../../components/AdminSection.js"; import { MutationError } from "../../components/QueryState.js"; import { StatusTag } from "../../components/StatusTag.js"; export type MiniAppSettingsValues = { appId: string; apiBaseUrl: string; privateKey?: string; appSecret?: string; }; interface MiniAppSettingsTabProps { settings: MiniAppReleaseSettings | undefined; saving: boolean; error?: unknown; onSave: (values: MiniAppSettingsValues) => void; } export function MiniAppSettingsTab({ settings, saving, error, onSave }: MiniAppSettingsTabProps) { const [form] = Form.useForm(); useEffect(() => { if (!settings) return; form.setFieldsValue({ appId: settings.appId, apiBaseUrl: settings.apiBaseUrl, privateKey: "", appSecret: "", }); }, [form, settings]); return (
{settings?.buildError ? ( ) : ( )}
!value || /^[A-Za-z0-9]{16,64}$/.test(value.trim()) ? Promise.resolve() : Promise.reject(new Error("AppSecret 应为 16-64 位字母或数字,请复制完整值")), }, ]} > !value || /^https:\/\/[^/]+/.test(value) ? Promise.resolve() : Promise.reject( new Error( "公网地址必须以 https:// 开头,例如 https://wechat.app.que01.top/api", ), ), }, ]} extra="构建时写入小程序包,必须与微信后台“开发设置 → 服务器域名 → request 合法域名”一致。修改后需重新构建并上传代码才生效。" > .key 全文,必须保留换行。" } > {!settings?.loginConfigured ? ( ) : null} {settings?.hasStoredCredentials ? ( ) : ( )} {settings?.hasStoredAppSecret ? ( ) : ( )}
); }