diff --git a/packages/plugins/plugin-cert/src/plugin/cert-plugin/base.ts b/packages/plugins/plugin-cert/src/plugin/cert-plugin/base.ts index 46bf9efb..da387e0e 100644 --- a/packages/plugins/plugin-cert/src/plugin/cert-plugin/base.ts +++ b/packages/plugins/plugin-cert/src/plugin/cert-plugin/base.ts @@ -145,7 +145,8 @@ export abstract class CertApplyBasePlugin extends CertApplyBaseConvertPlugin { throw new Error("过期时间不能为空"); } // 检查有效期 - const leftDays = dayjs(expires).diff(dayjs(), "day"); + const leftDays = Math.floor((expires - dayjs().valueOf()) / (1000 * 60 * 60 * 24)); + this.logger.info(`证书剩余天数:${leftDays}`); return { isWillExpire: leftDays <= maxDays, leftDays, diff --git a/packages/plugins/plugin-cert/test/cert-plugin.test.mjs b/packages/plugins/plugin-cert/test/cert-plugin.test.mjs new file mode 100644 index 00000000..7af120ee --- /dev/null +++ b/packages/plugins/plugin-cert/test/cert-plugin.test.mjs @@ -0,0 +1,27 @@ +import { expect } from "chai"; +import { CertApplyPlugin } from "../dist/index.js"; +import dayjs from "dayjs"; +import { logger } from "@certd/basic"; + +describe("test/cert-plugin.ts", () => { + const certApplyPlugin = new CertApplyPlugin(); + certApplyPlugin.logger = logger; + it("should throw error when expires is null or undefined", () => { + expect(() => { + // @ts-ignore + certApplyPlugin.isWillExpire(undefined); + }).throw("过期时间不能为空"); + + expect(() => { + // @ts-ignore + certApplyPlugin.isWillExpire(null); + }).throw("过期时间不能为空"); + }); + + it("isWillExpire", () => { + const now = dayjs().add(36, "day") - 10000; + const res = certApplyPlugin.isWillExpire(now.valueOf(), 35); + console.log(res); + expect(res.isWillExpire).eq(true); + }); +}); diff --git a/packages/ui/certd-client/src/style/antdv4.less b/packages/ui/certd-client/src/style/antdv4.less index 40c79d3b..227c9096 100644 --- a/packages/ui/certd-client/src/style/antdv4.less +++ b/packages/ui/certd-client/src/style/antdv4.less @@ -65,4 +65,10 @@ footer{ .ant-select-multiple .ant-select-selection-item-remove{ display: flex; align-items: center; +} + + +.ant-progress.ant-progress-show-info .ant-progress-outer { + margin-inline-end: calc(-3em - 8px); + padding-inline-end: calc(3em + 8px); } \ No newline at end of file