Merge remote-tracking branch 'origin/v2-dev' into v2-dev

pull/189/head
xiaojunnuo 2024-09-23 13:34:36 +08:00
commit e85b4da2e3
12 changed files with 107 additions and 57 deletions

View File

@ -33,10 +33,11 @@ export class IframeClient {
window.addEventListener('message', async (event: MessageEvent<IframeMessageData<any>>) => { window.addEventListener('message', async (event: MessageEvent<IframeMessageData<any>>) => {
const data = event.data; const data = event.data;
if (data.action) { if (data.action) {
console.log('收到消息', data); console.log(`收到消息[isSub:${this.isInFrame()}]`, data);
try { try {
const handler = this.handlers[data.action]; const handler = this.handlers[data.action];
if (handler) { if (handler) {
debugger;
const res = await handler(data); const res = await handler(data);
if (data.id && data.action !== 'reply') { if (data.id && data.action !== 'reply') {
await this.send('reply', res, data.id); await this.send('reply', res, data.id);
@ -45,6 +46,7 @@ export class IframeClient {
throw new Error(`action:${data.action} 未注册处理器`); throw new Error(`action:${data.action} 未注册处理器`);
} }
} catch (e: any) { } catch (e: any) {
console.error(e);
await this.send('reply', {}, data.id, 500, e.message); await this.send('reply', {}, data.id, 500, e.message);
} }
} }
@ -77,7 +79,7 @@ export class IframeClient {
}; };
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const onReply = async (reply: IframeMessageData<R>) => { const onReply = (reply: IframeMessageData<R>) => {
if (reply.errorCode && reply.errorCode > 0) { if (reply.errorCode && reply.errorCode > 0) {
reject(new IframeException(reply)); reject(new IframeException(reply));
return; return;
@ -89,6 +91,7 @@ export class IframeClient {
onReply, onReply,
}; };
try { try {
console.log(`send message[isSub:${this.isInFrame()}]:`, reqMessageData);
if (!this.iframe) { if (!this.iframe) {
if (!window.parent) { if (!window.parent) {
reject('当前页面不在 iframe 中'); reject('当前页面不在 iframe 中');

View File

@ -1,55 +1,55 @@
import { request } from "/src/api/service"; import { request } from "/src/api/service";
const apiPrefix = "/pi/access"; const apiPrefix = "/pi/access";
export function GetList(query: any) { export async function GetList(query: any) {
return request({ return await request({
url: apiPrefix + "/page", url: apiPrefix + "/page",
method: "post", method: "post",
data: query data: query
}); });
} }
export function AddObj(obj: any) { export async function AddObj(obj: any) {
return request({ return await request({
url: apiPrefix + "/add", url: apiPrefix + "/add",
method: "post", method: "post",
data: obj data: obj
}); });
} }
export function UpdateObj(obj: any) { export async function UpdateObj(obj: any) {
return request({ return await request({
url: apiPrefix + "/update", url: apiPrefix + "/update",
method: "post", method: "post",
data: obj data: obj
}); });
} }
export function DelObj(id: number) { export async function DelObj(id: number) {
return request({ return await request({
url: apiPrefix + "/delete", url: apiPrefix + "/delete",
method: "post", method: "post",
params: { id } params: { id }
}); });
} }
export function GetObj(id: number) { export async function GetObj(id: number) {
return request({ return await request({
url: apiPrefix + "/info", url: apiPrefix + "/info",
method: "post", method: "post",
params: { id } params: { id }
}); });
} }
export function GetProviderDefine(type: string) { export async function GetProviderDefine(type: string) {
return request({ return await request({
url: apiPrefix + "/define", url: apiPrefix + "/define",
method: "post", method: "post",
params: { type } params: { type }
}); });
} }
export function GetProviderDefineByAccessType(type: string) { export async function GetProviderDefineByAccessType(type: string) {
return request({ return await request({
url: apiPrefix + "/defineByAccessType", url: apiPrefix + "/defineByAccessType",
method: "post", method: "post",
params: { type } params: { type }

View File

@ -3,7 +3,7 @@ import { request } from "/src/api/service";
const apiPrefix = "/pi/history"; const apiPrefix = "/pi/history";
export function GetList(query: any) { export function GetList(query: any) {
return request({ return await request({
url: apiPrefix + "/page", url: apiPrefix + "/page",
method: "post", method: "post",
data: query data: query
@ -11,7 +11,7 @@ export function GetList(query: any) {
} }
export function AddObj(obj: any) { export function AddObj(obj: any) {
return request({ return await request({
url: apiPrefix + "/add", url: apiPrefix + "/add",
method: "post", method: "post",
data: obj data: obj
@ -19,7 +19,7 @@ export function AddObj(obj: any) {
} }
export function UpdateObj(obj: any) { export function UpdateObj(obj: any) {
return request({ return await request({
url: apiPrefix + "/update", url: apiPrefix + "/update",
method: "post", method: "post",
data: obj data: obj
@ -27,7 +27,7 @@ export function UpdateObj(obj: any) {
} }
export function DelObj(id: any) { export function DelObj(id: any) {
return request({ return await request({
url: apiPrefix + "/delete", url: apiPrefix + "/delete",
method: "post", method: "post",
params: { id } params: { id }
@ -35,7 +35,7 @@ export function DelObj(id: any) {
} }
export function GetObj(id: any) { export function GetObj(id: any) {
return request({ return await request({
url: apiPrefix + "/info", url: apiPrefix + "/info",
method: "post", method: "post",
params: { id } params: { id }
@ -43,7 +43,7 @@ export function GetObj(id: any) {
} }
export function GetDetail(id: any) { export function GetDetail(id: any) {
return request({ return await request({
url: apiPrefix + "/detail", url: apiPrefix + "/detail",
method: "post", method: "post",
params: { id } params: { id }
@ -51,7 +51,7 @@ export function GetDetail(id: any) {
} }
export function DeleteBatch(ids: any[]) { export function DeleteBatch(ids: any[]) {
return request({ return await request({
url: apiPrefix + "/deleteByIds", url: apiPrefix + "/deleteByIds",
method: "post", method: "post",
data: { ids } data: { ids }

View File

@ -1,14 +1,14 @@
import { request } from "/src/api/service"; import { request } from "/src/api/service";
export async function getMineInfo() { export async function getMineInfo() {
return request({ return await request({
url: "/mine/info", url: "/mine/info",
method: "POST" method: "POST"
}); });
} }
export async function changePassword(form: any) { export async function changePassword(form: any) {
return request({ return await request({
url: "/mine/changePassword", url: "/mine/changePassword",
method: "POST", method: "POST",
data: form data: form

View File

@ -4,7 +4,7 @@ const apiPrefix = "/pi/pipeline";
const historyApiPrefix = "/pi/history"; const historyApiPrefix = "/pi/history";
export function GetList(query: any) { export function GetList(query: any) {
return request({ return await request({
url: apiPrefix + "/page", url: apiPrefix + "/page",
method: "post", method: "post",
data: query data: query
@ -12,7 +12,7 @@ export function GetList(query: any) {
} }
export function AddObj(obj: any) { export function AddObj(obj: any) {
return request({ return await request({
url: apiPrefix + "/add", url: apiPrefix + "/add",
method: "post", method: "post",
data: obj data: obj
@ -20,7 +20,7 @@ export function AddObj(obj: any) {
} }
export function UpdateObj(obj: any) { export function UpdateObj(obj: any) {
return request({ return await request({
url: apiPrefix + "/update", url: apiPrefix + "/update",
method: "post", method: "post",
data: obj data: obj
@ -28,7 +28,7 @@ export function UpdateObj(obj: any) {
} }
export function DelObj(id: any) { export function DelObj(id: any) {
return request({ return await request({
url: apiPrefix + "/delete", url: apiPrefix + "/delete",
method: "post", method: "post",
params: { id } params: { id }
@ -36,7 +36,7 @@ export function DelObj(id: any) {
} }
export function GetObj(id: any) { export function GetObj(id: any) {
return request({ return await request({
url: apiPrefix + "/info", url: apiPrefix + "/info",
method: "post", method: "post",
params: { id } params: { id }
@ -44,7 +44,7 @@ export function GetObj(id: any) {
} }
export function GetDetail(id: any) { export function GetDetail(id: any) {
return request({ return await request({
url: apiPrefix + "/detail", url: apiPrefix + "/detail",
method: "post", method: "post",
params: { id } params: { id }
@ -52,7 +52,7 @@ export function GetDetail(id: any) {
} }
export function Save(pipelineEntity: any) { export function Save(pipelineEntity: any) {
return request({ return await request({
url: apiPrefix + "/save", url: apiPrefix + "/save",
method: "post", method: "post",
data: pipelineEntity data: pipelineEntity
@ -60,7 +60,7 @@ export function Save(pipelineEntity: any) {
} }
export function Trigger(id: any, stepId?: string) { export function Trigger(id: any, stepId?: string) {
return request({ return await request({
url: apiPrefix + "/trigger", url: apiPrefix + "/trigger",
method: "post", method: "post",
params: { id, stepId } params: { id, stepId }
@ -68,7 +68,7 @@ export function Trigger(id: any, stepId?: string) {
} }
export function Cancel(historyId: any) { export function Cancel(historyId: any) {
return request({ return await request({
url: apiPrefix + "/cancel", url: apiPrefix + "/cancel",
method: "post", method: "post",
params: { historyId } params: { historyId }
@ -76,7 +76,7 @@ export function Cancel(historyId: any) {
} }
export async function GetFiles(pipelineId: number) { export async function GetFiles(pipelineId: number) {
return request({ return await request({
url: historyApiPrefix + "/files", url: historyApiPrefix + "/files",
method: "post", method: "post",
params: { pipelineId } params: { pipelineId }

View File

@ -1,9 +1,25 @@
import { request } from "/@/api/service"; import { request } from "/@/api/service";
export function PreBindUser(userId: number) { export async function PreBindUser(userId: number) {
request({ await request({
url: "/sys/account/preBindUser", url: "/sys/account/preBindUser",
method: "post", method: "post",
data: { userId } data: { userId }
}); });
} }
export async function BindUser(userId: number) {
await request({
url: "/sys/account/bindUser",
method: "post",
data: { userId }
});
}
export async function UnbindUser(userId: number) {
await request({
url: "/sys/account/unbindUser",
method: "post",
data: { userId }
});
}

View File

@ -32,10 +32,21 @@ onMounted(() => {
return subjectInfo; return subjectInfo;
}); });
iframeClient.register("preBindSubject", async (req) => { let preBindUserId = null;
iframeClient.register("preBindUser", async (req) => {
const userId = req.data.userId; const userId = req.data.userId;
preBindUserId = userId;
await api.PreBindUser(userId); await api.PreBindUser(userId);
}); });
iframeClient.register("onBoundUser", async (req) => {
await api.BindUser(preBindUserId);
});
iframeClient.register("unbindUser", async (req) => {
const userId = req.data.userId;
await api.UnbindUser(userId);
});
}); });
</script> </script>

View File

@ -1,7 +1,7 @@
import { request } from "/src/api/service"; import { request } from "/src/api/service";
const apiPrefix = "/sys/authority/permission"; const apiPrefix = "/sys/authority/permission";
export async function GetList(query: any) { export async function GetList(query: any) {
return request({ return await request({
url: apiPrefix + "/page", url: apiPrefix + "/page",
method: "post", method: "post",
data: query data: query
@ -9,14 +9,14 @@ export async function GetList(query: any) {
} }
export async function GetTree() { export async function GetTree() {
return request({ return await request({
url: apiPrefix + "/tree", url: apiPrefix + "/tree",
method: "post" method: "post"
}); });
} }
export async function AddObj(obj: any) { export async function AddObj(obj: any) {
return request({ return await request({
url: apiPrefix + "/add", url: apiPrefix + "/add",
method: "post", method: "post",
data: obj data: obj
@ -24,7 +24,7 @@ export async function AddObj(obj: any) {
} }
export async function UpdateObj(obj: any) { export async function UpdateObj(obj: any) {
return request({ return await request({
url: apiPrefix + "/update", url: apiPrefix + "/update",
method: "post", method: "post",
data: obj data: obj
@ -32,7 +32,7 @@ export async function UpdateObj(obj: any) {
} }
export async function DelObj(id: any) { export async function DelObj(id: any) {
return request({ return await request({
url: apiPrefix + "/delete", url: apiPrefix + "/delete",
method: "post", method: "post",
params: { id } params: { id }
@ -40,7 +40,7 @@ export async function DelObj(id: any) {
} }
export async function GetObj(id: any) { export async function GetObj(id: any) {
return request({ return await request({
url: apiPrefix + "/info", url: apiPrefix + "/info",
method: "post", method: "post",
params: { id } params: { id }

View File

@ -1,7 +1,7 @@
import { request } from "/src/api/service"; import { request } from "/src/api/service";
const apiPrefix = "/sys/authority/role"; const apiPrefix = "/sys/authority/role";
export async function GetList(query: any) { export async function GetList(query: any) {
return request({ return await request({
url: apiPrefix + "/page", url: apiPrefix + "/page",
method: "post", method: "post",
data: query data: query
@ -9,7 +9,7 @@ export async function GetList(query: any) {
} }
export async function AddObj(obj: any) { export async function AddObj(obj: any) {
return request({ return await request({
url: apiPrefix + "/add", url: apiPrefix + "/add",
method: "post", method: "post",
data: obj data: obj
@ -17,7 +17,7 @@ export async function AddObj(obj: any) {
} }
export async function UpdateObj(obj: any) { export async function UpdateObj(obj: any) {
return request({ return await request({
url: apiPrefix + "/update", url: apiPrefix + "/update",
method: "post", method: "post",
data: obj data: obj
@ -25,7 +25,7 @@ export async function UpdateObj(obj: any) {
} }
export async function DelObj(id: any) { export async function DelObj(id: any) {
return request({ return await request({
url: apiPrefix + "/delete", url: apiPrefix + "/delete",
method: "post", method: "post",
params: { id } params: { id }
@ -33,7 +33,7 @@ export async function DelObj(id: any) {
} }
export async function GetObj(id: any) { export async function GetObj(id: any) {
return request({ return await request({
url: apiPrefix + "/info", url: apiPrefix + "/info",
method: "post", method: "post",
params: { id } params: { id }
@ -47,7 +47,7 @@ export async function GetObj(id: any) {
* @constructor * @constructor
*/ */
export function getPermissionIds(roleId: any) { export function getPermissionIds(roleId: any) {
return request({ return await request({
url: apiPrefix + "/getPermissionIds", url: apiPrefix + "/getPermissionIds",
method: "post", method: "post",
params: { id: roleId } params: { id: roleId }
@ -62,7 +62,7 @@ export function getPermissionIds(roleId: any) {
* @constructor * @constructor
*/ */
export function DoAuthz(roleId: any, permissionIds: any) { export function DoAuthz(roleId: any, permissionIds: any) {
return request({ return await request({
url: apiPrefix + "/authz", url: apiPrefix + "/authz",
method: "post", method: "post",
data: { roleId, permissionIds } data: { roleId, permissionIds }

View File

@ -1,7 +1,7 @@
import { request } from "/src/api/service"; import { request } from "/src/api/service";
const apiPrefix = "/sys/authority/user"; const apiPrefix = "/sys/authority/user";
export async function GetList(query: any) { export async function GetList(query: any) {
return request({ return await request({
url: apiPrefix + "/page", url: apiPrefix + "/page",
method: "post", method: "post",
data: query data: query
@ -9,7 +9,7 @@ export async function GetList(query: any) {
} }
export async function AddObj(obj: any) { export async function AddObj(obj: any) {
return request({ return await request({
url: apiPrefix + "/add", url: apiPrefix + "/add",
method: "post", method: "post",
data: obj data: obj
@ -17,7 +17,7 @@ export async function AddObj(obj: any) {
} }
export async function UpdateObj(obj: any) { export async function UpdateObj(obj: any) {
return request({ return await request({
url: apiPrefix + "/update", url: apiPrefix + "/update",
method: "post", method: "post",
data: obj data: obj
@ -25,7 +25,7 @@ export async function UpdateObj(obj: any) {
} }
export async function DelObj(id: any) { export async function DelObj(id: any) {
return request({ return await request({
url: apiPrefix + "/delete", url: apiPrefix + "/delete",
method: "post", method: "post",
params: { id } params: { id }
@ -33,7 +33,7 @@ export async function DelObj(id: any) {
} }
export async function GetObj(id: any) { export async function GetObj(id: any) {
return request({ return await request({
url: apiPrefix + "/info", url: apiPrefix + "/info",
method: "post", method: "post",
params: { id } params: { id }

View File

@ -8,7 +8,9 @@ import { SysInstallInfo } from '../system/service/models.js';
export type PreBindUserReq = { export type PreBindUserReq = {
userId: number; userId: number;
}; };
export type BindUserReq = {
userId: number;
};
/** /**
*/ */
@Provide() @Provide()
@ -35,4 +37,20 @@ export class BasicController extends BaseController {
return this.ok({}); return this.ok({});
} }
@Post('/bindUser', { summary: 'sys:settings:edit' })
public async bindUser(@Body(ALL) body: BindUserReq) {
const installInfo: SysInstallInfo = await this.sysSettingsService.getSetting(SysInstallInfo);
installInfo.bindUserId = body.userId;
await this.sysSettingsService.saveSetting(installInfo);
return this.ok({});
}
@Post('/unbindUser', { summary: 'sys:settings:edit' })
public async unbindUser() {
const installInfo: SysInstallInfo = await this.sysSettingsService.getSetting(SysInstallInfo);
installInfo.bindUserId = null;
await this.sysSettingsService.saveSetting(installInfo);
return this.ok({});
}
} }

View File

@ -30,6 +30,8 @@ export class SysInstallInfo extends BaseSettings {
static __access__ = 'private'; static __access__ = 'private';
installTime: number; installTime: number;
siteId?: string; siteId?: string;
bindUserId?: number;
bindUrl?: string;
} }
export class SysLicenseInfo extends BaseSettings { export class SysLicenseInfo extends BaseSettings {