perf: 专业版试用,无需绑定账号

pull/265/head
xiaojunnuo 2024-11-17 01:06:27 +08:00
parent c6488b58f5
commit c7c4318c11
5 changed files with 42 additions and 5 deletions

View File

@ -108,6 +108,23 @@ export class PlusService {
return res.accessToken;
}
async getVipTrial() {
const plusRequestService = await this.getPlusRequestService();
await this.register();
const res = await plusRequestService.request({
url: '/activation/subject/vip/trialGet',
method: 'POST',
});
if (res.license) {
await this.updateLicense(res.license);
return {
duration: res.duration,
};
} else {
throw new Error('您已经领取过VIP试用了');
}
}
async requestWithToken(config: HttpRequestConfig) {
const plusRequestService = await this.getPlusRequestService();
const token = await this.getAccessToken();

View File

@ -73,7 +73,6 @@ export abstract class CertApplyBasePlugin extends AbstractTaskPlugin {
})
renewDays!: number;
@TaskInput({
title: "成功后邮件通知",
value: true,

View File

@ -7,3 +7,11 @@ export async function doActive(form: any) {
data: form
});
}
export async function getVipTrial() {
return await request({
url: "/sys/plus/getVipTrial",
method: "post",
data: {}
});
}

View File

@ -12,13 +12,14 @@
</div>
</template>
<script lang="tsx" setup>
import { computed, reactive, ref } from "vue";
import { computed, reactive } from "vue";
import dayjs from "dayjs";
import { message, Modal } from "ant-design-vue";
import * as api from "./api";
import { useSettingStore } from "/@/store/modules/settings";
import { useRouter } from "vue-router";
import { useUserStore } from "/@/store/modules/user";
const settingStore = useSettingStore();
const props = withDefaults(
defineProps<{
@ -129,21 +130,27 @@ function goAccount() {
router.push("/sys/account");
}
async function getVipTrial() {
const res = await api.getVipTrial();
message.success(`恭喜,您已获得专业版${res.duration}天试用`);
await settingStore.init();
}
function openTrialModal() {
Modal.destroyAll();
modal.confirm({
title: "7天专业版试用获取",
okText: "立即去绑定账号",
okText: "立即获取",
onOk() {
goAccount();
getVipTrial();
},
width: 600,
content: () => {
return (
<div class="flex-col mt-10 mb-10">
<div>感谢您对开源项目的支持</div>
<div>绑定袖手账号后即可获取7天专业版试用</div>
<div>点击确认即可获取7天专业版试用</div>
</div>
);
}

View File

@ -35,6 +35,12 @@ export class SysPlusController extends BaseController {
return this.ok(true);
}
@Post('/getVipTrial', { summary: 'sys:settings:edit' })
async getVipTrial(@Body(ALL) body) {
const res = await this.plusService.getVipTrial();
return this.ok(res);
}
//
// @Get('/test', { summary: Constants.per.guest })
// async test() {