docs:重命名文件、变量名称

This commit is contained in:
2026-06-09 18:54:01 +08:00
parent c18d9c8404
commit 1c27283b56
5 changed files with 29 additions and 17 deletions

2
.gitignore vendored
View File

@@ -36,5 +36,5 @@ dist-ssr
*.py *.py
*.pyi *.pyi
WORKLOG.md WORKLOG.md
*openapi*.json *open*.json
response_*.json response_*.json

View File

@@ -21,7 +21,7 @@ import { Drawer, Modal } from 'antd';
import { EVENTS, off, on } from '@/utils/event-bus'; import { EVENTS, off, on } from '@/utils/event-bus';
import { FloatingPanel } from '@/components/ui/FloatingPanel'; import { FloatingPanel } from '@/components/ui/FloatingPanel';
import { WechatWorkPage } from '@/pages/headers/WechatWorkPage'; import { WechatWorkPage } from '@/pages/headers/WechatWorkPage';
import { Test2 } from '@/pages/headers/Test2'; import { AccountInfo } from '@/pages/headers/AccountInfo.tsx';
// ---------- 类型 ---------- // ---------- 类型 ----------
@@ -73,7 +73,7 @@ const PAGE_MAP: Record<string, PageConfig> = {
'/wechat-work': { component: WechatWorkPage, label: '企业微信' }, '/wechat-work': { component: WechatWorkPage, label: '企业微信' },
'/compliance-assets': { label: '合规素材库' }, '/compliance-assets': { label: '合规素材库' },
'/account': { '/account': {
component: Test2, component: AccountInfo,
label: '账户', label: '账户',
width: () => Math.min(window.innerWidth * 0.6, 720), width: () => Math.min(window.innerWidth * 0.6, 720),
height: () => Math.min(window.innerHeight * 0.6, 680), height: () => Math.min(window.innerHeight * 0.6, 680),
@@ -198,6 +198,7 @@ export function PageDispatcher() {
width={panelWidth ?? defaultDrawerWidth} width={panelWidth ?? defaultDrawerWidth}
height={panelHeight} height={panelHeight}
> >
{/* eslint-disable-next-line react-hooks/static-components */}
<PanelPage /> <PanelPage />
</FloatingPanel> </FloatingPanel>
)} )}

View File

@@ -1,5 +1,5 @@
// ============================================================ // ============================================================
// Test2 — 账户信息展示 // AccountInfo — 账户信息展示
// 数据来源AuthAPI.getUserInfo() → GET /api/v1/auth/me // 数据来源AuthAPI.getUserInfo() → GET /api/v1/auth/me
// ============================================================ // ============================================================
@@ -39,7 +39,7 @@ function formatDate(date: Date | string | undefined): string {
return d.toLocaleDateString('zh-CN', { year: 'numeric', month: '2-digit', day: '2-digit' }); return d.toLocaleDateString('zh-CN', { year: 'numeric', month: '2-digit', day: '2-digit' });
} }
export function Test2() { export function AccountInfo() {
const { token } = antTheme.useToken(); const { token } = antTheme.useToken();
const [userInfo, setUserInfo] = useState<UserInfoBody | null>(null); const [userInfo, setUserInfo] = useState<UserInfoBody | null>(null);
const [loading, setLoading] = useState(true); const [loading, setLoading] = useState(true);

View File

@@ -4,7 +4,7 @@
import { useState, useCallback } from 'react'; import { useState, useCallback } from 'react';
import { Input, Button, Checkbox, Typography } from 'antd'; import { Input, Button, Checkbox, Typography } from 'antd';
import { UserOutlined, LockOutlined } from '@ant-design/icons'; import { UserOutlined, LockOutlined, EyeTwoTone, EyeInvisibleOutlined } from '@ant-design/icons';
import { loginFields } from '../config/login-fields'; import { loginFields } from '../config/login-fields';
import { validateForm } from '../config/validators'; import { validateForm } from '../config/validators';
@@ -40,7 +40,7 @@ export function LoginForm({
const [password, setPassword] = useState(initialPassword || ''); const [password, setPassword] = useState(initialPassword || '');
const [remember, setRemember] = useState(initialRemember); const [remember, setRemember] = useState(initialRemember);
const [autoLogin, setAutoLogin] = useState(initialAutoLogin); const [autoLogin, setAutoLogin] = useState(initialAutoLogin);
const [agreed, setAgreed] = useState(false); const [agreed, setAgreed] = useState(true);
const [errors, setErrors] = useState<Record<string, string[]>>({}); const [errors, setErrors] = useState<Record<string, string[]>>({});
// 协议弹窗 // 协议弹窗
@@ -103,6 +103,8 @@ export function LoginForm({
setPassword(e.target.value); setPassword(e.target.value);
clearError('password'); clearError('password');
}} }}
iconRender={(visible) => (visible ? <EyeTwoTone /> : <EyeInvisibleOutlined />)}
onPressEnter={handleSubmit}
status={errors.password ? 'error' : undefined} status={errors.password ? 'error' : undefined}
allowClear allowClear
/> />
@@ -162,6 +164,11 @@ export function LoginForm({
setAgreed(e.target.checked); setAgreed(e.target.checked);
clearError('_agreement'); clearError('_agreement');
}} }}
onKeyDown={(event)=>{
if (event.key === 'Enter' || event.keyCode === 13) {
setAgreed(!agreed);
}
}}
className="text-xs" className="text-xs"
> >

View File

@@ -2,7 +2,7 @@
// RegisterForm — 注册表单(仅个人版) // RegisterForm — 注册表单(仅个人版)
// ============================================================ // ============================================================
import { useState, useCallback, useRef } from 'react'; import React, { useState, useCallback, useRef } from 'react';
import { Input, Button, Checkbox, Typography } from 'antd'; import { Input, Button, Checkbox, Typography } from 'antd';
import { LegalTextModal } from '@/components/ui/LegalTextModal'; import { LegalTextModal } from '@/components/ui/LegalTextModal';
@@ -87,17 +87,16 @@ export function RegisterForm({ submitting = false, onSubmit, onSendSms }: Regist
onSendSms?.(phone); onSendSms?.(phone);
}, [values.phone, onSendSms]); }, [values.phone, onSendSms]);
// 跨字段校验
const crossValidators = {
confirmPassword: (val: string) => {
if (!val) return '请再次输入密码';
if (val !== values.password) return '两次密码不一致';
return null;
},
};
// 提交 // 提交
const handleSubmit = useCallback(() => { const handleSubmit = useCallback(() => {
// 跨字段校验(内联避免每次渲染创建新引用致使用 useCallback 失效)
const crossValidators = {
confirmPassword: (val: string) => {
if (!val) return '请再次输入密码';
if (val !== values.password) return '两次密码不一致';
return null;
},
};
const fieldErrors = validateForm(values, registerFields, crossValidators); const fieldErrors = validateForm(values, registerFields, crossValidators);
if (Object.keys(fieldErrors).length > 0) { if (Object.keys(fieldErrors).length > 0) {
setErrors(fieldErrors); setErrors(fieldErrors);
@@ -208,6 +207,11 @@ export function RegisterForm({ submitting = false, onSubmit, onSendSms }: Regist
return n; return n;
}); });
}} }}
onKeyDown={(e)=>{
if(e.key==="Enter" || e.keyCode == 13) {
setAgreed(!agreed);
}
}}
className="text-xs" className="text-xs"
> >