perf: 支持部署到lucky

pull/361/head
xiaojunnuo 2025-03-24 18:39:22 +08:00
parent d66ade4e47
commit e18e399ce6
4 changed files with 55 additions and 29 deletions

View File

@ -7,6 +7,11 @@ export type SiteEnv = {
contactLink?: string; contactLink?: string;
}; };
}; };
export type AppInfo = {
version?: string;
time?: number;
deltaTime?: number;
};
export type SiteInfo = { export type SiteInfo = {
title?: string; title?: string;
slogan?: string; slogan?: string;
@ -71,12 +76,13 @@ export type AllSettings = {
siteEnv: SiteEnv; siteEnv: SiteEnv;
headerMenus: HeaderMenus; headerMenus: HeaderMenus;
suiteSetting: SuiteSetting; suiteSetting: SuiteSetting;
app: AppInfo;
}; };
export async function loadAllSettings(): Promise<AllSettings> { export async function loadAllSettings(): Promise<AllSettings> {
return await request({ return await request({
url: "/basic/settings/all", url: "/basic/settings/all",
method: "get" method: "get",
}); });
} }
@ -84,7 +90,7 @@ export async function bindUrl(data: any): Promise<any> {
return await request({ return await request({
url: "/sys/plus/bindUrl", url: "/sys/plus/bindUrl",
method: "post", method: "post",
data data,
}); });
} }
@ -92,7 +98,7 @@ export async function sendSmsCode(data: any): Promise<any> {
return await request({ return await request({
url: "/basic/code/sendSmsCode", url: "/basic/code/sendSmsCode",
method: "post", method: "post",
data data,
}); });
} }
@ -100,6 +106,6 @@ export async function sendEmailCode(data: any): Promise<any> {
return await request({ return await request({
url: "/basic/code/sendEmailCode", url: "/basic/code/sendEmailCode",
method: "post", method: "post",
data data,
}); });
} }

View File

