bug修复
This commit is contained in:
1 parent
ec4ca451bb
commit
ab0245b9a3
24 files changed
+468
-3
No files matched your search
@@ -0,0 +1,19 @@
|
|||||||
|
package com.shoplix.admin.controller;
|
||||||
|
|
||||||
|
import com.shoplix.admin.facade.AdminDashboardFacade;
|
||||||
|
import com.shoplix.admin.modules.dashboard.req.DashboardOverviewAdminReq;
|
||||||
|
import com.shoplix.admin.modules.dashboard.res.DashboardOverviewAdminRes;
|
||||||
|
import jakarta.validation.Valid;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
/** 运营后台首页数据看板接口。 */
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/api/admin/v1/dashboard")
|
||||||
|
public class AdminDashboardController {
|
||||||
|
private final AdminDashboardFacade facade;
|
||||||
|
/** 注入数据看板 Facade。 */ public AdminDashboardController(AdminDashboardFacade facade) { this.facade = facade; }
|
||||||
|
/** 查询当前站点整体运营概览。 */ @PostMapping("/overview") public DashboardOverviewAdminRes overview(@Valid @RequestBody DashboardOverviewAdminReq request) { return facade.overview(request); }
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package com.shoplix.admin.facade;
|
||||||
|
|
||||||
|
import com.shoplix.admin.modules.dashboard.req.DashboardOverviewAdminReq;
|
||||||
|
import com.shoplix.admin.modules.dashboard.res.DashboardOverviewAdminRes;
|
||||||
|
import com.shoplix.admin.service.AdminDashboardService;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/** 运营后台数据看板统一出口。 */
|
||||||
|
@Component
|
||||||
|
public class AdminDashboardFacade {
|
||||||
|
private final AdminDashboardService service;
|
||||||
|
/** 注入数据看板业务。 */ public AdminDashboardFacade(AdminDashboardService service) { this.service = service; }
|
||||||
|
/** 查询首页概览。 */ public DashboardOverviewAdminRes overview(DashboardOverviewAdminReq request) { return service.overview(request.siteCode()); }
|
||||||
|
}
|
||||||
+9
@@ -0,0 +1,9 @@
|
|||||||
|
package com.shoplix.admin.modules.dashboard.req;
|
||||||
|
|
||||||
|
import jakarta.validation.constraints.NotBlank;
|
||||||
|
import jakarta.validation.constraints.Size;
|
||||||
|
|
||||||
|
/** 后台首页概览查询请求。 */
|
||||||
|
public record DashboardOverviewAdminReq(
|
||||||
|
/** 站点业务编号。 */ @NotBlank @Size(max = 16) String siteCode) {
|
||||||
|
}
|
||||||
+9
@@ -0,0 +1,9 @@
|
|||||||
|
package com.shoplix.admin.modules.dashboard.res;
|
||||||
|
|
||||||
|
/** 看板内容发布统计。 */
|
||||||
|
public record DashboardContentStatAdminRes(
|
||||||
|
/** 内容类型编码。 */ String type,
|
||||||
|
/** 中文类型名称。 */ String label,
|
||||||
|
/** 全部内容数量。 */ long total,
|
||||||
|
/** 已发布内容数量。 */ long published) {
|
||||||
|
}
|
||||||
+7
@@ -0,0 +1,7 @@
|
|||||||
|
package com.shoplix.admin.modules.dashboard.res;
|
||||||
|
|
||||||
|
/** 看板设备访问分布。 */
|
||||||
|
public record DashboardDeviceAdminRes(
|
||||||
|
/** 设备类型编码。 */ String device,
|
||||||
|
/** 页面浏览次数。 */ long pageViews) {
|
||||||
|
}
|
||||||
+13
@@ -0,0 +1,13 @@
|
|||||||
|
package com.shoplix.admin.modules.dashboard.res;
|
||||||
|
|
||||||
|
/** 看板最近询盘摘要。 */
|
||||||
|
public record DashboardInquiryAdminRes(
|
||||||
|
/** 询盘业务编号。 */ String inquiryCode,
|
||||||
|
/** 客户姓名。 */ String customerName,
|
||||||
|
/** 公司名称。 */ String companyName,
|
||||||
|
/** 国家或地区名称。 */ String countryName,
|
||||||
|
/** 来源产品名称。 */ String productName,
|
||||||
|
/** 询盘状态值。 */ String status,
|
||||||
|
/** 询盘状态文案。 */ String statusLabel,
|
||||||
|
/** 创建毫秒时间戳。 */ Long createTime) {
|
||||||
|
}
|
||||||
+23
@@ -0,0 +1,23 @@
|
|||||||
|
package com.shoplix.admin.modules.dashboard.res;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/** 后台首页完整概览响应。 */
|
||||||
|
public record DashboardOverviewAdminRes(
|
||||||
|
/** 数据生成毫秒时间戳。 */ long generatedAt,
|
||||||
|
/** 今日页面浏览次数。 */ long todayPageViews,
|
||||||
|
/** 今日独立访客数量。 */ long todayVisitors,
|
||||||
|
/** 最近30天页面浏览次数。 */ long pageViews30Days,
|
||||||
|
/** 最近30天独立访客数量。 */ long visitors30Days,
|
||||||
|
/** 最近30天会话数量。 */ long sessions30Days,
|
||||||
|
/** 最近30天平均页面停留秒数。 */ long averageDurationSeconds,
|
||||||
|
/** 最近30天有效询盘数量。 */ long inquiries30Days,
|
||||||
|
/** 当前未读有效询盘数量。 */ long unreadInquiries,
|
||||||
|
/** 最近30天访客询盘转化率,单位百分比。 */ BigDecimal inquiryConversionRate,
|
||||||
|
/** 产品及内容发布统计。 */ List<DashboardContentStatAdminRes> contentStats,
|
||||||
|
/** 最近14天访问趋势。 */ List<DashboardTrendAdminRes> trafficTrend,
|
||||||
|
/** 最近30天热门页面。 */ List<DashboardTopPageAdminRes> topPages,
|
||||||
|
/** 最近30天设备分布。 */ List<DashboardDeviceAdminRes> devices,
|
||||||
|
/** 最近有效询盘。 */ List<DashboardInquiryAdminRes> recentInquiries) {
|
||||||
|
}
|
||||||
+9
@@ -0,0 +1,9 @@
|
|||||||
|
package com.shoplix.admin.modules.dashboard.res;
|
||||||
|
|
||||||
|
/** 看板热门页面。 */
|
||||||
|
public record DashboardTopPageAdminRes(
|
||||||
|
/** 页面路径。 */ String path,
|
||||||
|
/** 页面标题。 */ String title,
|
||||||
|
/** 页面浏览次数。 */ long pageViews,
|
||||||
|
/** 独立访客数量。 */ long visitors) {
|
||||||
|
}
|
||||||
+8
@@ -0,0 +1,8 @@
|
|||||||
|
package com.shoplix.admin.modules.dashboard.res;
|
||||||
|
|
||||||
|
/** 看板每日访问趋势。 */
|
||||||
|
public record DashboardTrendAdminRes(
|
||||||
|
/** 日期,格式yyyy-MM-dd。 */ String date,
|
||||||
|
/** 页面浏览次数。 */ long pageViews,
|
||||||
|
/** 独立访客数量。 */ long visitors) {
|
||||||
|
}
|
||||||
@@ -0,0 +1,96 @@
|
|||||||
|
package com.shoplix.admin.service;
|
||||||
|
|
||||||
|
import com.shoplix.admin.modules.dashboard.res.DashboardContentStatAdminRes;
|
||||||
|
import com.shoplix.admin.modules.dashboard.res.DashboardDeviceAdminRes;
|
||||||
|
import com.shoplix.admin.modules.dashboard.res.DashboardInquiryAdminRes;
|
||||||
|
import com.shoplix.admin.modules.dashboard.res.DashboardOverviewAdminRes;
|
||||||
|
import com.shoplix.admin.modules.dashboard.res.DashboardTopPageAdminRes;
|
||||||
|
import com.shoplix.admin.modules.dashboard.res.DashboardTrendAdminRes;
|
||||||
|
import com.shoplix.modules.analytics.dto.FlowSummaryDto;
|
||||||
|
import com.shoplix.modules.analytics.dto.FlowTrendDto;
|
||||||
|
import com.shoplix.modules.analytics.repository.service.FlowLogRepositoryService;
|
||||||
|
import com.shoplix.modules.common.enums.PublishStatusEnum;
|
||||||
|
import com.shoplix.modules.content.repository.service.ContentRepositoryService;
|
||||||
|
import com.shoplix.modules.inquiry.enums.InquiryStatusEnum;
|
||||||
|
import com.shoplix.modules.inquiry.repository.service.InquiryRecordRepositoryService;
|
||||||
|
import com.shoplix.modules.product.repository.service.ProductRepositoryService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.math.RoundingMode;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.ZoneId;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.function.Function;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/** 运营后台首页数据看板业务。 */
|
||||||
|
@Service
|
||||||
|
public class AdminDashboardService {
|
||||||
|
private static final ZoneId BUSINESS_ZONE = ZoneId.of("Asia/Shanghai");
|
||||||
|
private static final DateTimeFormatter DATE_KEY_FORMAT = DateTimeFormatter.BASIC_ISO_DATE;
|
||||||
|
private static final DateTimeFormatter DISPLAY_DATE_FORMAT = DateTimeFormatter.ISO_LOCAL_DATE;
|
||||||
|
private final FlowLogRepositoryService flowLogs;
|
||||||
|
private final ProductRepositoryService products;
|
||||||
|
private final ContentRepositoryService contents;
|
||||||
|
private final InquiryRecordRepositoryService inquiries;
|
||||||
|
|
||||||
|
/** 注入看板数据源。 */
|
||||||
|
public AdminDashboardService(FlowLogRepositoryService flowLogs, ProductRepositoryService products,
|
||||||
|
ContentRepositoryService contents, InquiryRecordRepositoryService inquiries) {
|
||||||
|
this.flowLogs = flowLogs;
|
||||||
|
this.products = products;
|
||||||
|
this.contents = contents;
|
||||||
|
this.inquiries = inquiries;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 查询站点首页完整概览。 */
|
||||||
|
public DashboardOverviewAdminRes overview(String siteCode) {
|
||||||
|
LocalDate today = LocalDate.now(BUSINESS_ZONE);
|
||||||
|
FlowSummaryDto todayFlow = flowLogs.summary(siteCode, dateKey(today));
|
||||||
|
FlowSummaryDto monthFlow = flowLogs.summary(siteCode, dateKey(today.minusDays(29)));
|
||||||
|
long inquiryCount = inquiries.countSince(siteCode, today.minusDays(29).atStartOfDay(BUSINESS_ZONE).toInstant().toEpochMilli());
|
||||||
|
BigDecimal conversionRate = monthFlow.getVisitors() == null || monthFlow.getVisitors() == 0 ? BigDecimal.ZERO
|
||||||
|
: BigDecimal.valueOf(inquiryCount * 100D / monthFlow.getVisitors()).setScale(2, RoundingMode.HALF_UP);
|
||||||
|
List<DashboardTrendAdminRes> trend = trafficTrend(siteCode, today);
|
||||||
|
return new DashboardOverviewAdminRes(System.currentTimeMillis(), value(todayFlow.getPageViews()),
|
||||||
|
value(todayFlow.getVisitors()), value(monthFlow.getPageViews()), value(monthFlow.getVisitors()),
|
||||||
|
value(monthFlow.getSessions()), value(monthFlow.getAverageDuration()), inquiryCount,
|
||||||
|
inquiries.countUnread(siteCode), conversionRate, contentStats(siteCode), trend,
|
||||||
|
flowLogs.topPages(siteCode, dateKey(today.minusDays(29))).stream()
|
||||||
|
.map(item -> new DashboardTopPageAdminRes(item.getPath(), item.getTitle(), value(item.getPageViews()), value(item.getVisitors()))).toList(),
|
||||||
|
flowLogs.devices(siteCode, dateKey(today.minusDays(29))).stream()
|
||||||
|
.map(item -> new DashboardDeviceAdminRes(item.getDevice(), value(item.getPageViews()))).toList(),
|
||||||
|
inquiries.recent(siteCode, 6).stream().map(item -> {
|
||||||
|
InquiryStatusEnum status = InquiryStatusEnum.valueOf(item.getStatus());
|
||||||
|
return new DashboardInquiryAdminRes(item.getInquiryCode(), item.getCustomerName(), item.getCompanyName(),
|
||||||
|
item.getCountryName(), item.getProductNameSnapshot(), status.name(), status.getLabel(), item.getCreateTime());
|
||||||
|
}).toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 统计产品、新闻、案例和帮助的发布数量。 */
|
||||||
|
private List<DashboardContentStatAdminRes> contentStats(String siteCode) {
|
||||||
|
String published = PublishStatusEnum.PUBLISHED.name();
|
||||||
|
return List.of(new DashboardContentStatAdminRes("PRODUCT", "产品", products.count(siteCode), products.countByStatus(siteCode, published)),
|
||||||
|
new DashboardContentStatAdminRes("NEWS", "新闻", contents.count(siteCode, "NEWS"), contents.countByStatus(siteCode, "NEWS", published)),
|
||||||
|
new DashboardContentStatAdminRes("CASE", "案例", contents.count(siteCode, "CASE"), contents.countByStatus(siteCode, "CASE", published)),
|
||||||
|
new DashboardContentStatAdminRes("HELP", "帮助", contents.count(siteCode, "HELP"), contents.countByStatus(siteCode, "HELP", published)));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 查询并补齐最近十四天访问趋势中的无数据日期。 */
|
||||||
|
private List<DashboardTrendAdminRes> trafficTrend(String siteCode, LocalDate today) {
|
||||||
|
Map<Integer, FlowTrendDto> values = flowLogs
|
||||||
|
.trend(siteCode, dateKey(today.minusDays(13))).stream()
|
||||||
|
.collect(Collectors.toMap(item -> item.getDate(), Function.identity()));
|
||||||
|
return today.minusDays(13).datesUntil(today.plusDays(1)).map(date -> {
|
||||||
|
FlowTrendDto item = values.get(dateKey(date));
|
||||||
|
return new DashboardTrendAdminRes(date.format(DISPLAY_DATE_FORMAT),
|
||||||
|
item == null ? 0L : value(item.getPageViews()), item == null ? 0L : value(item.getVisitors()));
|
||||||
|
}).toList();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 将业务日期转换为数据库日期键。 */ private int dateKey(LocalDate date) { return Integer.parseInt(date.format(DATE_KEY_FORMAT)); }
|
||||||
|
/** 将可空统计值转换为零。 */ private long value(Long value) { return value == null ? 0L : value; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,78 @@
|
|||||||
|
package com.shoplix.admin.service;
|
||||||
|
|
||||||
|
import com.shoplix.admin.modules.dashboard.res.DashboardOverviewAdminRes;
|
||||||
|
import com.shoplix.modules.analytics.dto.FlowSummaryDto;
|
||||||
|
import com.shoplix.modules.analytics.repository.service.FlowLogRepositoryService;
|
||||||
|
import com.shoplix.modules.content.repository.service.ContentRepositoryService;
|
||||||
|
import com.shoplix.modules.inquiry.repository.service.InquiryRecordRepositoryService;
|
||||||
|
import com.shoplix.modules.product.repository.service.ProductRepositoryService;
|
||||||
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.junit.jupiter.api.extension.ExtendWith;
|
||||||
|
import org.mockito.InjectMocks;
|
||||||
|
import org.mockito.Mock;
|
||||||
|
import org.mockito.junit.jupiter.MockitoExtension;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.mockito.ArgumentMatchers.anyInt;
|
||||||
|
import static org.mockito.ArgumentMatchers.anyLong;
|
||||||
|
import static org.mockito.ArgumentMatchers.eq;
|
||||||
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
/** 运营后台首页数据看板业务测试。 */
|
||||||
|
@ExtendWith(MockitoExtension.class)
|
||||||
|
class AdminDashboardServiceTest {
|
||||||
|
private static final String SITE_CODE = "SIT0000000000001";
|
||||||
|
@Mock private FlowLogRepositoryService flowLogs;
|
||||||
|
@Mock private ProductRepositoryService products;
|
||||||
|
@Mock private ContentRepositoryService contents;
|
||||||
|
@Mock private InquiryRecordRepositoryService inquiries;
|
||||||
|
@InjectMocks private AdminDashboardService service;
|
||||||
|
|
||||||
|
/** 初始化看板通用空列表数据。 */
|
||||||
|
@BeforeEach
|
||||||
|
void setUp() {
|
||||||
|
when(flowLogs.trend(eq(SITE_CODE), anyInt())).thenReturn(List.of());
|
||||||
|
when(flowLogs.topPages(eq(SITE_CODE), anyInt())).thenReturn(List.of());
|
||||||
|
when(flowLogs.devices(eq(SITE_CODE), anyInt())).thenReturn(List.of());
|
||||||
|
when(inquiries.recent(SITE_CODE, 6)).thenReturn(List.of());
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 验证访问、询盘转化率和内容发布数量的聚合结果。 */
|
||||||
|
@Test
|
||||||
|
void shouldAggregateDashboardOverview() {
|
||||||
|
FlowSummaryDto today = summary(12L, 8L, 9L, 41L);
|
||||||
|
FlowSummaryDto month = summary(300L, 80L, 120L, 52L);
|
||||||
|
when(flowLogs.summary(eq(SITE_CODE), anyInt())).thenReturn(today, month);
|
||||||
|
when(inquiries.countSince(eq(SITE_CODE), anyLong())).thenReturn(4L);
|
||||||
|
when(inquiries.countUnread(SITE_CODE)).thenReturn(2L);
|
||||||
|
when(products.count(SITE_CODE)).thenReturn(5L);
|
||||||
|
when(products.countByStatus(SITE_CODE, "PUBLISHED")).thenReturn(3L);
|
||||||
|
when(contents.count(SITE_CODE, "NEWS")).thenReturn(7L);
|
||||||
|
when(contents.countByStatus(SITE_CODE, "NEWS", "PUBLISHED")).thenReturn(6L);
|
||||||
|
|
||||||
|
DashboardOverviewAdminRes result = service.overview(SITE_CODE);
|
||||||
|
|
||||||
|
assertEquals(12L, result.todayPageViews());
|
||||||
|
assertEquals(300L, result.pageViews30Days());
|
||||||
|
assertEquals(4L, result.inquiries30Days());
|
||||||
|
assertEquals(new BigDecimal("5.00"), result.inquiryConversionRate());
|
||||||
|
assertEquals(4, result.contentStats().size());
|
||||||
|
assertEquals(3L, result.contentStats().getFirst().published());
|
||||||
|
assertEquals(6L, result.contentStats().get(1).published());
|
||||||
|
assertEquals(14, result.trafficTrend().size());
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 创建访问统计测试数据。 */
|
||||||
|
private FlowSummaryDto summary(long pageViews, long visitors, long sessions, long averageDuration) {
|
||||||
|
FlowSummaryDto value = new FlowSummaryDto();
|
||||||
|
value.setPageViews(pageViews);
|
||||||
|
value.setVisitors(visitors);
|
||||||
|
value.setSessions(sessions);
|
||||||
|
value.setAverageDuration(averageDuration);
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package com.shoplix.modules.analytics.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/** 访问设备分布数据。 */
|
||||||
|
@Data
|
||||||
|
public class FlowDeviceDto {
|
||||||
|
/** 设备类型。 */ private String device;
|
||||||
|
/** 页面浏览次数。 */ private Long pageViews;
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package com.shoplix.modules.analytics.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/** 热门页面访问数据。 */
|
||||||
|
@Data
|
||||||
|
public class FlowPageDto {
|
||||||
|
/** 页面路径。 */ private String path;
|
||||||
|
/** 页面标题。 */ private String title;
|
||||||
|
/** 页面浏览次数。 */ private Long pageViews;
|
||||||
|
/** 独立访客数量。 */ private Long visitors;
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package com.shoplix.modules.analytics.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/** 访问流量汇总数据。 */
|
||||||
|
@Data
|
||||||
|
public class FlowSummaryDto {
|
||||||
|
/** 页面浏览次数。 */ private Long pageViews;
|
||||||
|
/** 独立访客数量。 */ private Long visitors;
|
||||||
|
/** 独立会话数量。 */ private Long sessions;
|
||||||
|
/** 平均页面停留秒数。 */ private Long averageDuration;
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
package com.shoplix.modules.analytics.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/** 每日访问趋势数据。 */
|
||||||
|
@Data
|
||||||
|
public class FlowTrendDto {
|
||||||
|
/** 日期,格式yyyyMMdd。 */ private Integer date;
|
||||||
|
/** 页面浏览次数。 */ private Long pageViews;
|
||||||
|
/** 独立访客数量。 */ private Long visitors;
|
||||||
|
}
|
||||||
+46
@@ -1,10 +1,56 @@
|
|||||||
package com.shoplix.modules.analytics.repository.mapper;
|
package com.shoplix.modules.analytics.repository.mapper;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.shoplix.modules.analytics.dto.FlowDeviceDto;
|
||||||
|
import com.shoplix.modules.analytics.dto.FlowPageDto;
|
||||||
|
import com.shoplix.modules.analytics.dto.FlowSummaryDto;
|
||||||
|
import com.shoplix.modules.analytics.dto.FlowTrendDto;
|
||||||
import com.shoplix.modules.analytics.repository.entity.FlowLogEntity;
|
import com.shoplix.modules.analytics.repository.entity.FlowLogEntity;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
import org.apache.ibatis.annotations.Select;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/** 前台访问打点Mapper。 */
|
/** 前台访问打点Mapper。 */
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface FlowLogMapper extends BaseMapper<FlowLogEntity> {
|
public interface FlowLogMapper extends BaseMapper<FlowLogEntity> {
|
||||||
|
/** 汇总指定日期范围的访问数据。 */
|
||||||
|
@Select("""
|
||||||
|
SELECT COALESCE(SUM(event_name = 'page_view'), 0) AS pageViews,
|
||||||
|
COUNT(DISTINCT CASE WHEN event_name = 'page_view' THEN cuid END) AS visitors,
|
||||||
|
COUNT(DISTINCT CASE WHEN event_name = 'page_view' THEN session_code END) AS sessions,
|
||||||
|
COALESCE(ROUND(AVG(CASE WHEN event_name = 'page_leave' AND duration >= 0 THEN duration END)), 0) AS averageDuration
|
||||||
|
FROM flow_log WHERE site_code = #{siteCode} AND deleted = 0 AND dt >= #{startDate}
|
||||||
|
""")
|
||||||
|
FlowSummaryDto summary(@Param("siteCode") String siteCode, @Param("startDate") Integer startDate);
|
||||||
|
|
||||||
|
/** 查询指定日期范围的每日访问趋势。 */
|
||||||
|
@Select("""
|
||||||
|
SELECT dt AS date, COUNT(*) AS pageViews, COUNT(DISTINCT cuid) AS visitors
|
||||||
|
FROM flow_log WHERE site_code = #{siteCode} AND deleted = 0
|
||||||
|
AND event_name = 'page_view' AND dt >= #{startDate}
|
||||||
|
GROUP BY dt ORDER BY dt
|
||||||
|
""")
|
||||||
|
List<FlowTrendDto> trend(@Param("siteCode") String siteCode, @Param("startDate") Integer startDate);
|
||||||
|
|
||||||
|
/** 查询指定日期范围的热门页面。 */
|
||||||
|
@Select("""
|
||||||
|
SELECT COALESCE(NULLIF(url_body, ''), '/') AS path,
|
||||||
|
MAX(COALESCE(NULLIF(page_title, ''), NULLIF(page_name, ''), '未命名页面')) AS title,
|
||||||
|
COUNT(*) AS pageViews, COUNT(DISTINCT cuid) AS visitors
|
||||||
|
FROM flow_log WHERE site_code = #{siteCode} AND deleted = 0
|
||||||
|
AND event_name = 'page_view' AND dt >= #{startDate}
|
||||||
|
GROUP BY COALESCE(NULLIF(url_body, ''), '/') ORDER BY pageViews DESC LIMIT 8
|
||||||
|
""")
|
||||||
|
List<FlowPageDto> topPages(@Param("siteCode") String siteCode, @Param("startDate") Integer startDate);
|
||||||
|
|
||||||
|
/** 查询指定日期范围的设备分布。 */
|
||||||
|
@Select("""
|
||||||
|
SELECT COALESCE(NULLIF(device, ''), 'UNKNOWN') AS device, COUNT(*) AS pageViews
|
||||||
|
FROM flow_log WHERE site_code = #{siteCode} AND deleted = 0
|
||||||
|
AND event_name = 'page_view' AND dt >= #{startDate}
|
||||||
|
GROUP BY COALESCE(NULLIF(device, ''), 'UNKNOWN') ORDER BY pageViews DESC
|
||||||
|
""")
|
||||||
|
List<FlowDeviceDto> devices(@Param("siteCode") String siteCode, @Param("startDate") Integer startDate);
|
||||||
}
|
}
|
||||||
+11
@@ -1,9 +1,15 @@
|
|||||||
package com.shoplix.modules.analytics.repository.service;
|
package com.shoplix.modules.analytics.repository.service;
|
||||||
|
|
||||||
|
import com.shoplix.modules.analytics.dto.FlowDeviceDto;
|
||||||
|
import com.shoplix.modules.analytics.dto.FlowPageDto;
|
||||||
|
import com.shoplix.modules.analytics.dto.FlowSummaryDto;
|
||||||
|
import com.shoplix.modules.analytics.dto.FlowTrendDto;
|
||||||
import com.shoplix.modules.analytics.repository.entity.FlowLogEntity;
|
import com.shoplix.modules.analytics.repository.entity.FlowLogEntity;
|
||||||
import com.shoplix.modules.analytics.repository.mapper.FlowLogMapper;
|
import com.shoplix.modules.analytics.repository.mapper.FlowLogMapper;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/** 前台访问打点单表数据源服务。 */
|
/** 前台访问打点单表数据源服务。 */
|
||||||
@Service
|
@Service
|
||||||
public class FlowLogRepositoryService {
|
public class FlowLogRepositoryService {
|
||||||
@@ -19,4 +25,9 @@ public class FlowLogRepositoryService {
|
|||||||
public int insert(FlowLogEntity entity) {
|
public int insert(FlowLogEntity entity) {
|
||||||
return mapper.insert(entity);
|
return mapper.insert(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 汇总指定日期范围的访问数据。 */ public FlowSummaryDto summary(String siteCode, Integer startDate) { return mapper.summary(siteCode, startDate); }
|
||||||
|
/** 查询每日访问趋势。 */ public List<FlowTrendDto> trend(String siteCode, Integer startDate) { return mapper.trend(siteCode, startDate); }
|
||||||
|
/** 查询热门页面。 */ public List<FlowPageDto> topPages(String siteCode, Integer startDate) { return mapper.topPages(siteCode, startDate); }
|
||||||
|
/** 查询设备分布。 */ public List<FlowDeviceDto> devices(String siteCode, Integer startDate) { return mapper.devices(siteCode, startDate); }
|
||||||
}
|
}
|
||||||
+2
@@ -32,6 +32,8 @@ public class ContentRepositoryService {
|
|||||||
.eq(ContentEntity::getContentType, type).orderByDesc(ContentEntity::getPublishTime)
|
.eq(ContentEntity::getContentType, type).orderByDesc(ContentEntity::getPublishTime)
|
||||||
.orderByDesc(ContentEntity::getUpdateTime));
|
.orderByDesc(ContentEntity::getUpdateTime));
|
||||||
}
|
}
|
||||||
|
/** 统计站点指定类型的全部未删除内容。 */ public long count(String siteCode, String type) { return mapper.selectCount(Wrappers.<ContentEntity>lambdaQuery().eq(ContentEntity::getSiteCode, siteCode).eq(ContentEntity::getDeleted, 0).eq(ContentEntity::getContentType, type)); }
|
||||||
|
/** 统计站点指定类型及发布状态的内容。 */ public long countByStatus(String siteCode, String type, String status) { return mapper.selectCount(Wrappers.<ContentEntity>lambdaQuery().eq(ContentEntity::getSiteCode, siteCode).eq(ContentEntity::getDeleted, 0).eq(ContentEntity::getContentType, type).eq(ContentEntity::getStatus, status)); }
|
||||||
/** 查询站点指定类型的已发布内容列表。 */
|
/** 查询站点指定类型的已发布内容列表。 */
|
||||||
public List<ContentEntity> listPublished(String siteCode, String type) {
|
public List<ContentEntity> listPublished(String siteCode, String type) {
|
||||||
return mapper.selectList(Wrappers.<ContentEntity>lambdaQuery().eq(ContentEntity::getSiteCode, siteCode)
|
return mapper.selectList(Wrappers.<ContentEntity>lambdaQuery().eq(ContentEntity::getSiteCode, siteCode)
|
||||||
|
|||||||
+3
@@ -5,6 +5,9 @@ public class InquiryRecordRepositoryService {
|
|||||||
private final InquiryRecordMapper mapper; /** 注入Mapper。 */ public InquiryRecordRepositoryService(InquiryRecordMapper mapper){this.mapper=mapper;}
|
private final InquiryRecordMapper mapper; /** 注入Mapper。 */ public InquiryRecordRepositoryService(InquiryRecordMapper mapper){this.mapper=mapper;}
|
||||||
/** 新增询盘。 */ public int insert(InquiryRecordEntity e){return mapper.insert(e);}
|
/** 新增询盘。 */ public int insert(InquiryRecordEntity e){return mapper.insert(e);}
|
||||||
/** 查询后台询盘列表。 */ public List<InquiryRecordEntity> list(String site,String status){var q=Wrappers.<InquiryRecordEntity>lambdaQuery().eq(InquiryRecordEntity::getSiteCode,site);if(status!=null&&!status.isBlank())q.eq(InquiryRecordEntity::getStatus,status);return mapper.selectList(q.orderByDesc(InquiryRecordEntity::getCreateTime).last("LIMIT 500"));}
|
/** 查询后台询盘列表。 */ public List<InquiryRecordEntity> list(String site,String status){var q=Wrappers.<InquiryRecordEntity>lambdaQuery().eq(InquiryRecordEntity::getSiteCode,site);if(status!=null&&!status.isBlank())q.eq(InquiryRecordEntity::getStatus,status);return mapper.selectList(q.orderByDesc(InquiryRecordEntity::getCreateTime).last("LIMIT 500"));}
|
||||||
|
/** 统计站点指定时间后的有效询盘。 */ public long countSince(String site,Long start){return mapper.selectCount(Wrappers.<InquiryRecordEntity>lambdaQuery().eq(InquiryRecordEntity::getSiteCode,site).eq(InquiryRecordEntity::getDeleted,0).ge(InquiryRecordEntity::getCreateTime,start).eq(InquiryRecordEntity::getSpamFlag,0));}
|
||||||
|
/** 统计站点未读且非垃圾询盘。 */ public long countUnread(String site){return mapper.selectCount(Wrappers.<InquiryRecordEntity>lambdaQuery().eq(InquiryRecordEntity::getSiteCode,site).eq(InquiryRecordEntity::getDeleted,0).eq(InquiryRecordEntity::getReadStatus,0).eq(InquiryRecordEntity::getSpamFlag,0));}
|
||||||
|
/** 查询站点最近的有效询盘。 */ public List<InquiryRecordEntity> recent(String site,int limit){return mapper.selectList(Wrappers.<InquiryRecordEntity>lambdaQuery().eq(InquiryRecordEntity::getSiteCode,site).eq(InquiryRecordEntity::getDeleted,0).eq(InquiryRecordEntity::getSpamFlag,0).orderByDesc(InquiryRecordEntity::getCreateTime).last("LIMIT "+limit));}
|
||||||
/** 按编号查询询盘。 */ public Optional<InquiryRecordEntity> find(String site,String code){return Optional.ofNullable(mapper.selectOne(Wrappers.<InquiryRecordEntity>lambdaQuery().eq(InquiryRecordEntity::getSiteCode,site).eq(InquiryRecordEntity::getInquiryCode,code)));}
|
/** 按编号查询询盘。 */ public Optional<InquiryRecordEntity> find(String site,String code){return Optional.ofNullable(mapper.selectOne(Wrappers.<InquiryRecordEntity>lambdaQuery().eq(InquiryRecordEntity::getSiteCode,site).eq(InquiryRecordEntity::getInquiryCode,code)));}
|
||||||
/** 更新可变处理字段。 */ public int update(InquiryRecordEntity e){return mapper.update(e,Wrappers.<InquiryRecordEntity>lambdaUpdate().eq(InquiryRecordEntity::getSiteCode,e.getSiteCode()).eq(InquiryRecordEntity::getInquiryCode,e.getInquiryCode()));}
|
/** 更新可变处理字段。 */ public int update(InquiryRecordEntity e){return mapper.update(e,Wrappers.<InquiryRecordEntity>lambdaUpdate().eq(InquiryRecordEntity::getSiteCode,e.getSiteCode()).eq(InquiryRecordEntity::getInquiryCode,e.getInquiryCode()));}
|
||||||
/** 统计IP时间窗口提交数。 */ public long countIp(String site,String hash,Long start){return mapper.selectCount(Wrappers.<InquiryRecordEntity>lambdaQuery().eq(InquiryRecordEntity::getSiteCode,site).eq(InquiryRecordEntity::getIpHash,hash).ge(InquiryRecordEntity::getCreateTime,start));}
|
/** 统计IP时间窗口提交数。 */ public long countIp(String site,String hash,Long start){return mapper.selectCount(Wrappers.<InquiryRecordEntity>lambdaQuery().eq(InquiryRecordEntity::getSiteCode,site).eq(InquiryRecordEntity::getIpHash,hash).ge(InquiryRecordEntity::getCreateTime,start));}
|
||||||
|
|||||||
+2
@@ -31,6 +31,8 @@ public class ProductRepositoryService {
|
|||||||
.eq(ProductEntity::getDeleted, 0)
|
.eq(ProductEntity::getDeleted, 0)
|
||||||
.orderByAsc(ProductEntity::getSortNo).orderByDesc(ProductEntity::getUpdateTime));
|
.orderByAsc(ProductEntity::getSortNo).orderByDesc(ProductEntity::getUpdateTime));
|
||||||
}
|
}
|
||||||
|
/** 统计站点全部未删除产品。 */ public long count(String siteCode) { return mapper.selectCount(Wrappers.<ProductEntity>lambdaQuery().eq(ProductEntity::getSiteCode, siteCode).eq(ProductEntity::getDeleted, 0)); }
|
||||||
|
/** 统计站点指定发布状态的产品。 */ public long countByStatus(String siteCode, String status) { return mapper.selectCount(Wrappers.<ProductEntity>lambdaQuery().eq(ProductEntity::getSiteCode, siteCode).eq(ProductEntity::getDeleted, 0).eq(ProductEntity::getStatus, status)); }
|
||||||
/** 查询前台已发布产品列表。 */
|
/** 查询前台已发布产品列表。 */
|
||||||
public List<ProductEntity> listPublished(String siteCode, String categoryCode) {
|
public List<ProductEntity> listPublished(String siteCode, String categoryCode) {
|
||||||
var query = Wrappers.<ProductEntity>lambdaQuery().eq(ProductEntity::getSiteCode, siteCode)
|
var query = Wrappers.<ProductEntity>lambdaQuery().eq(ProductEntity::getSiteCode, siteCode)
|
||||||
|
|||||||
@@ -0,0 +1,61 @@
|
|||||||
|
import { useEffect, useMemo, useState } from "react";
|
||||||
|
import { Activity, ArrowUpRight, Clock3, Eye, FileCheck2, Mail, Monitor, RefreshCw, Users } from "lucide-react";
|
||||||
|
import { apiPost } from "./api";
|
||||||
|
|
||||||
|
const SITE = "SIT0000000000001";
|
||||||
|
type Trend = { date: string; pageViews: number; visitors: number };
|
||||||
|
type ContentStat = { type: string; label: string; total: number; published: number };
|
||||||
|
type TopPage = { path: string; title: string; pageViews: number; visitors: number };
|
||||||
|
type Device = { device: string; pageViews: number };
|
||||||
|
type RecentInquiry = { inquiryCode: string; customerName?: string; companyName?: string; countryName?: string; productName?: string; status: string; statusLabel: string; createTime: number };
|
||||||
|
type DashboardData = {
|
||||||
|
generatedAt: number; todayPageViews: number; todayVisitors: number; pageViews30Days: number; visitors30Days: number;
|
||||||
|
sessions30Days: number; averageDurationSeconds: number; inquiries30Days: number; unreadInquiries: number;
|
||||||
|
inquiryConversionRate: number; contentStats: ContentStat[]; trafficTrend: Trend[]; topPages: TopPage[];
|
||||||
|
devices: Device[]; recentInquiries: RecentInquiry[];
|
||||||
|
};
|
||||||
|
|
||||||
|
/** 格式化看板整数指标。 */
|
||||||
|
function number(value?: number): string { return new Intl.NumberFormat("zh-CN").format(value || 0); }
|
||||||
|
/** 格式化最近更新时间。 */
|
||||||
|
function time(value?: number): string { return value ? new Intl.DateTimeFormat("zh-CN", { hour: "2-digit", minute: "2-digit", hour12: false }).format(value) : "--"; }
|
||||||
|
/** 格式化询盘创建时间。 */
|
||||||
|
function dateTime(value: number): string { return new Intl.DateTimeFormat("zh-CN", { month: "2-digit", day: "2-digit", hour: "2-digit", minute: "2-digit", hour12: false }).format(value); }
|
||||||
|
/** 将设备编码转换为中文文案。 */
|
||||||
|
function deviceLabel(value: string): string { return ({ DESKTOP: "桌面端", MOBILE: "移动端", TABLET: "平板", UNKNOWN: "未知设备" } as Record<string, string>)[value] || value; }
|
||||||
|
|
||||||
|
/** 运营后台首页整体数据看板。 */
|
||||||
|
export default function DashboardPage({ onNavigate }: { onNavigate: (section: string) => void }) {
|
||||||
|
const [data, setData] = useState<DashboardData>();
|
||||||
|
const [error, setError] = useState("");
|
||||||
|
const [loading, setLoading] = useState(true);
|
||||||
|
const load = async () => { try { setLoading(true); setError(""); setData(await apiPost("/dashboard/overview", { siteCode: SITE })); } catch (reason) { setError(reason instanceof Error ? reason.message : "看板加载失败"); } finally { setLoading(false); } };
|
||||||
|
useEffect(() => { void load(); }, []);
|
||||||
|
const maxTrend = useMemo(() => Math.max(1, ...(data?.trafficTrend || []).map((item) => item.pageViews)), [data]);
|
||||||
|
const maxDevice = useMemo(() => Math.max(1, ...(data?.devices || []).map((item) => item.pageViews)), [data]);
|
||||||
|
if (loading && !data) return <div className="dashboard-state"><RefreshCw className="spin" size={22}/><span>正在汇总网站数据</span></div>;
|
||||||
|
if (error && !data) return <div className="dashboard-state error"><span>{error}</span><button onClick={() => void load()}>重新加载</button></div>;
|
||||||
|
if (!data) return null;
|
||||||
|
return <div className="dashboard-page">
|
||||||
|
<header className="dashboard-header"><div><h1>数据概览</h1><p>网站访问、内容与询盘的整体运营情况</p></div><div className="dashboard-updated"><span>更新于 {time(data.generatedAt)}</span><button title="刷新数据" onClick={() => void load()} disabled={loading}><RefreshCw className={loading ? "spin" : ""} size={17}/></button></div></header>
|
||||||
|
{error && <div className="dashboard-inline-error">{error}</div>}
|
||||||
|
<section className="dashboard-kpis">
|
||||||
|
<Metric icon={<Eye/>} label="今日浏览量" value={number(data.todayPageViews)} meta={`${number(data.todayVisitors)} 位访客`}/>
|
||||||
|
<Metric icon={<Users/>} label="近30天访客" value={number(data.visitors30Days)} meta={`${number(data.sessions30Days)} 次会话`}/>
|
||||||
|
<Metric icon={<Mail/>} label="近30天询盘" value={number(data.inquiries30Days)} meta={`${data.inquiryConversionRate || 0}% 访客转化率`} action={() => onNavigate("inquiries")}/>
|
||||||
|
<Metric icon={<Clock3/>} label="平均停留" value={`${number(data.averageDurationSeconds)} 秒`} meta={`${number(data.pageViews30Days)} 次浏览`}/>
|
||||||
|
</section>
|
||||||
|
<div className="dashboard-grid dashboard-primary-grid">
|
||||||
|
<section className="dashboard-panel traffic-panel"><PanelTitle title="近14天访问趋势" detail="PV / UV"/><div className="traffic-legend"><span><i className="pv"/>浏览量</span><span><i className="uv"/>访客数</span></div>{data.trafficTrend.length ? <div className="traffic-chart">{data.trafficTrend.map((item) => <div className="traffic-day" key={item.date} title={`${item.date}:${item.pageViews} PV / ${item.visitors} UV`}><div className="traffic-bars"><i className="pv" style={{ height: `${Math.max(3, item.pageViews / maxTrend * 100)}%` }}/><i className="uv" style={{ height: `${Math.max(3, item.visitors / maxTrend * 100)}%` }}/></div><span>{item.date.slice(5)}</span></div>)}</div> : <Empty text="近14天暂无访问数据"/>}</section>
|
||||||
|
<section className="dashboard-panel"><PanelTitle title="内容发布情况" detail="已发布 / 全部"/><div className="content-stat-list">{data.contentStats.map((item) => { const rate = item.total ? item.published / item.total * 100 : 0; return <button key={item.type} onClick={() => onNavigate(({ PRODUCT: "products", NEWS: "NEWS", CASE: "CASE", HELP: "HELP" } as Record<string, string>)[item.type])}><span><b>{item.label}</b><small>{item.published} / {item.total}</small></span><i><em style={{ width: `${rate}%` }}/></i></button>; })}</div><div className="publish-summary"><FileCheck2 size={18}/><span>共发布 {number(data.contentStats.reduce((sum, item) => sum + item.published, 0))} 条内容</span></div></section>
|
||||||
|
</div>
|
||||||
|
<div className="dashboard-grid dashboard-secondary-grid">
|
||||||
|
<section className="dashboard-panel"><PanelTitle title="热门页面" detail="最近30天"/>{data.topPages.length ? <div className="top-page-list">{data.topPages.map((item, index) => <div key={item.path}><b>{String(index + 1).padStart(2, "0")}</b><span><strong>{item.title}</strong><small>{item.path}</small></span><em>{number(item.pageViews)} PV</em></div>)}</div> : <Empty text="暂无热门页面数据"/>}</section>
|
||||||
|
<section className="dashboard-panel device-panel"><PanelTitle title="访问设备" detail="最近30天"/>{data.devices.length ? <div className="device-list">{data.devices.map((item) => <div key={item.device}><span><Monitor size={16}/>{deviceLabel(item.device)}</span><b>{number(item.pageViews)}</b><i><em style={{ width: `${item.pageViews / maxDevice * 100}%` }}/></i></div>)}</div> : <Empty text="暂无设备数据"/>}</section>
|
||||||
|
<section className="dashboard-panel inquiry-panel"><PanelTitle title="最近询盘" detail={`${data.unreadInquiries} 条未读`} action={() => onNavigate("inquiries")}/>{data.recentInquiries.length ? <div className="recent-inquiries">{data.recentInquiries.map((item) => <button key={item.inquiryCode} onClick={() => onNavigate("inquiries")}><span><strong>{item.companyName || item.customerName || "未填写公司"}</strong><small>{item.countryName || "未知地区"} · {item.productName || "通用询盘"}</small></span><em>{item.statusLabel}<small>{dateTime(item.createTime)}</small></em></button>)}</div> : <Empty text="暂无询盘"/>}</section>
|
||||||
|
</div>
|
||||||
|
</div>;
|
||||||
|
}
|
||||||
|
function Metric({ icon, label, value, meta, action }: { icon: React.ReactNode; label: string; value: string; meta: string; action?: () => void }) { return <button className="dashboard-metric" onClick={action} disabled={!action}><span className="metric-icon">{icon}</span><span><small>{label}</small><strong>{value}</strong><em>{meta}</em></span>{action && <ArrowUpRight size={17}/>}</button>; }
|
||||||
|
function PanelTitle({ title, detail, action }: { title: string; detail: string; action?: () => void }) { return <div className="dashboard-panel-title"><h2>{title}</h2>{action ? <button onClick={action}>{detail}<ArrowUpRight size={14}/></button> : <span>{detail}</span>}</div>; }
|
||||||
|
function Empty({ text }: { text: string }) { return <div className="dashboard-empty"><Activity size={20}/><span>{text}</span></div>; }
|
||||||
+11
-2
@@ -8,6 +8,7 @@ import {
|
|||||||
FileText,
|
FileText,
|
||||||
FolderTree,
|
FolderTree,
|
||||||
Globe2,
|
Globe2,
|
||||||
|
LayoutDashboard,
|
||||||
HelpCircle,
|
HelpCircle,
|
||||||
Image,
|
Image,
|
||||||
Mail,
|
Mail,
|
||||||
@@ -37,6 +38,7 @@ import SeoSettingsPage from "./SeoSettingsPage";
|
|||||||
import NavigationManager from "./NavigationManager";
|
import NavigationManager from "./NavigationManager";
|
||||||
import AgreementSettingsPage from "./AgreementSettingsPage";
|
import AgreementSettingsPage from "./AgreementSettingsPage";
|
||||||
import AboutUsSettingsPage from "./AboutUsSettingsPage";
|
import AboutUsSettingsPage from "./AboutUsSettingsPage";
|
||||||
|
import DashboardPage from "./DashboardPage";
|
||||||
import { apiPost } from "./api";
|
import { apiPost } from "./api";
|
||||||
import { statusLabel } from "./statusLabels";
|
import { statusLabel } from "./statusLabels";
|
||||||
|
|
||||||
@@ -46,6 +48,7 @@ const SITE_WEB =
|
|||||||
: "http://localhost:5174";
|
: "http://localhost:5174";
|
||||||
const SITE = "SIT0000000000001";
|
const SITE = "SIT0000000000001";
|
||||||
type Section =
|
type Section =
|
||||||
|
| "dashboard"
|
||||||
| "products"
|
| "products"
|
||||||
| "product-categories"
|
| "product-categories"
|
||||||
| "NEWS"
|
| "NEWS"
|
||||||
@@ -128,6 +131,7 @@ const menus = [
|
|||||||
{ key: "inquiries" as Section, label: "询盘", icon: Mail },
|
{ key: "inquiries" as Section, label: "询盘", icon: Mail },
|
||||||
];
|
];
|
||||||
const sectionLabels: Record<Section, string> = {
|
const sectionLabels: Record<Section, string> = {
|
||||||
|
dashboard: "数据概览",
|
||||||
products: "产品",
|
products: "产品",
|
||||||
"product-categories": "产品分类",
|
"product-categories": "产品分类",
|
||||||
NEWS: "新闻",
|
NEWS: "新闻",
|
||||||
@@ -178,7 +182,7 @@ function App({
|
|||||||
const initialContentEditor = resolveContentRoute();
|
const initialContentEditor = resolveContentRoute();
|
||||||
const [section, setSection] = useState<Section>(
|
const [section, setSection] = useState<Section>(
|
||||||
initialContentEditor?.contentType ||
|
initialContentEditor?.contentType ||
|
||||||
(window.location.pathname.startsWith("/pages/") ? "pages" : "products"),
|
(window.location.pathname.startsWith("/pages/") ? "pages" : "dashboard"),
|
||||||
);
|
);
|
||||||
const [items, setItems] = useState<Item[]>([]);
|
const [items, setItems] = useState<Item[]>([]);
|
||||||
const [error, setError] = useState("");
|
const [error, setError] = useState("");
|
||||||
@@ -226,6 +230,8 @@ function App({
|
|||||||
setError("");
|
setError("");
|
||||||
const data = section.endsWith("-categories")
|
const data = section.endsWith("-categories")
|
||||||
? { items: [] }
|
? { items: [] }
|
||||||
|
: section === "dashboard"
|
||||||
|
? { items: [] }
|
||||||
: section === "settings"
|
: section === "settings"
|
||||||
? { items: [] }
|
? { items: [] }
|
||||||
: section === "navigation"
|
: section === "navigation"
|
||||||
@@ -426,6 +432,7 @@ function App({
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<nav>
|
<nav>
|
||||||
|
<button className={section === "dashboard" ? "active" : ""} onClick={() => navigateSection("dashboard")}><LayoutDashboard size={18}/>数据概览</button>
|
||||||
<div className="nav-group">
|
<div className="nav-group">
|
||||||
<button
|
<button
|
||||||
className={
|
className={
|
||||||
@@ -584,7 +591,9 @@ function App({
|
|||||||
</div>
|
</div>
|
||||||
</aside>
|
</aside>
|
||||||
<main>
|
<main>
|
||||||
{section === "settings" ? (
|
{section === "dashboard" ? (
|
||||||
|
<DashboardPage onNavigate={(next) => navigateSection(next as Section)} />
|
||||||
|
) : section === "settings" ? (
|
||||||
<SettingsPage
|
<SettingsPage
|
||||||
account={account}
|
account={account}
|
||||||
onAccount={onAccount}
|
onAccount={onAccount}
|
||||||
|
|||||||
@@ -440,3 +440,4 @@ header p {
|
|||||||
.specification-row{display:grid;grid-template-columns:minmax(150px,.85fr) minmax(280px,1.65fr) minmax(130px,.7fr) minmax(110px,.55fr) 42px;gap:12px;align-items:end;padding:14px 0;border-top:1px solid #edf0f2}.specification-row label{display:grid;gap:7px;min-width:0}.specification-row label>span{font-size:12px;font-weight:600;color:#53616b}.specification-row input{box-sizing:border-box;border:1px solid #d8dee3;border-radius:5px;padding:10px 12px;font:inherit;width:100%}.specification-row button{height:43px;border:1px solid #ead6d6;background:#fff;color:#a93636;border-radius:5px;display:inline-grid;place-items:center;cursor:pointer}.specification-empty{border:1px dashed #d8dee3;border-radius:5px;padding:26px;text-align:center;color:#81908b;font-size:13px}
|
.specification-row{display:grid;grid-template-columns:minmax(150px,.85fr) minmax(280px,1.65fr) minmax(130px,.7fr) minmax(110px,.55fr) 42px;gap:12px;align-items:end;padding:14px 0;border-top:1px solid #edf0f2}.specification-row label{display:grid;gap:7px;min-width:0}.specification-row label>span{font-size:12px;font-weight:600;color:#53616b}.specification-row input{box-sizing:border-box;border:1px solid #d8dee3;border-radius:5px;padding:10px 12px;font:inherit;width:100%}.specification-row button{height:43px;border:1px solid #ead6d6;background:#fff;color:#a93636;border-radius:5px;display:inline-grid;place-items:center;cursor:pointer}.specification-empty{border:1px dashed #d8dee3;border-radius:5px;padding:26px;text-align:center;color:#81908b;font-size:13px}
|
||||||
.pv-product-detail{padding:44px 5%;display:grid;grid-template-columns:minmax(0,1.05fr) minmax(300px,.95fr);gap:34px;align-items:start}.pv-product-image{aspect-ratio:1/1;background:#eef2f0;display:grid;place-items:center;color:#899691;overflow:hidden}.pv-product-image img{width:100%;height:100%;object-fit:contain}.pv-product-detail>div:nth-child(2)>span{font-size:11px;font-weight:800;color:#176b5d}.pv-product-detail h1{font-size:34px;line-height:1.12;margin:12px 0 18px}.pv-product-detail small{display:block;border-block:1px solid #dce2df;padding:10px 0}.pv-product-detail p{line-height:1.65;color:#61706b}.pv-product-detail button{border:0;color:#fff;padding:12px 20px;font-weight:700;margin-top:10px}.pv-product-detail dl{grid-column:1/-1;margin:8px 0 0;border-top:2px solid #203630}.pv-product-detail dl>div{display:flex;justify-content:space-between;padding:10px 0;border-bottom:1px solid #dce2df}.pv-product-detail dt,.pv-product-detail dd{margin:0;font-size:12px}.preview-frame[style*="390px"] .pv-product-detail{grid-template-columns:1fr;padding:28px 20px}.preview-frame[style*="390px"] .pv-product-detail h1{font-size:27px}
|
.pv-product-detail{padding:44px 5%;display:grid;grid-template-columns:minmax(0,1.05fr) minmax(300px,.95fr);gap:34px;align-items:start}.pv-product-image{aspect-ratio:1/1;background:#eef2f0;display:grid;place-items:center;color:#899691;overflow:hidden}.pv-product-image img{width:100%;height:100%;object-fit:contain}.pv-product-detail>div:nth-child(2)>span{font-size:11px;font-weight:800;color:#176b5d}.pv-product-detail h1{font-size:34px;line-height:1.12;margin:12px 0 18px}.pv-product-detail small{display:block;border-block:1px solid #dce2df;padding:10px 0}.pv-product-detail p{line-height:1.65;color:#61706b}.pv-product-detail button{border:0;color:#fff;padding:12px 20px;font-weight:700;margin-top:10px}.pv-product-detail dl{grid-column:1/-1;margin:8px 0 0;border-top:2px solid #203630}.pv-product-detail dl>div{display:flex;justify-content:space-between;padding:10px 0;border-bottom:1px solid #dce2df}.pv-product-detail dt,.pv-product-detail dd{margin:0;font-size:12px}.preview-frame[style*="390px"] .pv-product-detail{grid-template-columns:1fr;padding:28px 20px}.preview-frame[style*="390px"] .pv-product-detail h1{font-size:27px}
|
||||||
@media(max-width:900px){.specification-row{grid-template-columns:1fr 1fr}.specification-values{grid-column:1/-1}.specification-row button{grid-column:2;justify-self:end;width:42px}}
|
@media(max-width:900px){.specification-row{grid-template-columns:1fr 1fr}.specification-values{grid-column:1/-1}.specification-row button{grid-column:2;justify-self:end;width:42px}}
|
||||||
|
.dashboard-page{padding:34px 38px 48px;max-width:1600px;margin:0 auto}.dashboard-header{display:flex;align-items:flex-start;justify-content:space-between;margin-bottom:26px}.dashboard-header h1{font-size:30px;margin:0 0 7px;letter-spacing:0}.dashboard-header p{margin:0;color:#76827f}.dashboard-updated{display:flex;align-items:center;gap:12px;color:#7b8784;font-size:13px}.dashboard-updated button{width:38px;height:38px;border:1px solid #d9e0dd;background:#fff;display:grid;place-items:center;color:#176b5b}.spin{animation:dashboard-spin 1s linear infinite}@keyframes dashboard-spin{to{transform:rotate(360deg)}}.dashboard-inline-error{padding:10px 14px;margin-bottom:18px;background:#fff3f1;color:#a43d31;border-left:3px solid #c95043}.dashboard-kpis{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));border:1px solid #dfe5e2;background:#fff;margin-bottom:20px}.dashboard-metric{min-width:0;height:132px;border:0;border-right:1px solid #e5e9e7;background:#fff;padding:24px;display:flex;align-items:flex-start;gap:16px;text-align:left;color:#182522}.dashboard-metric:last-child{border-right:0}.dashboard-metric:not(:disabled){cursor:pointer}.dashboard-metric:not(:disabled):hover{background:#f7faf9}.dashboard-metric>span:nth-child(2){display:grid;gap:4px}.dashboard-metric small{color:#74817d;font-size:12px}.dashboard-metric strong{font-size:29px;letter-spacing:0}.dashboard-metric em{font-style:normal;color:#697672;font-size:12px}.dashboard-metric>svg{margin-left:auto;color:#176b5b}.metric-icon{width:38px;height:38px;display:grid;place-items:center;background:#e9f3ef;color:#176b5b}.metric-icon svg{width:19px}.dashboard-grid{display:grid;gap:20px;margin-bottom:20px}.dashboard-primary-grid{grid-template-columns:minmax(0,1.7fr) minmax(320px,.8fr)}.dashboard-secondary-grid{grid-template-columns:minmax(0,1.35fr) minmax(250px,.7fr) minmax(0,1.15fr)}.dashboard-panel{background:#fff;border:1px solid #dfe5e2;padding:24px;min-width:0}.dashboard-panel-title{height:30px;display:flex;align-items:start;justify-content:space-between}.dashboard-panel-title h2{font-size:17px;margin:0;letter-spacing:0}.dashboard-panel-title>span,.dashboard-panel-title button{font-size:12px;color:#7b8784}.dashboard-panel-title button{border:0;background:transparent;display:flex;align-items:center;gap:4px;cursor:pointer}.traffic-legend{display:flex;justify-content:flex-end;gap:16px;font-size:11px;color:#77837f}.traffic-legend span{display:flex;align-items:center;gap:5px}.traffic-legend i{width:8px;height:8px}.traffic-legend .pv,.traffic-bars .pv{background:#176b5b}.traffic-legend .uv,.traffic-bars .uv{background:#b9d6cc}.traffic-chart{height:230px;display:flex;align-items:end;gap:9px;border-bottom:1px solid #dfe5e2;padding-top:24px}.traffic-day{height:100%;flex:1;min-width:0;display:grid;grid-template-rows:1fr 22px;gap:8px}.traffic-bars{display:flex;align-items:end;justify-content:center;gap:3px}.traffic-bars i{width:min(12px,40%);min-height:3px}.traffic-day>span{text-align:center;font-size:10px;color:#83908c;white-space:nowrap}.content-stat-list{display:grid;gap:20px;margin-top:22px}.content-stat-list button{border:0;background:transparent;padding:0;text-align:left;cursor:pointer}.content-stat-list button>span{display:flex;justify-content:space-between}.content-stat-list b{font-size:13px}.content-stat-list small{color:#76827f}.content-stat-list i,.device-list i{display:block;height:5px;background:#edf1ef;margin-top:8px}.content-stat-list em,.device-list em{display:block;height:100%;background:#176b5b}.publish-summary{display:flex;gap:8px;align-items:center;margin-top:24px;padding-top:18px;border-top:1px solid #e2e7e5;color:#52615d;font-size:12px}.top-page-list{margin-top:14px}.top-page-list>div{display:grid;grid-template-columns:28px minmax(0,1fr) auto;gap:10px;align-items:center;padding:11px 0;border-bottom:1px solid #edf0ef}.top-page-list>div>b{color:#9aa5a1;font-size:11px}.top-page-list span{min-width:0;display:grid}.top-page-list strong,.top-page-list small{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.top-page-list strong{font-size:13px}.top-page-list small{font-size:11px;color:#86918e}.top-page-list em{font-style:normal;font-size:12px;color:#52615d}.device-list{display:grid;gap:20px;margin-top:22px}.device-list>div{display:grid;grid-template-columns:1fr auto;align-items:center}.device-list span{display:flex;gap:7px;align-items:center;font-size:12px}.device-list b{font-size:12px}.device-list i{grid-column:1/-1}.recent-inquiries{margin-top:12px}.recent-inquiries button{width:100%;border:0;border-bottom:1px solid #edf0ef;background:transparent;padding:12px 0;display:flex;justify-content:space-between;gap:12px;text-align:left;cursor:pointer}.recent-inquiries button:hover strong{color:#176b5b}.recent-inquiries span,.recent-inquiries em{display:grid;gap:3px;min-width:0}.recent-inquiries strong{font-size:13px}.recent-inquiries small{font-size:11px;color:#83908c;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.recent-inquiries emLine truncated
|
||||||
@@ -1 +1 @@
|
|||||||
{"root":["./src/agreementsettingspage.tsx","./src/categorymanager.tsx","./src/contenteditor.tsx","./src/customcodemanager.tsx","./src/decorationeditor.tsx","./src/inquirysettingspanel.tsx","./src/loginpage.tsx","./src/mediacenter.tsx","./src/navigationmanager.tsx","./src/pageeditor.tsx","./src/producteditor.tsx","./src/seosettingspage.tsx","./src/settingspage.tsx","./src/api.ts","./src/main.tsx","./src/vite-env.d.ts"],"version":"5.7.3"}
|
{"root":["./src/aboutussettingspage.tsx","./src/agreementsettingspage.tsx","./src/categorymanager.tsx","./src/contenteditor.tsx","./src/customcodemanager.tsx","./src/dashboardpage.tsx","./src/decorationeditor.tsx","./src/inquirysettingspanel.tsx","./src/loginpage.tsx","./src/mediacenter.tsx","./src/navigationmanager.tsx","./src/pageeditor.tsx","./src/producteditor.tsx","./src/seosettingspage.tsx","./src/settingspage.tsx","./src/api.ts","./src/main.tsx","./src/statuslabels.ts","./src/vite-env.d.ts"],"version":"5.7.3"}
|
||||||
Reference in new issue
Block a user