feat:【代码优化】减少部分模块的 import * 的 API

This commit is contained in:
YunaiV
2025-10-27 09:34:45 +08:00
parent d2db16c8c6
commit 86c68b5466
35 changed files with 185 additions and 164 deletions

View File

@@ -7,10 +7,10 @@ import { onMounted, ref } from 'vue';
import { EchartsUI, useEcharts } from '@vben/plugins/echarts';
import { ElCard, ElRadio, ElRadioGroup } from 'element-plus';
import dayjs from 'dayjs';
import { ElCard, ElRadio, ElRadioGroup } from 'element-plus';
import * as MemberStatisticsApi from '#/api/mall/statistics/member';
import { getMemberRegisterCountList } from '#/api/mall/statistics/member';
import {
getMemberStatisticsChartOptions,
@@ -41,7 +41,7 @@ const timeRangeConfig = {
const timeRangeType = ref(TimeRangeTypeEnum.DAY30); // 日期快捷选择按钮, 默认 30 天
/** 时间范围类型单选按钮选中 */
const handleTimeRangeTypeChange = async () => {
async function handleTimeRangeTypeChange() {
// 设置时间范围
let beginTime: Dayjs;
let endTime: Dayjs;
@@ -71,13 +71,13 @@ const handleTimeRangeTypeChange = async () => {
}
}
// 发送时间范围选中事件
await getMemberRegisterCountList(beginTime, endTime);
};
await loadMemberRegisterCountList(beginTime, endTime);
}
async function getMemberRegisterCountList(beginTime: Dayjs, endTime: Dayjs) {
async function loadMemberRegisterCountList(beginTime: Dayjs, endTime: Dayjs) {
loading.value = true;
try {
const list = await MemberStatisticsApi.getMemberRegisterCountList(
const list = await getMemberRegisterCountList(
beginTime.toDate(),
endTime.toDate(),
);

View File

@@ -6,9 +6,9 @@ import { CountTo } from '@vben/common-ui';
import { ElCard } from 'element-plus';
import * as ProductSpuApi from '#/api/mall/product/spu';
import * as PayStatisticsApi from '#/api/mall/statistics/pay';
import * as TradeStatisticsApi from '#/api/mall/statistics/trade';
import { getTabsCount } from '#/api/mall/product/spu';
import { getWalletRechargePrice } from '#/api/mall/statistics/pay';
import { getOrderCount } from '#/api/mall/statistics/trade';
/** 运营数据卡片 */
defineOptions({ name: 'OperationDataCard' });
@@ -51,8 +51,8 @@ const data = reactive({
});
/** 查询订单数据 */
async function getOrderData() {
const orderCount = await TradeStatisticsApi.getOrderCount();
async function loadOrderData() {
const orderCount = await getOrderCount();
if (orderCount.undelivered) {
data.orderUndelivered.value = orderCount.undelivered;
}
@@ -68,16 +68,16 @@ async function getOrderData() {
}
/** 查询商品数据 */
async function getProductData() {
const productCount = await ProductSpuApi.getTabsCount();
async function loadProductData() {
const productCount = await getTabsCount();
data.productForSale.value = productCount['0'] || 0;
data.productInWarehouse.value = productCount['1'] || 0;
data.productAlertStock.value = productCount['3'] || 0;
}
/** 查询钱包充值数据 */
async function getWalletRechargeData() {
const paySummary = await PayStatisticsApi.getWalletRechargePrice();
async function loadWalletRechargeData() {
const paySummary = await getWalletRechargePrice();
data.rechargePrice.value = paySummary.rechargePrice;
}
@@ -88,9 +88,9 @@ function handleClick(routerName: string) {
/** 激活时 */
onActivated(() => {
getOrderData();
getProductData();
getWalletRechargeData();
loadOrderData();
loadProductData();
loadWalletRechargeData();
});
/** 初始化 */

View File

@@ -11,7 +11,7 @@ import { fenToYuan } from '@vben/utils';
import dayjs from 'dayjs';
import { ElCard, ElRadio, ElRadioGroup } from 'element-plus';
import * as TradeStatisticsApi from '#/api/mall/statistics/trade';
import { getOrderCountTrendComparison } from '#/api/mall/statistics/trade';
import {
getTradeTrendChartOptions,
@@ -76,15 +76,15 @@ async function handleTimeRangeTypeChange() {
}
}
// 发送时间范围选中事件
await getOrderCountTrendComparison(beginTime, endTime);
await loadOrderCountTrendComparison(beginTime, endTime);
}
/** 查询订单数量趋势对照数据 */
async function getOrderCountTrendComparison(beginTime: Dayjs, endTime: Dayjs) {
async function loadOrderCountTrendComparison(beginTime: Dayjs, endTime: Dayjs) {
loading.value = true;
try {
// 1. 查询数据
const list = await TradeStatisticsApi.getOrderCountTrendComparison(
const list = await getOrderCountTrendComparison(
timeRangeType.value,
beginTime.toDate(),
endTime.toDate(),