From ecad7f58c137b8459cdc1f72bbbc4fce7f26326a Mon Sep 17 00:00:00 2001 From: xiaojunnuo Date: Thu, 5 Sep 2024 14:33:45 +0800 Subject: [PATCH] chore: --- packages/core/pipeline/src/core/license.ts | 8 ++++++- packages/ui/Dockerfile | 1 + .../ui/certd-client/src/components/index.ts | 6 +++-- .../src/components/vip-button/directive.ts | 23 +++++++++++++++++++ .../src/components/vip-button/install.ts | 6 +++++ .../ui/certd-client/src/store/modules/user.ts | 11 +++++++-- .../ui/certd-client/src/style/common.less | 6 ++++- .../src/views/certd/pipeline/crud.tsx | 4 +++- .../pipeline/component/task-form/index.vue | 7 ++++-- .../views/certd/pipeline/pipeline/index.vue | 12 ++++++---- .../plugin/host-shell-execute/index.ts | 2 +- test/docker/Dockerfile | 3 +++ test/docker/docker-compose.yaml | 14 +++++++++++ 13 files changed, 89 insertions(+), 14 deletions(-) create mode 100644 packages/ui/certd-client/src/components/vip-button/directive.ts create mode 100644 packages/ui/certd-client/src/components/vip-button/install.ts create mode 100644 test/docker/Dockerfile create mode 100644 test/docker/docker-compose.yaml diff --git a/packages/core/pipeline/src/core/license.ts b/packages/core/pipeline/src/core/license.ts index 23cdbc6a..01bef9a3 100644 --- a/packages/core/pipeline/src/core/license.ts +++ b/packages/core/pipeline/src/core/license.ts @@ -1,4 +1,10 @@ import { logger } from "../utils/index.js"; -import { setLogger } from "@certd/plus"; +import { setLogger, isPlus } from "@certd/plus"; setLogger(logger); export * from "@certd/plus"; + +export function checkPlus() { + if (!isPlus()) { + throw new Error("此为专业版功能,请升级到专业版"); + } +} diff --git a/packages/ui/Dockerfile b/packages/ui/Dockerfile index 427d2a36..c1fe92cc 100644 --- a/packages/ui/Dockerfile +++ b/packages/ui/Dockerfile @@ -10,6 +10,7 @@ RUN cd /workspace/certd-server && pnpm install && npm run build-on-docker FROM node:20-alpine +RUN apk add --no-cache openssl WORKDIR /app/ COPY --from=builder /workspace/certd-server/ /app/ RUN chmod +x /app/tools/linux/* diff --git a/packages/ui/certd-client/src/components/index.ts b/packages/ui/certd-client/src/components/index.ts index 07e3fce0..3df02964 100644 --- a/packages/ui/certd-client/src/components/index.ts +++ b/packages/ui/certd-client/src/components/index.ts @@ -3,7 +3,7 @@ import PiAccessSelector from "../views/certd/access/access-selector/index.vue"; import PiDnsProviderSelector from "./dns-provider-selector/index.vue"; import PiOutputSelector from "../views/certd/pipeline/pipeline/component/output-selector/index.vue"; import PiEditable from "./editable.vue"; -import VipButton from "./vip-button/index.vue"; +import vip from "./vip-button/install.js"; import { CheckCircleOutlined, InfoCircleOutlined, UndoOutlined } from "@ant-design/icons-vue"; import CronEditor from "./cron-editor/index.vue"; import { CronLight } from "@vue-js-cron/light"; @@ -15,12 +15,14 @@ export default { app.component("PiEditable", PiEditable); app.component("PiOutputSelector", PiOutputSelector); app.component("PiDnsProviderSelector", PiDnsProviderSelector); - app.component("VipButton", VipButton); + app.component("CronLight", CronLight); app.component("CronEditor", CronEditor); app.component("CheckCircleOutlined", CheckCircleOutlined); app.component("InfoCircleOutlined", InfoCircleOutlined); app.component("UndoOutlined", UndoOutlined); + + app.use(vip); } }; diff --git a/packages/ui/certd-client/src/components/vip-button/directive.ts b/packages/ui/certd-client/src/components/vip-button/directive.ts new file mode 100644 index 00000000..bf6f28de --- /dev/null +++ b/packages/ui/certd-client/src/components/vip-button/directive.ts @@ -0,0 +1,23 @@ +import { message, notification } from "ant-design-vue"; +import { useUserStore } from "/@/store/modules/user"; +export default { + mounted(el: any, binding: any, vnode: any) { + const { value } = binding; + const userStore = useUserStore(); + el.className = el.className + " need-plus"; + if (!userStore.isPlus) { + function checkPlus() { + // 事件处理代码 + notification.warn({ + message: "此为专业版功能,请升级到专业版" + }); + } + el.addEventListener("click", function (event: any) { + checkPlus(); + }); + el.addEventListener("move", function (event: any) { + checkPlus(); + }); + } + } +}; diff --git a/packages/ui/certd-client/src/components/vip-button/install.ts b/packages/ui/certd-client/src/components/vip-button/install.ts new file mode 100644 index 00000000..5dfa93d7 --- /dev/null +++ b/packages/ui/certd-client/src/components/vip-button/install.ts @@ -0,0 +1,6 @@ +import VipButton from "./index.vue"; +import plus from "./directive.js"; +export default function (app: any) { + app.component("VipButton", VipButton); + app.directive("plus", plus); +} diff --git a/packages/ui/certd-client/src/store/modules/user.ts b/packages/ui/certd-client/src/store/modules/user.ts index 06c1ad9b..019b78d0 100644 --- a/packages/ui/certd-client/src/store/modules/user.ts +++ b/packages/ui/certd-client/src/store/modules/user.ts @@ -7,7 +7,7 @@ import * as UserApi from "/src/api/modules/api.user"; import { RegisterReq } from "/src/api/modules/api.user"; // @ts-ignore import { LoginReq, UserInfoRes } from "/@/api/modules/api.user"; -import { Modal, notification } from "ant-design-vue"; +import { message, Modal, notification } from "ant-design-vue"; import { useI18n } from "vue-i18n"; import { mitter } from "/src/utils/util.mitt"; @@ -67,7 +67,14 @@ export const useUserStore = defineStore({ LocalStorage.remove(TOKEN_KEY); LocalStorage.remove(USER_INFO_KEY); }, - + checkPlus() { + if (!this.isPlus) { + notification.warn({ + message: "此为专业版功能,请先升级到专业版" + }); + throw new Error("此为专业版功能,请升级到专业版"); + } + }, async register(user: RegisterReq) { await UserApi.register(user); notification.success({ diff --git a/packages/ui/certd-client/src/style/common.less b/packages/ui/certd-client/src/style/common.less index 68712ee4..52db4981 100644 --- a/packages/ui/certd-client/src/style/common.less +++ b/packages/ui/certd-client/src/style/common.less @@ -161,4 +161,8 @@ h1, h2, h3, h4, h5, h6 { align-items: center; justify-content: center; } -} \ No newline at end of file +} + +.need-plus { + color: #c5913f !important; +} diff --git a/packages/ui/certd-client/src/views/certd/pipeline/crud.tsx b/packages/ui/certd-client/src/views/certd/pipeline/crud.tsx index bfd1df90..eaf59228 100644 --- a/packages/ui/certd-client/src/views/certd/pipeline/crud.tsx +++ b/packages/ui/certd-client/src/views/certd/pipeline/crud.tsx @@ -191,6 +191,7 @@ export default function ({ crudExpose, context: { certdFormRef } }: CreateCrudOp }, copy: { click: async (context) => { + userStore.checkPlus(); const { ui } = useUi(); // @ts-ignore let row = context[ui.tableColumn.row]; @@ -200,7 +201,8 @@ export default function ({ crudExpose, context: { certdFormRef } }: CreateCrudOp row: row, index: context.index }); - } + }, + class: "need-plus" }, config: { order: 1, diff --git a/packages/ui/certd-client/src/views/certd/pipeline/pipeline/component/task-form/index.vue b/packages/ui/certd-client/src/views/certd/pipeline/pipeline/component/task-form/index.vue index c2e0b45c..352cebe4 100644 --- a/packages/ui/certd-client/src/views/certd/pipeline/pipeline/component/task-form/index.vue +++ b/packages/ui/certd-client/src/views/certd/pipeline/pipeline/component/task-form/index.vue @@ -43,7 +43,7 @@ 添加步骤 - + @@ -83,6 +83,7 @@ import PiStepForm from "../step-form/index.vue"; import { Modal } from "ant-design-vue"; import { CopyOutlined } from "@ant-design/icons-vue"; import VDraggable from "vuedraggable"; +import { useUserStore } from "/@/store/modules/user"; export default { name: "PiTaskForm", components: { CopyOutlined, PiStepForm, VDraggable }, @@ -94,6 +95,7 @@ export default { }, emits: ["update"], setup(props: any, ctx: any) { + const userStore = useUserStore(); function useStep() { const stepFormRef: Ref = ref(null); const currentStepIndex = ref(0); @@ -248,6 +250,7 @@ export default { }; } return { + userStore, labelCol: { span: 6 }, wrapperCol: { span: 16 }, ...useTaskForm(), diff --git a/packages/ui/certd-client/src/views/certd/pipeline/pipeline/index.vue b/packages/ui/certd-client/src/views/certd/pipeline/pipeline/index.vue index a76a3fbb..072396f8 100644 --- a/packages/ui/certd-client/src/views/certd/pipeline/pipeline/index.vue +++ b/packages/ui/certd-client/src/views/certd/pipeline/pipeline/index.vue @@ -20,7 +20,7 @@
- +