mirror of https://github.com/certd/certd
perf: 站点证书监控增加通知设置
parent
f807b8cb46
commit
3422a1a59f
|
@ -204,3 +204,5 @@ export class SysSafeSetting extends BaseSettings {
|
||||||
autoHiddenTimes: 5,
|
autoHiddenTimes: 5,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -143,6 +143,17 @@ export const certdResources = [
|
||||||
keepAlive: true,
|
keepAlive: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
title: "站点监控设置",
|
||||||
|
name: "SiteMonitorSetting",
|
||||||
|
path: "/certd/monitor/setting",
|
||||||
|
component: "/certd/monitor/site/setting/index.vue",
|
||||||
|
meta: {
|
||||||
|
icon: "ion:videocam-outline",
|
||||||
|
auth: true,
|
||||||
|
isMenu: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
title: "认证安全设置",
|
title: "认证安全设置",
|
||||||
name: "UserSecurity",
|
name: "UserSecurity",
|
||||||
|
|
|
@ -35,10 +35,15 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
|
||||||
pageRequest,
|
pageRequest,
|
||||||
addRequest,
|
addRequest,
|
||||||
editRequest,
|
editRequest,
|
||||||
delRequest
|
delRequest,
|
||||||
|
},
|
||||||
|
table: {
|
||||||
|
remove: {
|
||||||
|
confirmMessage: "授权如果已经被使用,可能会导致流水线无法正常运行,请谨慎操作",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
rowHandle: {
|
rowHandle: {
|
||||||
width: 200
|
width: 200,
|
||||||
},
|
},
|
||||||
columns: {
|
columns: {
|
||||||
id: {
|
id: {
|
||||||
|
@ -46,24 +51,24 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
|
||||||
key: "id",
|
key: "id",
|
||||||
type: "number",
|
type: "number",
|
||||||
column: {
|
column: {
|
||||||
width: 100
|
width: 100,
|
||||||
},
|
},
|
||||||
form: {
|
form: {
|
||||||
show: false
|
show: false,
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
name: {
|
name: {
|
||||||
title: "名称",
|
title: "名称",
|
||||||
type: "text",
|
type: "text",
|
||||||
search: {
|
search: {
|
||||||
show: true
|
show: true,
|
||||||
},
|
},
|
||||||
form: {
|
form: {
|
||||||
rules: [{ required: true, message: "必填项" }]
|
rules: [{ required: true, message: "必填项" }],
|
||||||
},
|
},
|
||||||
column: {
|
column: {
|
||||||
width: 300
|
width: 300,
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
from: {
|
from: {
|
||||||
title: "级别",
|
title: "级别",
|
||||||
|
@ -71,29 +76,29 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
|
||||||
dict: dict({
|
dict: dict({
|
||||||
data: [
|
data: [
|
||||||
{ label: "系统", value: "sys" },
|
{ label: "系统", value: "sys" },
|
||||||
{ label: "用户", value: "user" }
|
{ label: "用户", value: "user" },
|
||||||
]
|
],
|
||||||
}),
|
}),
|
||||||
search: {
|
search: {
|
||||||
show: false
|
show: false,
|
||||||
},
|
},
|
||||||
form: {
|
form: {
|
||||||
show: false
|
show: false,
|
||||||
},
|
},
|
||||||
column: {
|
column: {
|
||||||
width: 100,
|
width: 100,
|
||||||
align: "center",
|
align: "center",
|
||||||
component: {
|
component: {
|
||||||
color: "auto"
|
color: "auto",
|
||||||
},
|
},
|
||||||
order: 10
|
order: 10,
|
||||||
},
|
},
|
||||||
valueBuilder: ({ row, key, value }) => {
|
valueBuilder: ({ row, key, value }) => {
|
||||||
row[key] = row.userId > 0 ? "user" : "sys";
|
row[key] = row.userId > 0 ? "user" : "sys";
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
...commonColumnsDefine
|
...commonColumnsDefine,
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ export const siteInfoApi = {
|
||||||
return await request({
|
return await request({
|
||||||
url: apiPrefix + "/page",
|
url: apiPrefix + "/page",
|
||||||
method: "post",
|
method: "post",
|
||||||
data: query
|
data: query,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ export const siteInfoApi = {
|
||||||
return await request({
|
return await request({
|
||||||
url: apiPrefix + "/add",
|
url: apiPrefix + "/add",
|
||||||
method: "post",
|
method: "post",
|
||||||
data: obj
|
data: obj,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ export const siteInfoApi = {
|
||||||
return await request({
|
return await request({
|
||||||
url: apiPrefix + "/update",
|
url: apiPrefix + "/update",
|
||||||
method: "post",
|
method: "post",
|
||||||
data: obj
|
data: obj,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ export const siteInfoApi = {
|
||||||
return await request({
|
return await request({
|
||||||
url: apiPrefix + "/delete",
|
url: apiPrefix + "/delete",
|
||||||
method: "post",
|
method: "post",
|
||||||
params: { id }
|
params: { id },
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -39,20 +39,20 @@ export const siteInfoApi = {
|
||||||
return await request({
|
return await request({
|
||||||
url: apiPrefix + "/info",
|
url: apiPrefix + "/info",
|
||||||
method: "post",
|
method: "post",
|
||||||
params: { id }
|
params: { id },
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
async DoCheck(id: number) {
|
async DoCheck(id: number) {
|
||||||
return await request({
|
return await request({
|
||||||
url: apiPrefix + "/check",
|
url: apiPrefix + "/check",
|
||||||
method: "post",
|
method: "post",
|
||||||
data: { id }
|
data: { id },
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
async CheckAll() {
|
async CheckAll() {
|
||||||
return await request({
|
return await request({
|
||||||
url: apiPrefix + "/checkAll",
|
url: apiPrefix + "/checkAll",
|
||||||
method: "post"
|
method: "post",
|
||||||
});
|
});
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -4,7 +4,10 @@
|
||||||
<div class="title flex items-center">
|
<div class="title flex items-center">
|
||||||
站点证书监控
|
站点证书监控
|
||||||
<div class="sub flex-1">
|
<div class="sub flex-1">
|
||||||
<div>每天0点,检查网站证书的过期时间,到期前10天时将发出提醒(使用默认通知渠道);</div>
|
<div>
|
||||||
|
每天0点,检查网站证书的过期时间,到期前10天时将发出提醒(使用默认通知渠道);
|
||||||
|
<router-link to="/certd/monitor/setting">站点监控设置</router-link>
|
||||||
|
</div>
|
||||||
<div class="flex items-center">基础版限制1条,专业版以上无限制,当前<vip-button class="ml-5" mode="nav"></vip-button></div>
|
<div class="flex items-center">基础版限制1条,专业版以上无限制,当前<vip-button class="ml-5" mode="nav"></vip-button></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
// @ts-ignore
|
||||||
|
import { request } from "/src/api/service";
|
||||||
|
const apiPrefix = "/monitor/site/setting";
|
||||||
|
export type UserSiteMonitorSetting = {
|
||||||
|
notificationId?: number;
|
||||||
|
};
|
||||||
|
|
||||||
|
export async function SiteMonitorSettingsGet() {
|
||||||
|
const res = await request({
|
||||||
|
url: apiPrefix + "/get",
|
||||||
|
method: "post",
|
||||||
|
});
|
||||||
|
if (!res) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
return res as UserSiteMonitorSetting;
|
||||||
|
}
|
||||||
|
export async function SiteMonitorSettingsSave(data: UserSiteMonitorSetting) {
|
||||||
|
await request({
|
||||||
|
url: apiPrefix + "/save",
|
||||||
|
method: "post",
|
||||||
|
data: data,
|
||||||
|
});
|
||||||
|
}
|
|
@ -0,0 +1,63 @@
|
||||||
|
<template>
|
||||||
|
<fs-page class="page-user-settings page-site-monitor-setting">
|
||||||
|
<template #header>
|
||||||
|
<div class="title">站点监控设置</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="通知渠道" :name="['notificationId']">
|
||||||
|
<div class="flex">
|
||||||
|
<NotificationSelector v-model="formState.notificationId" />
|
||||||
|
</div>
|
||||||
|
<div class="helper">设置通知渠道</div>
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item label=" " :colon="false" :wrapper-col="{ span: 16 }">
|
||||||
|
<loading-button type="primary" html-type="button" :click="doSave">保存</loading-button>
|
||||||
|
</a-form-item>
|
||||||
|
</a-form>
|
||||||
|
</div>
|
||||||
|
</fs-page>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="tsx">
|
||||||
|
import { reactive } from "vue";
|
||||||
|
import * as api from "./api";
|
||||||
|
import { UserSiteMonitorSetting } from "./api";
|
||||||
|
import { notification } from "ant-design-vue";
|
||||||
|
import { merge } from "lodash-es";
|
||||||
|
import { useSettingStore } from "/src/store/settings";
|
||||||
|
import NotificationSelector from "/@/views/certd/notification/notification-selector/index.vue";
|
||||||
|
|
||||||
|
const settingsStore = useSettingStore();
|
||||||
|
defineOptions({
|
||||||
|
name: "UserSecurity",
|
||||||
|
});
|
||||||
|
|
||||||
|
const formState = reactive<Partial<UserSiteMonitorSetting>>({
|
||||||
|
notificationId: 0,
|
||||||
|
});
|
||||||
|
|
||||||
|
async function loadUserSettings() {
|
||||||
|
const data: any = await api.SiteMonitorSettingsGet();
|
||||||
|
merge(formState, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
loadUserSettings();
|
||||||
|
const doSave = async (form: any) => {
|
||||||
|
await api.SiteMonitorSettingsSave({
|
||||||
|
...formState,
|
||||||
|
});
|
||||||
|
notification.success({
|
||||||
|
message: "保存成功",
|
||||||
|
});
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="less">
|
||||||
|
.page-user-settings {
|
||||||
|
.user-settings-form {
|
||||||
|
width: 600px;
|
||||||
|
margin: 20px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
|
@ -1,7 +1,9 @@
|
||||||
import { ALL, Body, Controller, Inject, Post, Provide, Query } from '@midwayjs/core';
|
import { ALL, Body, Controller, Inject, Post, Provide, Query } from "@midwayjs/core";
|
||||||
import { Constants, CrudController } from '@certd/lib-server';
|
import { Constants, CrudController } from "@certd/lib-server";
|
||||||
import { AuthService } from '../../../modules/sys/authority/service/auth-service.js';
|
import { AuthService } from "../../../modules/sys/authority/service/auth-service.js";
|
||||||
import { SiteInfoService } from '../../../modules/monitor/service/site-info-service.js';
|
import { SiteInfoService } from "../../../modules/monitor/service/site-info-service.js";
|
||||||
|
import { UserSiteMonitorSetting } from "../../../modules/mine/service/models.js";
|
||||||
|
import { merge } from "lodash-es";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
|
@ -94,4 +96,23 @@ export class SiteInfoController extends CrudController<SiteInfoService> {
|
||||||
await this.service.checkAllByUsers(userId);
|
await this.service.checkAllByUsers(userId);
|
||||||
return this.ok();
|
return this.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Post("/setting/get", { summary: Constants.per.authOnly })
|
||||||
|
async get() {
|
||||||
|
const userId = this.getUserId();
|
||||||
|
const setting = await this.service.getSetting(userId)
|
||||||
|
return this.ok(setting);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Post("/setting/save", { summary: Constants.per.authOnly })
|
||||||
|
async save(@Body(ALL) bean: any) {
|
||||||
|
const userId = this.getUserId();
|
||||||
|
const setting = new UserSiteMonitorSetting();
|
||||||
|
merge(setting, bean);
|
||||||
|
|
||||||
|
await this.service.saveSetting(userId, setting);
|
||||||
|
return this.ok({});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,3 +19,10 @@ export class UserTwoFactorSetting extends BaseSettings {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
export class UserSiteMonitorSetting extends BaseSettings {
|
||||||
|
static __title__ = "站点监控设置";
|
||||||
|
static __key__ = "user.site.monitor";
|
||||||
|
|
||||||
|
notificationId?:number= 0;
|
||||||
|
}
|
||||||
|
|
|
@ -10,6 +10,8 @@ import { PeerCertificate } from 'tls';
|
||||||
import { NotificationService } from '../../pipeline/service/notification-service.js';
|
import { NotificationService } from '../../pipeline/service/notification-service.js';
|
||||||
import { isComm, isPlus } from '@certd/plus-core';
|
import { isComm, isPlus } from '@certd/plus-core';
|
||||||
import { UserSuiteService } from '@certd/commercial-core';
|
import { UserSuiteService } from '@certd/commercial-core';
|
||||||
|
import { UserSettingsService } from "../../mine/service/user-settings-service.js";
|
||||||
|
import { UserSiteMonitorSetting } from "../../mine/service/models.js";
|
||||||
|
|
||||||
@Provide()
|
@Provide()
|
||||||
@Scope(ScopeEnum.Request, { allowDowngrade: true })
|
@Scope(ScopeEnum.Request, { allowDowngrade: true })
|
||||||
|
@ -26,6 +28,10 @@ export class SiteInfoService extends BaseService<SiteInfoEntity> {
|
||||||
@Inject()
|
@Inject()
|
||||||
userSuiteService: UserSuiteService;
|
userSuiteService: UserSuiteService;
|
||||||
|
|
||||||
|
@Inject()
|
||||||
|
userSettingsService: UserSettingsService;
|
||||||
|
|
||||||
|
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
getRepository() {
|
getRepository() {
|
||||||
return this.repository;
|
return this.repository;
|
||||||
|
@ -236,4 +242,12 @@ export class SiteInfoService extends BaseService<SiteInfoEntity> {
|
||||||
await utils.sleep(200);
|
await utils.sleep(200);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async getSetting(userId: number){
|
||||||
|
return await this.userSettingsService.getSetting<UserSiteMonitorSetting>(userId, UserSiteMonitorSetting);
|
||||||
|
}
|
||||||
|
|
||||||
|
async saveSetting(userId: number, bean: UserSiteMonitorSetting) {
|
||||||
|
await this.userSettingsService.saveSetting(userId, bean);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue