From e5a52257eac5a9cf1aeb38a976b640b7453c8c94 Mon Sep 17 00:00:00 2001 From: moonrailgun Date: Sun, 7 Jan 2024 01:36:51 +0800 Subject: [PATCH] feat: add telegram notification support --- src/client/components/AutoLoadingButton.tsx | 17 +++++ .../NotificationInfo/strategies/index.ts | 6 ++ .../NotificationInfo/strategies/telegram.tsx | 75 +++++++++++++++++++ .../model/notification/provider/index.ts | 2 + .../model/notification/provider/telegram.ts | 49 ++++++++++++ src/server/model/notification/token/index.ts | 2 + .../notification/token/tokenizer/base.ts | 3 +- .../notification/token/tokenizer/telegram.ts | 22 ++++++ 8 files changed, 175 insertions(+), 1 deletion(-) create mode 100644 src/client/components/AutoLoadingButton.tsx create mode 100644 src/client/components/modals/NotificationInfo/strategies/telegram.tsx create mode 100644 src/server/model/notification/provider/telegram.ts create mode 100644 src/server/model/notification/token/tokenizer/telegram.ts diff --git a/src/client/components/AutoLoadingButton.tsx b/src/client/components/AutoLoadingButton.tsx new file mode 100644 index 0000000..8285ccd --- /dev/null +++ b/src/client/components/AutoLoadingButton.tsx @@ -0,0 +1,17 @@ +import { Button, ButtonProps } from 'antd'; +import React, { useState } from 'react'; +import { useEvent } from '../hooks/useEvent'; + +export const AutoLoadingButton: React.FC = React.memo((props) => { + const [loading, setLoading] = useState(false); + + const handleClick = useEvent( + async (e: React.MouseEvent) => { + setLoading(true); + await props.onClick?.(e); + setLoading(false); + } + ); + return