mirror of https://github.com/certd/certd
feat: 账号绑定
parent
e86756e4c6
commit
e0466409d0
|
@ -0,0 +1,9 @@
|
|||
import { request } from "/@/api/service";
|
||||
|
||||
export function PreBindUser(userId: number) {
|
||||
request({
|
||||
url: "/sys/account/preBindUser",
|
||||
method: "post",
|
||||
data: { userId }
|
||||
});
|
||||
}
|
|
@ -9,7 +9,7 @@ import { IframeClient } from "@certd/lib-iframe";
|
|||
import { onMounted, ref } from "vue";
|
||||
import { useUserStore } from "/@/store/modules/user";
|
||||
import { useSettingStore } from "/@/store/modules/settings";
|
||||
|
||||
import * as api from "./api";
|
||||
const iframeRef = ref();
|
||||
|
||||
const userStore = useUserStore();
|
||||
|
@ -22,7 +22,7 @@ type SubjectInfo = {
|
|||
};
|
||||
onMounted(() => {
|
||||
const iframeClient = new IframeClient(iframeRef.value);
|
||||
iframeClient.register("getSubjectInfo", (req) => {
|
||||
iframeClient.register("getSubjectInfo", async (req) => {
|
||||
const subjectInfo: SubjectInfo = {
|
||||
subjectId: settingStore.installInfo.siteId,
|
||||
installTime: settingStore.installInfo.installTime,
|
||||
|
@ -31,11 +31,22 @@ onMounted(() => {
|
|||
};
|
||||
return subjectInfo;
|
||||
});
|
||||
|
||||
iframeClient.register("preBindSubject", async (req) => {
|
||||
const userId = req.data.userId;
|
||||
await api.PreBindUser(userId);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="less">
|
||||
.cd-page-account {
|
||||
.fs-page-content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
.account-iframe {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
import { ALL, Body, Controller, Inject, Post, Provide } from '@midwayjs/core';
|
||||
import { BaseController } from '../../basic/base-controller.js';
|
||||
import { PlusService } from '../basic/service/plus-service.js';
|
||||
import { AppKey } from '@certd/pipeline';
|
||||
import { SysSettingsService } from '../system/service/sys-settings-service.js';
|
||||
import { SysInstallInfo } from '../system/service/models.js';
|
||||
|
||||
export type PreBindUserReq = {
|
||||
userId: number;
|
||||
};
|
||||
|
||||
/**
|
||||
*/
|
||||
@Provide()
|
||||
@Controller('/api/sys/account')
|
||||
export class BasicController extends BaseController {
|
||||
@Inject()
|
||||
plusService: PlusService;
|
||||
|
||||
@Inject()
|
||||
sysSettingsService: SysSettingsService;
|
||||
|
||||
@Post('/preBindUser', { summary: 'sys:settings:edit' })
|
||||
public async preBindUser(@Body(ALL) body: PreBindUserReq) {
|
||||
const installInfo: SysInstallInfo = await this.sysSettingsService.getSetting(SysInstallInfo);
|
||||
// 设置缓存内容
|
||||
await this.plusService.request({
|
||||
url: '/activation/subject/preBind',
|
||||
data: {
|
||||
userId: body.userId,
|
||||
appKey: AppKey,
|
||||
subjectId: installInfo.siteId,
|
||||
},
|
||||
});
|
||||
|
||||
return this.ok({});
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue