From 361e8fe7ae5877e23fd5de31bc919bedd09c57f5 Mon Sep 17 00:00:00 2001 From: xiaojunnuo Date: Mon, 23 Sep 2024 14:04:33 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=94=AF=E6=8C=81vip=E8=BD=AC=E7=A7=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../libs/lib-iframe/src/lib/iframe.client.ts | 18 ++++++++++--- .../src/layout/layout-outside.vue | 5 ++-- .../src/views/certd/history/api.ts | 14 +++++----- .../src/views/certd/pipeline/api.ts | 18 ++++++------- .../src/views/framework/login/index.vue | 3 ++- .../certd-client/src/views/sys/account/api.ts | 8 ++++++ .../src/views/sys/account/index.vue | 17 +++++++++++- .../src/views/sys/authority/role/api.ts | 4 +-- .../ui/certd-server/.env.development.yaml | 10 +++---- .../src/modules/account/account-controller.ts | 10 ++++++- .../src/modules/basic/service/plus-service.ts | 25 +++++++++++++++-- .../system/controller/plus-controller.ts | 27 +++++-------------- 12 files changed, 104 insertions(+), 55 deletions(-) diff --git a/packages/libs/lib-iframe/src/lib/iframe.client.ts b/packages/libs/lib-iframe/src/lib/iframe.client.ts index 85556c92..527f8dcd 100644 --- a/packages/libs/lib-iframe/src/lib/iframe.client.ts +++ b/packages/libs/lib-iframe/src/lib/iframe.client.ts @@ -26,10 +26,12 @@ export class IframeClient { requestQueue: Record = {}; //当前客户端是否是父级页面 iframe?: HTMLIFrameElement; + onError?: any; handlers: Record) => Promise> = {}; - constructor(iframe?: HTMLIFrameElement) { + constructor(iframe?: HTMLIFrameElement, onError?: (e: any) => void) { this.iframe = iframe; + this.onError = onError; window.addEventListener('message', async (event: MessageEvent>) => { const data = event.data; if (data.action) { @@ -37,13 +39,12 @@ export class IframeClient { try { const handler = this.handlers[data.action]; if (handler) { - debugger; const res = await handler(data); if (data.id && data.action !== 'reply') { await this.send('reply', res, data.id); } } else { - throw new Error(`action:${data.action} 未注册处理器`); + throw new Error(`action:${data.action} 未注册处理器,可能版本过低`); } } catch (e: any) { console.error(e); @@ -69,6 +70,17 @@ export class IframeClient { } async send(action: string, data?: T, replyId?: string, errorCode?: number, message?: string): Promise> { + try { + return await this.doSend(action, data, replyId, errorCode, message); + } catch (e) { + if (this.onError) { + this.onError(e); + } + throw e; + } + } + + async doSend(action: string, data?: T, replyId?: string, errorCode?: number, message?: string): Promise> { const reqMessageData: IframeMessageData = { id: nanoid(), action, diff --git a/packages/ui/certd-client/src/layout/layout-outside.vue b/packages/ui/certd-client/src/layout/layout-outside.vue index 52492168..34ef6f24 100644 --- a/packages/ui/certd-client/src/layout/layout-outside.vue +++ b/packages/ui/certd-client/src/layout/layout-outside.vue @@ -136,14 +136,15 @@ export default { } .main { - min-width: 260px; + min-width: 300px; + width: 94%; } .footer { // position: absolute; width: 100%; bottom: 0; - margin: 48px 0 24px; + margin: 24px 0 24px; text-align: center; .links { diff --git a/packages/ui/certd-client/src/views/certd/history/api.ts b/packages/ui/certd-client/src/views/certd/history/api.ts index 46807654..eae98960 100644 --- a/packages/ui/certd-client/src/views/certd/history/api.ts +++ b/packages/ui/certd-client/src/views/certd/history/api.ts @@ -2,7 +2,7 @@ import { request } from "/src/api/service"; const apiPrefix = "/pi/history"; -export function GetList(query: any) { +export async function GetList(query: any) { return await request({ url: apiPrefix + "/page", method: "post", @@ -10,7 +10,7 @@ export function GetList(query: any) { }); } -export function AddObj(obj: any) { +export async function AddObj(obj: any) { return await request({ url: apiPrefix + "/add", method: "post", @@ -18,7 +18,7 @@ export function AddObj(obj: any) { }); } -export function UpdateObj(obj: any) { +export async function UpdateObj(obj: any) { return await request({ url: apiPrefix + "/update", method: "post", @@ -26,7 +26,7 @@ export function UpdateObj(obj: any) { }); } -export function DelObj(id: any) { +export async function DelObj(id: any) { return await request({ url: apiPrefix + "/delete", method: "post", @@ -34,7 +34,7 @@ export function DelObj(id: any) { }); } -export function GetObj(id: any) { +export async function GetObj(id: any) { return await request({ url: apiPrefix + "/info", method: "post", @@ -42,7 +42,7 @@ export function GetObj(id: any) { }); } -export function GetDetail(id: any) { +export async function GetDetail(id: any) { return await request({ url: apiPrefix + "/detail", method: "post", @@ -50,7 +50,7 @@ export function GetDetail(id: any) { }); } -export function DeleteBatch(ids: any[]) { +export async function DeleteBatch(ids: any[]) { return await request({ url: apiPrefix + "/deleteByIds", method: "post", diff --git a/packages/ui/certd-client/src/views/certd/pipeline/api.ts b/packages/ui/certd-client/src/views/certd/pipeline/api.ts index ee467dd3..22abab61 100644 --- a/packages/ui/certd-client/src/views/certd/pipeline/api.ts +++ b/packages/ui/certd-client/src/views/certd/pipeline/api.ts @@ -3,7 +3,7 @@ import { request } from "/src/api/service"; const apiPrefix = "/pi/pipeline"; const historyApiPrefix = "/pi/history"; -export function GetList(query: any) { +export async function GetList(query: any) { return await request({ url: apiPrefix + "/page", method: "post", @@ -11,7 +11,7 @@ export function GetList(query: any) { }); } -export function AddObj(obj: any) { +export async function AddObj(obj: any) { return await request({ url: apiPrefix + "/add", method: "post", @@ -19,7 +19,7 @@ export function AddObj(obj: any) { }); } -export function UpdateObj(obj: any) { +export async function UpdateObj(obj: any) { return await request({ url: apiPrefix + "/update", method: "post", @@ -27,7 +27,7 @@ export function UpdateObj(obj: any) { }); } -export function DelObj(id: any) { +export async function DelObj(id: any) { return await request({ url: apiPrefix + "/delete", method: "post", @@ -35,7 +35,7 @@ export function DelObj(id: any) { }); } -export function GetObj(id: any) { +export async function GetObj(id: any) { return await request({ url: apiPrefix + "/info", method: "post", @@ -43,7 +43,7 @@ export function GetObj(id: any) { }); } -export function GetDetail(id: any) { +export async function GetDetail(id: any) { return await request({ url: apiPrefix + "/detail", method: "post", @@ -51,7 +51,7 @@ export function GetDetail(id: any) { }); } -export function Save(pipelineEntity: any) { +export async function Save(pipelineEntity: any) { return await request({ url: apiPrefix + "/save", method: "post", @@ -59,7 +59,7 @@ export function Save(pipelineEntity: any) { }); } -export function Trigger(id: any, stepId?: string) { +export async function Trigger(id: any, stepId?: string) { return await request({ url: apiPrefix + "/trigger", method: "post", @@ -67,7 +67,7 @@ export function Trigger(id: any, stepId?: string) { }); } -export function Cancel(historyId: any) { +export async function Cancel(historyId: any) { return await request({ url: apiPrefix + "/cancel", method: "post", diff --git a/packages/ui/certd-client/src/views/framework/login/index.vue b/packages/ui/certd-client/src/views/framework/login/index.vue index 959a0e62..b9b1f5ca 100644 --- a/packages/ui/certd-client/src/views/framework/login/index.vue +++ b/packages/ui/certd-client/src/views/framework/login/index.vue @@ -208,7 +208,8 @@ export default defineComponent({