@ -1,11 +1,8 @@
import { defineStore } from "pinia"; import { defineStore } from "pinia";
import { Modal, notification } from "ant-design-vue"; import { Modal, notification } from "ant-design-vue";
import * as _ from "lodash-es"; import * as _ from "lodash-es";
// @ts-ignore
import { LocalStorage } from "/src/utils/util.storage";
import * as basicApi from "/@/api/modules/api.basic"; import * as basicApi from "/@/api/modules/api.basic";
import { HeaderMenus, PlusInfo, SiteEnv, SiteInfo, SuiteSetting, SysInstallInfo, SysPublicSetting } from "/@/api/modules/api.basic"; import { AppInfo, HeaderMenus, PlusInfo, SiteEnv, SiteInfo, SuiteSetting, SysInstallInfo, SysPublicSetting } from "/@/api/modules/api.basic";
import { useUserStore } from "/@/store/modules/user"; import { useUserStore } from "/@/store/modules/user";
import { mitter } from "/@/utils/util.mitt"; import { mitter } from "/@/utils/util.mitt";
import { env } from "/@/utils/util.env"; import { env } from "/@/utils/util.env";
@ -29,6 +26,11 @@ export interface SettingState {
headerMenus?: HeaderMenus; headerMenus?: HeaderMenus;
inited?: boolean; inited?: boolean;
suiteSetting?: SuiteSetting; suiteSetting?: SuiteSetting;
app: {
version?: string;
time?: number;
deltaTime?: number;
};
} }
const defaultSiteInfo: SiteInfo = { const defaultSiteInfo: SiteInfo = {
@ -37,7 +39,7 @@ const defaultSiteInfo: SiteInfo = {
logo: env.LOGO || "/static/images/logo/logo.svg", logo: env.LOGO || "/static/images/logo/logo.svg",
loginLogo: env.LOGIN_LOGO || "/static/images/logo/rect-block.svg", loginLogo: env.LOGIN_LOGO || "/static/images/logo/rect-block.svg",
licenseTo: "", licenseTo: "",
licenseToUrl: "" licenseToUrl: "",
}; };
export const useSettingStore = defineStore({ export const useSettingStore = defineStore({
id: "app.setting", id: "app.setting",
@ -45,33 +47,38 @@ export const useSettingStore = defineStore({
plusInfo: { plusInfo: {
isPlus: false, isPlus: false,
vipType: "free", vipType: "free",
isComm: false isComm: false,
}, },
sysPublic: { sysPublic: {
registerEnabled: false, registerEnabled: false,
managerOtherUserPipeline: false, managerOtherUserPipeline: false,
icpNo: env.ICP_NO || "" icpNo: env.ICP_NO || "",
}, },
installInfo: { installInfo: {
siteId: "", siteId: "",
bindUserId: null, bindUserId: null,
bindUrl: "", bindUrl: "",
accountServerBaseUrl: "", accountServerBaseUrl: "",
appKey: "" appKey: "",
}, },
siteInfo: defaultSiteInfo, siteInfo: defaultSiteInfo,
siteEnv: { siteEnv: {
agent: { agent: {
enabled: undefined, enabled: undefined,
contactText: "", contactText: "",
contactLink: "" contactLink: "",
} },
}, },
headerMenus: { headerMenus: {
menus: [] menus: [],
}, },
suiteSetting: { enabled: false }, suiteSetting: { enabled: false },
inited: false inited: false,
app: {
version: "",
time: 0,
deltaTime: 0,
},
}), }),
getters: { getters: {
getSysPublic(): SysPublicSetting { getSysPublic(): SysPublicSetting {
@ -96,7 +103,7 @@ export const useSettingStore = defineStore({
const vipLabelMap: any = { const vipLabelMap: any = {
free: "基础版", free: "基础版",
plus: "专业版", plus: "专业版",
comm: "商业版" comm: "商业版",
}; };
return vipLabelMap[this.plusInfo?.vipType || "free"]; return vipLabelMap[this.plusInfo?.vipType || "free"];
}, },
@ -113,21 +120,21 @@ export const useSettingStore = defineStore({
title: menu.title, title: menu.title,
icon: menu.icon, icon: menu.icon,
link: menu.path, link: menu.path,
order: 99999 order: 99999,
} },
}; };
}); });
}, },
isSuiteEnabled(): boolean { isSuiteEnabled(): boolean {
// @ts-ignore // @ts-ignore
return this.suiteSetting?.enabled === true; return this.suiteSetting?.enabled === true;
} },
}, },
actions: { actions: {
checkPlus() { checkPlus() {
if (!this.isPlus) { if (!this.isPlus) {
notification.warn({ notification.warn({
message: "此为专业版功能,请先升级到专业版" message: "此为专业版功能,请先升级到专业版",
}); });
throw new Error("此为专业版功能,请升级到专业版"); throw new Error("此为专业版功能,请升级到专业版");
} }
@ -142,6 +149,12 @@ export const useSettingStore = defineStore({
_.merge(this.suiteSetting, allSettings.suiteSetting || {}); _.merge(this.suiteSetting, allSettings.suiteSetting || {});
//@ts-ignore //@ts-ignore
this.initSiteInfo(allSettings.siteInfo || {}); this.initSiteInfo(allSettings.siteInfo || {});
this.initAppInfo(allSettings.app || {});
},
initAppInfo(appInfo: AppInfo) {
this.app.time = appInfo.time;
this.app.version = appInfo.version;
this.app.deltaTime = new Date().getTime() - this.app.time;
}, },
initSiteInfo(siteInfo: SiteInfo) { initSiteInfo(siteInfo: SiteInfo) {
//@ts-ignore //@ts-ignore
@ -158,15 +171,15 @@ export const useSettingStore = defineStore({
if (this.siteInfo.logo) { if (this.siteInfo.logo) {
updatePreferences({ updatePreferences({
logo: { logo: {
source: this.siteInfo.logo source: this.siteInfo.logo,
} },
}); });
} }
if (this.siteInfo.title) { if (this.siteInfo.title) {
updatePreferences({ updatePreferences({
app: { app: {
name: this.siteInfo.title name: this.siteInfo.title,
} },
}); });
useTitle(this.siteInfo.title); useTitle(this.siteInfo.title);
} }
@ -210,7 +223,7 @@ export const useSettingStore = defineStore({
cancelText: "不是,回到原来的地址", cancelText: "不是,回到原来的地址",
onCancel: () => { onCancel: () => {
window.location.href = bindUrl; window.location.href = bindUrl;
} },
}); });
} }
} }
@ -224,8 +237,8 @@ export const useSettingStore = defineStore({
} }
await this.init(); await this.init();
this.inited = true; this.inited = true;
} },
} },
}); });
mitter.on("app.login", async () => { mitter.on("app.login", async () => {

View File

@ -12,6 +12,7 @@ import {
} from '@certd/lib-server'; } from '@certd/lib-server';
import { AppKey, getPlusInfo, isComm } from '@certd/plus-core'; import { AppKey, getPlusInfo, isComm } from '@certd/plus-core';
import { cloneDeep } from 'lodash-es'; import { cloneDeep } from 'lodash-es';
import {getVersion} from "../../utils/version.js";
/** /**
*/ */
@ -81,6 +82,8 @@ export class BasicSettingsController extends BaseController {
const plusInfo = await this.plusInfo(); const plusInfo = await this.plusInfo();
const headerMenus = await this.getHeaderMenus(); const headerMenus = await this.getHeaderMenus();
const suiteSetting = await this.getSuiteSetting(); const suiteSetting = await this.getSuiteSetting();
const version = await getVersion()
return this.ok({ return this.ok({
sysPublic, sysPublic,
installInfo, installInfo,
@ -89,6 +92,10 @@ export class BasicSettingsController extends BaseController {
plusInfo, plusInfo,
headerMenus, headerMenus,
suiteSetting, suiteSetting,
app:{
time: new Date().getTime(),
version,
}
}); });
} }
} }

View File

@ -4,7 +4,7 @@ import { createCertDomainGetterInputDefine, createRemoteSelectInputDefine } from
import { optionsUtils } from '@certd/basic/dist/utils/util.options.js'; import { optionsUtils } from '@certd/basic/dist/utils/util.options.js';
import { CertApplyPluginNames} from '@certd/plugin-cert'; import { CertApplyPluginNames} from '@certd/plugin-cert';
@IsTaskPlugin({ @IsTaskPlugin({
//命名规范,插件名称+功能就是目录plugin-demo中的demo大写字母开头驼峰命名 //命名规范,插件类型+功能就是目录plugin-demo中的demo大写字母开头驼峰命名
name: 'DemoTest', name: 'DemoTest',
title: 'Demo-测试插件', title: 'Demo-测试插件',
icon: 'clarity:plugin-line', icon: 'clarity:plugin-line',