feat(site): 重构网站信息模块并添加应用信息相关功能

- 新增 AppInfo 接口,用于存储应用信息
- 修改 getSiteInfo API 调用路径
- 更新 site store 中的数据结构和相关方法,支持应用信息- 调整 dashboard 页面中显示的网站信息,改为应用信息
This commit is contained in:
2025-08-13 02:53:45 +08:00
parent 332982f31f
commit 3fc6d21c76
5 changed files with 99 additions and 51 deletions

View File

@@ -1,5 +1,6 @@
import type { PageParam } from '@/api'; import type { PageParam } from '@/api';
import {CmsWebsiteSetting} from "@/api/cms/cmsWebsiteSetting/model"; import {CmsWebsiteSetting} from "@/api/cms/cmsWebsiteSetting/model";
import {CmsNavigation} from "@/api/cms/cmsNavigation/model";
/** /**
* 网站信息记录表 * 网站信息记录表
@@ -121,6 +122,33 @@ export interface CmsWebsite {
setting?: CmsWebsiteSetting; 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;
}
/** /**
* 网站信息记录表搜索条件 * 网站信息记录表搜索条件
*/ */

View File

@@ -26,7 +26,7 @@ export async function getTenantInfo(): Promise<Company> {
*/ */
export async function getSiteInfo() { export async function getSiteInfo() {
const res = await request.get<ApiResult<CmsWebsite>>( const res = await request.get<ApiResult<CmsWebsite>>(
MODULES_API_URL + '/cms/cms-website/getSiteInfo', MODULES_API_URL + '/cms/getSiteInfo',
{ {
params: { params: {
lang: getLang() lang: getLang()

View File

@@ -1,13 +1,13 @@
/** /**
* 网站信息 store * 应用信息 store
*/ */
import { defineStore } from 'pinia'; import { defineStore } from 'pinia';
import { getSiteInfo } from '@/api/layout'; import { getSiteInfo } from '@/api/layout';
import { CmsWebsite } from '@/api/cms/cmsWebsite/model'; import {AppInfo, CmsWebsite} from '@/api/cms/cmsWebsite/model';
export interface SiteState { export interface SiteState {
// 网站信息 // 应用信息
siteInfo: CmsWebsite | null; siteInfo: AppInfo | null;
// 加载状态 // 加载状态
loading: boolean; loading: boolean;
// 最后更新时间 // 最后更新时间
@@ -25,50 +25,70 @@ export const useSiteStore = defineStore({
// 默认缓存30分钟 // 默认缓存30分钟
cacheExpiry: 30 * 60 * 1000 cacheExpiry: 30 * 60 * 1000
}), }),
getters: { getters: {
/** /**
* 获取网站名称 * 获取应用ID
*/ */
websiteName: (state): string => { appId: (state): number | undefined => {
return state.siteInfo?.websiteName || ''; return state.siteInfo?.appId;
}, },
/** /**
* 获取网站Logo * 获取应用名称
*/ */
websiteLogo: (state): string => { appName: (state): string => {
return state.siteInfo?.websiteLogo || '/logo.png'; return state.siteInfo?.appName || '';
}, },
/** /**
* 获取网站描述 * 获取应用Logo
*/ */
websiteComments: (state): string => { logo: (state): string => {
return state.siteInfo?.comments || ''; return state.siteInfo?.logo || '/logo.png';
}, },
/**
* 获取应用描述
*/
description: (state): string => {
return state.siteInfo?.description || '';
},
/** /**
* 获取小程序码 * 获取小程序码
*/ */
websiteDarkLogo: (state): string => { mpQrCode: (state): string => {
return state.siteInfo?.websiteDarkLogo || ''; return state.siteInfo?.mpQrCode || '';
}, },
/** /**
* 获取网站域名 * 获取应用域名
*/ */
websiteDomain: (state): string => { domain: (state): string => {
return state.siteInfo?.domain || ''; return state.siteInfo?.domain || '';
}, },
/** /**
* 获取网站ID * 获取应用版本
* @param state
*/ */
websiteId: (state): number | undefined => { version: (state): string => {
return state.siteInfo?.websiteId; 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(); const now = new Date().getTime();
return Math.floor((now - createTime) / (24 * 60 * 60 * 1000)); return Math.floor((now - createTime) / (24 * 60 * 60 * 1000));
}, },
/** /**
* 检查缓存是否有效 * 检查缓存是否有效
*/ */
@@ -88,10 +108,10 @@ export const useSiteStore = defineStore({
return (now - state.lastUpdateTime) < state.cacheExpiry; return (now - state.lastUpdateTime) < state.cacheExpiry;
} }
}, },
actions: { actions: {
/** /**
* 获取网站信息 * 获取应用信息
* @param forceRefresh 是否强制刷新 * @param forceRefresh 是否强制刷新
*/ */
async fetchSiteInfo(forceRefresh = false) { async fetchSiteInfo(forceRefresh = false) {
@@ -99,13 +119,13 @@ export const useSiteStore = defineStore({
if (!forceRefresh && this.isCacheValid && this.siteInfo) { if (!forceRefresh && this.isCacheValid && this.siteInfo) {
return this.siteInfo; return this.siteInfo;
} }
this.loading = true; this.loading = true;
try { try {
const data = await getSiteInfo(); const data = await getSiteInfo();
this.siteInfo = data; this.siteInfo = data;
this.lastUpdateTime = Date.now(); this.lastUpdateTime = Date.now();
// 更新localStorage中的相关信息 // 更新localStorage中的相关信息
if (data.websiteId) { if (data.websiteId) {
localStorage.setItem('WebsiteId', String(data.websiteId)); localStorage.setItem('WebsiteId', String(data.websiteId));
@@ -114,18 +134,18 @@ export const useSiteStore = defineStore({
localStorage.setItem('Domain', data.domain); localStorage.setItem('Domain', data.domain);
localStorage.setItem('SiteUrl', `${data.prefix || 'https://'}${data.domain}`); localStorage.setItem('SiteUrl', `${data.prefix || 'https://'}${data.domain}`);
} }
return data; return data;
} catch (error) { } catch (error) {
console.error('获取网站信息失败:', error); console.error('获取应用信息失败:', error);
throw error; throw error;
} finally { } finally {
this.loading = false; this.loading = false;
} }
}, },
/** /**
* 更新网站信息 * 更新应用信息
*/ */
updateSiteInfo(siteInfo: Partial<CmsWebsite>) { updateSiteInfo(siteInfo: Partial<CmsWebsite>) {
if (this.siteInfo) { if (this.siteInfo) {
@@ -133,7 +153,7 @@ export const useSiteStore = defineStore({
this.lastUpdateTime = Date.now(); this.lastUpdateTime = Date.now();
} }
}, },
/** /**
* 清除缓存 * 清除缓存
*/ */
@@ -141,7 +161,7 @@ export const useSiteStore = defineStore({
this.siteInfo = null; this.siteInfo = null;
this.lastUpdateTime = null; this.lastUpdateTime = null;
}, },
/** /**
* 设置缓存有效期 * 设置缓存有效期
*/ */

View File

@@ -11,20 +11,20 @@
:height="80" :height="80"
:preview="false" :preview="false"
style="border-radius: 8px" style="border-radius: 8px"
:src="siteStore.websiteLogo" :src="siteStore.logo"
fallback="/logo.png" fallback="/logo.png"
/> />
</a-col> </a-col>
<a-col :span="14"> <a-col :span="14">
<div class="system-info"> <div class="system-info">
<h2 class="ele-text-heading">{{ siteStore.websiteName }}</h2> <h2 class="ele-text-heading">{{ siteStore.appName }}</h2>
<p class="ele-text-secondary">{{ siteStore.websiteComments }}</p> <p class="ele-text-secondary">{{ siteStore.description }}</p>
<a-space> <a-space>
<a-tag color="blue">版本 {{ systemInfo.version }}</a-tag> <a-tag color="blue">{{ siteStore.version }}</a-tag>
<a-tag color="green">{{ systemInfo.status }}</a-tag> <a-tag color="green">{{ siteStore.statusText }}</a-tag>
<a-popover title="小程序码"> <a-popover title="小程序码">
<template #content> <template #content>
<p><img :src="siteStore.websiteDarkLogo" alt="小程序码" width="300" height="300"></p> <p><img :src="siteStore.mpQrCode" alt="小程序码" width="300" height="300"></p>
</template> </template>
<a-tag> <a-tag>
<QrcodeOutlined/> <QrcodeOutlined/>

View File

@@ -11,20 +11,20 @@
:height="80" :height="80"
:preview="false" :preview="false"
style="border-radius: 8px" style="border-radius: 8px"
:src="siteStore.websiteLogo" :src="siteStore.logo"
fallback="/logo.png" fallback="/logo.png"
/> />
</a-col> </a-col>
<a-col :span="14"> <a-col :span="14">
<div class="system-info"> <div class="system-info">
<h2 class="ele-text-heading">{{ siteStore.websiteName }}</h2> <h2 class="ele-text-heading">{{ siteStore.appName }}</h2>
<p class="ele-text-secondary">{{ siteStore.websiteComments }}</p> <p class="ele-text-secondary">{{ siteStore.description }}</p>
<a-space> <a-space>
<a-tag color="blue">版本 {{ systemInfo.version }}</a-tag> <a-tag color="blue">{{ siteStore.version }}</a-tag>
<a-tag color="green">{{ systemInfo.status }}</a-tag> <a-tag color="green">{{ siteStore.statusText }}</a-tag>
<a-popover title="小程序码"> <a-popover title="小程序码">
<template #content> <template #content>
<p><img :src="siteStore.websiteDarkLogo" alt="小程序码" width="300" height="300"></p> <p><img :src="siteStore.mpQrCode" alt="小程序码" width="300" height="300"></p>
</template> </template>
<a-tag> <a-tag>
<QrcodeOutlined/> <QrcodeOutlined/>