2024-08-14 21:24:12 +08:00
|
|
|
|
<template>
|
2024-09-01 04:49:26 +08:00
|
|
|
|
<div class="layout-vip isPlus" @click="openUpgrade">
|
2024-08-14 21:24:12 +08:00
|
|
|
|
<contextHolder />
|
2024-09-01 04:49:26 +08:00
|
|
|
|
<fs-icon icon="mingcute:vip-1-line" :title="text.title" />
|
|
|
|
|
|
|
|
|
|
|
|
<div v-if="mode !== 'icon'" class="text">
|
|
|
|
|
|
<a-tooltip>
|
|
|
|
|
|
<template #title> {{ text.title }}</template>
|
|
|
|
|
|
<span>{{ text.name }}</span>
|
|
|
|
|
|
</a-tooltip>
|
2024-08-14 21:24:12 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
<script lang="tsx" setup>
|
2024-08-24 23:48:26 +08:00
|
|
|
|
import { ref, reactive, computed } from "vue";
|
2024-08-24 01:05:06 +08:00
|
|
|
|
import { useUserStore } from "/src/store/modules/user";
|
2024-08-14 21:24:12 +08:00
|
|
|
|
import dayjs from "dayjs";
|
|
|
|
|
|
import { message, Modal } from "ant-design-vue";
|
|
|
|
|
|
import * as api from "./api";
|
2024-08-25 01:55:34 +08:00
|
|
|
|
import { useSettingStore } from "/@/store/modules/settings";
|
2024-08-14 21:24:12 +08:00
|
|
|
|
|
2024-09-01 04:49:26 +08:00
|
|
|
|
const props = withDefaults(
|
|
|
|
|
|
defineProps<{
|
|
|
|
|
|
mode?: "button" | "nav" | "icon";
|
|
|
|
|
|
}>(),
|
|
|
|
|
|
{
|
|
|
|
|
|
mode: "button"
|
|
|
|
|
|
}
|
|
|
|
|
|
);
|
|
|
|
|
|
type Text = {
|
|
|
|
|
|
name: string;
|
|
|
|
|
|
title?: string;
|
2024-08-24 23:48:26 +08:00
|
|
|
|
};
|
2024-09-01 04:49:26 +08:00
|
|
|
|
const text = computed<Text>(() => {
|
|
|
|
|
|
const map = {
|
|
|
|
|
|
isPlus: {
|
|
|
|
|
|
button: {
|
|
|
|
|
|
name: "专业版已开通",
|
|
|
|
|
|
title: "到期时间:" + expireTime.value
|
|
|
|
|
|
},
|
|
|
|
|
|
icon: {
|
|
|
|
|
|
name: "",
|
|
|
|
|
|
title: "专业版已开通"
|
|
|
|
|
|
},
|
|
|
|
|
|
nav: {
|
|
|
|
|
|
name: "专业版",
|
|
|
|
|
|
title: "到期时间:" + expireTime.value
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
free: {
|
|
|
|
|
|
button: {
|
|
|
|
|
|
name: "此为专业版功能",
|
|
|
|
|
|
title: "升级专业版,享受更多VIP特权"
|
|
|
|
|
|
},
|
|
|
|
|
|
icon: {
|
|
|
|
|
|
name: "",
|
|
|
|
|
|
title: "此为专业版功能"
|
|
|
|
|
|
},
|
|
|
|
|
|
nav: {
|
|
|
|
|
|
name: "免费版",
|
|
|
|
|
|
title: "升级专业版,享受更多VIP特权"
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
if (userStore.isPlus) {
|
|
|
|
|
|
return map.isPlus[props.mode];
|
2024-08-24 23:48:26 +08:00
|
|
|
|
} else {
|
2024-09-01 04:49:26 +08:00
|
|
|
|
return map.free[props.mode];
|
2024-08-24 23:48:26 +08:00
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
|
2024-08-14 21:24:12 +08:00
|
|
|
|
const userStore = useUserStore();
|
2024-08-25 01:55:34 +08:00
|
|
|
|
const expireTime = computed(() => {
|
|
|
|
|
|
if (userStore.isPlus) {
|
|
|
|
|
|
return dayjs(userStore.plusInfo.expireTime).format("YYYY-MM-DD");
|
|
|
|
|
|
}
|
|
|
|
|
|
return "";
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
const expiredDays = computed(() => {
|
|
|
|
|
|
if (userStore.plusInfo?.isPlus && !userStore.isPlus) {
|
|
|
|
|
|
//已过期多少天
|
|
|
|
|
|
const days = dayjs().diff(dayjs(userStore.plusInfo.expireTime), "day");
|
|
|
|
|
|
return `专业版已过期${days}天`;
|
|
|
|
|
|
}
|
|
|
|
|
|
return "";
|
|
|
|
|
|
});
|
2024-08-14 21:24:12 +08:00
|
|
|
|
|
|
|
|
|
|
const formState = reactive({
|
|
|
|
|
|
code: ""
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
async function doActive() {
|
|
|
|
|
|
if (!formState.code) {
|
|
|
|
|
|
message.error("请输入激活码");
|
|
|
|
|
|
throw new Error("请输入激活码");
|
|
|
|
|
|
}
|
|
|
|
|
|
const res = await api.doActive(formState);
|
|
|
|
|
|
if (res) {
|
|
|
|
|
|
await userStore.reInit();
|
|
|
|
|
|
Modal.success({
|
|
|
|
|
|
title: "激活成功",
|
|
|
|
|
|
content: `您已成功激活专业版,有效期至:${dayjs(userStore.plusInfo.expireTime).format("YYYY-MM-DD")}`
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-08-25 01:55:34 +08:00
|
|
|
|
|
|
|
|
|
|
const settingStore = useSettingStore();
|
|
|
|
|
|
const computedSiteId = computed(() => settingStore.installInfo?.siteId);
|
2024-08-14 21:24:12 +08:00
|
|
|
|
const [modal, contextHolder] = Modal.useModal();
|
2024-09-01 04:49:26 +08:00
|
|
|
|
|
2024-08-14 21:24:12 +08:00
|
|
|
|
function openUpgrade() {
|
2024-09-02 01:02:41 +08:00
|
|
|
|
if (!userStore.isAdmin) {
|
|
|
|
|
|
message.info("仅限管理员操作");
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
2024-08-14 21:24:12 +08:00
|
|
|
|
const placeholder = "请输入激活码";
|
2024-09-02 23:55:38 +08:00
|
|
|
|
const isPlus = userStore.isPlus;
|
2024-08-14 21:24:12 +08:00
|
|
|
|
modal.confirm({
|
2024-09-02 23:55:38 +08:00
|
|
|
|
title: isPlus ? "续期专业版" : "激活专业版",
|
2024-08-14 21:24:12 +08:00
|
|
|
|
async onOk() {
|
2024-08-21 12:38:09 +08:00
|
|
|
|
return await doActive();
|
2024-08-14 21:24:12 +08:00
|
|
|
|
},
|
2024-08-21 12:38:09 +08:00
|
|
|
|
okText: "激活",
|
|
|
|
|
|
width: 500,
|
2024-08-14 21:24:12 +08:00
|
|
|
|
content: () => {
|
|
|
|
|
|
return (
|
|
|
|
|
|
<div class="mt-10 mb-10">
|
2024-08-21 12:38:09 +08:00
|
|
|
|
<div>
|
|
|
|
|
|
<h3 class="block-header">专业版特权</h3>
|
|
|
|
|
|
<ul>
|
|
|
|
|
|
<li>可加VIP群,需求优先实现</li>
|
2024-09-03 00:06:13 +08:00
|
|
|
|
<li>证书流水线数量无限制(免费版限制10条)</li>
|
|
|
|
|
|
<li>免配置发邮件功能</li>
|
|
|
|
|
|
<li>FTP上传、cdnfly、宝塔、易盾等部署插件</li>
|
2024-08-21 12:38:09 +08:00
|
|
|
|
<li>更多特权敬请期待</li>
|
|
|
|
|
|
</ul>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div>
|
2024-09-02 23:55:38 +08:00
|
|
|
|
<h3 class="block-header">{isPlus ? "续期" : "立刻激活"}</h3>
|
|
|
|
|
|
<div>{isPlus ? "当前专业版已激活,到期时间" + dayjs(userStore.plusInfo.expireTime).format("YYYY-MM-DD") : ""}</div>
|
2024-08-21 12:38:09 +08:00
|
|
|
|
<div class="mt-10">
|
2024-08-25 01:55:34 +08:00
|
|
|
|
<div class="flex-o w-100">
|
|
|
|
|
|
<span>站点ID:</span>
|
|
|
|
|
|
<fs-copyable class="flex-1" v-model={computedSiteId.value}></fs-copyable>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<a-input class="mt-10" v-model:value={formState.code} placeholder={placeholder} />
|
2024-08-21 12:38:09 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<div class="mt-10">
|
|
|
|
|
|
没有激活码?
|
|
|
|
|
|
<a href="https://afdian.com/a/greper" target="_blank">
|
|
|
|
|
|
爱发电赞助“VIP会员”后获取
|
|
|
|
|
|
</a>
|
|
|
|
|
|
</div>
|
2024-08-14 21:24:12 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<style lang="less">
|
|
|
|
|
|
.layout-vip {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
justify-content: center;
|
|
|
|
|
|
height: 100%;
|
2024-08-24 23:48:26 +08:00
|
|
|
|
cursor: pointer;
|
2024-09-01 04:49:26 +08:00
|
|
|
|
|
2024-08-14 21:24:12 +08:00
|
|
|
|
&.isPlus {
|
|
|
|
|
|
color: #c5913f;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.text {
|
|
|
|
|
|
margin-left: 5px;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
</style>
|