This commit is contained in:
xiaojunnuo
2024-08-24 23:48:26 +08:00
parent c28f3cdcf7
commit 86ebbcb9bb
5 changed files with 62 additions and 21 deletions
@@ -6,20 +6,41 @@
<span v-if="userStore.plusInfo?.isPlus">
<a-tooltip>
<template #title> 到期时间{{ expireTime }} </template>
<span @click="openUpgrade">专业版</span>
<span @click="openUpgrade">{{ texts.plus }}</span>
</a-tooltip>
</span>
<span v-else @click="openUpgrade"> 当前免费版 </span>
<span v-else @click="openUpgrade"> {{ texts.free }} </span>
</div>
</div>
</template>
<script lang="tsx" setup>
import { ref, reactive } from "vue";
import { ref, reactive, computed } from "vue";
import { useUserStore } from "/src/store/modules/user";
import dayjs from "dayjs";
import { message, Modal } from "ant-design-vue";
import * as api from "./api";
const props = defineProps<{
mode: "button" | "nav";
}>();
type Texts = {
plus: string;
free: string;
};
const texts = computed<Texts>(() => {
if (props.mode === "button") {
return {
plus: "已开通",
free: "专业版功能"
};
} else {
return {
plus: "专业版",
free: "免费版,立即升级"
};
}
});
const userStore = useUserStore();
const expireTime = ref("");
if (userStore.plusInfo?.isPlus) {
@@ -91,6 +112,7 @@ function openUpgrade() {
align-items: center;
justify-content: center;
height: 100%;
cursor: pointer;
&.isPlus {
color: #c5913f;
}
@@ -14,11 +14,11 @@
@finish-failed="onFinishFailed"
>
<a-form-item label="使用邮件代理" name="usePlus">
<a-switch v-model:checked="formState.usePlus" :disabled="!userStore.isPlus" />
<div class="helper">专业版功能免除繁琐的邮件配置直接发邮件</div>
<div>
<vip-button></vip-button>
<div class="flex-o">
<a-switch v-model:checked="formState.usePlus" :disabled="!userStore.isPlus" />
<vip-button class="ml-5" mode="button"></vip-button>
</div>
<div class="helper">专业版功能免除繁琐的邮件配置直接发邮件</div>
</a-form-item>
<template v-if="!formState.usePlus">
<a-form-item label="SMTP域名" name="host" :rules="[{ required: true, message: '请输入smtp域名或ip' }]">
@@ -1,10 +1,10 @@
import { MidwayEnvironmentService } from '@midwayjs/core';
import { Controller, Get, Inject, Provide } from '@midwayjs/core';
import { logger } from '../utils/logger.js';
import { Constants } from '../basic/constants.js';
import { logger } from '../../../utils/logger.js';
import { Constants } from '../../../basic/constants.js';
@Provide()
@Controller('/hello')
@Controller('/home')
export class HomeController {
@Inject()
environmentService: MidwayEnvironmentService;
@@ -1,7 +1,7 @@
import { Config, Inject, Provide, Scope, ScopeEnum } from '@midwayjs/core';
import { SysSettingsService } from '../../system/service/sys-settings-service.js';
import { SysInstallInfo } from '../../system/service/models.js';
import { appKey, getPlusInfo } from '@certd/pipeline';
import { appKey, getPlusInfo, isPlus } from '@certd/pipeline';
import * as crypto from 'crypto';
import { request } from '../../../utils/http.js';
import { logger } from '../../../utils/logger.js';
@@ -20,6 +20,9 @@ export class PlusService {
}
async request(config: any) {
if (!isPlus()) {
throw new Error('您还不是专业版,请先激活专业版');
}
const { url, data } = config;
const timestamps = Date.now();
const installInfo: SysInstallInfo = await this.sysSettingsService.getSetting(SysInstallInfo);
@@ -51,6 +54,13 @@ export class PlusService {
const params = JSON.stringify(body);
const plusInfo = getPlusInfo();
const secret = plusInfo.secret;
if (!secret) {
const randomTime = Math.floor(Math.random() * 3 * 60 * 1000 + 30 * 1000);
setTimeout(() => {
process.exit();
}, randomTime);
return 'xxxxx';
}
const content = `${params}.${timestamps}.${secret}`;
// sha256