Files
certd/packages/ui/certd-client/src/views/sys/account/index.vue
T

83 lines
2.1 KiB
Vue
Raw Normal View History

2024-09-22 02:06:34 +08:00
<template>
<fs-page class="cd-page-account">
2024-09-22 23:19:10 +08:00
<iframe ref="iframeRef" class="account-iframe" src="http://localhost:1017/#/?appKey=z4nXOeTeSnnpUpnmsV"> </iframe>
2024-09-22 02:06:34 +08:00
</fs-page>
</template>
<script setup lang="tsx">
import { IframeClient } from "@certd/lib-iframe";
import { onMounted, ref } from "vue";
import { useUserStore } from "/@/store/modules/user";
import { useSettingStore } from "/@/store/modules/settings";
2024-09-23 01:52:42 +08:00
import * as api from "./api";
2024-09-23 14:04:33 +08:00
import { notification } from "ant-design-vue";
2024-09-22 02:06:34 +08:00
const iframeRef = ref();
const userStore = useUserStore();
const settingStore = useSettingStore();
type SubjectInfo = {
subjectId: string;
installTime?: number;
vipType?: string;
expiresTime?: number;
};
onMounted(() => {
2024-09-23 14:04:33 +08:00
const iframeClient = new IframeClient(iframeRef.value, (e: any) => {
notification.error({
message: " error",
description: e.message
});
});
2024-09-23 01:52:42 +08:00
iframeClient.register("getSubjectInfo", async (req) => {
2024-09-22 02:06:34 +08:00
const subjectInfo: SubjectInfo = {
subjectId: settingStore.installInfo.siteId,
installTime: settingStore.installInfo.installTime,
vipType: userStore.plusInfo.vipType || "free",
expiresTime: userStore.plusInfo.expireTime
};
return subjectInfo;
});
2024-09-23 01:52:42 +08:00
2024-09-23 13:23:49 +08:00
let preBindUserId = null;
iframeClient.register("preBindUser", async (req) => {
2024-09-23 01:52:42 +08:00
const userId = req.data.userId;
2024-09-23 13:23:49 +08:00
preBindUserId = userId;
2024-09-23 01:52:42 +08:00
await api.PreBindUser(userId);
});
2024-09-23 13:23:49 +08:00
iframeClient.register("onBoundUser", async (req) => {
await api.BindUser(preBindUserId);
});
iframeClient.register("unbindUser", async (req) => {
const userId = req.data.userId;
await api.UnbindUser(userId);
});
2024-09-23 14:04:33 +08:00
iframeClient.register("updateLicense", async (req) => {
await api.UpdateLicense(req.data);
await userStore.reInit();
notification.success({
message: "更新成功",
description: "专业版已激活"
});
});
2024-09-22 02:06:34 +08:00
});
</script>
<style lang="less">
.cd-page-account {
2024-09-23 01:52:42 +08:00
.fs-page-content {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
2024-09-22 02:06:34 +08:00
.account-iframe {
width: 100%;
height: 100%;
border: none;
}
}
</style>