This commit is contained in:
xiaojunnuo
2024-10-03 01:29:12 +08:00
parent aeed24e87d
commit c9d18f6d8a
17 changed files with 100 additions and 34 deletions
@@ -13,13 +13,21 @@ const emit = defineEmits<{
}>();
const optionsRef = ref([]);
const message = ref("");
const getOptions = async () => {
return await doRequest({
type: props.type,
typeName: props.typeName,
action: props.action,
input: props.form
});
return await doRequest(
{
type: props.type,
typeName: props.typeName,
action: props.action,
input: props.form
},
{
onError(err) {
message.value = err.message;
}
}
);
};
const filterOption = (input: string, option: any) => {
@@ -53,7 +61,8 @@ watch(
</script>
<template>
<a-select
<div>
<a-select
class="remote-select"
show-search
:filter-option="filterOption"
@@ -62,6 +71,10 @@ watch(
@click="onClick"
@update:value="emit('update:value', $event)"
/>
<div class="helper">
{{ message }}
</div>
</div>
</template>
<style lang="less"></style>
@@ -14,7 +14,7 @@ export type RequestHandleReq<T = any> = {
input: T;
};
export async function doRequest(req: RequestHandleReq) {
export async function doRequest(req: RequestHandleReq, opts?: any = {}) {
const url = req.type === "access" ? "/pi/handle/access" : "/pi/handle/plugin";
const { typeName, action, data, input } = req;
const res = await request({
@@ -25,7 +25,8 @@ export async function doRequest(req: RequestHandleReq) {
action,
data,
input
}
},
...opts
});
return res;
}
@@ -1,7 +1,7 @@
<template>
<div>
<contextHolder />
<a-input :value="value" :allow-clear="true" @update:value="emit('update:value', $event)">
<a-input v-bind="attrs" :value="value" :allow-clear="true" @update:value="emit('update:value', $event)">
<template #suffix>
<a-tag class="cursor-pointer" @click="getDeviceId">获取设备ID</a-tag>
</template>
@@ -33,18 +33,19 @@ type Text = {
title?: string;
};
const text = computed<Text>(() => {
const vipLabel = userStore.vipLabel;
const map = {
isPlus: {
button: {
name: "专业版已开通",
name: `${vipLabel}已开通`,
title: "到期时间:" + expireTime.value
},
icon: {
name: "",
title: "专业版已开通"
title: `${vipLabel}已开通`
},
nav: {
name: "专业版",
name: `${vipLabel}`,
title: "到期时间:" + expireTime.value
}
},
@@ -82,7 +83,7 @@ const expiredDays = computed(() => {
if (userStore.plusInfo?.isPlus && !userStore.isPlus) {
//已过期多少天
const days = dayjs().diff(dayjs(userStore.plusInfo.expireTime), "day");
return `专业版已过期${days}`;
return `${userStore.vipLabel}已过期${days}`;
}
return "";
});
@@ -100,15 +101,16 @@ async function doActive() {
const res = await api.doActive(formState);
if (res) {
await userStore.reInit();
const vipLabel = userStore.vipLabel;
Modal.success({
title: "激活成功",
content: `您已成功激活专业版,有效期至:${dayjs(userStore.plusInfo.expireTime).format("YYYY-MM-DD")}`,
content: `您已成功激活${vipLabel},有效期至:${dayjs(userStore.plusInfo.expireTime).format("YYYY-MM-DD")}`,
onOk() {
if (!(settingStore.installInfo.bindUserId > 0)) {
//未绑定账号
Modal.confirm({
title: "是否绑定袖手账号",
content: "绑定账号后,可以避免专业版License丢失,强烈建议绑定",
content: "绑定账号后,可以避免License丢失,强烈建议绑定",
onOk() {
router.push("/sys/account");
}
@@ -130,8 +132,15 @@ function openUpgrade() {
}
const placeholder = "请输入激活码";
const isPlus = userStore.isPlus;
let title = "激活专业版/商业版";
if (userStore.isComm) {
title = "续期商业版";
} else if (userStore.isPlus) {
title = "续期专业版/升级商业版";
}
modal.confirm({
title: isPlus ? "续期专业版" : "激活专业版",
title,
async onOk() {
return await doActive();
},
@@ -139,6 +148,7 @@ function openUpgrade() {
okText: "激活",
width: 500,
content: () => {
const vipLabel = userStore.vipLabel;
return (
<div class="mt-10 mb-10">
<div>
@@ -153,7 +163,7 @@ function openUpgrade() {
</div>
<div>
<h3 class="block-header">{isPlus ? "续期" : "立刻激活"}</h3>
<div>{isPlus ? "当前专业版已激活,到期时间" + dayjs(userStore.plusInfo.expireTime).format("YYYY-MM-DD") : ""}</div>
<div>{isPlus ? `当前${vipLabel}已激活,到期时间` + dayjs(userStore.plusInfo.expireTime).format("YYYY-MM-DD") : ""}</div>
<div class="mt-10">
<div class="flex-o w-100">
<span>站点ID</span>