chore(config): 初始化项目配置文件
- 添加 .editorconfig 文件统一代码风格 - 配置 .env.development 环境变量文件 - 创建 .env.example 环境变量示例文件 - 设置 .eslintignore 忽略检查规则 - 配置 .eslintrc.js 代码检查规则 - 添加 .gitignore 文件忽略版本控制 - 设置 .prettierignore 忽略格式化规则 - 新增隐私政策HTML页面文件 - 创建API密钥编辑组件基础结构
This commit is contained in:
101
src/composables/useSiteData.ts
Normal file
101
src/composables/useSiteData.ts
Normal file
@@ -0,0 +1,101 @@
|
||||
/**
|
||||
* 网站数据组合式函数
|
||||
* 提供统一的网站信息和统计数据访问接口
|
||||
*/
|
||||
import { computed } from 'vue';
|
||||
import { useSiteStore } from '@/store/modules/site';
|
||||
import { useStatisticsStore } from '@/store/modules/statistics';
|
||||
|
||||
export function useSiteData() {
|
||||
const siteStore = useSiteStore();
|
||||
const statisticsStore = useStatisticsStore();
|
||||
|
||||
// 网站信息相关
|
||||
const siteInfo = computed(() => siteStore.siteInfo);
|
||||
const websiteName = computed(() => siteStore.appName);
|
||||
const websiteLogo = computed(() => siteStore.logo);
|
||||
const websiteComments = computed(() => siteStore.description);
|
||||
const websiteDarkLogo = computed(() => siteStore.logo);
|
||||
const websiteDomain = computed(() => siteStore.domain);
|
||||
const websiteId = computed(() => siteStore.appId);
|
||||
const runDays = computed(() => siteStore.runDays);
|
||||
const siteLoading = computed(() => siteStore.loading);
|
||||
|
||||
// 统计数据相关
|
||||
const statistics = computed(() => statisticsStore.statistics);
|
||||
const userCount = computed(() => statisticsStore.userCount);
|
||||
const orderCount = computed(() => statisticsStore.orderCount);
|
||||
const totalSales = computed(() => statisticsStore.totalSales);
|
||||
const todaySales = computed(() => statisticsStore.todaySales);
|
||||
const monthSales = computed(() => statisticsStore.monthSales);
|
||||
const todayOrders = computed(() => statisticsStore.todayOrders);
|
||||
const todayUsers = computed(() => statisticsStore.todayUsers);
|
||||
const statisticsLoading = computed(() => statisticsStore.loading);
|
||||
|
||||
// 整体加载状态
|
||||
const loading = computed(() => siteLoading.value || statisticsLoading.value);
|
||||
|
||||
// 方法
|
||||
const fetchSiteInfo = (forceRefresh = false) => {
|
||||
return siteStore.fetchSiteInfo(forceRefresh);
|
||||
};
|
||||
|
||||
const fetchStatistics = (forceRefresh = false) => {
|
||||
return statisticsStore.fetchStatistics(forceRefresh);
|
||||
};
|
||||
|
||||
const refreshAll = async (forceRefresh = true) => {
|
||||
await Promise.all([
|
||||
fetchSiteInfo(forceRefresh),
|
||||
fetchStatistics(forceRefresh)
|
||||
]);
|
||||
};
|
||||
|
||||
const startAutoRefresh = (interval?: number) => {
|
||||
statisticsStore.startAutoRefresh(interval);
|
||||
};
|
||||
|
||||
const stopAutoRefresh = () => {
|
||||
statisticsStore.stopAutoRefresh();
|
||||
};
|
||||
|
||||
const clearCache = () => {
|
||||
siteStore.clearCache();
|
||||
statisticsStore.clearCache();
|
||||
};
|
||||
|
||||
return {
|
||||
// 网站信息
|
||||
siteInfo,
|
||||
websiteName,
|
||||
websiteLogo,
|
||||
websiteComments,
|
||||
websiteDarkLogo,
|
||||
websiteDomain,
|
||||
websiteId,
|
||||
runDays,
|
||||
siteLoading,
|
||||
|
||||
// 统计数据
|
||||
statistics,
|
||||
userCount,
|
||||
orderCount,
|
||||
totalSales,
|
||||
todaySales,
|
||||
monthSales,
|
||||
todayOrders,
|
||||
todayUsers,
|
||||
statisticsLoading,
|
||||
|
||||
// 状态
|
||||
loading,
|
||||
|
||||
// 方法
|
||||
fetchSiteInfo,
|
||||
fetchStatistics,
|
||||
refreshAll,
|
||||
startAutoRefresh,
|
||||
stopAutoRefresh,
|
||||
clearCache
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user