Browse Source

fix: resolve remaining react-doctor issues for semantic HTML and accessibility

- Replace non-navigational `<a href="#">` with `<span>` or add `e.preventDefault()`
- Use actual `href` values from data instead of placeholder `#`
- Simplify optional chaining for geographic data access
- Remove unnecessary default function parameter for onClick
- Use `[...arr].sort()` instead of `toSorted()` for broader compatibility

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
pull/11780/head
afc163 4 months ago
parent
commit
6b4093d356
  1. 7
      src/components/AvatarList/index.tsx
  2. 20
      src/pages/account/center/index.tsx
  3. 6
      src/pages/account/settings/components/binding.tsx
  4. 10
      src/pages/account/settings/components/security.tsx
  5. 2
      src/pages/dashboard/monitor/components/ActiveChart/index.tsx
  6. 8
      src/pages/dashboard/workplace/index.tsx
  7. 2
      src/pages/list/card-list/index.tsx
  8. 2
      src/pages/list/search/projects/index.tsx
  9. 2
      src/pages/result/fail/index.tsx
  10. 6
      src/pages/user/login/index.tsx

7
src/components/AvatarList/index.tsx

@ -31,12 +31,7 @@ const avatarSizeToClassName = (styles: any, size?: SizeType | 'mini') =>
[styles.avatarItemMini]: size === 'mini',
});
const Item: React.FC<AvatarItemProps> = ({
src,
size,
tips,
onClick = () => {},
}) => {
const Item: React.FC<AvatarItemProps> = ({ src, size, tips, onClick }) => {
const { styles } = useStyles();
const cls = avatarSizeToClassName(styles, size);
return (

20
src/pages/account/center/index.tsx

@ -167,24 +167,8 @@ const UserInfo: React.FC<{ user: Partial<CurrentUser> }> = ({ user }) => {
marginRight: 8,
}}
/>
{
(
user.geographic || {
province: {
label: '',
},
}
).province.label
}
{
(
user.geographic || {
city: {
label: '',
},
}
).city.label
}
{user.geographic?.province?.label}
{user.geographic?.city?.label}
</p>
</div>
);

6
src/pages/account/settings/components/binding.tsx

@ -12,7 +12,7 @@ const BindingView: React.FC = () => {
title: '绑定淘宝',
description: '当前未绑定淘宝账号',
actions: [
<a key="Bind" href="#">
<a key="Bind" href="#" onClick={(e) => e.preventDefault()}>
</a>,
],
@ -22,7 +22,7 @@ const BindingView: React.FC = () => {
title: '绑定支付宝',
description: '当前未绑定支付宝账号',
actions: [
<a key="Bind" href="#">
<a key="Bind" href="#" onClick={(e) => e.preventDefault()}>
</a>,
],
@ -32,7 +32,7 @@ const BindingView: React.FC = () => {
title: '绑定钉钉',
description: '当前未绑定钉钉账号',
actions: [
<a key="Bind" href="#">
<a key="Bind" href="#" onClick={(e) => e.preventDefault()}>
</a>,
],

10
src/pages/account/settings/components/security.tsx

@ -20,7 +20,7 @@ const SecurityView: React.FC = () => {
</>
),
actions: [
<a key="Modify" href="#">
<a key="Modify" href="#" onClick={(e) => e.preventDefault()}>
</a>,
],
@ -29,7 +29,7 @@ const SecurityView: React.FC = () => {
title: '密保手机',
description: `已绑定手机:138****8293`,
actions: [
<a key="Modify" href="#">
<a key="Modify" href="#" onClick={(e) => e.preventDefault()}>
</a>,
],
@ -38,7 +38,7 @@ const SecurityView: React.FC = () => {
title: '密保问题',
description: '未设置密保问题,密保问题可有效保护账户安全',
actions: [
<a key="Set" href="#">
<a key="Set" href="#" onClick={(e) => e.preventDefault()}>
</a>,
],
@ -47,7 +47,7 @@ const SecurityView: React.FC = () => {
title: '备用邮箱',
description: `已绑定邮箱:ant***sign.com`,
actions: [
<a key="Modify" href="#">
<a key="Modify" href="#" onClick={(e) => e.preventDefault()}>
</a>,
],
@ -56,7 +56,7 @@ const SecurityView: React.FC = () => {
title: 'MFA 设备',
description: '未绑定 MFA 设备,绑定后,可以进行二次确认',
actions: [
<a key="bind" href="#">
<a key="bind" href="#" onClick={(e) => e.preventDefault()}>
</a>,
],

2
src/pages/dashboard/monitor/components/ActiveChart/index.tsx

@ -38,7 +38,7 @@ const ActiveChart = () => {
// Memoize max and median to avoid double sort on every render
const { maxValue, medianValue } = useMemo(() => {
if (!activeData.length) return { maxValue: 0, medianValue: 0 };
const sorted = activeData.toSorted((a, b) => a.y - b.y);
const sorted = [...activeData].sort((a, b) => a.y - b.y);
return {
maxValue: sorted[sorted.length - 1]?.y ?? 0,
medianValue: sorted[Math.floor(sorted.length / 2)]?.y ?? 0,

8
src/pages/dashboard/workplace/index.tsx

@ -118,9 +118,7 @@ const Workplace: FC = () => {
avatar={<Avatar src={item.user.avatar} />}
title={
<span>
<a className={styles.username} href="#">
{item.user.name}
</a>
<span className={styles.username}>{item.user.name}</span>
&nbsp;
<span className={styles.event}>{events}</span>
</span>
@ -281,12 +279,12 @@ const Workplace: FC = () => {
{projectNotice.map((item) => {
return (
<Col span={12} key={`members-item-${item.id}`}>
<a href="#">
<span>
<Avatar src={item.logo} size="small" />
<span className={styles.member}>
{item.member.substring(0, 3)}
</span>
</a>
</span>
</Col>
);
})}

2
src/pages/list/card-list/index.tsx

@ -95,7 +95,7 @@ const CardList = () => {
src={item.avatar}
/>
}
title={<a href="#">{item.title}</a>}
title={<a href={item.href}>{item.title}</a>}
description={
<Paragraph
className={styles.item}

2
src/pages/list/search/projects/index.tsx

@ -50,7 +50,7 @@ const Projects: FC = () => {
cover={<img alt={item.title} src={item.cover} />}
>
<Card.Meta
title={<a href="#">{item.title}</a>}
title={<a href={item.href}>{item.title}</a>}
description={
<Paragraph
ellipsis={{

2
src/pages/result/fail/index.tsx

@ -24,6 +24,7 @@ export default () => {
<span></span>
<a
href="#"
onClick={(e) => e.preventDefault()}
style={{
marginLeft: 16,
}}
@ -42,6 +43,7 @@ export default () => {
<span></span>
<a
href="#"
onClick={(e) => e.preventDefault()}
style={{
marginLeft: 16,
}}

6
src/pages/user/login/index.tsx

@ -397,17 +397,17 @@ const Login: React.FC = () => {
defaultMessage="自动登录"
/>
</ProFormCheckbox>
<a
href="#"
<span
style={{
float: 'right',
cursor: 'pointer',
}}
>
<FormattedMessage
id="pages.login.forgotPassword"
defaultMessage="忘记密码"
/>
</a>
</span>
</div>
</LoginForm>
</div>

Loading…
Cancel
Save