mirror of
https://github.com/certd/certd.git
synced 2026-04-24 04:17:25 +08:00
perf: 支持域名到期时间监控通知
This commit is contained in:
@@ -221,6 +221,7 @@ export default {
|
||||
projectJoin: "Join Project",
|
||||
currentProject: "Current Project",
|
||||
projectMemberManager: "Project Member",
|
||||
domainMonitorSetting: "Domain Monitor Settings",
|
||||
},
|
||||
certificateRepo: {
|
||||
title: "Certificate Repository",
|
||||
|
||||
@@ -64,6 +64,18 @@ export default {
|
||||
dnsServerHelper: "Use a custom domain name resolution server, such as: 1.1.1.1 , support multiple",
|
||||
certValidDays: "Certificate Valid Days",
|
||||
certValidDaysHelper: "Number of days before expiration to send a notification",
|
||||
|
||||
domain: {
|
||||
monitorSettings: "Domain Monitor Settings",
|
||||
enabled: "Enable Domain Monitor",
|
||||
enabledHelper: "Enable to monitor all domain registration expiration time",
|
||||
notificationChannel: "Notification Channel",
|
||||
setNotificationChannel: "Set the notification channel",
|
||||
willExpireDays: "Will Expire Days",
|
||||
willExpireDaysHelper: "Number of days before expiration to send a notification",
|
||||
monitorCronSetting: "Monitoring Schedule",
|
||||
cronTrigger: "Scheduled trigger for monitoring",
|
||||
},
|
||||
},
|
||||
cert: {
|
||||
expired: "Expired",
|
||||
|
||||
@@ -226,6 +226,7 @@ export default {
|
||||
projectJoin: "加入项目",
|
||||
currentProject: "当前项目",
|
||||
projectMemberManager: "项目成员管理",
|
||||
domainMonitorSetting: "域名监控设置",
|
||||
},
|
||||
certificateRepo: {
|
||||
title: "证书仓库",
|
||||
|
||||
@@ -68,6 +68,17 @@ export default {
|
||||
dnsServerHelper: "使用自定义的域名解析服务器,如:1.1.1.1 , 支持多个",
|
||||
certValidDays: "证书到期前天数",
|
||||
certValidDaysHelper: "证书到期前多少天发送通知",
|
||||
domain: {
|
||||
monitorSettings: "域名监控设置",
|
||||
enabled: "启用域名监控",
|
||||
enabledHelper: "启用后,将监控域名管理中的域名的过期时间",
|
||||
notificationChannel: "通知渠道",
|
||||
setNotificationChannel: "设置通知渠道",
|
||||
willExpireDays: "到期前天数",
|
||||
willExpireDaysHelper: "域名有效期到期前多少天发送通知",
|
||||
monitorCronSetting: "监控定时设置",
|
||||
cronTrigger: "定时触发监控",
|
||||
},
|
||||
},
|
||||
cert: {
|
||||
expired: "已过期",
|
||||
|
||||
@@ -241,6 +241,17 @@ export const certdResources = [
|
||||
isMenu: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
title: "certd.sysResources.domainMonitorSetting",
|
||||
name: "DomainMonitorSetting",
|
||||
path: "/certd/cert/domain/setting",
|
||||
component: "/certd/cert/domain/setting/index.vue",
|
||||
meta: {
|
||||
icon: "ion:videocam-outline",
|
||||
auth: true,
|
||||
isMenu: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
title: "certd.userSecurity",
|
||||
name: "UserSecurity",
|
||||
|
||||
@@ -128,6 +128,18 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
|
||||
}, 2000);
|
||||
},
|
||||
},
|
||||
monitorSettingSave: {
|
||||
show: hasActionPermission("write"),
|
||||
title: "域名过期监控设置",
|
||||
type: "primary",
|
||||
icon: "ion:save-outline",
|
||||
text: "域名过期监控设置",
|
||||
click: async () => {
|
||||
router.push({
|
||||
path: "/certd/cert/domain/setting",
|
||||
});
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
columns: {
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
// @ts-ignore
|
||||
import { request } from "/src/api/service";
|
||||
const apiPrefix = "/cert/domain/setting";
|
||||
export type UserDomainMonitorSetting = {
|
||||
enabled?: boolean;
|
||||
notificationId?: number;
|
||||
cron?: string;
|
||||
willExpireDays?: number;
|
||||
};
|
||||
|
||||
export async function DomainMonitorSettingsGet() {
|
||||
const res = await request({
|
||||
url: apiPrefix + "/get",
|
||||
method: "post",
|
||||
});
|
||||
if (!res) {
|
||||
return {};
|
||||
}
|
||||
return res as UserDomainMonitorSetting;
|
||||
}
|
||||
export async function DomainMonitorSettingsSave(data: UserDomainMonitorSetting) {
|
||||
await request({
|
||||
url: apiPrefix + "/save",
|
||||
method: "post",
|
||||
data: data,
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
<template>
|
||||
<fs-page class="page-user-settings page-domain-monitor-setting">
|
||||
<template #header>
|
||||
<div class="title">{{ t("monitor.setting.domain.monitorSettings") }}</div>
|
||||
</template>
|
||||
<div class="user-settings-form settings-form">
|
||||
<a-form :model="formState" name="basic" :label-col="{ span: 8 }" :wrapper-col="{ span: 16 }" autocomplete="off">
|
||||
<a-form-item :label="t('monitor.setting.domain.enabled')" :name="['enabled']">
|
||||
<div class="flex flex-baseline">
|
||||
<a-switch v-model:checked="formState.enabled" :disabled="!settingsStore.isPlus" />
|
||||
<vip-button class="ml-5" mode="button"></vip-button>
|
||||
</div>
|
||||
<div class="helper">{{ t("monitor.setting.domain.enabledHelper") }}</div>
|
||||
</a-form-item>
|
||||
<a-form-item v-if="formState.enabled" :label="t('monitor.setting.domain.notificationChannel')" :name="['notificationId']">
|
||||
<div class="flex">
|
||||
<NotificationSelector v-model="formState.notificationId" />
|
||||
</div>
|
||||
<div class="helper">{{ t("monitor.setting.domain.setNotificationChannel") }}</div>
|
||||
</a-form-item>
|
||||
<a-form-item v-if="formState.enabled" :label="t('monitor.setting.domain.willExpireDays')" :name="['willExpireDays']">
|
||||
<div class="flex">
|
||||
<a-input-number v-model:value="formState.willExpireDays" />
|
||||
</div>
|
||||
<div class="helper">{{ t("monitor.setting.domain.willExpireDaysHelper") }}</div>
|
||||
</a-form-item>
|
||||
<a-form-item v-if="formState.enabled" :label="t('monitor.setting.domain.monitorCronSetting')" :name="['cron']">
|
||||
<div class="flex flex-baseline">
|
||||
<cron-editor v-model="formState.cron" :disabled="!settingsStore.isPlus" :allow-every-min="userStore.isAdmin" />
|
||||
<vip-button class="ml-5" mode="button"></vip-button>
|
||||
</div>
|
||||
<div class="helper">{{ t("monitor.setting.domain.cronTrigger") }}</div>
|
||||
</a-form-item>
|
||||
<a-form-item label=" " :colon="false" :wrapper-col="{ span: 16 }">
|
||||
<loading-button type="primary" html-type="button" :click="doSave" :disabled="!hasActionPermission('write')">{{ t("certd.save") }}</loading-button>
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</div>
|
||||
</fs-page>
|
||||
</template>
|
||||
|
||||
<script setup lang="tsx">
|
||||
import { notification } from "ant-design-vue";
|
||||
import { merge } from "lodash-es";
|
||||
import { reactive } from "vue";
|
||||
import * as api from "./api";
|
||||
import { UserDomainMonitorSetting } from "./api";
|
||||
import { useUserStore } from "/@/store/user";
|
||||
import { utils } from "/@/utils";
|
||||
import NotificationSelector from "/@/views/certd/notification/notification-selector/index.vue";
|
||||
import { useI18n } from "/src/locales";
|
||||
import { useSettingStore } from "/src/store/settings";
|
||||
import { useCrudPermission } from "/@/plugin/permission";
|
||||
|
||||
const { t } = useI18n();
|
||||
|
||||
const settingsStore = useSettingStore();
|
||||
const userStore = useUserStore();
|
||||
defineOptions({
|
||||
name: "DomainMonitorSetting",
|
||||
});
|
||||
|
||||
const randomHour = Math.floor(Math.random() * 9);
|
||||
const randomMin = Math.floor(Math.random() * 59);
|
||||
const randomCron = `0 ${randomMin} ${randomHour} * * *`;
|
||||
|
||||
const formState = reactive<Partial<UserDomainMonitorSetting>>({
|
||||
enabled: false,
|
||||
notificationId: 0,
|
||||
cron: randomCron,
|
||||
willExpireDays: 30,
|
||||
});
|
||||
|
||||
async function loadUserSettings() {
|
||||
const data: any = await api.DomainMonitorSettingsGet();
|
||||
merge(formState, data);
|
||||
}
|
||||
|
||||
const { hasActionPermission } = useCrudPermission({ permission: { isProjectPermission: true } });
|
||||
|
||||
loadUserSettings();
|
||||
const doSave = async (form: any) => {
|
||||
await utils.sleep(300);
|
||||
await api.DomainMonitorSettingsSave({
|
||||
...formState,
|
||||
});
|
||||
notification.success({
|
||||
message: t("certd.saveSuccess"),
|
||||
});
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="less">
|
||||
.page-domain-monitor-setting {
|
||||
.settings-form {
|
||||
width: 700px;
|
||||
margin: 20px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user