From 1c8e25beb34e4deed98d05f02e45860fb30ee1c7 Mon Sep 17 00:00:00 2001 From: xiaojunnuo Date: Wed, 18 Dec 2024 09:07:52 +0800 Subject: [PATCH] chore: suite --- .../ui/certd-client/src/style/common.less | 4 + .../src/views/framework/home/dashboard/api.ts | 6 +- .../src/views/sys/suite/product/crud.tsx | 157 +++++++++++++----- .../sys/suite/product/duration-prices.vue | 48 ++++++ .../src/views/sys/suite/product/index.vue | 9 +- .../sys/suite/product/suite-value-edit.vue | 32 ++++ .../views/sys/suite/product/suite-value.vue | 38 +++++ .../db/migration/v10018__suite.sql | 55 +++--- .../src/controller/basic/app-controller.ts | 1 + 9 files changed, 270 insertions(+), 80 deletions(-) create mode 100644 packages/ui/certd-client/src/views/sys/suite/product/duration-prices.vue create mode 100644 packages/ui/certd-client/src/views/sys/suite/product/suite-value-edit.vue create mode 100644 packages/ui/certd-client/src/views/sys/suite/product/suite-value.vue diff --git a/packages/ui/certd-client/src/style/common.less b/packages/ui/certd-client/src/style/common.less index fc2ede2e..ad1641a5 100644 --- a/packages/ui/certd-client/src/style/common.less +++ b/packages/ui/certd-client/src/style/common.less @@ -280,3 +280,7 @@ h1, h2, h3, h4, h5, h6 { .fs-16{ font-size: 16px; } + +.w-50\%{ + width: 50%; +} \ No newline at end of file diff --git a/packages/ui/certd-client/src/views/framework/home/dashboard/api.ts b/packages/ui/certd-client/src/views/framework/home/dashboard/api.ts index 393a4411..cc5d6f03 100644 --- a/packages/ui/certd-client/src/views/framework/home/dashboard/api.ts +++ b/packages/ui/certd-client/src/views/framework/home/dashboard/api.ts @@ -14,12 +14,12 @@ export async function GetLatestVersion() { return latest; } const res = await request({ - url: "https://registry.npmmirror.com/@certd/pipeline", + url: "/app/latest", method: "GET", - unpack: false + unpack: true }); try { - const latest = res["dist-tags"].latest; + const latest = res; LocalStorage.set("latestVersion", latest, 60 * 60 * 24); return latest; } catch (e: any) { diff --git a/packages/ui/certd-client/src/views/sys/suite/product/crud.tsx b/packages/ui/certd-client/src/views/sys/suite/product/crud.tsx index 5e6aec26..afcc1e6e 100644 --- a/packages/ui/certd-client/src/views/sys/suite/product/crud.tsx +++ b/packages/ui/certd-client/src/views/sys/suite/product/crud.tsx @@ -1,11 +1,12 @@ import * as api from "./api"; import { useI18n } from "vue-i18n"; -import { computed, Ref, ref } from "vue"; +import { Ref, ref } from "vue"; import { useRouter } from "vue-router"; -import { AddReq, compute, CreateCrudOptionsProps, CreateCrudOptionsRet, DelReq, dict, EditReq, UserPageQuery, UserPageRes, utils } from "@fast-crud/fast-crud"; +import { AddReq, CreateCrudOptionsProps, CreateCrudOptionsRet, DelReq, dict, EditReq, UserPageQuery, UserPageRes } from "@fast-crud/fast-crud"; import { useUserStore } from "/@/store/modules/user"; import { useSettingStore } from "/@/store/modules/settings"; -import { Modal } from "ant-design-vue"; +import SuiteValue from "./suite-value.vue"; +import SuiteValueEdit from "./suite-value-edit.vue"; export default function ({ crudExpose, context }: CreateCrudOptionsProps): CreateCrudOptionsRet { const router = useRouter(); @@ -63,6 +64,20 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat minWidth: 200, fixed: "right" }, + form: { + group: { + groups: { + base: { + header: "基础信息", + columns: ["title", "type", "price", "originPrice", "duration", "isBootstrap", "intro"] + }, + content: { + header: "套餐内容", + columns: ["maxDomainCount", "maxPipelineCount", "maxDeployCount", "siteMonitor"] + } + } + } + }, columns: { id: { title: "ID", @@ -78,11 +93,6 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat title: { title: "套餐名称", type: "text", - editForm: { - component: { - disabled: true - } - }, search: { show: true }, @@ -93,77 +103,134 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat type: { title: "类型", type: "dict-select", + editForm: { + component: { + disabled: true + } + }, dict: dict({ data: [ { label: "套餐", value: "suite" }, { label: "加量包", value: "addon" } ] - }) + }), + column: { + width: 100 + } }, maxDomainCount: { title: "域名数量", - type: "number" + type: "number", + form: { + component: { + name: SuiteValueEdit, + vModel: "modelValue", + unit: "个" + } + }, + column: { + width: 100, + component: { + name: SuiteValue + } + } }, maxPipelineCount: { title: "流水线数量", - type: "number" + type: "number", + form: { + component: { + name: SuiteValueEdit, + vModel: "modelValue", + unit: "条" + } + }, + column: { + width: 100, + component: { + name: SuiteValue + } + } }, maxDeployCount: { title: "部署次数", - type: "number" + type: "number", + form: { + component: { + name: SuiteValueEdit, + vModel: "modelValue", + unit: "次" + } + }, + column: { + width: 100, + component: { + name: SuiteValue + } + } + }, + siteMonitor: { + title: "支持证书监控", + type: "dict-switch", + dict: dict({ + data: [ + { label: "是", value: true, color: "success" }, + { label: "否", value: false, color: "error" } + ] + }), + column: { + width: 120 + } + }, + isBootstrap: { + title: "是否初始套餐", + type: "dict-switch", + dict: dict({ + data: [ + { label: "是", value: true, color: "success" }, + { label: "否", value: false, color: "error" } + ] + }), + column: { + width: 120 + } }, price: { title: "单价", - type: "number" + type: "number", + column: { + width: 100 + } }, originPrice: { title: "原价", - type: "number" + type: "number", + column: { + width: 100 + } }, duration: { title: "有效时长", - type: "number" + type: "dict-select", + column: { + width: 100 + } }, intro: { title: "说明", - type: "textarea" + type: "textarea", + column: { + width: 200 + } }, order: { title: "排序", type: "number", form: { show: false - } - }, - disabled: { - title: "禁用/启用", - type: "dict-switch", - dict: dict({ - data: [ - { label: "启用", value: false, color: "success" }, - { label: "禁用", value: true, color: "error" } - ] - }), - form: { - value: false }, column: { - width: 100, - component: { - title: "点击可禁用/启用", - on: { - async click({ value, row }) { - Modal.confirm({ - title: "提示", - content: `确定要${!value ? "禁用" : "启用"}吗?`, - onOk: async () => { - await api.SetDisabled(row.id, !value); - await crudExpose.doRefresh(); - } - }); - } - } - } + width: 100 } }, createTime: { diff --git a/packages/ui/certd-client/src/views/sys/suite/product/duration-prices.vue b/packages/ui/certd-client/src/views/sys/suite/product/duration-prices.vue new file mode 100644 index 00000000..7fe616ec --- /dev/null +++ b/packages/ui/certd-client/src/views/sys/suite/product/duration-prices.vue @@ -0,0 +1,48 @@ + + + diff --git a/packages/ui/certd-client/src/views/sys/suite/product/index.vue b/packages/ui/certd-client/src/views/sys/suite/product/index.vue index 331f1282..3b8a14e9 100644 --- a/packages/ui/certd-client/src/views/sys/suite/product/index.vue +++ b/packages/ui/certd-client/src/views/sys/suite/product/index.vue @@ -2,11 +2,8 @@ @@ -27,7 +24,7 @@ import { message, Modal } from "ant-design-vue"; import { DeleteBatch } from "./api"; defineOptions({ - name: "CnameProvider" + name: "ProductManager" }); const { crudBinding, crudRef, crudExpose, context } = useFs({ createCrudOptions }); diff --git a/packages/ui/certd-client/src/views/sys/suite/product/suite-value-edit.vue b/packages/ui/certd-client/src/views/sys/suite/product/suite-value-edit.vue new file mode 100644 index 00000000..d84ce694 --- /dev/null +++ b/packages/ui/certd-client/src/views/sys/suite/product/suite-value-edit.vue @@ -0,0 +1,32 @@ + + + diff --git a/packages/ui/certd-client/src/views/sys/suite/product/suite-value.vue b/packages/ui/certd-client/src/views/sys/suite/product/suite-value.vue new file mode 100644 index 00000000..ffb5c701 --- /dev/null +++ b/packages/ui/certd-client/src/views/sys/suite/product/suite-value.vue @@ -0,0 +1,38 @@ + + + diff --git a/packages/ui/certd-server/db/migration/v10018__suite.sql b/packages/ui/certd-server/db/migration/v10018__suite.sql index 11604428..b850d032 100644 --- a/packages/ui/certd-server/db/migration/v10018__suite.sql +++ b/packages/ui/certd-server/db/migration/v10018__suite.sql @@ -9,11 +9,12 @@ CREATE TABLE "cd_product" "max_deploy_count" integer, "deploy_count_period" varchar(100), "site_monitor" boolean, - "expires_time" integer, + "duration" integer, "price" integer, "origin_price" integer, "intro" varchar(2048), "order" integer, + "is_bootstrap" boolean, "disabled" boolean NOT NULL DEFAULT (false), "create_time" datetime NOT NULL DEFAULT (CURRENT_TIMESTAMP), "update_time" datetime NOT NULL DEFAULT (CURRENT_TIMESTAMP) @@ -23,34 +24,34 @@ CREATE TABLE "cd_product" CREATE TABLE "cd_payment" ( - "id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, - "type" varchar(100), - "title" varchar(100), - "setting" text, - "order" integer, - "disabled" boolean NOT NULL DEFAULT (false), - "create_time" datetime NOT NULL DEFAULT (CURRENT_TIMESTAMP), - "update_time" datetime NOT NULL DEFAULT (CURRENT_TIMESTAMP) + "id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, + "type" varchar(100), + "title" varchar(100), + "setting" text, + "order" integer, + "disabled" boolean NOT NULL DEFAULT (false), + "create_time" datetime NOT NULL DEFAULT (CURRENT_TIMESTAMP), + "update_time" datetime NOT NULL DEFAULT (CURRENT_TIMESTAMP) ); CREATE TABLE "cd_order" ( - "id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, - "user_id" integer, - "product_id" integer, - "title" varchar(100), - "count" integer, - "price" integer, - "amount" integer, - "remark" varchar(100), - "status" varchar(100), - "pay_id" integer, - "pay_time" integer, - "pay_type" varchar(100), - "pay_no" varchar(100), - "create_time" datetime NOT NULL DEFAULT (CURRENT_TIMESTAMP), - "update_time" datetime NOT NULL DEFAULT (CURRENT_TIMESTAMP) + "id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, + "user_id" integer, + "product_id" integer, + "title" varchar(100), + "count" integer, + "price" integer, + "amount" integer, + "remark" varchar(100), + "status" varchar(100), + "pay_id" integer, + "pay_time" integer, + "pay_type" varchar(100), + "pay_no" varchar(100), + "create_time" datetime NOT NULL DEFAULT (CURRENT_TIMESTAMP), + "update_time" datetime NOT NULL DEFAULT (CURRENT_TIMESTAMP) ); @@ -65,10 +66,12 @@ CREATE TABLE "cd_user_suite" "max_domain_count" integer, "max_pipeline_count" integer, "max_deploy_count" integer, - "used_deploy_count" integer, + "deploy_count_period" varchar(100), "site_monitor" boolean, + "duration" integer, + "used_deploy_count" integer, + "active_time" integer, "expires_time" integer, - "disabled" boolean NOT NULL DEFAULT (false), "create_time" datetime NOT NULL DEFAULT (CURRENT_TIMESTAMP), "update_time" datetime NOT NULL DEFAULT (CURRENT_TIMESTAMP) ); diff --git a/packages/ui/certd-server/src/controller/basic/app-controller.ts b/packages/ui/certd-server/src/controller/basic/app-controller.ts index bed23429..01c1b45c 100644 --- a/packages/ui/certd-server/src/controller/basic/app-controller.ts +++ b/packages/ui/certd-server/src/controller/basic/app-controller.ts @@ -18,6 +18,7 @@ export class AppController extends BaseController { const res = await http.request({ url: 'https://registry.npmmirror.com/@certd/pipeline', method: 'get', + logRes: false, }); try { const latest = res['dist-tags'].latest;