From da406014ad106e1d97b3b20118d2756dd6cecd56 Mon Sep 17 00:00:00 2001 From: xiaojunnuo Date: Sun, 30 Aug 2026 00:43:47 +0800 Subject: [PATCH] chore(plugin): add online plugin author email update function MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 新增修改在线插件作者邮箱的接口与前后端实现 2. 调整插件作者相关类型定义,精简冗余字段并添加email字段 3. 新增邮箱格式校验逻辑 4. 在插件发布页面添加修改作者邮箱的交互功能 --- .../certd-client/src/views/sys/plugin/api.ts | 14 ++-- .../src/views/sys/plugin/use-publish.tsx | 78 ++++++++++++++++++- .../sys/plugin/plugin-controller.ts | 6 ++ .../modules/plugin/service/plugin-service.ts | 19 ++++- 4 files changed, 102 insertions(+), 15 deletions(-) diff --git a/packages/ui/certd-client/src/views/sys/plugin/api.ts b/packages/ui/certd-client/src/views/sys/plugin/api.ts index 1522711df..914d33dd6 100644 --- a/packages/ui/certd-client/src/views/sys/plugin/api.ts +++ b/packages/ui/certd-client/src/views/sys/plugin/api.ts @@ -108,6 +108,7 @@ export type OnlinePluginBean = { desc?: string; latest?: string; status?: string; + email?: string; downloadCount?: number; score?: number; aiCheckStatus?: string; @@ -218,14 +219,8 @@ export async function OnlinePluginPublishInfo(body: { id: number }): Promise<{ export type OnlinePluginAuthorBean = { id?: number; - appId?: number; - appOwnerId?: number; - developerId?: number; name?: string; - displayName?: string; - avatar?: string; - desc?: string; - status?: string; + email?: string; }; export async function OnlinePluginAuthorGet(options?: { showErrorNotify?: boolean }): Promise<{ registered?: boolean; author?: OnlinePluginAuthorBean }> { @@ -236,13 +231,16 @@ export async function OnlinePluginAuthorGet(options?: { showErrorNotify?: boolea }); } -export async function OnlinePluginAuthorAdd(body: { name: string; displayName?: string; avatar?: string; desc?: string }): Promise { +export async function OnlinePluginAuthorAdd(body: { name: string; email: string }): Promise { return await request({ url: apiPrefix + "/online/author/add", method: "post", data: body, }); } +export async function OnlinePluginAuthorUpdate(body: { email: string }): Promise { + return await request({ url: apiPrefix + "/online/author/update", method: "post", data: body }); +} export type PluginConfigBean = { name: string; diff --git a/packages/ui/certd-client/src/views/sys/plugin/use-publish.tsx b/packages/ui/certd-client/src/views/sys/plugin/use-publish.tsx index bdb9ba6ed..6350da3c7 100644 --- a/packages/ui/certd-client/src/views/sys/plugin/use-publish.tsx +++ b/packages/ui/certd-client/src/views/sys/plugin/use-publish.tsx @@ -14,6 +14,9 @@ type PublishManagerResult = | { action: "registered"; } + | { + action: "updated"; + } | { action: "cancel"; }; @@ -61,7 +64,7 @@ export function usePluginPublish() { initialForm: { name: "", nameConfirm: "", - desc: "", + email: "", }, async onSubmit(form: any) { if (form.name?.trim() !== form.nameConfirm?.trim()) { @@ -72,8 +75,7 @@ export function usePluginPublish() { } const author = await api.OnlinePluginAuthorAdd({ name: form.name, - displayName: form.displayName, - desc: form.desc, + email: form.email, }); resolveAuthor(author); }, @@ -111,6 +113,51 @@ export function usePluginPublish() { ], }, }, + email: { + title: "作者邮箱", + type: "text", + form: { + col: { span: 24 }, + rules: [ + { required: true, message: "请输入作者邮箱" }, + { type: "email", message: "请输入有效的作者邮箱" }, + ], + }, + }, + }, + }); + }); + } + + function updatePluginAuthorEmail(author?: api.OnlinePluginAuthorBean) { + return new Promise(async resolve => { + let resolved = false; + const resolveAuthor = (result?: api.OnlinePluginAuthorBean) => { + if (!resolved) { + resolved = true; + resolve(result); + } + }; + await openFormDialog({ + title: "修改作者邮箱", + wrapper: { width: 560, onClosed: () => resolveAuthor() }, + initialForm: { email: author?.email || "" }, + async onSubmit(form: any) { + const result = await api.OnlinePluginAuthorUpdate({ email: form.email }); + resolveAuthor(result); + }, + columns: { + email: { + title: "作者邮箱", + type: "text", + form: { + col: { span: 24 }, + rules: [ + { required: true, message: "请输入作者邮箱" }, + { type: "email", message: "请输入有效的作者邮箱" }, + ], + }, + }, }, }); }); @@ -326,7 +373,26 @@ export function usePluginPublish() { function renderAuthor() { if (info.authorRegistered) { - return author?.displayName || author?.name || "-"; + return ( + + {author?.name || "-"} + { + event.stopPropagation(); + const updatedAuthor = await updatePluginAuthorEmail(author); + if (!updatedAuthor?.id) { + return; + } + resolveResult({ action: "updated" }); + formWrapper?.close?.(); + }} + > + 修改邮箱 + + + ); } return ( @@ -490,6 +556,10 @@ export function usePluginPublish() { await publishLocalPlugin(row, options); return; } + if (action.action === "updated") { + await publishLocalPlugin(row, options); + return; + } if (action.action !== "publish") { return; } diff --git a/packages/ui/certd-server/src/controller/sys/plugin/plugin-controller.ts b/packages/ui/certd-server/src/controller/sys/plugin/plugin-controller.ts index 9b2f878bb..edbbefd5b 100644 --- a/packages/ui/certd-server/src/controller/sys/plugin/plugin-controller.ts +++ b/packages/ui/certd-server/src/controller/sys/plugin/plugin-controller.ts @@ -3,6 +3,7 @@ import { merge } from "lodash-es"; import { CrudController } from "@certd/lib-server"; import { OnlinePluginAuthorAddReq, + OnlinePluginAuthorUpdateReq, OnlinePluginDependenciesReq, OnlinePluginInstallReq, OnlinePluginListReq, @@ -192,6 +193,11 @@ export class PluginController extends CrudController { return this.ok(res); } + @Post("/online/author/update", { description: "sys:settings:edit", summary: "修改在线插件作者邮箱" }) + async onlineAuthorUpdate(@Body(ALL) body: OnlinePluginAuthorUpdateReq) { + return this.ok(await this.service.updateOnlinePluginAuthor(body)); + } + @Post("/online/publish/info", { description: "sys:settings:view", summary: "查询本地插件发布信息" }) async onlinePublishInfo(@Body(ALL) body: OnlinePluginPublishInfoReq) { const res = await this.service.getOnlinePluginPublishInfo(body); diff --git a/packages/ui/certd-server/src/modules/plugin/service/plugin-service.ts b/packages/ui/certd-server/src/modules/plugin/service/plugin-service.ts index e97d42b6f..518fde1f8 100644 --- a/packages/ui/certd-server/src/modules/plugin/service/plugin-service.ts +++ b/packages/ui/certd-server/src/modules/plugin/service/plugin-service.ts @@ -85,6 +85,7 @@ export type OnlinePluginAuthorBean = { avatar?: string; desc?: string; status?: string; + email?: string; }; export type OnlinePluginAuthorGetReply = { @@ -97,7 +98,9 @@ export type OnlinePluginAuthorAddReq = { displayName?: string; avatar?: string; desc?: string; + email: string; }; +export type OnlinePluginAuthorUpdateReq = { email: string }; export type OnlinePluginBean = { id?: number; @@ -1208,6 +1211,9 @@ export class PluginService extends BaseService { } async addOnlinePluginAuthor(req: OnlinePluginAuthorAddReq): Promise { + if (!/^\S+@\S+\.\S+$/.test(req.email?.trim() || "")) { + throw new Error("请输入有效的作者邮箱"); + } await this.getBindUserId("注册插件作者"); await this.plusService.register(); return await this.plusService.request({ @@ -1215,13 +1221,20 @@ export class PluginService extends BaseService { method: "post", data: { name: req.name, - displayName: req.displayName || "", - avatar: req.avatar || "", - desc: req.desc || "", + email: req.email, }, }); } + async updateOnlinePluginAuthor(req: OnlinePluginAuthorUpdateReq): Promise { + if (!/^\S+@\S+\.\S+$/.test(req.email?.trim() || "")) { + throw new Error("请输入有效的作者邮箱"); + } + await this.getBindUserId("修改插件作者"); + await this.plusService.register(); + return await this.plusService.request({ url: "/activation/plugin/author/update", method: "post", data: { email: req.email } }); + } + async getOnlinePluginPublishInfo(req: OnlinePluginPublishInfoReq): Promise { if (!req.id) { throw new Error("插件ID不能为空");