diff --git a/packages/libs/lib-server/src/system/settings/service/sys-settings-service.ts b/packages/libs/lib-server/src/system/settings/service/sys-settings-service.ts index 021dd3c4..9d52eba4 100644 --- a/packages/libs/lib-server/src/system/settings/service/sys-settings-service.ts +++ b/packages/libs/lib-server/src/system/settings/service/sys-settings-service.ts @@ -6,7 +6,7 @@ import { CacheManager } from '@midwayjs/cache'; import { BaseSettings, SysPrivateSettings, SysPublicSettings } from './models.js'; import * as _ from 'lodash-es'; import { BaseService } from '../../../basic/index.js'; -import { checkComm } from '@certd/pipeline'; +import { isComm } from '@certd/pipeline'; /** * 设置 @@ -40,8 +40,8 @@ export class SysSettingsService extends BaseService { if (!key) { return null; } - if (key === 'sys.site') { - checkComm(); + if (key === 'sys.site' && isComm()) { + return null; } return await this.repository.findOne({ where: { diff --git a/packages/ui/certd-client/src/App.vue b/packages/ui/certd-client/src/App.vue index dc7e2ccd..8357be32 100644 --- a/packages/ui/certd-client/src/App.vue +++ b/packages/ui/certd-client/src/App.vue @@ -48,7 +48,6 @@ export default { const pageStore = usePageStore(); pageStore.init(); const settingStore = useSettingStore(); - settingStore.init(); return { routerEnabled, diff --git a/packages/ui/certd-client/src/api/modules/api.basic.ts b/packages/ui/certd-client/src/api/modules/api.basic.ts index 71879335..20248c4b 100644 --- a/packages/ui/certd-client/src/api/modules/api.basic.ts +++ b/packages/ui/certd-client/src/api/modules/api.basic.ts @@ -1,6 +1,28 @@ import { request } from "../service"; -import { SiteEnv, SiteInfo } from "/@/store/modules/settings"; +export type SiteEnv = { + agent?: { + enabled?: boolean; + contactText?: string; + contactLink?: string; + }; +}; +export type SiteInfo = { + title: string; + slogan: string; + logo: string; + loginLogo: string; + icpNo: string; + licenseTo?: string; + licenseToUrl?: string; +}; + +export type PlusInfo = { + vipType?: string; + expireTime?: number; + isPlus: boolean; + isComm?: boolean; +}; export type SysPublicSetting = { registerEnabled: boolean; managerOtherUserPipeline: boolean; @@ -11,29 +33,17 @@ export type SysInstallInfo = { siteId: string; }; -export async function getSysPublicSettings(): Promise { - return await request({ - url: "/basic/settings/public", - method: "get" - }); -} +export type AllSettings = { + sysPublic: SysPublicSetting; + installInfo: SysInstallInfo; + plusInfo: PlusInfo; + siteInfo: SiteInfo; + siteEnv: SiteEnv; +}; -export async function getInstallInfo(): Promise { +export async function loadAllSettings(): Promise { return await request({ - url: "/basic/settings/install", - method: "get" - }); -} - -export async function getSiteInfo(): Promise { - return await request({ - url: "/basic/settings/siteInfo", - method: "get" - }); -} -export async function getSiteEnv(): Promise { - return await request({ - url: "/basic/settings/siteEnv", + url: "/basic/settings/all", method: "get" }); } @@ -45,10 +55,3 @@ export async function bindUrl(data: any): Promise { data }); } - -export async function getPlusInfo() { - return await request({ - url: "/basic/settings/plusInfo", - method: "get" - }); -} diff --git a/packages/ui/certd-client/src/layout/components/user-info/index.vue b/packages/ui/certd-client/src/layout/components/user-info/index.vue index be8aef97..cc513cd7 100644 --- a/packages/ui/certd-client/src/layout/components/user-info/index.vue +++ b/packages/ui/certd-client/src/layout/components/user-info/index.vue @@ -3,6 +3,9 @@ - diff --git a/packages/ui/certd-client/src/router/index.ts b/packages/ui/certd-client/src/router/index.ts index c5fd956c..55368329 100644 --- a/packages/ui/certd-client/src/router/index.ts +++ b/packages/ui/certd-client/src/router/index.ts @@ -7,6 +7,8 @@ import { site } from "../utils/util.site"; import { routes } from "./resolve"; import { useResourceStore } from "../store/modules/resource"; import { useUserStore } from "../store/modules/user"; +import { useSettingStore } from "/@/store/modules/settings"; + const router = createRouter({ history: createWebHashHistory(), routes @@ -18,6 +20,8 @@ const router = createRouter({ router.beforeEach(async (to, from, next) => { // 进度条 NProgress.start(); + const settingStore = useSettingStore(); + await settingStore.initOnce(); // 修复三级以上路由页面无法缓存的问题 if (to.matched && to.matched.length > 2) { to.matched.splice(1, to.matched.length - 2); diff --git a/packages/ui/certd-client/src/router/source/framework.ts b/packages/ui/certd-client/src/router/source/framework.ts index 800fcf99..305343be 100644 --- a/packages/ui/certd-client/src/router/source/framework.ts +++ b/packages/ui/certd-client/src/router/source/framework.ts @@ -27,8 +27,7 @@ export const frameworkResource = [ } }, //...crudResources, - ...certdResources, - ...sysResources + ...certdResources ] } ]; diff --git a/packages/ui/certd-client/src/router/source/modules/certd.ts b/packages/ui/certd-client/src/router/source/modules/certd.ts index 94e47df3..b3ef3f67 100644 --- a/packages/ui/certd-client/src/router/source/modules/certd.ts +++ b/packages/ui/certd-client/src/router/source/modules/certd.ts @@ -1,3 +1,5 @@ +import { sysResources } from "/@/router/source/modules/sys"; + export const certdResources = [ { title: "证书自动化", @@ -73,9 +75,11 @@ export const certdResources = [ component: "/certd/mine/user-profile.vue", meta: { icon: "ion:person-outline", - auth: true + auth: true, + isMenu: false } - } + }, + ...sysResources ] } ]; diff --git a/packages/ui/certd-client/src/router/source/modules/sys.ts b/packages/ui/certd-client/src/router/source/modules/sys.ts index 1b8d61a9..6555e4b0 100644 --- a/packages/ui/certd-client/src/router/source/modules/sys.ts +++ b/packages/ui/certd-client/src/router/source/modules/sys.ts @@ -13,40 +13,6 @@ export const sysResources = [ permission: "sys" }, children: [ - { - title: "权限管理", - name: "AuthorityManager", - path: "/sys/authority", - redirect: "/sys/authority/permission", - meta: { - icon: "ion:ribbon-outline", - //需要校验权限 - permission: "sys:auth" - }, - children: [ - { - title: "权限资源管理", - name: "PermissionManager", - path: "/sys/authority/permission", - component: "/sys/authority/permission/index.vue", - meta: { - icon: "ion:list-outline", - //需要校验权限 - permission: "sys:auth:per:view" - } - }, - { - title: "角色管理", - name: "RoleManager", - path: "/sys/authority/role", - component: "/sys/authority/role/index.vue", - meta: { - icon: "ion:people-outline", - permission: "sys:auth:role:view" - } - } - ] - }, { title: "用户管理", name: "UserManager", @@ -102,6 +68,37 @@ export const sysResources = [ permission: "sys:settings:view" } }, + { + title: "账号绑定", + name: "AccountBind", + path: "/sys/account", + component: "/sys/account/index.vue", + meta: { + icon: "ion:golf-outline", + permission: "sys:settings:view" + } + }, + { + title: "权限管理", + name: "PermissionManager", + path: "/sys/authority/permission", + component: "/sys/authority/permission/index.vue", + meta: { + icon: "ion:list-outline", + //需要校验权限 + permission: "sys:auth:per:view" + } + }, + { + title: "角色管理", + name: "RoleManager", + path: "/sys/authority/role", + component: "/sys/authority/role/index.vue", + meta: { + icon: "ion:people-outline", + permission: "sys:auth:role:view" + } + } // { // title: "商业版设置", @@ -130,16 +127,6 @@ export const sysResources = [ // } // ] // } - { - title: "账号绑定", - name: "AccountBind", - path: "/sys/account", - component: "/sys/account/index.vue", - meta: { - icon: "ion:golf-outline", - permission: "sys:settings:view" - } - } ] } ]; diff --git a/packages/ui/certd-client/src/store/modules/settings.ts b/packages/ui/certd-client/src/store/modules/settings.ts index 7ecf2bb0..9e283604 100644 --- a/packages/ui/certd-client/src/store/modules/settings.ts +++ b/packages/ui/certd-client/src/store/modules/settings.ts @@ -5,7 +5,7 @@ import _ from "lodash-es"; import { LocalStorage } from "/src/utils/util.storage"; import * as basicApi from "/@/api/modules/api.basic"; -import { SysInstallInfo, SysPublicSetting } from "/@/api/modules/api.basic"; +import { PlusInfo, SiteEnv, SiteInfo, SysInstallInfo, SysPublicSetting } from "/@/api/modules/api.basic"; import { useUserStore } from "/@/store/modules/user"; import { mitter } from "/@/utils/util.mitt"; import { env } from "/@/utils/util.env"; @@ -36,31 +36,7 @@ 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; - logo: string; - loginLogo: string; - warningOff: boolean; - icpNo: string; - licenseTo?: string; - licenseToUrl?: string; -}; - -interface PlusInfo { - vipType?: string; - expireTime?: number; - isPlus: boolean; - isComm?: boolean; + inited?: boolean; } const defaultThemeConfig = { @@ -73,7 +49,6 @@ const defaultSiteInfo = { slogan: env.SLOGAN || "让你的证书永不过期", logo: env.LOGO || "/static/images/logo/logo.svg", loginLogo: env.LOGIN_LOGO || "/static/images/logo/rect-block.svg", - warningOff: false, icpNo: env.ICP_NO, licenseTo: "", licenseToUrl: "" @@ -88,7 +63,8 @@ export const useSettingStore = defineStore({ }, plusInfo: { isPlus: false, - vipType: "free" + vipType: "free", + isComm: false }, sysPublic: { registerEnabled: false, @@ -109,7 +85,8 @@ export const useSettingStore = defineStore({ contactText: "", contactLink: "" } - } + }, + inited: false }), getters: { getThemeConfig(): any { @@ -127,6 +104,12 @@ export const useSettingStore = defineStore({ isComm(): boolean { return this.plusInfo?.isComm && this.plusInfo?.expireTime > new Date().getTime(); }, + isAgent(): boolean { + return this.siteEnv?.agent?.enabled === true; + }, + isCommOrAgent() { + return this.isComm || this.isAgent; + }, vipLabel(): string { const vipLabelMap: any = { free: "免费版", @@ -146,33 +129,18 @@ export const useSettingStore = defineStore({ } }, async loadSysSettings() { - await this.loadSysPublicSettings(); - await this.loadSiteEnv(); - await this.loadInstallInfo(); - await this.loadPlusInfo(); - await this.loadSiteInfo(); + const allSettings = await basicApi.loadAllSettings(); + _.merge(this.sysPublic, allSettings.sysPublic || {}); + _.merge(this.installInfo, allSettings.installInfo || {}); + _.merge(this.siteEnv, allSettings.siteEnv || {}); + _.merge(this.plusInfo, allSettings.plusInfo || {}); + //@ts-ignore + this.initSiteInfo(allSettings.siteInfo || {}); await this.checkUrlBound(); }, - async loadSysPublicSettings() { - const settings = await basicApi.getSysPublicSettings(); - _.merge(this.sysPublic, settings); - }, - async loadInstallInfo() { - 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: SiteInfo = {}; - if (isComm) { - siteInfo = await basicApi.getSiteInfo(); + initSiteInfo(siteInfo: SiteInfo) { + //@ts-ignore + if (this.isComm) { if (siteInfo.logo) { siteInfo.logo = `/api/basic/file/download?key=${siteInfo.logo}`; } @@ -205,8 +173,9 @@ export const useSettingStore = defineStore({ const doBindUrl = async (url: string) => { await basicApi.bindUrl({ url }); - await this.loadInstallInfo(); + await this.loadSysSettings(); }; + const baseUrl = getBaseUrl(); if (!bindUrl) { //绑定url @@ -269,6 +238,13 @@ export const useSettingStore = defineStore({ async init() { await this.setThemeConfig(this.getThemeConfig); await this.loadSysSettings(); + }, + async initOnce() { + if (this.inited) { + return; + } + await this.init(); + this.inited = true; } } }); diff --git a/packages/ui/certd-client/src/utils/index.ts b/packages/ui/certd-client/src/utils/index.ts index 7e3f9afe..890f2d58 100644 --- a/packages/ui/certd-client/src/utils/index.ts +++ b/packages/ui/certd-client/src/utils/index.ts @@ -1,7 +1,7 @@ import * as envs from "./util.env"; import * as sites from "./util.site"; import * as storages from "./util.storage"; -import * as commons from "./util.common"; +import commons from "./util.common"; import * as mitt from "./util.mitt"; export const util = { ...envs, diff --git a/packages/ui/certd-client/src/utils/util.common.ts b/packages/ui/certd-client/src/utils/util.common.ts index 3149032a..a5074ce9 100644 --- a/packages/ui/certd-client/src/utils/util.common.ts +++ b/packages/ui/certd-client/src/utils/util.common.ts @@ -29,5 +29,9 @@ export default { array.push(item); } return array; + }, + + async sleep(ms: number) { + return new Promise((resolve) => setTimeout(resolve, ms)); } }; diff --git a/packages/ui/certd-client/src/views/certd/mine/user-profile.vue b/packages/ui/certd-client/src/views/certd/mine/user-profile.vue index edb1994d..309a1ca6 100644 --- a/packages/ui/certd-client/src/views/certd/mine/user-profile.vue +++ b/packages/ui/certd-client/src/views/certd/mine/user-profile.vue @@ -5,7 +5,7 @@
- {{ userInfo.userInfoname }} + {{ userInfo.username }} {{ userInfo.nickName }} {{ userInfo.email }} {{ userInfo.phoneCode }}{{ userInfo.mobile }} diff --git a/packages/ui/certd-client/src/views/framework/home/content/index.vue b/packages/ui/certd-client/src/views/framework/home/content/index.vue index a62de3bc..5efb2ebc 100644 --- a/packages/ui/certd-client/src/views/framework/home/content/index.vue +++ b/packages/ui/certd-client/src/views/framework/home/content/index.vue @@ -6,7 +6,7 @@

{{ siteInfo.slogan }}

-
+
-
+
-