From ffa4de6911a3cee5fe53009ef5f9b428af422363 Mon Sep 17 00:00:00 2001 From: xiaojunnuo Date: Tue, 24 Dec 2024 01:12:12 +0800 Subject: [PATCH] chore: --- .../src/components/vip-button/index.vue | 20 ++++++++--- .../src/plugin/validator/index.ts | 2 +- .../src/router/source/modules/sys.ts | 2 +- .../src/views/certd/monitor/site/crud.tsx | 9 +++-- .../src/views/certd/suite/order-modal.vue | 6 ++-- .../src/views/sys/settings/index.vue | 5 +-- .../src/views/sys/settings/tabs/payment.vue | 6 +++- .../src/views/sys/suite/product/crud.tsx | 4 ++- .../src/views/sys/suite/setting/index.vue | 3 +- .../src/views/sys/suite/user-suite/api.ts | 10 +++++- .../src/views/sys/suite/user-suite/crud.tsx | 35 ++++++++++++------- .../monitor/site-info-controller.ts | 8 +++-- .../sys/authority/user-controller.ts | 19 ++++++++++ .../monitor/service/site-info-service.ts | 11 +++++- 14 files changed, 107 insertions(+), 33 deletions(-) diff --git a/packages/ui/certd-client/src/components/vip-button/index.vue b/packages/ui/certd-client/src/components/vip-button/index.vue index 75720d26..90a9d432 100644 --- a/packages/ui/certd-client/src/components/vip-button/index.vue +++ b/packages/ui/certd-client/src/components/vip-button/index.vue @@ -231,6 +231,7 @@ function openUpgrade() { title: "基础版", desc: "社区免费版", type: "free", + icon: "lucide:package-open", privilege: ["证书申请无限制", "域名数量无限制", "证书流水线数量无限制", "常用的主机、云平台、cdn等部署插件", "邮件、webhook通知方式"] }, plus: { @@ -244,6 +245,7 @@ function openUpgrade() { openStarModal(); } }, + icon: "stash:thumb-up", price: 29.9, get() { return ( @@ -259,6 +261,7 @@ function openUpgrade() { title: "商业版", desc: "商业授权,可对外运营", type: "comm", + icon: "vaadin:handshake", privilege: ["拥有专业版所有特权", "允许商用,可修改logo、标题", "数据统计", "插件管理", "多用户无限制", "支持用户支付"], price: 399, get() { @@ -293,8 +296,8 @@ function openUpgrade() { slots.push(
-

- {item.title} +

+ {item.title} {item.trial && ( @@ -303,8 +306,11 @@ function openUpgrade() { )}

-
{item.desc}
-
    +
    + + {item.desc} +
    +
      {item.privilege.map((p: string) => (
    • @@ -430,9 +436,13 @@ onMounted(() => { color: green; } .vip-type-vs { + .privilege { + .fs-icon { + color: green; + } + } .fs-icon { margin-right: 5px; - color: green; } } } diff --git a/packages/ui/certd-client/src/plugin/validator/index.ts b/packages/ui/certd-client/src/plugin/validator/index.ts index 964c60ec..105b9a10 100644 --- a/packages/ui/certd-client/src/plugin/validator/index.ts +++ b/packages/ui/certd-client/src/plugin/validator/index.ts @@ -1,7 +1,7 @@ import Validator from "async-validator"; // 自定义验证器函数 export function isDomain(rule: any, value: any) { - if (value == null) { + if (value == null || value == "") { return true; } let domains: string[] = value; diff --git a/packages/ui/certd-client/src/router/source/modules/sys.ts b/packages/ui/certd-client/src/router/source/modules/sys.ts index 010ae6ad..b633464f 100644 --- a/packages/ui/certd-client/src/router/source/modules/sys.ts +++ b/packages/ui/certd-client/src/router/source/modules/sys.ts @@ -216,7 +216,7 @@ export const sysResources = [ title: "用户套餐", name: "UserSuites", path: "/sys/suite/user-suite", - component: "/certd/suite/user-suite/index.vue", + component: "/sys/suite/user-suite/index.vue", meta: { show: () => { const settingStore = useSettingStore(); diff --git a/packages/ui/certd-client/src/views/certd/monitor/site/crud.tsx b/packages/ui/certd-client/src/views/certd/monitor/site/crud.tsx index a3df8c23..c29aec9d 100644 --- a/packages/ui/certd-client/src/views/certd/monitor/site/crud.tsx +++ b/packages/ui/certd-client/src/views/certd/monitor/site/crud.tsx @@ -59,7 +59,9 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat order: 0, type: "link", text: null, - title: "立即检查", + tooltip: { + title: "立即检查" + }, icon: "ion:play-sharp", click: async ({ row }) => { await api.DoCheck(row.id); @@ -107,7 +109,10 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat }, type: "text", form: { - rules: [{ required: true, message: "请输入域名" }] + rules: [ + { required: true, message: "请输入域名" }, + { type: "domains", message: "请输入正确的域名" } + ] }, column: { width: 160, diff --git a/packages/ui/certd-client/src/views/certd/suite/order-modal.vue b/packages/ui/certd-client/src/views/certd/suite/order-modal.vue index 2106fa61..0f32758b 100644 --- a/packages/ui/certd-client/src/views/certd/suite/order-modal.vue +++ b/packages/ui/certd-client/src/views/certd/suite/order-modal.vue @@ -76,7 +76,7 @@ async function orderCreate() { payType: formRef.value.payType }); - function onPaid() { + async function onPaid() { openRef.value = false; router.push({ path: "/" @@ -114,7 +114,7 @@ async function orderCreate() { } function doAlipay(paymentReq: any) { - window.open(paymentReq.api); + window.open(paymentReq.url); } async function doWxpay(qrcodeText: string, onPaid: () => Promise) { @@ -157,7 +157,7 @@ function doYizhifu(paymentReq: any) { * 签名类型 sign_type 是 String MD5 默认为MD5 */ const form = document.createElement("form"); - form.action = paymentReq.api; + form.action = paymentReq.url; form.method = "post"; form.target = "_blank"; // form.style.display = "none"; diff --git a/packages/ui/certd-client/src/views/sys/settings/index.vue b/packages/ui/certd-client/src/views/sys/settings/index.vue index e91e7644..fdd3d723 100644 --- a/packages/ui/certd-client/src/views/sys/settings/index.vue +++ b/packages/ui/certd-client/src/views/sys/settings/index.vue @@ -11,7 +11,7 @@ - + @@ -25,10 +25,11 @@ import SettingRegister from "/@/views/sys/settings/tabs/register.vue"; import SettingPayment from "/@/views/sys/settings/tabs/payment.vue"; import { useRoute, useRouter } from "vue-router"; import { ref } from "vue"; +import { useSettingStore } from "/@/store/modules/settings"; defineOptions({ name: "SysSettings" }); - +const settingsStore = useSettingStore(); const activeKey = ref(""); const route = useRoute(); const router = useRouter(); diff --git a/packages/ui/certd-client/src/views/sys/settings/tabs/payment.vue b/packages/ui/certd-client/src/views/sys/settings/tabs/payment.vue index a091317d..c645de02 100644 --- a/packages/ui/certd-client/src/views/sys/settings/tabs/payment.vue +++ b/packages/ui/certd-client/src/views/sys/settings/tabs/payment.vue @@ -68,7 +68,11 @@ const formState = reactive< alipay: PaymentItem; wxpay: PaymentItem; }> ->({}); +>({ + yizhifu: { enabled: false }, + alipay: { enabled: false }, + wxpay: { enabled: false } +}); async function loadSettings() { const data: any = await api.SettingGet(); 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 f372c165..64a2a09f 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 @@ -106,7 +106,9 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat ] }), form: { - rules: [{ required: true, message: "此项必填" }] + value: "suite", + rules: [{ required: true, message: "此项必填" }], + helper: "目前没区别,重复购买可叠加数量" }, column: { width: 80, diff --git a/packages/ui/certd-client/src/views/sys/suite/setting/index.vue b/packages/ui/certd-client/src/views/sys/suite/setting/index.vue index c076046c..98dc318c 100644 --- a/packages/ui/certd-client/src/views/sys/suite/setting/index.vue +++ b/packages/ui/certd-client/src/views/sys/suite/setting/index.vue @@ -3,7 +3,7 @@ @@ -31,6 +31,7 @@ 保存 +
      需要 开启至少一种支付方式
diff --git a/packages/ui/certd-client/src/views/sys/suite/user-suite/api.ts b/packages/ui/certd-client/src/views/sys/suite/user-suite/api.ts index ee4c77ce..682a3f0e 100644 --- a/packages/ui/certd-client/src/views/sys/suite/user-suite/api.ts +++ b/packages/ui/certd-client/src/views/sys/suite/user-suite/api.ts @@ -1,7 +1,7 @@ import { request } from "/src/api/service"; export function createApi() { - const apiPrefix = "/sys/suite/userSuites"; + const apiPrefix = "/sys/suite/user-suite"; return { async GetList(query: any) { return await request({ @@ -47,6 +47,14 @@ export function createApi() { url: apiPrefix + "/all", method: "post" }); + }, + + async GetSimpleUserByIds(ids: number[]) { + return await request({ + url: "/sys/authority/user/getSimpleUserByIds", + method: "post", + data: { ids } + }); } }; } diff --git a/packages/ui/certd-client/src/views/sys/suite/user-suite/crud.tsx b/packages/ui/certd-client/src/views/sys/suite/user-suite/crud.tsx index 1d4e1951..5041bf7c 100644 --- a/packages/ui/certd-client/src/views/sys/suite/user-suite/crud.tsx +++ b/packages/ui/certd-client/src/views/sys/suite/user-suite/crud.tsx @@ -55,26 +55,26 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat }, actionbar: { buttons: { - add: { show: false }, - buy: { - text: "购买", - type: "primary", - click() { - router.push({ - path: "/certd/suite/buy" - }); - } - } + add: { show: false } + // buy: { + // text: "购买", + // type: "primary", + // click() { + // router.push({ + // path: "/certd/suite/buy" + // }); + // } + // } } }, rowHandle: { width: 200, fixed: "right", buttons: { - view: { show: false }, + view: { show: true }, copy: { show: false }, edit: { show: false }, - remove: { show: false } + remove: { show: true } // continue:{ // text:"续期", // type:"link", @@ -115,6 +115,17 @@ export default function ({ crudExpose, context }: CreateCrudOptionsProps): Creat width: 200 } }, + userId: { + title: "用户", + type: "table-select", + dict: dict({ + async getNodesByValues(ids: number[]) { + return await api.GetSimpleUserByIds(ids); + }, + value: "id", + label: "nickName" + }) + }, productType: { title: "类型", type: "dict-select", diff --git a/packages/ui/certd-server/src/controller/monitor/site-info-controller.ts b/packages/ui/certd-server/src/controller/monitor/site-info-controller.ts index 03efbc58..53f5a861 100644 --- a/packages/ui/certd-server/src/controller/monitor/site-info-controller.ts +++ b/packages/ui/certd-server/src/controller/monitor/site-info-controller.ts @@ -39,14 +39,18 @@ export class SiteInfoController extends CrudController { @Post('/add', { summary: Constants.per.authOnly }) async add(@Body(ALL) bean: any) { bean.userId = this.getUserId(); - return await super.add(bean); + const res = await this.service.add(bean); + await this.service.check(res.id); + return this.ok(res); } @Post('/update', { summary: Constants.per.authOnly }) async update(@Body(ALL) bean) { await this.service.checkUserId(bean.id, this.getUserId()); delete bean.userId; - return await super.update(bean); + await this.service.update(bean); + await this.service.check(bean.id); + return this.ok(); } @Post('/info', { summary: Constants.per.authOnly }) async info(@Query('id') id: number) { diff --git a/packages/ui/certd-server/src/controller/sys/authority/user-controller.ts b/packages/ui/certd-server/src/controller/sys/authority/user-controller.ts index 048922d5..e31e915c 100644 --- a/packages/ui/certd-server/src/controller/sys/authority/user-controller.ts +++ b/packages/ui/certd-server/src/controller/sys/authority/user-controller.ts @@ -4,6 +4,7 @@ import { CrudController } from '@certd/lib-server'; import { RoleService } from '../../../modules/sys/authority/service/role-service.js'; import { PermissionService } from '../../../modules/sys/authority/service/permission-service.js'; import { Constants } from '@certd/lib-server'; +import { In } from 'typeorm'; /** * 系统用户 @@ -23,6 +24,24 @@ export class UserController extends CrudController { return this.service; } + @Post('/getSimpleUserByIds', { summary: 'sys:auth:user:add' }) + async getSimpleUserByIds(@Body('ids') ids: number[]) { + const users = await this.service.find({ + select: { + id: true, + username: true, + nickName: true, + mobile: true, + phoneCode: true, + }, + where: { + id: In(ids), + }, + }); + + return this.ok(users); + } + @Post('/page', { summary: 'sys:auth:user:view' }) async page( @Body(ALL) diff --git a/packages/ui/certd-server/src/modules/monitor/service/site-info-service.ts b/packages/ui/certd-server/src/modules/monitor/service/site-info-service.ts index 4308eaa0..7ac256a3 100644 --- a/packages/ui/certd-server/src/modules/monitor/service/site-info-service.ts +++ b/packages/ui/certd-server/src/modules/monitor/service/site-info-service.ts @@ -51,7 +51,16 @@ export class SiteInfoService extends BaseService { } } - return await this.repository.save(data); + data.disabled = false; + return await super.add(data); + } + + async update(data: any) { + if (!data.id) { + throw new Error('id is required'); + } + delete data.userId; + await super.update(data); } async getUserMonitorCount(userId: number) {