2024-09-22 02:06:34 +08:00
|
|
|
|
<template>
|
|
|
|
|
|
<fs-page class="cd-page-account">
|
2024-12-09 00:12:15 +08:00
|
|
|
|
<!-- <template #header>-->
|
|
|
|
|
|
<!-- <div class="title">-->
|
|
|
|
|
|
<!-- 站点绑定-->
|
|
|
|
|
|
<!-- <span class="sub">管理你安装过的Certd站点,可以通过转移功能避免丢失VIP,强烈建议绑定</span>-->
|
|
|
|
|
|
<!-- </div>-->
|
|
|
|
|
|
<!-- </template>-->
|
2024-09-24 02:42:08 +08:00
|
|
|
|
|
|
|
|
|
|
<iframe ref="iframeRef" class="account-iframe" :src="iframeSrcRef"> </iframe>
|
2024-09-22 02:06:34 +08:00
|
|
|
|
</fs-page>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script setup lang="tsx">
|
|
|
|
|
|
import { IframeClient } from "@certd/lib-iframe";
|
2024-09-24 02:42:08 +08:00
|
|
|
|
import { computed, onMounted, ref } from "vue";
|
2025-04-12 23:59:03 +08:00
|
|
|
|
import { useUserStore } from "/@/store/user";
|
|
|
|
|
|
import { useSettingStore } from "/@/store/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-10-07 03:21:16 +08:00
|
|
|
|
|
|
|
|
|
|
defineOptions({
|
2025-04-08 23:36:50 +08:00
|
|
|
|
name: "AccountBind",
|
2024-10-07 03:21:16 +08:00
|
|
|
|
});
|
2024-09-22 02:06:34 +08:00
|
|
|
|
const iframeRef = ref();
|
|
|
|
|
|
|
|
|
|
|
|
const userStore = useUserStore();
|
|
|
|
|
|
const settingStore = useSettingStore();
|
2024-09-24 02:42:08 +08:00
|
|
|
|
|
|
|
|
|
|
const iframeSrcRef = computed(() => {
|
|
|
|
|
|
if (!settingStore.installInfo.accountServerBaseUrl) {
|
2025-11-09 04:14:33 +08:00
|
|
|
|
return "#/app/certd/home";
|
2024-09-24 02:42:08 +08:00
|
|
|
|
}
|
2025-11-11 11:05:34 +08:00
|
|
|
|
const timestamp = Date.now();
|
|
|
|
|
|
return `${settingStore.installInfo.accountServerBaseUrl}/#/app/certd/home?t=${timestamp}`;
|
2024-09-24 02:42:08 +08:00
|
|
|
|
});
|
|
|
|
|
|
|
2024-09-22 02:06:34 +08:00
|
|
|
|
type SubjectInfo = {
|
|
|
|
|
|
subjectId: string;
|
2024-11-08 16:53:45 +08:00
|
|
|
|
installAt?: number;
|
2024-09-22 02:06:34 +08:00
|
|
|
|
vipType?: string;
|
2024-11-08 16:53:45 +08:00
|
|
|
|
expiresAt?: number;
|
2024-09-22 02:06:34 +08:00
|
|
|
|
};
|
|
|
|
|
|
onMounted(() => {
|
2024-09-23 14:04:33 +08:00
|
|
|
|
const iframeClient = new IframeClient(iframeRef.value, (e: any) => {
|
|
|
|
|
|
notification.error({
|
|
|
|
|
|
message: " error",
|
2025-04-08 23:36:50 +08:00
|
|
|
|
description: e.message,
|
2024-09-23 14:04:33 +08:00
|
|
|
|
});
|
|
|
|
|
|
});
|
2024-11-06 01:17:36 +08:00
|
|
|
|
iframeClient.register("getSubjectInfo", async (req: any) => {
|
2024-09-22 02:06:34 +08:00
|
|
|
|
const subjectInfo: SubjectInfo = {
|
|
|
|
|
|
subjectId: settingStore.installInfo.siteId,
|
2024-11-08 16:53:45 +08:00
|
|
|
|
installAt: settingStore.installInfo.installTime,
|
2024-10-05 01:46:25 +08:00
|
|
|
|
vipType: settingStore.plusInfo.vipType || "free",
|
2025-04-08 23:36:50 +08:00
|
|
|
|
expiresAt: settingStore.plusInfo.expireTime,
|
2024-09-22 02:06:34 +08:00
|
|
|
|
};
|
|
|
|
|
|
return subjectInfo;
|
|
|
|
|
|
});
|
2024-09-23 01:52:42 +08:00
|
|
|
|
|
2024-11-06 01:17:36 +08:00
|
|
|
|
let preBindUserId: any = null;
|
2025-04-08 23:36:50 +08:00
|
|
|
|
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
|
|
|
|
|
2025-04-08 23:36:50 +08:00
|
|
|
|
iframeClient.register("onBoundUser", async req => {
|
2024-09-23 13:23:49 +08:00
|
|
|
|
await api.BindUser(preBindUserId);
|
|
|
|
|
|
});
|
|
|
|
|
|
|
2025-04-08 23:36:50 +08:00
|
|
|
|
iframeClient.register("unbindUser", async req => {
|
2024-09-23 13:23:49 +08:00
|
|
|
|
const userId = req.data.userId;
|
|
|
|
|
|
await api.UnbindUser(userId);
|
|
|
|
|
|
});
|
2024-09-23 14:04:33 +08:00
|
|
|
|
|
2025-04-08 23:36:50 +08:00
|
|
|
|
iframeClient.register("updateLicense", async req => {
|
2024-09-23 14:04:33 +08:00
|
|
|
|
await api.UpdateLicense(req.data);
|
2024-11-06 01:17:36 +08:00
|
|
|
|
await settingStore.init();
|
2025-04-19 11:48:23 +08:00
|
|
|
|
await settingStore.doBindUrl();
|
2024-09-23 14:04:33 +08:00
|
|
|
|
notification.success({
|
|
|
|
|
|
message: "更新成功",
|
2025-04-08 23:36:50 +08:00
|
|
|
|
description: "专业版/商业版已激活",
|
2024-09-23 14:04:33 +08:00
|
|
|
|
});
|
|
|
|
|
|
});
|
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>
|