mirror of https://github.com/certd/certd
chore: 优化站点ip检查
parent
41f4617e66
commit
45814ceb49
|
@ -16,6 +16,7 @@
|
||||||
"pub": "npm publish"
|
"pub": "npm publish"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@alicloud/credentials": "^2.4.3",
|
||||||
"@alicloud/openapi-client": "^0.4.14",
|
"@alicloud/openapi-client": "^0.4.14",
|
||||||
"@alicloud/pop-core": "^1.7.10",
|
"@alicloud/pop-core": "^1.7.10",
|
||||||
"@alicloud/tea-util": "^1.4.10",
|
"@alicloud/tea-util": "^1.4.10",
|
||||||
|
|
|
@ -32,9 +32,15 @@ export class AliyunClientV2 {
|
||||||
return this.client;
|
return this.client;
|
||||||
}
|
}
|
||||||
const $OpenApi = await import("@alicloud/openapi-client");
|
const $OpenApi = await import("@alicloud/openapi-client");
|
||||||
const config = new $OpenApi.Config({
|
const Credential = await import("@alicloud/credentials");
|
||||||
|
//@ts-ignore
|
||||||
|
const credential = new Credential.default.default({
|
||||||
accessKeyId: this.access.accessKeyId,
|
accessKeyId: this.access.accessKeyId,
|
||||||
accessKeySecret: this.access.accessKeySecret,
|
accessKeySecret: this.access.accessKeySecret,
|
||||||
|
type: "access_key",
|
||||||
|
});
|
||||||
|
const config = new $OpenApi.Config({
|
||||||
|
credential,
|
||||||
});
|
});
|
||||||
// Endpoint 请参考 https://api.aliyun.com/product/FC
|
// Endpoint 请参考 https://api.aliyun.com/product/FC
|
||||||
// config.endpoint = `esa.${this.regionId}.aliyuncs.com`;
|
// config.endpoint = `esa.${this.regionId}.aliyuncs.com`;
|
||||||
|
|
|
@ -56,6 +56,16 @@ export const siteInfoApi = {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
async DisabledChange(id: number, disabled: boolean) {
|
||||||
|
return await request({
|
||||||
|
url: apiPrefix + "/disabledChange",
|
||||||
|
method: "post",
|
||||||
|
data: {
|
||||||
|
id,
|
||||||
|
disabled,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
},
|
||||||
async IpCheckChange(id: number, ipCheck: boolean) {
|
async IpCheckChange(id: number, ipCheck: boolean) {
|
||||||
return await request({
|
return await request({
|
||||||
url: apiPrefix + "/ipCheckChange",
|
url: apiPrefix + "/ipCheckChange",
|
||||||
|
|
|
@ -360,6 +360,16 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
|
||||||
width: 100,
|
width: 100,
|
||||||
sorter: true,
|
sorter: true,
|
||||||
align: "center",
|
align: "center",
|
||||||
|
component: {
|
||||||
|
name: "fs-dict-switch",
|
||||||
|
vModel: "checked",
|
||||||
|
on: {
|
||||||
|
async change({ row, $event }) {
|
||||||
|
await api.DisabledChange(row.id, $event);
|
||||||
|
await crudExpose.doRefresh();
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
ipCheck: {
|
ipCheck: {
|
||||||
|
@ -367,8 +377,8 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
|
||||||
type: "dict-switch",
|
type: "dict-switch",
|
||||||
dict: dict({
|
dict: dict({
|
||||||
data: [
|
data: [
|
||||||
{ label: "启用", value: false, color: "green" },
|
{ label: "启用", value: true, color: "green" },
|
||||||
{ label: "禁用", value: true, color: "gray" },
|
{ label: "禁用", value: false, color: "gray" },
|
||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
form: {
|
form: {
|
||||||
|
@ -380,7 +390,7 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat
|
||||||
width: 100,
|
width: 100,
|
||||||
conditionalRender: false,
|
conditionalRender: false,
|
||||||
component: {
|
component: {
|
||||||
name: "a-switch",
|
name: "fs-dict-switch",
|
||||||
vModel: "checked",
|
vModel: "checked",
|
||||||
on: {
|
on: {
|
||||||
change({ row, $event }) {
|
change({ row, $event }) {
|
||||||
|
|
|
@ -9,7 +9,7 @@ import { onActivated, onMounted, ref, Ref } from "vue";
|
||||||
import { useFs } from "@fast-crud/fast-crud";
|
import { useFs } from "@fast-crud/fast-crud";
|
||||||
import createCrudOptions from "./crud";
|
import createCrudOptions from "./crud";
|
||||||
import { siteIpApi } from "./api";
|
import { siteIpApi } from "./api";
|
||||||
import { Modal, notification } from "ant-design-vue";
|
|
||||||
defineOptions({
|
defineOptions({
|
||||||
name: "SiteIpCertMonitor",
|
name: "SiteIpCertMonitor",
|
||||||
});
|
});
|
||||||
|
|
|
@ -62,7 +62,10 @@ export class SiteInfoController extends CrudController<SiteInfoService> {
|
||||||
async add(@Body(ALL) bean: any) {
|
async add(@Body(ALL) bean: any) {
|
||||||
bean.userId = this.getUserId();
|
bean.userId = this.getUserId();
|
||||||
const res = await this.service.add(bean);
|
const res = await this.service.add(bean);
|
||||||
this.service.check(res.id, true, 0);
|
const entity = await this.service.info(res.id);
|
||||||
|
if (entity.disabled) {
|
||||||
|
this.service.check(entity.id, true, 0);
|
||||||
|
}
|
||||||
return this.ok(res);
|
return this.ok(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,7 +74,10 @@ export class SiteInfoController extends CrudController<SiteInfoService> {
|
||||||
await this.service.checkUserId(bean.id, this.getUserId());
|
await this.service.checkUserId(bean.id, this.getUserId());
|
||||||
delete bean.userId;
|
delete bean.userId;
|
||||||
await this.service.update(bean);
|
await this.service.update(bean);
|
||||||
this.service.check(bean.id, true, 0);
|
const entity = await this.service.info(bean.id);
|
||||||
|
if (entity.disabled) {
|
||||||
|
this.service.check(entity.id, true, 0);
|
||||||
|
}
|
||||||
return this.ok();
|
return this.ok();
|
||||||
}
|
}
|
||||||
@Post('/info', { summary: Constants.per.authOnly })
|
@Post('/info', { summary: Constants.per.authOnly })
|
||||||
|
@ -110,6 +116,16 @@ export class SiteInfoController extends CrudController<SiteInfoService> {
|
||||||
return this.ok();
|
return this.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Post('/disabledChange', { summary: Constants.per.authOnly })
|
||||||
|
async disabledChange(@Body(ALL) bean: any) {
|
||||||
|
const userId = this.getUserId();
|
||||||
|
await this.service.checkUserId(bean.id, userId)
|
||||||
|
await this.service.disabledChange({
|
||||||
|
id: bean.id,
|
||||||
|
disabled: bean.disabled
|
||||||
|
});
|
||||||
|
return this.ok();
|
||||||
|
}
|
||||||
|
|
||||||
@Post("/setting/get", { summary: Constants.per.authOnly })
|
@Post("/setting/get", { summary: Constants.per.authOnly })
|
||||||
async get() {
|
async get() {
|
||||||
|
|
|
@ -45,8 +45,10 @@ export class SiteInfoController extends CrudController<SiteIpService> {
|
||||||
bean.from = "manual"
|
bean.from = "manual"
|
||||||
const res = await this.service.add(bean);
|
const res = await this.service.add(bean);
|
||||||
const siteEntity = await this.siteInfoService.info(bean.siteId);
|
const siteEntity = await this.siteInfoService.info(bean.siteId);
|
||||||
const {domain, httpsPort} = siteEntity;
|
if(!siteEntity.disabled){
|
||||||
this.service.check(res.id,domain, httpsPort);
|
const {domain, httpsPort} = siteEntity;
|
||||||
|
this.service.check(res.id,domain, httpsPort);
|
||||||
|
}
|
||||||
return this.ok(res);
|
return this.ok(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,8 +58,10 @@ export class SiteInfoController extends CrudController<SiteIpService> {
|
||||||
delete bean.userId;
|
delete bean.userId;
|
||||||
await this.service.update(bean);
|
await this.service.update(bean);
|
||||||
const siteEntity = await this.siteInfoService.info(bean.siteId);
|
const siteEntity = await this.siteInfoService.info(bean.siteId);
|
||||||
const {domain, httpsPort} = siteEntity;
|
if(!siteEntity.disabled){
|
||||||
this.service.check(bean.id,domain, httpsPort);
|
const {domain, httpsPort} = siteEntity;
|
||||||
|
this.service.check(siteEntity.id,domain, httpsPort);
|
||||||
|
}
|
||||||
return this.ok();
|
return this.ok();
|
||||||
}
|
}
|
||||||
@Post('/info', { summary: Constants.per.authOnly })
|
@Post('/info', { summary: Constants.per.authOnly })
|
||||||
|
|
|
@ -311,4 +311,14 @@ export class SiteInfoService extends BaseService<SiteInfoEntity> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async disabledChange(req: { disabled: any; id: any }) {
|
||||||
|
await this.update({
|
||||||
|
id: req.id,
|
||||||
|
disabled: req.disabled,
|
||||||
|
});
|
||||||
|
if(!req.disabled){
|
||||||
|
const site = await this.info(req.id);
|
||||||
|
await this.doCheck(site)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -682,6 +682,9 @@ importers:
|
||||||
|
|
||||||
packages/plugins/plugin-lib:
|
packages/plugins/plugin-lib:
|
||||||
dependencies:
|
dependencies:
|
||||||
|
'@alicloud/credentials':
|
||||||
|
specifier: ^2.4.3
|
||||||
|
version: 2.4.3
|
||||||
'@alicloud/openapi-client':
|
'@alicloud/openapi-client':
|
||||||
specifier: ^0.4.14
|
specifier: ^0.4.14
|
||||||
version: 0.4.14
|
version: 0.4.14
|
||||||
|
|
Loading…
Reference in New Issue