Enhance the message notification feature

This commit is contained in:
yoan
2024-09-24 22:39:42 +08:00
parent 4c9095400e
commit ac4904fb9a
18 changed files with 1322 additions and 337 deletions

308
ui/dist/assets/index-B-WSkv0U.js vendored Normal file

File diff suppressed because one or more lines are too long

1
ui/dist/assets/index-BLt37AhW.css vendored Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

4
ui/dist/index.html vendored
View File

@@ -5,8 +5,8 @@
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Certimate - Your Trusted SSL Automation Partner</title>
<script type="module" crossorigin src="/assets/index-Cum7econ.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-BmYeXvQX.css">
<script type="module" crossorigin src="/assets/index-B-WSkv0U.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-BLt37AhW.css">
</head>
<body class="bg-background">
<div id="root"></div>

View File

@@ -23,6 +23,7 @@ const Telegram = () => {
name: "notifyChannels",
data: {
apiToken: "",
chatId: "",
enabled: false,
},
});
@@ -31,6 +32,7 @@ const Telegram = () => {
const getDetailTelegram = () => {
const df: NotifyChannelTelegram = {
apiToken: "",
chatId: "",
enabled: false,
};
if (!config.content) {
@@ -98,6 +100,20 @@ const Telegram = () => {
}}
/>
<Input
placeholder="ChatId"
value={telegram.data.chatId}
onChange={(e) => {
setTelegram({
...telegram,
data: {
...telegram.data,
chatId: e.target.value,
},
});
}}
/>
<div className="flex items-center space-x-1 mt-2">
<Switch
id="airplane-mode"

View File

@@ -8,6 +8,7 @@ import { useEffect, useState } from "react";
import { update } from "@/repository/settings";
import { getErrMessage } from "@/lib/error";
import { useToast } from "../ui/use-toast";
import { isValidURL } from "@/lib/url";
type WebhookSetting = {
id: string;
@@ -55,6 +56,16 @@ const Webhook = () => {
const handleSaveClick = async () => {
try {
webhook.data.url = webhook.data.url.trim();
if (!isValidURL(webhook.data.url)) {
toast({
title: "保存失败",
description: "Url格式不正确",
variant: "destructive",
});
return;
}
const resp = await update({
...config,
name: "notifyChannels",

View File

@@ -36,6 +36,7 @@ export type NotifyChannelDingTalk = {
export type NotifyChannelTelegram = {
apiToken: string;
chatId: string;
enabled: boolean;
};

View File

@@ -1 +1 @@
export const version = "Certimate v0.1.10";
export const version = "Certimate v0.1.11";

8
ui/src/lib/url.ts Normal file
View File

@@ -0,0 +1,8 @@
export function isValidURL(url: string): boolean {
try {
new URL(url);
return true;
} catch (error) {
return false;
}
}

View File

@@ -25,7 +25,7 @@ const Notify = () => {
</Accordion>
</div>
<div className="border rounded-md p-5 mt-7 shadow-lg">
<Accordion type={"multiple"} className="dark:text-stone-200">
<Accordion type={"single"} className="dark:text-stone-200">
<AccordionItem value="item-2" className="dark:border-stone-200">
<AccordionTrigger></AccordionTrigger>
<AccordionContent>