chore: agent

This commit is contained in:
xiaojunnuo
2024-10-10 18:38:22 +08:00
parent 0e4b72c65d
commit 68e5ea1cad
8 changed files with 95 additions and 9 deletions
@@ -1,4 +1,5 @@
import { request } from "../service";
import { SiteEnv, SiteInfo } from "/@/store/modules/settings";
export type SysPublicSetting = {
registerEnabled: boolean;
@@ -24,14 +25,20 @@ export async function getInstallInfo(): Promise<SysInstallInfo> {
});
}
export async function getSiteInfo(): Promise<SysInstallInfo> {
export async function getSiteInfo(): Promise<SiteInfo> {
return await request({
url: "/basic/settings/siteInfo",
method: "get"
});
}
export async function getSiteEnv(): Promise<SiteEnv> {
return await request({
url: "/basic/settings/siteEnv",
method: "get"
});
}
export async function bindUrl(data): Promise<SysInstallInfo> {
export async function bindUrl(data: any): Promise<any> {
return await request({
url: "/sys/plus/bindUrl",
method: "post",
@@ -164,9 +164,27 @@ function openUpgrade() {
okText: "激活",
width: 900,
content: () => {
let activationCodeGetWay: any = null;
if (settingStore.siteEnv.agent.enabled != null) {
const agent = settingStore.siteEnv.agent;
if (agent.enabled === false) {
activationCodeGetWay = (
<a href="https://afdian.com/a/greper" target="_blank">
爱发电赞助VIP会员后获取
</a>
);
} else {
activationCodeGetWay = (
<a href={agent.contactLink} target="_blank">
{agent.contactText}
</a>
);
}
}
const vipLabel = settingStore.vipLabel;
const slots = [];
for (const key in vipTypeDefine) {
// @ts-ignore
const item = vipTypeDefine[key];
const vipBlockClass = `vip-block ${key === settingStore.plusInfo.vipType ? "current" : ""}`;
slots.push(
@@ -174,7 +192,7 @@ function openUpgrade() {
<div class={vipBlockClass}>
<h3 class="block-header">{item.title}</h3>
<ul>
{item.privilege.map((p) => (
{item.privilege.map((p: string) => (
<li>
<fs-icon class="color-green" icon="ion:checkmark-sharp" />
{p}
@@ -203,9 +221,7 @@ function openUpgrade() {
<div class="mt-10">
没有激活码
<a href="https://afdian.com/a/greper" target="_blank">
爱发电赞助VIP会员后获取
</a>
{activationCodeGetWay}
</div>
</div>
</div>
@@ -35,8 +35,16 @@ export interface SettingState {
};
siteInfo: SiteInfo;
plusInfo?: PlusInfo;
siteEnv?: SiteEnv;
}
export type SiteEnv = {
agent?: {
enabled?: boolean;
contactText?: string;
contactLink?: string;
};
};
export type SiteInfo = {
title: string;
slogan: string;
@@ -94,7 +102,14 @@ export const useSettingStore = defineStore({
accountServerBaseUrl: "",
appKey: ""
},
siteInfo: defaultSiteInfo
siteInfo: defaultSiteInfo,
siteEnv: {
agent: {
enabled: undefined,
contactText: "",
contactLink: ""
}
}
}),
getters: {
getThemeConfig(): any {
@@ -132,6 +147,7 @@ export const useSettingStore = defineStore({
},
async loadSysSettings() {
await this.loadSysPublicSettings();
await this.loadSiteEnv();
await this.loadInstallInfo();
await this.loadPlusInfo();
await this.loadSiteInfo();
@@ -145,12 +161,16 @@ export const useSettingStore = defineStore({
const installInfo = await basicApi.getInstallInfo();
_.merge(this.installInfo, installInfo);
},
async loadSiteEnv() {
const siteEnv = await basicApi.getSiteEnv();
_.merge(this.siteEnv, siteEnv);
},
async loadPlusInfo() {
this.plusInfo = await basicApi.getPlusInfo();
},
async loadSiteInfo() {
const isComm = this.isComm;
let siteInfo = {};
let siteInfo: SiteInfo;
if (isComm) {
siteInfo = await basicApi.getSiteInfo();
if (siteInfo.logo) {