From 3fc6d21c76b20bdd0689c1191d0d5dfe81ac44d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E5=BF=A0=E6=9E=97?= <170083662@qq.com> Date: Wed, 13 Aug 2025 02:53:45 +0800 Subject: [PATCH] =?UTF-8?q?feat(site):=20=E9=87=8D=E6=9E=84=E7=BD=91?= =?UTF-8?q?=E7=AB=99=E4=BF=A1=E6=81=AF=E6=A8=A1=E5=9D=97=E5=B9=B6=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E5=BA=94=E7=94=A8=E4=BF=A1=E6=81=AF=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增 AppInfo 接口,用于存储应用信息 - 修改 getSiteInfo API 调用路径 - 更新 site store 中的数据结构和相关方法,支持应用信息- 调整 dashboard 页面中显示的网站信息,改为应用信息 --- src/api/cms/cmsWebsite/model/index.ts | 28 ++++++++ src/api/layout/index.ts | 2 +- src/store/modules/site.ts | 96 ++++++++++++++++----------- src/views/bszx/dashboard/index.vue | 12 ++-- src/views/cms/dashboard/index.vue | 12 ++-- 5 files changed, 99 insertions(+), 51 deletions(-) diff --git a/src/api/cms/cmsWebsite/model/index.ts b/src/api/cms/cmsWebsite/model/index.ts index 0b98583..a2e7a7f 100644 --- a/src/api/cms/cmsWebsite/model/index.ts +++ b/src/api/cms/cmsWebsite/model/index.ts @@ -1,5 +1,6 @@ import type { PageParam } from '@/api'; import {CmsWebsiteSetting} from "@/api/cms/cmsWebsiteSetting/model"; +import {CmsNavigation} from "@/api/cms/cmsNavigation/model"; /** * 网站信息记录表 @@ -121,6 +122,33 @@ export interface CmsWebsite { setting?: CmsWebsiteSetting; } +export interface AppInfo { + appId?: number; + appName?: string; + description?: string; + keywords?: string; + appCode?: string; + mpQrCode?: string; + title?: string; + logo?: string; + icon?: string; + domain?: string; + running?: number; + version?: number; + expirationTime?: string; + expired?: boolean; + expiredDays?: number; + soon?: number; + statusIcon?: string; + statusText?: string; + config?: Object; + serverTime?: Object; + topNavs?: CmsNavigation[]; + bottomNavs?: CmsNavigation[]; + setting?: Object; + createTime?: string; +} + /** * 网站信息记录表搜索条件 */ diff --git a/src/api/layout/index.ts b/src/api/layout/index.ts index b329699..93650ea 100644 --- a/src/api/layout/index.ts +++ b/src/api/layout/index.ts @@ -26,7 +26,7 @@ export async function getTenantInfo(): Promise { */ export async function getSiteInfo() { const res = await request.get>( - MODULES_API_URL + '/cms/cms-website/getSiteInfo', + MODULES_API_URL + '/cms/getSiteInfo', { params: { lang: getLang() diff --git a/src/store/modules/site.ts b/src/store/modules/site.ts index 7a7bce4..48dd0da 100644 --- a/src/store/modules/site.ts +++ b/src/store/modules/site.ts @@ -1,13 +1,13 @@ /** - * 网站信息 store + * 应用信息 store */ import { defineStore } from 'pinia'; import { getSiteInfo } from '@/api/layout'; -import { CmsWebsite } from '@/api/cms/cmsWebsite/model'; +import {AppInfo, CmsWebsite} from '@/api/cms/cmsWebsite/model'; export interface SiteState { - // 网站信息 - siteInfo: CmsWebsite | null; + // 应用信息 + siteInfo: AppInfo | null; // 加载状态 loading: boolean; // 最后更新时间 @@ -25,50 +25,70 @@ export const useSiteStore = defineStore({ // 默认缓存30分钟 cacheExpiry: 30 * 60 * 1000 }), - + getters: { /** - * 获取网站名称 + * 获取应用ID */ - websiteName: (state): string => { - return state.siteInfo?.websiteName || ''; + appId: (state): number | undefined => { + return state.siteInfo?.appId; }, - /** - * 获取网站Logo + * 获取应用名称 */ - websiteLogo: (state): string => { - return state.siteInfo?.websiteLogo || '/logo.png'; + appName: (state): string => { + return state.siteInfo?.appName || ''; }, - + /** - * 获取网站描述 + * 获取应用Logo */ - websiteComments: (state): string => { - return state.siteInfo?.comments || ''; + logo: (state): string => { + return state.siteInfo?.logo || '/logo.png'; }, - + + /** + * 获取应用描述 + */ + description: (state): string => { + return state.siteInfo?.description || ''; + }, + /** * 获取小程序码 */ - websiteDarkLogo: (state): string => { - return state.siteInfo?.websiteDarkLogo || ''; + mpQrCode: (state): string => { + return state.siteInfo?.mpQrCode || ''; }, - + /** - * 获取网站域名 + * 获取应用域名 */ - websiteDomain: (state): string => { + domain: (state): string => { return state.siteInfo?.domain || ''; }, - + /** - * 获取网站ID + * 获取应用版本 + * @param state */ - websiteId: (state): number | undefined => { - return state.siteInfo?.websiteId; + version: (state): string => { + if(state.siteInfo?.version == 10){ + return '基础版' + } + if(state.siteInfo?.version == 20){ + return '专业版' + } + if(state.siteInfo?.version == 30){ + return '企业版' + } + return ''; }, - + + statusText: (state): string => { + return state.siteInfo?.statusText || ''; + }, + /** * 计算系统运行天数 */ @@ -78,7 +98,7 @@ export const useSiteStore = defineStore({ const now = new Date().getTime(); return Math.floor((now - createTime) / (24 * 60 * 60 * 1000)); }, - + /** * 检查缓存是否有效 */ @@ -88,10 +108,10 @@ export const useSiteStore = defineStore({ return (now - state.lastUpdateTime) < state.cacheExpiry; } }, - + actions: { /** - * 获取网站信息 + * 获取应用信息 * @param forceRefresh 是否强制刷新 */ async fetchSiteInfo(forceRefresh = false) { @@ -99,13 +119,13 @@ export const useSiteStore = defineStore({ if (!forceRefresh && this.isCacheValid && this.siteInfo) { return this.siteInfo; } - + this.loading = true; try { const data = await getSiteInfo(); this.siteInfo = data; this.lastUpdateTime = Date.now(); - + // 更新localStorage中的相关信息 if (data.websiteId) { localStorage.setItem('WebsiteId', String(data.websiteId)); @@ -114,18 +134,18 @@ export const useSiteStore = defineStore({ localStorage.setItem('Domain', data.domain); localStorage.setItem('SiteUrl', `${data.prefix || 'https://'}${data.domain}`); } - + return data; } catch (error) { - console.error('获取网站信息失败:', error); + console.error('获取应用信息失败:', error); throw error; } finally { this.loading = false; } }, - + /** - * 更新网站信息 + * 更新应用信息 */ updateSiteInfo(siteInfo: Partial) { if (this.siteInfo) { @@ -133,7 +153,7 @@ export const useSiteStore = defineStore({ this.lastUpdateTime = Date.now(); } }, - + /** * 清除缓存 */ @@ -141,7 +161,7 @@ export const useSiteStore = defineStore({ this.siteInfo = null; this.lastUpdateTime = null; }, - + /** * 设置缓存有效期 */ diff --git a/src/views/bszx/dashboard/index.vue b/src/views/bszx/dashboard/index.vue index 0da5ca4..f3d5c91 100644 --- a/src/views/bszx/dashboard/index.vue +++ b/src/views/bszx/dashboard/index.vue @@ -11,20 +11,20 @@ :height="80" :preview="false" style="border-radius: 8px" - :src="siteStore.websiteLogo" + :src="siteStore.logo" fallback="/logo.png" />
-

{{ siteStore.websiteName }}

-

{{ siteStore.websiteComments }}

+

{{ siteStore.appName }}

+

{{ siteStore.description }}

- 版本 {{ systemInfo.version }} - {{ systemInfo.status }} + {{ siteStore.version }} + {{ siteStore.statusText }} diff --git a/src/views/cms/dashboard/index.vue b/src/views/cms/dashboard/index.vue index 86e77d0..e0ad79e 100644 --- a/src/views/cms/dashboard/index.vue +++ b/src/views/cms/dashboard/index.vue @@ -11,20 +11,20 @@ :height="80" :preview="false" style="border-radius: 8px" - :src="siteStore.websiteLogo" + :src="siteStore.logo" fallback="/logo.png" />
-

{{ siteStore.websiteName }}

-

{{ siteStore.websiteComments }}

+

{{ siteStore.appName }}

+

{{ siteStore.description }}

- 版本 {{ systemInfo.version }} - {{ systemInfo.status }} + {{ siteStore.version }} + {{ siteStore.statusText }}