feat(components): add bottom drawer for notification permission guide

Introduce a bottom drawer in the notification permission control
component to provide a step-by-step guide for users (specifically
on iOS/Safari) to enable push notifications when the browser does
not support direct requests.

Key changes:
- Added a 'Drawer' component with 'placement="bottom"' to display
  instructions for adding the site to the home screen.
- Updated the permission control panel to use the same bottom
  placement for consistency.
- Refactored the notification control to toggle the drawer state
  upon interaction.

This improves the user experience by explicitly showing how to
enable features that are restricted in PWA-like environments.
This commit is contained in:
kyuuseiryuu 2026-03-25 00:54:10 +09:00
parent 36c72a1a11
commit 95655068b3
2 changed files with 52 additions and 29 deletions

View File

@ -1,6 +1,6 @@
import { Button, Flex, Form, Switch, Typography } from "antd";
import { Button, Drawer, Flex, Form, Switch, Typography } from "antd";
import { useNotificationControl } from "../hooks/useNotificationControl";
import { useCallback } from "react";
import { useCallback, useState } from "react";
const NotificationPermissionControl = () => {
const {
@ -10,36 +10,58 @@ const NotificationPermissionControl = () => {
handleDisableNotificationClick,
handleEnableNotificationClick,
} = useNotificationControl();
const [open, setOpen] = useState(false);
const showEnableNotification = useCallback(() => {
setOpen(true);
}, []);
return (
<Form.Item
label={'启用通知'}
tooltip={'分享 - 添加至桌面/主屏幕后,可接收通知'}
>
{isSupported ? (
<Switch
loading={loading}
disabled={!isSupported}
value={isNotificationEnable}
onChange={checked => {
if (checked) {
handleEnableNotificationClick();
} else {
handleDisableNotificationClick();
}
}}
/>
) : (
<Flex align="center" justify="center" wrap>
<Typography.Text type='secondary'>
</Typography.Text>
<Button type="link" onClick={showEnableNotification}></Button>
</Flex>
)}
</Form.Item>
<>
<Form.Item label={'启用通知'}>
{isSupported ? (
<Switch
loading={loading}
disabled={!isSupported}
value={isNotificationEnable}
onChange={checked => {
if (checked) {
handleEnableNotificationClick();
} else {
handleDisableNotificationClick();
}
}}
/>
) : (
<Flex align="center" justify="center" wrap>
<Typography.Text type='secondary'>
</Typography.Text>
<Button type="link" onClick={showEnableNotification}></Button>
</Flex>
)}
</Form.Item>
<Drawer
placement="bottom"
open={open}
onClose={() => setOpen(false)}
title={'帮助'}
>
<Typography.Title level={4}>
1. 使
</Typography.Title>
<Typography.Text>
iOS 使 Safari
</Typography.Text>
<Typography.Title level={4}>
2.
</Typography.Title>
<Typography.Title level={4}>
3.
</Typography.Title>
<Typography.Title level={4}>
4.
</Typography.Title>
</Drawer>
</>
);
};

View File

@ -10,6 +10,7 @@ const PermissionControlPanel = () => {
<Button block icon={<NotificationOutlined />} onClick={() => setOpen(true)}></Button>
<Drawer
open={open}
placement="bottom"
title={'权限设置'}
onClose={() => setOpen(false)}
>