feat: 忘了干啥了

This commit is contained in:
ah--desktop
2026-03-09 20:40:13 +08:00
parent 79109202d3
commit 60d34e2a47
37 changed files with 751 additions and 2673 deletions
@@ -29,7 +29,7 @@ export const MOCK_USERS: UserInfo[] = [
realName: 'Jack',
roles: ['user'],
username: 'jack',
homePath: '/analytics',
homePath: '/company-overview',
},
];
@@ -59,15 +59,15 @@ const dashboardMenus = [
},
name: 'Dashboard',
path: '/dashboard',
redirect: '/analytics',
redirect: '/company-overview',
children: [
{
name: 'Analytics',
path: '/analytics',
component: '/dashboard/analytics/index',
path: '/company-overview',
component: '/dashboard/company-overview/index',
meta: {
affixTab: true,
title: 'page.dashboard.analytics',
title: 'page.dashboard.companyOverview',
},
},
{
@@ -27,17 +27,23 @@ export namespace ProductDTO {
specs?: UpdateSpec[];
}
/** 商品规格DTO */
/** 商品规格DTO(创建时) */
export interface Spec {
/** 规格名称 */
name: string;
/** 规格编码 */
specCode?: string;
/** 成本价 */
costPrice: number;
/** 商品成本 */
productCost: number;
/** 运费成本 */
shippingCost?: number;
/** 其他成本 */
otherCost?: number;
/** 备注 */
remark?: string;
}
/** 创建商品规格参数 */
/** 创建商品规格参数(独立接口用) */
export interface CreateSpec {
/** 商品ID */
productId: number;
@@ -45,8 +51,14 @@ export namespace ProductDTO {
name: string;
/** 规格编码 */
specCode?: string;
/** 成本价 */
costPrice: number;
/** 商品成本 */
productCost: number;
/** 运费成本 */
shippingCost?: number;
/** 其他成本 */
otherCost?: number;
/** 备注 */
remark?: string;
}
/** 更新商品规格参数 */
@@ -57,8 +69,14 @@ export namespace ProductDTO {
name: string;
/** 规格编码 */
specCode?: string;
/** 成本价 */
costPrice: number;
/** 商品成本 */
productCost: number;
/** 运费成本 */
shippingCost?: number;
/** 其他成本 */
otherCost?: number;
/** 备注 */
remark?: string;
}
/** 商品过滤条件 */
@@ -13,10 +13,8 @@ export namespace ProductVO {
name: string;
/** 商品编码 */
productCode?: string;
/** 主图URL(冗余字段) */
/** 主图URL */
mainImage?: string;
/** 主图图片ID */
mainImageId?: number;
/** 创建时间 */
createTime: string;
/** 更新时间 */
@@ -43,8 +41,14 @@ export namespace ProductVO {
name: string;
/** 规格编码 */
specCode?: string;
/** 成本价 */
costPrice: number;
/** 商品成本 */
productCost: number;
/** 运费成本 */
shippingCost?: number;
/** 其他成本 */
otherCost?: number;
/** 备注 */
remark?: string;
/** 创建时间 */
createTime: string;
/** 更新时间 */
@@ -107,6 +107,8 @@ export namespace ShopVO {
/** 店铺概览统计信息 */
export interface OverviewStatistics {
/** 店铺名称 */
shopName: string;
/** 店铺总销售额 */
totalSalesAmount: number;
/** 较上月同期增长百分比 */
@@ -0,0 +1,67 @@
import type { FileDTO, FileVO } from './types';
import type { PageQueryDTO, PageResultVO } from '#/types/common';
import { requestClient } from '#/api/request';
/**
* 系统文件管理API
*/
/**
* 批量上传文件
* @param files 文件列表
*/
export async function batchUploadFilesApi(files: File[]) {
const formData = new FormData();
files.forEach((file) => {
formData.append('files', file);
});
return requestClient.post<FileVO.Upload[]>(
'/sys/file/batch-upload',
formData,
{
headers: {
'Content-Type': 'multipart/form-data',
},
},
);
}
/**
* 批量获取Header签名
* @param data 批量签名请求参数
*/
export async function batchSignUrlApi(data: FileDTO.BatchSignUrl) {
return requestClient.post<FileVO.BatchSignUrl>(
'/sys/file/batch-sign-url',
data,
);
}
/**
* 批量创建OSS文件记录
* @param data 批量创建OSS文件记录请求参数
*/
export async function batchCreateOssFilesApi(data: FileDTO.BatchCreateOss) {
return requestClient.post<FileVO.Info[]>('/sys/file/batch-create-oss', data);
}
/**
* 获取文件访问URL
* @param fileId 文件ID
*/
export async function getFileAccessUrlApi(fileId: number) {
return requestClient.get<string>(`/sys/file/${fileId}/access-url`);
}
/**
* 分页获取文件列表
* @param params 分页查询参数
*/
export async function getFilePageApi(params: PageQueryDTO<FileDTO.Filter>) {
return requestClient.post<PageResultVO<FileVO.Info>>(
'/sys/file/page',
params,
);
}
@@ -0,0 +1,6 @@
/**
* 系统文件管理模块API导出
*/
export * from './apis';
export * from './types';
@@ -0,0 +1,6 @@
/**
* 系统文件管理模块类型定义导出
*/
export * from './types.dto';
export * from './types.vo';
@@ -0,0 +1,63 @@
/**
* 系统文件管理模块DTO类型定义
*/
export namespace FileDTO {
/** 批量URL签名请求参数 */
export interface BatchSignUrl {
/** 文件列表 */
files: FileItem[];
}
/** 文件项 */
export interface FileItem {
/** 文件名 */
filename: string;
/** 文件哈希值 */
fileHash: string;
}
/** 批量创建OSS文件记录请求参数 */
export interface BatchCreateOss {
/** 文件列表 */
files: CreateOssFileItem[];
}
/** 创建OSS文件项 */
export interface CreateOssFileItem {
/** 文件名 */
filename: string;
/** 文件哈希值 */
fileHash: string;
/** 存储路径/Key */
storagePath: string;
/** 文件大小(字节) */
fileSize?: number;
/** MIME类型 */
mimeType?: string;
/** 文件分类 */
category?: string;
/** 标签 */
tags?: string;
/** 备注 */
remark?: string;
}
/** 文件过滤条件 */
export interface Filter {
/** 文件名(模糊查询) */
filename?: string;
/** 文件格式(精准查询) */
fileFormat?: string;
/** 存储类型(精准查询) */
storageType?: string;
/** 文件分类(精准查询) */
category?: string;
/** 标签(模糊查询) */
tags?: string;
/** 上传时间范围-开始时间 */
startUploadTime?: string;
/** 上传时间范围-结束时间 */
endUploadTime?: string;
}
}
@@ -0,0 +1,99 @@
/**
* 系统文件管理模块VO类型定义
*/
export namespace FileVO {
/** 文件上传响应信息 */
export interface Upload {
/** 文件ID */
id: number;
/** 存储类型 */
storageType: string;
/** 存储路径/Key */
storagePath: string;
/** 原始文件名 */
filename: string;
/** 文件格式 */
fileFormat: string;
/** MIME类型 */
mimeType: string;
/** 文件大小(字节) */
fileSize: number;
/** 文件哈希值 */
fileHash: string;
/** 文件分类 */
category?: string;
/** 标签 */
tags?: string;
/** 文件描述 */
remark?: string;
/** 访问URL(临时签名URL,仅OSS存储) */
accessUrl?: string;
}
/** 系统文件信息 */
export interface Info {
/** 文件ID */
id: number;
/** 公司ID */
companyId?: number;
/** 存储类型 */
storageType: string;
/** 存储路径/Key */
storagePath: string;
/** 原始文件名 */
filename: string;
/** 文件格式 */
fileFormat: string;
/** MIME类型 */
mimeType: string;
/** 文件大小(字节) */
fileSize: number;
/** 文件哈希值 */
fileHash: string;
/** 文件分类 */
category?: string;
/** 标签 */
tags?: string;
/** 文件描述 */
remark?: string;
/** 上传人ID */
uploadBy?: number;
/** 上传时间 */
uploadTime: string;
/** 更新时间 */
updateTime: string;
/** 更新人ID */
updateBy?: number;
/** 访问URL(临时签名URL) */
accessUrl?: string;
}
/** 批量Header签名响应(Header签名) */
export interface BatchSignUrl {
/** 文件信息列表 */
files: FileSignInfo[];
}
/** 文件签名信息 */
export interface FileSignInfo {
/** 文件名 */
filename: string;
/** 文件哈希值 */
fileHash: string;
/** 文件ID(如果文件已存在) */
fileId?: number;
/** 是否已存在 */
exists: boolean;
/** 上传URL(如果文件不存在,不含签名参数) */
uploadUrl?: string;
/** 上传所需的Header签名信息(如果文件不存在,包含Authorization、Date、x-oss-date、Content-Type等) */
uploadHeaders?: Record<string, string>;
/** 存储路径/Key(如果文件不存在,用于前端创建文件记录时使用) */
storagePath?: string;
/** 访问URL(如果文件已存在,临时签名URL) */
accessUrl?: string;
/** 文件信息(如果文件已存在) */
fileInfo?: Info;
}
}
@@ -11,6 +11,7 @@ export const overridesPreferences = defineOverridesPreferences({
name: import.meta.env.VITE_APP_TITLE,
accessMode: 'backend', // 启用后端访问控制模式
enableRefreshToken: true, // 启用token自动刷新功能 🔄
defaultHomePath: '/company-overview', // 设置默认首页路由
},
navigation: {
accordion: false, // 关闭手风琴模式,允许多个菜单同时展开
@@ -14,12 +14,12 @@ const routes: RouteRecordRaw[] = [
children: [
{
name: 'Analytics',
path: '/analytics',
component: () => import('#/views/dashboard/analytics/index.vue'),
path: '/company-overview',
component: () => import('#/views/dashboard/company-overview/index.vue'),
meta: {
affixTab: true,
icon: 'lucide:area-chart',
title: $t('page.dashboard.analytics'),
title: $t('page.dashboard.companyOverview'),
},
},
// {
@@ -210,7 +210,7 @@ export const useAuthStore = defineStore('auth', () => {
userId: user.id.toString(),
username: user.loginCode,
desc: user.remark || '',
homePath: '/dashboard',
homePath: preferences.app.defaultHomePath,
avatar: user.avatar || '',
};
userStore.setUserInfo(userInfo as any);
@@ -0,0 +1,259 @@
/**
* OSS文件上传工具
*/
import type { FileVO } from '#/api/system/file/types';
import { message } from 'ant-design-vue';
import { batchCreateOssFilesApi, batchSignUrlApi } from '#/api/system/file';
/**
* 上传选项
*/
export interface UploadOptions {
/** 文件分类 */
category?: string;
/** 错误提示消息 */
errorMessage?: string;
}
/**
* 计算文件的SHA-256哈希值
* @param file 文件对象
* @returns 返回文件的SHA-256哈希值(十六进制字符串)
*/
async function calculateFileHash(file: File): Promise<string> {
const arrayBuffer = await file.arrayBuffer();
const hashBuffer = await crypto.subtle.digest('SHA-256', arrayBuffer);
const hashArray = [...new Uint8Array(hashBuffer)];
const hashHex = hashArray
.map((b) => b.toString(16).padStart(2, '0'))
.join('');
return hashHex;
}
/**
* 使用Header签名上传文件到OSS
* @param file 要上传的文件
* @param uploadUrl 上传URL(不含签名参数)
* @param uploadHeaders Header签名信息(包含Authorization、Date、x-oss-date、Content-Type等)
* @returns Promise<void>
*/
async function uploadFileToOssWithHeaderSignature(
file: File,
uploadUrl: string,
uploadHeaders: Record<string, string>,
): Promise<void> {
const headers: Record<string, string> = {
...uploadHeaders,
};
const response = await fetch(uploadUrl, {
method: 'PUT',
body: file,
headers,
});
if (!response.ok) {
throw new Error(`上传失败: ${response.status} ${response.statusText}`);
}
}
/**
* 上传文件到OSS(通过Header签名)
* @param file 要上传的文件
* @param options 上传选项
* @param options.category 文件分类
* @param options.errorMessage 错误提示消息
* @returns 返回文件信息,包含文件ID
*/
export async function uploadFileToOss(
file: File,
options?: UploadOptions,
): Promise<FileVO.Info> {
try {
// 1. 计算文件哈希值
const fileHash = await calculateFileHash(file);
// 2. 获取Header签名
const signResponse = await batchSignUrlApi({
files: [
{
filename: file.name,
fileHash,
},
],
});
if (!signResponse.files || signResponse.files.length === 0) {
throw new Error('获取签名失败');
}
const signInfo = signResponse.files[0];
if (!signInfo) {
throw new Error('获取签名失败');
}
// 3. 如果文件已存在,直接返回文件信息
if (signInfo.exists && signInfo.fileInfo) {
return signInfo.fileInfo;
}
// 4. 如果文件不存在,使用Header签名上传到OSS
if (!signInfo.uploadUrl) {
throw new Error('未获取到上传URL');
}
if (!signInfo.uploadHeaders) {
throw new Error('未获取到上传Header签名信息');
}
await uploadFileToOssWithHeaderSignature(
file,
signInfo.uploadUrl,
signInfo.uploadHeaders,
);
// 5. 上传成功后,创建OSS文件记录
// 使用签名响应中的 storagePath
if (!signInfo.storagePath) {
throw new Error('未获取到存储路径');
}
const createResponse = await batchCreateOssFilesApi({
files: [
{
filename: file.name,
fileHash,
storagePath: signInfo.storagePath,
fileSize: file.size,
mimeType: file.type,
category: options?.category,
},
],
});
if (!createResponse || createResponse.length === 0) {
throw new Error('创建文件记录失败');
}
const fileInfo = createResponse[0];
if (!fileInfo) {
throw new Error('创建文件记录失败');
}
return fileInfo;
} catch (error) {
console.error('文件上传失败:', error);
const errorMsg = options?.errorMessage || '文件上传失败';
message.error(errorMsg);
throw error;
}
}
/**
* 批量上传文件到OSS(通过Header签名)
* @param files 要上传的文件列表
* @param options 上传选项
* @param options.category 文件分类
* @param options.errorMessage 错误提示消息
* @returns 返回文件信息列表
*/
export async function uploadFilesToOss(
files: File[],
options?: UploadOptions,
): Promise<FileVO.Info[]> {
try {
// 1. 计算所有文件的哈希值
const fileItems = await Promise.all(
files.map(async (file) => ({
filename: file.name,
fileHash: await calculateFileHash(file),
})),
);
// 2. 批量获取Header签名
const signResponse = await batchSignUrlApi({
files: fileItems,
});
if (!signResponse.files || signResponse.files.length === 0) {
throw new Error('获取签名失败');
}
const results: FileVO.Info[] = [];
const filesToUpload: Array<{
file: File;
fileHash: string;
signInfo: FileVO.FileSignInfo;
}> = [];
// 3. 分类处理:已存在的文件和需要上传的文件
for (let i = 0; i < signResponse.files.length; i++) {
const signInfo = signResponse.files[i];
const file = files[i];
const fileItem = fileItems[i];
if (!signInfo || !file || !fileItem) continue;
if (signInfo.exists && signInfo.fileInfo) {
// 文件已存在,直接使用
results.push(signInfo.fileInfo);
} else if (signInfo.uploadUrl && signInfo.uploadHeaders) {
// 文件不存在,需要上传
filesToUpload.push({
file,
fileHash: fileItem.fileHash,
signInfo,
});
}
}
// 4. 批量上传不存在的文件
if (filesToUpload.length > 0) {
await Promise.all(
filesToUpload.map(({ file, signInfo }) => {
if (!signInfo.uploadUrl) {
throw new Error('未获取到上传URL');
}
if (!signInfo.uploadHeaders) {
throw new Error('未获取到上传Header签名信息');
}
return uploadFileToOssWithHeaderSignature(
file,
signInfo.uploadUrl,
signInfo.uploadHeaders,
);
}),
);
// 5. 批量创建OSS文件记录
const createResponse = await batchCreateOssFilesApi({
files: filesToUpload.map(({ file, signInfo, fileHash }) => {
// 使用签名响应中的 storagePath
if (!signInfo.storagePath) {
throw new Error('未获取到存储路径');
}
return {
filename: file.name,
fileHash,
storagePath: signInfo.storagePath,
fileSize: file.size,
mimeType: file.type,
category: options?.category,
};
}),
});
if (createResponse && createResponse.length > 0) {
results.push(...createResponse);
}
}
return results;
} catch (error) {
console.error('文件上传失败:', error);
const errorMsg = options?.errorMessage || '文件上传失败';
message.error(errorMsg);
throw error;
}
}
@@ -1,98 +0,0 @@
<script lang="ts" setup>
import type { EchartsUIType } from '@vben/plugins/echarts';
import { onMounted, ref } from 'vue';
import { EchartsUI, useEcharts } from '@vben/plugins/echarts';
const chartRef = ref<EchartsUIType>();
const { renderEcharts } = useEcharts(chartRef);
onMounted(() => {
renderEcharts({
grid: {
bottom: 0,
containLabel: true,
left: '1%',
right: '1%',
top: '2 %',
},
series: [
{
areaStyle: {},
data: [
111, 2000, 6000, 16_000, 33_333, 55_555, 64_000, 33_333, 18_000,
36_000, 70_000, 42_444, 23_222, 13_000, 8000, 4000, 1200, 333, 222,
111,
],
itemStyle: {
color: '#5ab1ef',
},
smooth: true,
type: 'line',
},
{
areaStyle: {},
data: [
33, 66, 88, 333, 3333, 6200, 20_000, 3000, 1200, 13_000, 22_000,
11_000, 2221, 1201, 390, 198, 60, 30, 22, 11,
],
itemStyle: {
color: '#019680',
},
smooth: true,
type: 'line',
},
],
tooltip: {
axisPointer: {
lineStyle: {
color: '#019680',
width: 1,
},
},
trigger: 'axis',
},
// xAxis: {
// axisTick: {
// show: false,
// },
// boundaryGap: false,
// data: Array.from({ length: 18 }).map((_item, index) => `${index + 6}:00`),
// type: 'category',
// },
xAxis: {
axisTick: {
show: false,
},
boundaryGap: false,
data: Array.from({ length: 18 }).map((_item, index) => `${index + 6}:00`),
splitLine: {
lineStyle: {
type: 'solid',
width: 1,
},
show: true,
},
type: 'category',
},
yAxis: [
{
axisTick: {
show: false,
},
max: 80_000,
splitArea: {
show: true,
},
splitNumber: 4,
type: 'value',
},
],
});
});
</script>
<template>
<EchartsUI ref="chartRef" />
</template>
@@ -1,82 +0,0 @@
<script lang="ts" setup>
import type { EchartsUIType } from '@vben/plugins/echarts';
import { onMounted, ref } from 'vue';
import { EchartsUI, useEcharts } from '@vben/plugins/echarts';
const chartRef = ref<EchartsUIType>();
const { renderEcharts } = useEcharts(chartRef);
onMounted(() => {
renderEcharts({
legend: {
bottom: 0,
data: ['访问', '趋势'],
},
radar: {
indicator: [
{
name: '网页',
},
{
name: '移动端',
},
{
name: 'Ipad',
},
{
name: '客户端',
},
{
name: '第三方',
},
{
name: '其它',
},
],
radius: '60%',
splitNumber: 8,
},
series: [
{
areaStyle: {
opacity: 1,
shadowBlur: 0,
shadowColor: 'rgba(0,0,0,.2)',
shadowOffsetX: 0,
shadowOffsetY: 10,
},
data: [
{
itemStyle: {
color: '#b6a2de',
},
name: '访问',
value: [90, 50, 86, 40, 50, 20],
},
{
itemStyle: {
color: '#5ab1ef',
},
name: '趋势',
value: [70, 75, 70, 76, 20, 85],
},
],
itemStyle: {
// borderColor: '#fff',
borderRadius: 10,
borderWidth: 2,
},
symbolSize: 0,
type: 'radar',
},
],
tooltip: {},
});
});
</script>
<template>
<EchartsUI ref="chartRef" />
</template>
@@ -1,46 +0,0 @@
<script lang="ts" setup>
import type { EchartsUIType } from '@vben/plugins/echarts';
import { onMounted, ref } from 'vue';
import { EchartsUI, useEcharts } from '@vben/plugins/echarts';
const chartRef = ref<EchartsUIType>();
const { renderEcharts } = useEcharts(chartRef);
onMounted(() => {
renderEcharts({
series: [
{
animationDelay() {
return Math.random() * 400;
},
animationEasing: 'exponentialInOut',
animationType: 'scale',
center: ['50%', '50%'],
color: ['#5ab1ef', '#b6a2de', '#67e0e3', '#2ec7c9'],
data: [
{ name: '外包', value: 500 },
{ name: '定制', value: 310 },
{ name: '技术支持', value: 274 },
{ name: '远程', value: 400 },
].sort((a, b) => {
return a.value - b.value;
}),
name: '商业占比',
radius: '80%',
roseType: 'radius',
type: 'pie',
},
],
tooltip: {
trigger: 'item',
},
});
});
</script>
<template>
<EchartsUI ref="chartRef" />
</template>
@@ -1,65 +0,0 @@
<script lang="ts" setup>
import type { EchartsUIType } from '@vben/plugins/echarts';
import { onMounted, ref } from 'vue';
import { EchartsUI, useEcharts } from '@vben/plugins/echarts';
const chartRef = ref<EchartsUIType>();
const { renderEcharts } = useEcharts(chartRef);
onMounted(() => {
renderEcharts({
legend: {
bottom: '2%',
left: 'center',
},
series: [
{
animationDelay() {
return Math.random() * 100;
},
animationEasing: 'exponentialInOut',
animationType: 'scale',
avoidLabelOverlap: false,
color: ['#5ab1ef', '#b6a2de', '#67e0e3', '#2ec7c9'],
data: [
{ name: '搜索引擎', value: 1048 },
{ name: '直接访问', value: 735 },
{ name: '邮件营销', value: 580 },
{ name: '联盟广告', value: 484 },
],
emphasis: {
label: {
fontSize: '12',
fontWeight: 'bold',
show: true,
},
},
itemStyle: {
// borderColor: '#fff',
borderRadius: 10,
borderWidth: 2,
},
label: {
position: 'center',
show: false,
},
labelLine: {
show: false,
},
name: '访问来源',
radius: ['40%', '65%'],
type: 'pie',
},
],
tooltip: {
trigger: 'item',
},
});
});
</script>
<template>
<EchartsUI ref="chartRef" />
</template>
@@ -1,55 +0,0 @@
<script lang="ts" setup>
import type { EchartsUIType } from '@vben/plugins/echarts';
import { onMounted, ref } from 'vue';
import { EchartsUI, useEcharts } from '@vben/plugins/echarts';
const chartRef = ref<EchartsUIType>();
const { renderEcharts } = useEcharts(chartRef);
onMounted(() => {
renderEcharts({
grid: {
bottom: 0,
containLabel: true,
left: '1%',
right: '1%',
top: '2 %',
},
series: [
{
barMaxWidth: 80,
// color: '#4f69fd',
data: [
3000, 2000, 3333, 5000, 3200, 4200, 3200, 2100, 3000, 5100, 6000,
3200, 4800,
],
type: 'bar',
},
],
tooltip: {
axisPointer: {
lineStyle: {
// color: '#4f69fd',
width: 1,
},
},
trigger: 'axis',
},
xAxis: {
data: Array.from({ length: 12 }).map((_item, index) => `${index + 1}月`),
type: 'category',
},
yAxis: {
max: 8000,
splitNumber: 4,
type: 'value',
},
});
});
</script>
<template>
<EchartsUI ref="chartRef" />
</template>
@@ -1,90 +0,0 @@
<script lang="ts" setup>
import type { AnalysisOverviewItem } from '@vben/common-ui';
import type { TabOption } from '@vben/types';
import {
AnalysisChartCard,
AnalysisChartsTabs,
AnalysisOverview,
} from '@vben/common-ui';
import {
SvgBellIcon,
SvgCakeIcon,
SvgCardIcon,
SvgDownloadIcon,
} from '@vben/icons';
import AnalyticsTrends from './analytics-trends.vue';
import AnalyticsVisitsData from './analytics-visits-data.vue';
import AnalyticsVisitsSales from './analytics-visits-sales.vue';
import AnalyticsVisitsSource from './analytics-visits-source.vue';
import AnalyticsVisits from './analytics-visits.vue';
const overviewItems: AnalysisOverviewItem[] = [
{
icon: SvgCardIcon,
title: '用户量',
totalTitle: '总用户量',
totalValue: 120_000,
value: 2000,
},
{
icon: SvgCakeIcon,
title: '访问量',
totalTitle: '总访问量',
totalValue: 500_000,
value: 20_000,
},
{
icon: SvgDownloadIcon,
title: '下载量',
totalTitle: '总下载量',
totalValue: 120_000,
value: 8000,
},
{
icon: SvgBellIcon,
title: '使用量',
totalTitle: '总使用量',
totalValue: 50_000,
value: 5000,
},
];
const chartTabs: TabOption[] = [
{
label: '流量趋势',
value: 'trends',
},
{
label: '月访问量',
value: 'visits',
},
];
</script>
<template>
<div class="p-5">
<AnalysisOverview :items="overviewItems" />
<AnalysisChartsTabs :tabs="chartTabs" class="mt-5">
<template #trends>
<AnalyticsTrends />
</template>
<template #visits>
<AnalyticsVisits />
</template>
</AnalysisChartsTabs>
<div class="mt-5 w-full md:flex">
<AnalysisChartCard class="mt-5 md:mr-4 md:mt-0 md:w-1/3" title="访问数量">
<AnalyticsVisitsData />
</AnalysisChartCard>
<AnalysisChartCard class="mt-5 md:mr-4 md:mt-0 md:w-1/3" title="访问来源">
<AnalyticsVisitsSource />
</AnalysisChartCard>
<AnalysisChartCard class="mt-5 md:mt-0 md:w-1/3" title="访问来源">
<AnalyticsVisitsSales />
</AnalysisChartCard>
</div>
</div>
</template>
@@ -7,6 +7,7 @@ import type {
} from '#/api/ecommerce/company-overview';
import { onMounted, ref, watch } from 'vue';
import { useRouter } from 'vue-router';
import { Page } from '@vben/common-ui';
import { EchartsUI, useEcharts } from '@vben/plugins/echarts';
@@ -19,6 +20,9 @@ import { getShopPageApi } from '#/api/ecommerce/shop';
defineOptions({ name: 'CompanyOverview' });
// 路由
const router = useRouter();
// 响应式数据
const loading = ref(false);
const overviewData = ref<CompanyOverviewVO.Info | null>(null);
@@ -116,6 +120,17 @@ const formatPercentPlain = (value: number | undefined) => {
return `${value.toFixed(1)}%`;
};
// 跳转到店铺详情页
const navigateToShopOverview = (shopId: number) => {
router.push({
path: `/ecom/shop/overview/${shopId}`,
query: {
startDate: dateRange.value[0].format('YYYY-MM-DD'),
endDate: dateRange.value[1].format('YYYY-MM-DD'),
},
});
};
// 加载店铺数量
const loadShopCount = async () => {
try {
@@ -406,7 +421,7 @@ onMounted(async () => {
</template>
<Spin :spinning="loading">
<div class="mx-auto w-full space-y-6 p-4 md:p-8">
<div class="mx-auto w-full space-y-6">
<!-- 第一层:核心汇总指标 -->
<div class="grid grid-cols-1 gap-6 sm:grid-cols-2 xl:grid-cols-4">
<!-- 销售额 -->
@@ -673,9 +688,14 @@ onMounted(async () => {
class="transition-colors hover:bg-blue-50/50"
>
<td
class="sticky-col border-r-2 border-slate-100 bg-white p-6 font-bold text-slate-900 shadow-sm"
class="sticky-col border-r-2 border-slate-100 bg-white p-6 font-bold shadow-sm"
>
{{ shop.shopName }}
<span
class="cursor-pointer text-blue-600 transition-colors hover:text-blue-800 hover:underline"
@click="navigateToShopOverview(shop.shopId)"
>
{{ shop.shopName }}
</span>
</td>
<!-- 目标 -->
<td class="p-6 font-medium">
@@ -1,266 +0,0 @@
<script lang="ts" setup>
import type {
WorkbenchProjectItem,
WorkbenchQuickNavItem,
WorkbenchTodoItem,
WorkbenchTrendItem,
} from '@vben/common-ui';
import { ref } from 'vue';
import { useRouter } from 'vue-router';
import {
AnalysisChartCard,
WorkbenchHeader,
WorkbenchProject,
WorkbenchQuickNav,
WorkbenchTodo,
WorkbenchTrends,
} from '@vben/common-ui';
import { preferences } from '@vben/preferences';
import { useUserStore } from '@vben/stores';
import { openWindow } from '@vben/utils';
import AnalyticsVisitsSource from '../analytics/analytics-visits-source.vue';
const userStore = useUserStore();
// 这是一个示例数据,实际项目中需要根据实际情况进行调整
// url 也可以是内部路由,在 navTo 方法中识别处理,进行内部跳转
// 例如:url: /dashboard/workspace
const projectItems: WorkbenchProjectItem[] = [
{
color: '',
content: '不要等待机会,而要创造机会。',
date: '2021-04-01',
group: '开源组',
icon: 'carbon:logo-github',
title: 'Github',
url: 'https://github.com',
},
{
color: '#3fb27f',
content: '现在的你决定将来的你。',
date: '2021-04-01',
group: '算法组',
icon: 'ion:logo-vue',
title: 'Vue',
url: 'https://vuejs.org',
},
{
color: '#e18525',
content: '没有什么才能比努力更重要。',
date: '2021-04-01',
group: '上班摸鱼',
icon: 'ion:logo-html5',
title: 'Html5',
url: 'https://developer.mozilla.org/zh-CN/docs/Web/HTML',
},
{
color: '#bf0c2c',
content: '热情和欲望可以突破一切难关。',
date: '2021-04-01',
group: 'UI',
icon: 'ion:logo-angular',
title: 'Angular',
url: 'https://angular.io',
},
{
color: '#00d8ff',
content: '健康的身体是实现目标的基石。',
date: '2021-04-01',
group: '技术牛',
icon: 'bx:bxl-react',
title: 'React',
url: 'https://reactjs.org',
},
{
color: '#EBD94E',
content: '路是走出来的,而不是空想出来的。',
date: '2021-04-01',
group: '架构组',
icon: 'ion:logo-javascript',
title: 'Js',
url: 'https://developer.mozilla.org/zh-CN/docs/Web/JavaScript',
},
];
// 同样,这里的 url 也可以使用以 http 开头的外部链接
const quickNavItems: WorkbenchQuickNavItem[] = [
{
color: '#1fdaca',
icon: 'ion:home-outline',
title: '首页',
url: '/',
},
{
color: '#bf0c2c',
icon: 'ion:grid-outline',
title: '仪表盘',
url: '/dashboard',
},
{
color: '#e18525',
icon: 'ion:layers-outline',
title: '组件',
url: '/demos/features/icons',
},
{
color: '#3fb27f',
icon: 'ion:settings-outline',
title: '系统管理',
url: '/demos/features/login-expired', // 这里的 URL 是示例,实际项目中需要根据实际情况进行调整
},
{
color: '#4daf1bc9',
icon: 'ion:key-outline',
title: '权限管理',
url: '/demos/access/page-control',
},
{
color: '#00d8ff',
icon: 'ion:bar-chart-outline',
title: '图表',
url: '/analytics',
},
];
const todoItems = ref<WorkbenchTodoItem[]>([
{
completed: false,
content: `审查最近提交到Git仓库的前端代码,确保代码质量和规范。`,
date: '2024-07-30 11:00:00',
title: '审查前端代码提交',
},
{
completed: true,
content: `检查并优化系统性能,降低CPU使用率。`,
date: '2024-07-30 11:00:00',
title: '系统性能优化',
},
{
completed: false,
content: `进行系统安全检查,确保没有安全漏洞或未授权的访问。 `,
date: '2024-07-30 11:00:00',
title: '安全检查',
},
{
completed: false,
content: `更新项目中的所有npm依赖包,确保使用最新版本。`,
date: '2024-07-30 11:00:00',
title: '更新项目依赖',
},
{
completed: false,
content: `修复用户报告的页面UI显示问题,确保在不同浏览器中显示一致。 `,
date: '2024-07-30 11:00:00',
title: '修复UI显示问题',
},
]);
const trendItems: WorkbenchTrendItem[] = [
{
avatar: 'svg:avatar-1',
content: `在 <a>开源组</a> 创建了项目 <a>Vue</a>`,
date: '刚刚',
title: '威廉',
},
{
avatar: 'svg:avatar-2',
content: `关注了 <a>威廉</a> `,
date: '1个小时前',
title: '艾文',
},
{
avatar: 'svg:avatar-3',
content: `发布了 <a>个人动态</a> `,
date: '1天前',
title: '克里斯',
},
{
avatar: 'svg:avatar-4',
content: `发表文章 <a>如何编写一个Vite插件</a> `,
date: '2天前',
title: 'Vben',
},
{
avatar: 'svg:avatar-1',
content: `回复了 <a>杰克</a> 的问题 <a>如何进行项目优化?</a>`,
date: '3天前',
title: '皮特',
},
{
avatar: 'svg:avatar-2',
content: `关闭了问题 <a>如何运行项目</a> `,
date: '1周前',
title: '杰克',
},
{
avatar: 'svg:avatar-3',
content: `发布了 <a>个人动态</a> `,
date: '1周前',
title: '威廉',
},
{
avatar: 'svg:avatar-4',
content: `推送了代码到 <a>Github</a>`,
date: '2021-04-01 20:00',
title: '威廉',
},
{
avatar: 'svg:avatar-4',
content: `发表文章 <a>如何编写使用 Admin Vben</a> `,
date: '2021-03-01 20:00',
title: 'Vben',
},
];
const router = useRouter();
// 这是一个示例方法,实际项目中需要根据实际情况进行调整
// This is a sample method, adjust according to the actual project requirements
function navTo(nav: WorkbenchProjectItem | WorkbenchQuickNavItem) {
if (nav.url?.startsWith('http')) {
openWindow(nav.url);
return;
}
if (nav.url?.startsWith('/')) {
router.push(nav.url).catch((error) => {
console.error('Navigation failed:', error);
});
} else {
console.warn(`Unknown URL for navigation item: ${nav.title} -> ${nav.url}`);
}
}
</script>
<template>
<div class="p-5">
<WorkbenchHeader
:avatar="userStore.userInfo?.avatar || preferences.app.defaultAvatar"
>
<template #title>
早安, {{ userStore.userInfo?.realName }}, 开始您一天的工作吧!
</template>
<template #description> 今日晴,20℃ - 32℃! </template>
</WorkbenchHeader>
<div class="mt-5 flex flex-col lg:flex-row">
<div class="mr-4 w-full lg:w-3/5">
<WorkbenchProject :items="projectItems" title="项目" @click="navTo" />
<WorkbenchTrends :items="trendItems" class="mt-5" title="最新动态" />
</div>
<div class="w-full lg:w-2/5">
<WorkbenchQuickNav
:items="quickNavItems"
class="mt-5 lg:mt-0"
title="快捷导航"
@click="navTo"
/>
<WorkbenchTodo :items="todoItems" class="mt-5" title="待办事项" />
<AnalysisChartCard class="mt-5" title="访问来源">
<AnalyticsVisitsSource />
</AnalysisChartCard>
</div>
</div>
</div>
</template>
@@ -235,9 +235,7 @@ onUnmounted(() => {
</script>
<template>
<div
class="h-full overflow-hidden bg-gradient-to-br from-indigo-100 via-pink-100 to-slate-100 p-8"
>
<div class="h-full overflow-hidden bg-slate-100 p-8">
<div class="mx-auto flex h-full w-[60%] flex-col overflow-hidden">
<!-- 头部标题 -->
<div class="mb-12 shrink-0 text-center">
@@ -254,10 +252,8 @@ onUnmounted(() => {
v-if="csvData.length === 0"
class="flex min-h-0 flex-1 flex-col overflow-hidden"
>
<div
class="mb-8 grid shrink-0 grid-cols-1 gap-6 lg:grid-cols-[2fr_1fr]"
>
<!-- 左侧:导入区域 -->
<div class="mb-8 shrink-0">
<!-- 导入区域 -->
<div
class="relative flex min-h-[400px] flex-col items-center justify-center overflow-hidden rounded-[2rem] border border-white/50 bg-white/45 p-8 shadow-[0_25px_50px_-12px_rgba(0,0,0,0.1)] backdrop-blur-2xl"
>
@@ -273,68 +269,6 @@ onUnmounted(() => {
/>
</div>
</div>
<!-- 右侧:指引与历史 -->
<div class="flex flex-col gap-6">
<!-- 操作指南卡片 -->
<div
class="relative flex flex-col gap-4 overflow-hidden rounded-[2rem] border border-white/50 bg-white/45 p-6 shadow-[0_25px_50px_-12px_rgba(0,0,0,0.1)] backdrop-blur-2xl"
>
<h3 class="m-0 text-base font-bold text-slate-800">操作指南</h3>
<div class="flex flex-col gap-4">
<div class="flex items-start gap-3">
<div
class="flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-indigo-600 text-xs font-bold text-white"
>
1
</div>
<p
class="m-0 text-xs font-medium leading-relaxed text-slate-500"
>
从电商后台导出【订单详情】CSV文件
</p>
</div>
<div class="flex items-start gap-3">
<div
class="flex h-6 w-6 shrink-0 items-center justify-center rounded-full border border-indigo-100 bg-white text-xs font-bold text-indigo-600"
>
2
</div>
<p
class="m-0 text-xs font-medium leading-relaxed text-slate-500"
>
检查文件是否包含【订单号】与【金额】列
</p>
</div>
<div class="flex items-start gap-3">
<div
class="flex h-6 w-6 shrink-0 items-center justify-center rounded-full border border-indigo-100 bg-white text-xs font-bold text-indigo-600"
>
3
</div>
<p
class="m-0 text-xs font-medium leading-relaxed text-slate-500"
>
上传成功后,系统将自动解析并显示数据
</p>
</div>
</div>
</div>
</div>
</div>
<!-- 底部全局按钮 -->
<div class="flex justify-center gap-4 pt-4">
<Button :disabled="csvData.length === 0" @click="handleClearData">
清空当前选择
</Button>
<Button
type="primary"
:disabled="csvHeaders.length === 0"
@click="handleCreateImportTask"
>
创建导入任务
</Button>
</div>
</div>
@@ -342,7 +276,7 @@ onUnmounted(() => {
<div v-else class="flex min-h-0 w-full flex-1 flex-col overflow-hidden">
<div
class="mb-6 flex shrink-0 flex-wrap items-start justify-between gap-4"
>
>
<div class="flex-1">
<h2 class="mb-1 text-2xl font-bold text-slate-800">数据预览</h2>
<p class="m-0 text-sm text-slate-500">
@@ -102,7 +102,7 @@ const handleDelete = (product: ProductVO.Info) => {
</span>
</div>
<span class="ml-4 font-semibold text-red-500 dark:text-red-400">
¥{{ spec.costPrice.toFixed(2) }}
¥{{ spec.productCost.toFixed(2) }}
</span>
</div>
</div>
@@ -17,7 +17,7 @@ import {
} from 'ant-design-vue';
import { createProductApi, updateProductApi } from '#/api/ecommerce/product';
import { uploadImageApi } from '#/api/media/image';
import { uploadFileToOss } from '#/utils/oss-upload';
interface Emits {
(e: 'success'): void;
@@ -30,9 +30,9 @@ const emit = defineEmits<Emits>();
// 创建Vben Modal实例
const [Modal, modalApi] = useVbenModal({
title: '添加商品',
class: 'w-[800px]',
class: 'w-[1000px]',
draggable: true, // 开启拖拽
contentClass: 'px-6 py-4',
contentClass: 'px-5 py-4',
onConfirm: handleSubmit,
onCancel: close,
onOpenChange: (isOpen: boolean) => {
@@ -67,10 +67,7 @@ const imageLoadError = ref(false); // 图片加载错误状态
const formData = ref({
name: '',
productCode: '',
specCode: '',
skuCode: '',
mainImageId: undefined as number | undefined,
costPrice: 0,
});
// 规格数据 - 支持创建和更新
@@ -88,30 +85,17 @@ const currentImageUrl = computed(() => {
// 初始化表单数据
function initFormData() {
if (isEdit.value && currentProductData.value) {
// 编辑模式
// 注意:ProductVO.Info 中可能没有 specCode、skuCode、costPrice 字段
// 这些字段可能需要在编辑时从其他地方获取或设置为空
const productData = currentProductData.value as any;
formData.value = {
name: currentProductData.value.name || '',
productCode: currentProductData.value.productCode || '',
specCode: productData.specCode || '',
skuCode: productData.skuCode || '',
mainImageId: undefined,
costPrice: productData.costPrice ?? 0,
};
// 设置原始图片 URL
originalImageUrl.value = currentProductData.value.mainImage || '';
} else {
// 创建模式 - 如果有传入的productData,则使用它来初始化表单
formData.value = {
name: currentProductData.value?.name || '',
productCode: currentProductData.value?.productCode || '',
specCode: '',
skuCode: '',
mainImageId: undefined,
costPrice: 0,
};
originalImageUrl.value = currentProductData.value?.mainImage || '';
}
@@ -130,25 +114,25 @@ function initFormData() {
'specs' in currentProductData.value &&
currentProductData.value.specs
) {
if (isEdit.value) {
// 编辑模式:使用 UpdateSpec 格式,包含 id
specs.value = currentProductData.value.specs.map(
(spec) =>
({
id: (spec as ProductVO.SpecInfo).id,
name: (spec as ProductVO.SpecInfo).name || spec.specCode || '',
specCode: spec.specCode || '',
costPrice: spec.costPrice || 0,
}) as ProductDTO.UpdateSpec,
);
} else {
// 创建模式:使用 Spec 格式
specs.value = currentProductData.value.specs.map((spec) => ({
name: (spec as ProductVO.SpecInfo).name || spec.specCode || '',
specCode: spec.specCode || '',
costPrice: spec.costPrice || 0,
}));
}
const mapSpec = (spec: ProductVO.SpecInfo) => ({
name: spec.name || spec.specCode || '',
specCode: spec.specCode || '',
productCost: spec.productCost ?? 0,
shippingCost: spec.shippingCost ?? 0,
otherCost: spec.otherCost ?? 0,
remark: spec.remark || '',
});
specs.value = isEdit.value
? currentProductData.value.specs.map(
(spec) =>
({
id: (spec as ProductVO.SpecInfo).id,
...mapSpec(spec as ProductVO.SpecInfo),
}) as ProductDTO.UpdateSpec,
)
: currentProductData.value.specs.map((spec) =>
mapSpec(spec as ProductVO.SpecInfo),
);
showSpecs.value = specs.value.length > 0;
}
}
@@ -305,22 +289,21 @@ function removeNewImage() {
message.success('已重置图片');
}
const defaultSpec = (): ProductDTO.Spec => ({
name: '',
specCode: '',
productCost: 0,
shippingCost: 0,
otherCost: 0,
remark: '',
});
// 添加规格
function addSpec() {
if (isEdit.value) {
// 编辑模式:新增的规格暂时不包含id,服务器端会识别并创建新规格
specs.value.push({
name: '',
specCode: '',
costPrice: 0,
} as ProductDTO.Spec);
specs.value.push(defaultSpec() as ProductDTO.Spec);
} else {
// 创建模式
specs.value.push({
name: '',
specCode: '',
costPrice: 0,
});
specs.value.push(defaultSpec());
}
}
@@ -335,7 +318,7 @@ const specColumns = [
title: '规格名称',
dataIndex: 'name',
key: 'name',
width: '30%',
width: 300,
customRender: ({
record,
}: {
@@ -354,7 +337,7 @@ const specColumns = [
title: '规格编码',
dataIndex: 'specCode',
key: 'specCode',
width: '30%',
width: 140,
customRender: ({
record,
}: {
@@ -370,23 +353,86 @@ const specColumns = [
},
},
{
title: '成本价',
dataIndex: 'costPrice',
key: 'costPrice',
width: '25%',
title: '商品成本',
dataIndex: 'productCost',
key: 'productCost',
width: 100,
customRender: ({
record,
}: {
record: ProductDTO.Spec | ProductDTO.UpdateSpec;
}) => {
return h(InputNumber, {
value: record.costPrice,
placeholder: '请输入成本价',
value: record.productCost,
placeholder: '商品成本',
min: 0,
precision: 2,
style: { width: '100%' },
'onUpdate:value': (value: null | number) => {
record.costPrice = value ?? 0;
record.productCost = value ?? 0;
},
} as any);
},
},
{
title: '运费成本',
dataIndex: 'shippingCost',
key: 'shippingCost',
width: 90,
customRender: ({
record,
}: {
record: ProductDTO.Spec | ProductDTO.UpdateSpec;
}) => {
return h(InputNumber, {
value: record.shippingCost ?? 0,
placeholder: '运费',
min: 0,
precision: 2,
style: { width: '100%' },
'onUpdate:value': (value: null | number) => {
record.shippingCost = value ?? 0;
},
} as any);
},
},
{
title: '其他成本',
dataIndex: 'otherCost',
key: 'otherCost',
width: 90,
customRender: ({
record,
}: {
record: ProductDTO.Spec | ProductDTO.UpdateSpec;
}) => {
return h(InputNumber, {
value: record.otherCost ?? 0,
placeholder: '其他',
min: 0,
precision: 2,
style: { width: '100%' },
'onUpdate:value': (value: null | number) => {
record.otherCost = value ?? 0;
},
} as any);
},
},
{
title: '备注',
dataIndex: 'remark',
key: 'remark',
width: 100,
customRender: ({
record,
}: {
record: ProductDTO.Spec | ProductDTO.UpdateSpec;
}) => {
return h(Input, {
value: record.remark ?? '',
placeholder: '备注',
'onUpdate:value': (value: string) => {
record.remark = value ?? '';
},
});
},
@@ -394,7 +440,7 @@ const specColumns = [
{
title: '操作',
key: 'action',
width: '15%',
width: 80,
align: 'center' as const,
customRender: ({ index }: { index: number }) => {
return h(
@@ -421,11 +467,13 @@ async function uploadImageAndGetId(): Promise<number | undefined> {
}
try {
const response = await uploadImageApi(newImageFile.value);
return response.id;
const fileInfo = await uploadFileToOss(newImageFile.value, {
category: 'product-main-image',
errorMessage: '主图上传失败',
});
return fileInfo.id;
} catch (error) {
console.error('图片上传失败:', error);
message.error('图片上传失败');
throw error;
}
}
@@ -448,12 +496,7 @@ onUnmounted(() => {
<template>
<Modal>
<Form
ref="formRef"
:model="formData"
:label-col="{ span: 6 }"
:wrapper-col="{ span: 18 }"
>
<Form ref="formRef" :model="formData">
<Form.Item label="商品主图" name="mainImageId">
<div style="display: flex; align-items: center; gap: 16px">
<!-- 主图预览区域 -->
@@ -335,7 +335,7 @@ defineExpose({
white-space: nowrap;
"
>
¥{{ spec.costPrice.toFixed(2) }}
¥{{ spec.productCost.toFixed(2) }}
</span>
</div>
</div>
@@ -8,11 +8,8 @@ import { createIconifyIcon } from '@vben/icons';
import { Button, Form, Input, message, Select } from 'ant-design-vue';
import {
createShopApi,
updateShopApi,
uploadShopLogoApi,
} from '#/api/ecommerce/shop';
import { createShopApi, updateShopApi } from '#/api/ecommerce/shop';
import { uploadFileToOss } from '#/utils/oss-upload';
interface Emits {
(e: 'success'): void;
@@ -230,11 +227,13 @@ async function uploadLogoAndGetId(): Promise<number | undefined> {
}
try {
const response = await uploadShopLogoApi(newLogoFile.value);
return response.id;
const fileInfo = await uploadFileToOss(newLogoFile.value, {
category: 'shop-logo',
errorMessage: 'Logo上传失败',
});
return fileInfo.id;
} catch (error) {
console.error('Logo上传失败:', error);
message.error('Logo上传失败');
throw error;
}
}
@@ -256,13 +255,12 @@ onUnmounted(() => {
</script>
<template>
<Modal :title="modalTitle" :confirm-loading="loading">
<Form
ref="formRef"
:model="formData"
:label-col="{ span: 6 }"
:wrapper-col="{ span: 18 }"
>
<Modal
:title="modalTitle"
:confirm-loading="loading"
content-class="px-5 py-4"
>
<Form ref="formRef" :model="formData">
<Form.Item label="店铺Logo" name="logoImageId">
<div style="display: flex; align-items: center; gap: 16px">
<!-- Logo预览区域 -->
@@ -227,7 +227,7 @@ function handleModalSuccess() {
// 处理查看详情
function handleViewDetails(record: ShopVO.Info) {
router.push(`/ecom/shop/details/${record.id}`);
router.push(`/ecom/shop/overview/${record.id}`);
}
</script>
@@ -267,6 +267,48 @@ watch(
// 初始化
onMounted(() => {
// 检查查询参数,如果有则设置时间范围
const query = route.query;
if (query.startDate && query.endDate) {
const startDate = dayjs(query.startDate as string);
const endDate = dayjs(query.endDate as string);
const today = dayjs();
if (startDate.isValid() && endDate.isValid()) {
dateRange.value = [startDate, endDate];
// 判断时间范围类型
const daysDiff = endDate.diff(startDate, 'day');
const isEndDateToday = endDate.isSame(today, 'day');
const isStartDate7DaysAgo = startDate.isSame(
dayjs().subtract(7, 'day'),
'day',
);
const isStartDate30DaysAgo = startDate.isSame(
dayjs().subtract(30, 'day'),
'day',
);
if (daysDiff === 0 && startDate.isSame(today, 'day')) {
activeTimeRange.value = 'today';
} else if (
daysDiff === 0 &&
startDate.isSame(dayjs().subtract(1, 'day'), 'day')
) {
activeTimeRange.value = 'yesterday';
} else if (isEndDateToday && isStartDate7DaysAgo) {
// 近7天:从7天前到今天
activeTimeRange.value = '7days';
} else if (isEndDateToday && isStartDate30DaysAgo) {
// 近30天:从30天前到今天
activeTimeRange.value = '30days';
} else {
activeTimeRange.value = 'custom';
customDateRange.value = [startDate, endDate];
}
}
}
// 设置完时间范围后再加载数据
if (shopId.value) {
loadOverviewData();
}
@@ -274,7 +316,11 @@ onMounted(() => {
</script>
<template>
<Page title="店铺经营概览" auto-content-height class="bg-[#f8fafc]">
<Page
:title="overviewData?.shopName || '店铺经营概览'"
auto-content-height
class="bg-[#f8fafc]"
>
<template #description>
<div class="mt-1 text-sm font-bold italic text-slate-500">
数据更新于:{{ dayjs().format('今日 HH:mm:ss') }}
@@ -1,157 +0,0 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>订单导入中心 - 毛玻璃设计</title>
<script src="https://cdn.tailwindcss.com"></script>
<link href="https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;600;700&display=swap" rel="stylesheet">
<style>
body {
font-family: 'Plus Jakarta Sans', sans-serif;
/* 延续统计页的柔和渐变背景 */
background: linear-gradient(135deg, #e0e7ff 0%, #fae8ff 50%, #f1f5f9 100%);
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
}
.glass {
background: rgba(255, 255, 255, 0.45);
backdrop-filter: blur(16px);
-webkit-backdrop-filter: blur(16px);
border: 1px solid rgba(255, 255, 255, 0.5);
box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.1);
}
.drop-zone {
border: 2px dashed rgba(99, 102, 241, 0.3);
transition: all 0.3s ease;
}
.drop-zone:hover {
border-color: #6366f1;
background: rgba(99, 102, 241, 0.05);
transform: scale(1.01);
}
.step-circle {
width: 24px;
height: 24px;
display: flex;
align-items: center;
justify-content: center;
border-radius: 50%;
font-size: 12px;
font-weight: bold;
}
</style>
</head>
<body class="p-4">
<div class="max-w-4xl w-full space-y-6">
<!-- 头部标题 -->
<div class="text-center space-y-2 mb-8">
<h1 class="text-4xl font-black text-slate-800 tracking-tight">订单导入中心</h1>
<p class="text-slate-500 font-medium">请上传 CSV 格式的订单原始数据进行分析</p>
</div>
<div class="grid grid-cols-1 lg:grid-cols-3 gap-6">
<!-- 左侧:导入区域 -->
<div class="lg:col-span-2 glass p-8 rounded-[2.5rem] flex flex-col justify-center items-center relative overflow-hidden">
<!-- 装饰性光晕 -->
<div class="absolute -top-10 -right-10 w-32 h-32 bg-indigo-400 opacity-10 blur-3xl"></div>
<div class="w-full drop-zone rounded-[2rem] p-12 flex flex-col items-center justify-center space-y-4 cursor-pointer">
<div class="w-16 h-16 bg-indigo-100 text-indigo-600 rounded-2xl flex items-center justify-center shadow-inner">
<svg xmlns="http://www.w3.org/2000/svg" class="h-8 w-8" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 16a4 4 0 01-.88-7.903A5 5 0 1115.9 6L16 6a5 5 0 011 9.9M15 13l-3-3m0 0l-3 3m3-3v12" />
</svg>
</div>
<div class="text-center">
<p class="text-lg font-bold text-slate-700">拖拽 CSV 文件到此处上传</p>
<p class="text-sm text-slate-400 mt-1">支持标准电商平台导出格式,最大 20MB</p>
</div>
<button class="bg-indigo-600 text-white px-8 py-3 rounded-xl font-bold shadow-lg shadow-indigo-200 hover:bg-indigo-700 transition">
选择本地文件
</button>
</div>
<!-- 导入选项 -->
<div class="w-full mt-8 flex justify-between items-center text-sm">
<div class="flex items-center gap-4">
<label class="flex items-center gap-2 cursor-pointer">
<input type="checkbox" class="rounded text-indigo-600 focus:ring-indigo-500">
<span class="text-slate-500 font-medium">自动去重</span>
</label>
<label class="flex items-center gap-2 cursor-pointer">
<input type="checkbox" checked class="rounded text-indigo-600 focus:ring-indigo-500">
<span class="text-slate-500 font-medium">覆盖旧数据</span>
</label>
</div>
<a href="#" class="text-indigo-600 font-bold hover:underline">下载导入模板</a>
</div>
</div>
<!-- 右侧:指引与历史 -->
<div class="space-y-6">
<!-- 步骤卡片 -->
<div class="glass p-6 rounded-[2rem] space-y-4">
<h3 class="font-bold text-slate-800 flex items-center gap-2">
操作指南
</h3>
<div class="space-y-4">
<div class="flex gap-3">
<div class="step-circle bg-indigo-600 text-white">1</div>
<p class="text-xs text-slate-500 leading-relaxed font-medium">从电商后台导出【订单详情】CSV文件</p>
</div>
<div class="flex gap-3">
<div class="step-circle bg-white text-indigo-600 border border-indigo-100">2</div>
<p class="text-xs text-slate-500 leading-relaxed font-medium">检查文件是否包含【订单号】与【金额】列</p>
</div>
<div class="flex gap-3">
<div class="step-circle bg-white text-indigo-600 border border-indigo-100">3</div>
<p class="text-xs text-slate-500 leading-relaxed font-medium">上传成功后,系统将自动跳转至统计页面</p>
</div>
</div>
</div>
<!-- 最近上传历史 -->
<div class="glass p-6 rounded-[2rem] space-y-4">
<div class="flex justify-between items-center">
<h3 class="font-bold text-slate-800">最近导入</h3>
<span class="text-[10px] font-bold text-indigo-500">查看全部</span>
</div>
<div class="space-y-3">
<div class="flex items-center justify-between p-3 rounded-2xl bg-white/30 text-xs">
<div>
<p class="font-bold text-slate-700 italic">20231027_orders.csv</p>
<p class="text-[10px] text-slate-400">10:20 · 1,280 行</p>
</div>
<span class="text-emerald-500 font-black">完成</span>
</div>
<div class="flex items-center justify-between p-3 rounded-2xl bg-white/30 text-xs">
<div>
<p class="font-bold text-slate-700 italic">temp_data_02.csv</p>
<p class="text-[10px] text-slate-400">昨天 · 450 行</p>
</div>
<span class="text-slate-400 font-black">失效</span>
</div>
</div>
</div>
</div>
</div>
<!-- 底部全局按钮 -->
<div class="flex justify-center gap-4 pt-4">
<button class="glass px-10 py-3 rounded-2xl font-bold text-slate-500 hover:bg-white/60 transition">
清空当前选择
</button>
<button class="bg-slate-900 text-white px-10 py-3 rounded-2xl font-bold shadow-2xl hover:bg-slate-800 transition">
开始解析并创建任务
</button>
</div>
</div>
</body>
</html>
@@ -1,178 +0,0 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>创建导入任务 - 毛玻璃组件</title>
<script src="https://cdn.tailwindcss.com"></script>
<link href="https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;600;700&display=swap" rel="stylesheet">
<style>
body {
font-family: 'Plus Jakarta Sans', sans-serif;
background: linear-gradient(135deg, #e0e7ff 0%, #fae8ff 50%, #f1f5f9 100%);
min-height: 100vh;
display: flex; align-items: center; justify-content: center;
}
/* 延续之前的 Glass 核心类 */
.glass {
background: rgba(255, 255, 255, 0.45);
backdrop-filter: blur(20px);
-webkit-backdrop-filter: blur(20px);
border: 1px solid rgba(255, 255, 255, 0.5);
}
/* 内部映射卡片 */
.glass-inner-card {
background: rgba(255, 255, 255, 0.3);
border: 1px solid rgba(255, 255, 255, 0.4);
transition: all 0.3s ease;
}
.glass-inner-card:hover { background: rgba(255, 255, 255, 0.5); transform: translateY(-2px); }
/* 步进器线条动画 */
.step-line { height: 2px; background: rgba(99, 102, 241, 0.1); flex-grow: 1; margin: 0 1rem; position: relative; overflow: hidden; }
.step-line-active::after { content: ""; position: absolute; left: 0; top: 0; height: 100%; width: 100%; background: #6366f1; animation: slide 1s ease-in-out; }
@keyframes slide { from { width: 0; } to { width: 100%; } }
.custom-scroll::-webkit-scrollbar { width: 4px; }
.custom-scroll::-webkit-scrollbar-thumb { background: rgba(99, 102, 241, 0.2); border-radius: 10px; }
</style>
</head>
<body class="p-4">
<!-- 弹窗主体容器 -->
<div class="max-w-4xl w-full glass rounded-[3rem] shadow-2xl overflow-hidden flex flex-col max-h-[90vh]">
<!-- Header -->
<div class="px-10 py-8 border-b border-white/40 flex justify-between items-center">
<div>
<h2 class="text-2xl font-black text-slate-800 tracking-tight">创建导入任务</h2>
<p class="text-xs text-slate-500 font-bold mt-1 uppercase tracking-widest">Import Task Wizard</p>
</div>
<button class="w-10 h-10 glass rounded-full flex items-center justify-center text-slate-400 hover:text-slate-600 transition">✕</button>
</div>
<!-- 步进器 Stepper -->
<div class="px-12 py-10">
<div class="flex items-center">
<!-- Step 1: Done -->
<div class="flex items-center">
<div class="w-10 h-10 bg-indigo-100 text-indigo-600 rounded-2xl flex items-center justify-center font-bold shadow-inner">✓</div>
<span class="ml-3 text-xs font-black text-indigo-600">选择店铺</span>
</div>
<div class="step-line step-line-active"></div>
<!-- Step 2: Active -->
<div class="flex items-center">
<div class="w-10 h-10 bg-indigo-600 text-white rounded-2xl flex items-center justify-center font-bold shadow-lg shadow-indigo-200">2</div>
<span class="ml-3 text-xs font-black text-slate-700">字段映射</span>
</div>
<div class="step-line"></div>
<!-- Step 3: Pending -->
<div class="flex items-center">
<div class="w-10 h-10 glass rounded-2xl flex items-center justify-center font-bold text-slate-400">3</div>
<span class="ml-3 text-xs font-bold text-slate-400">状态映射</span>
</div>
<div class="step-line"></div>
<!-- Step 4: Pending -->
<div class="flex items-center">
<div class="w-10 h-10 glass rounded-2xl flex items-center justify-center font-bold text-slate-400">4</div>
<span class="ml-3 text-xs font-bold text-slate-400">确认信息</span>
</div>
</div>
</div>
<!-- 内容区域 (这里以 Step 2 字段映射为例展示) -->
<div class="px-12 pb-10 flex-1 overflow-y-auto custom-scroll space-y-6">
<!-- 顶部操作栏 -->
<div class="flex justify-between items-center bg-white/20 p-4 rounded-2xl border border-white/40">
<span class="text-sm font-medium text-slate-600">系统已根据 CSV 表头为您自动匹配了 5 个字段</span>
<div class="flex gap-2">
<select class="bg-white/50 border-none rounded-xl text-xs font-bold px-4 py-2 outline-none">
<option>默认映射模板 (拼多多)</option>
</select>
<button class="text-xs font-bold text-indigo-600 hover:underline">保存为新模板</button>
</div>
</div>
<!-- 映射列表布局 -->
<div class="grid grid-cols-1 gap-4">
<!-- 映射单元 1 -->
<div class="glass-inner-card p-5 rounded-[1.5rem] flex items-center gap-8">
<div class="w-1/3">
<label class="text-[10px] font-black text-indigo-500 uppercase">系统标准字段</label>
<h4 class="text-base font-bold text-slate-800">规格编码 <span class="text-rose-500">*</span></h4>
<p class="text-[10px] text-slate-400">字段定义: spec_code</p>
</div>
<div class="flex-1 flex items-center gap-4">
<div class="text-slate-300">
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M14 5l7 7m0 0l-7 7m7-7H3"/></svg>
</div>
<div class="flex-1">
<select class="w-full bg-white/60 border border-white/80 rounded-2xl px-5 py-3 text-sm font-bold outline-none focus:ring-2 focus:ring-indigo-300 transition-all">
<option>商家编码-规格维度 (CSV列)</option>
<option>商品ID</option>
</select>
</div>
</div>
</div>
<!-- 映射单元 2 (错误示例) -->
<div class="glass-inner-card p-5 rounded-[1.5rem] flex items-center gap-8 border-rose-200 bg-rose-50/20">
<div class="w-1/3">
<label class="text-[10px] font-black text-rose-500 uppercase">系统标准字段</label>
<h4 class="text-base font-bold text-slate-800">商家实收金额 <span class="text-rose-500">*</span></h4>
<p class="text-[10px] text-slate-400">字段定义: received_amount</p>
</div>
<div class="flex-1 flex items-center gap-4">
<div class="text-rose-300">
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M14 5l7 7m0 0l-7 7m7-7H3"/></svg>
</div>
<div class="flex-1">
<select class="w-full bg-rose-50/50 border border-rose-200 rounded-2xl px-5 py-3 text-sm font-bold outline-none text-rose-500">
<option>-- 请选择 CSV 对应列 --</option>
</select>
</div>
</div>
</div>
<!-- 映射单元 3 -->
<div class="glass-inner-card p-5 rounded-[1.5rem] flex items-center gap-8">
<div class="w-1/3">
<label class="text-[10px] font-black text-indigo-500 uppercase">系统标准字段</label>
<h4 class="text-base font-bold text-slate-800">下单时间 <span class="text-rose-500">*</span></h4>
</div>
<div class="flex-1 flex items-center gap-4">
<div class="text-slate-300">
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M14 5l7 7m0 0l-7 7m7-7H3"/></svg>
</div>
<div class="flex-1">
<select class="w-full bg-white/60 border border-white/80 rounded-2xl px-5 py-3 text-sm font-bold outline-none">
<option>支付时间 (Pay Time)</option>
</select>
</div>
</div>
</div>
</div>
</div>
<!-- Footer -->
<div class="px-12 py-8 border-t border-white/40 bg-white/20 flex justify-between items-center">
<button class="px-8 py-3 rounded-2xl font-bold text-slate-500 hover:bg-white/50 transition">
取消导入
</button>
<div class="flex gap-4">
<button class="glass px-8 py-3 rounded-2xl font-bold text-indigo-600 hover:bg-white/60 transition border border-indigo-100">
上一步
</button>
<button class="bg-indigo-600 text-white px-10 py-3 rounded-2xl font-bold shadow-xl shadow-indigo-200 hover:bg-indigo-700 transition">
下一步:状态映射
</button>
</div>
</div>
</div>
</body>
</html>
@@ -1,306 +0,0 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>全店铺经营看板</title>
<script src="https://cdn.tailwindcss.com"></script>
<script src="https://cdn.jsdelivr.net/npm/echarts@5.4.3/dist/echarts.min.js"></script>
<!-- 引入中文字体优化 -->
<link href="https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@400;500;700;900&display=swap" rel="stylesheet">
<style>
body {
font-family: 'Noto Sans SC', sans-serif;
background-color: #f8fafc; /* 参考背景色 */
color: #0f172a; /* 加深文字颜色提升清晰度 */
}
.glass-card {
background: rgba(255, 255, 255, 0.9); /* 增加不透明度提升识别度 */
backdrop-filter: blur(10px);
border: 1px solid #e2e8f0;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
border-radius: 16px;
}
/* 表格滚动条 */
.table-container::-webkit-scrollbar { height: 8px; }
.table-container::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; }
.table-container::-webkit-scrollbar-track { background: #f1f5f9; }
/* 固定首列颜色 */
.sticky-col {
position: sticky;
left: 0;
background: #fff;
z-index: 10;
border-right: 2px solid #f1f5f9;
}
</style>
</head>
<body class="p-4 md:p-8">
<div class="w-full mx-auto space-y-6">
<!-- 头部:标题与筛选 -->
<header class="flex flex-col lg:flex-row justify-between items-start lg:items-center gap-6">
<div>
<h1 class="text-3xl font-black text-slate-900 tracking-tight">全店铺经营概览大盘</h1>
<p class="text-slate-500 font-bold mt-1 text-sm">数据范围:公司旗下所有店铺汇总统计</p>
</div>
<!-- 时间选择器 -->
<div class="flex items-center gap-2 bg-slate-200/50 p-1.5 rounded-2xl border border-slate-200">
<div class="flex gap-1">
<button class="bg-white px-5 py-2 text-sm font-bold rounded-xl shadow-sm text-blue-600">今日</button>
<button class="px-5 py-2 text-sm font-bold text-slate-600 hover:bg-white/50 rounded-xl transition">昨日</button>
<button class="px-5 py-2 text-sm font-bold text-slate-600 hover:bg-white/50 rounded-xl transition">近7日</button>
<button class="px-5 py-2 text-sm font-bold text-slate-600 hover:bg-white/50 rounded-xl transition">近30日</button>
</div>
<div class="w-px h-6 bg-slate-300 mx-2"></div>
<div class="flex items-center gap-2 px-3">
<span class="text-xs font-bold text-slate-400">自定义日期</span>
<input type="date" class="bg-transparent text-sm font-bold outline-none border-none cursor-pointer">
</div>
</div>
</header>
<!-- 第一层:核心汇总指标 (适配 Info 接口) -->
<div class="grid grid-cols-1 sm:grid-cols-2 xl:grid-cols-4 gap-6">
<!-- 销售额 -->
<div class="glass-card p-6">
<div class="flex justify-between items-start mb-4">
<span class="text-xs font-black text-slate-500">全店总销售额</span>
<span class="text-xs font-bold text-emerald-600 bg-emerald-50 px-2 py-1 rounded">较上月 +14.2%</span>
</div>
<div class="text-4xl font-black text-slate-900 leading-none">¥4,829,400</div>
<div class="mt-6 pt-4 border-t border-slate-100 flex justify-between items-center">
<span class="text-xs font-bold text-slate-400">销售额目标达成率</span>
<span class="text-sm font-black text-blue-600">96.5%</span>
</div>
</div>
<!-- ROI效率 -->
<div class="glass-card p-6">
<div class="text-xs font-black text-slate-500 mb-4">投资回报率 (ROI)</div>
<div class="text-4xl font-black text-indigo-600 leading-none">4.05</div>
<div class="mt-6 pt-4 border-t border-slate-100">
<div class="flex justify-between text-xs font-bold text-slate-400">
<span>全店平均费比</span>
<span class="text-slate-900">24.6%</span>
</div>
</div>
</div>
<!-- 订单达成 -->
<div class="glass-card p-6">
<div class="text-xs font-black text-slate-500 mb-4">销量目标达成率 (订单数)</div>
<div class="text-4xl font-black text-slate-900 leading-none">92.1%</div>
<div class="w-full bg-slate-100 h-2 mt-6 rounded-full overflow-hidden">
<div class="bg-indigo-500 h-full" style="width: 92.1%"></div>
</div>
</div>
<!-- 税后利润 -->
<div class="glass-card p-6 border-l-4 border-l-emerald-500">
<div class="text-xs font-black text-emerald-600 mb-4">全店总净利润 (税后)</div>
<div class="text-4xl font-black text-emerald-600 leading-none">¥842,500</div>
<div class="mt-6 pt-4 border-t border-slate-100 flex justify-between text-[11px] font-bold text-slate-400">
<span>已扣除预扣税额 (4%)</span>
<span>¥193,176</span>
</div>
</div>
</div>
<!-- 第二层:深度分析图表 -->
<div class="grid grid-cols-1 xl:grid-cols-2 gap-6">
<!-- 销售占比排行 -->
<div class="glass-card p-8">
<h3 class="text-lg font-black text-slate-800 mb-6">各店铺销售贡献排行</h3>
<div id="salesRatioChart" style="height: 380px;" class="w-full"></div>
</div>
<!-- 效率象限图 -->
<div class="glass-card p-8">
<h3 class="text-lg font-black text-slate-800 mb-6">店铺经营效率象限 (ROI vs 净利)</h3>
<div id="efficiencyChart" style="height: 380px;" class="w-full"></div>
<!-- 象限图中文说明 -->
<div class="mt-4 flex gap-6 justify-center">
<div class="flex items-center gap-2 text-xs font-bold text-slate-600"><span class="w-3 h-3 bg-emerald-500 rounded-full"></span> 高产区</div>
<div class="flex items-center gap-2 text-xs font-bold text-slate-600"><span class="w-3 h-3 bg-blue-500 rounded-full"></span> 潜力区</div>
<div class="flex items-center gap-2 text-xs font-bold text-slate-600"><span class="w-3 h-3 bg-rose-500 rounded-full"></span> 风险区</div>
</div>
</div>
</div>
<!-- 第三层:横向对比大表 (适配 16 个维度) -->
<div class="glass-card overflow-hidden">
<div class="p-8 border-b border-slate-100 flex flex-col md:flex-row justify-between items-start md:items-center gap-4">
<div>
<h3 class="text-xl font-black text-slate-800">各店铺多维度经营明细对比</h3>
<p class="text-xs text-slate-400 font-bold mt-1">包含:目标达成、规模、成本及最终损益所有维度</p>
</div>
<button class="bg-slate-900 text-white px-8 py-3 rounded-2xl text-sm font-bold shadow-xl shadow-slate-200 hover:scale-105 active:scale-95 transition-all">导出财务分析报表</button>
</div>
<div class="table-container overflow-x-auto">
<table class="w-full text-left text-sm whitespace-nowrap">
<!-- 表头分组 -->
<thead class="bg-slate-50 text-[11px] font-black text-slate-500 uppercase">
<tr>
<th rowspan="2" class="p-6 border-b sticky-col shadow-sm text-slate-900 text-sm">店铺名称</th>
<th colspan="4" class="p-3 border-b border-l border-slate-200 text-center bg-blue-50/50 text-blue-700">目标达成维度</th>
<th colspan="3" class="p-3 border-b border-l border-slate-200 text-center bg-slate-100/50">经营规模维度</th>
<th colspan="5" class="p-3 border-b border-l border-slate-200 text-center bg-orange-50/50 text-orange-700">成本费用维度</th>
<th colspan="4" class="p-3 border-b border-l border-slate-200 text-center bg-emerald-50/50 text-emerald-700">盈利分析维度</th>
</tr>
<tr class="bg-slate-50/80">
<!-- 目标 -->
<th class="px-6 py-4 border-b border-l">目标单量</th>
<th class="px-6 py-4 border-b text-blue-600">单量达成率</th>
<th class="px-6 py-4 border-b">目标额</th>
<th class="px-6 py-4 border-b text-blue-600">销售达成率</th>
<!-- 规模 -->
<th class="px-6 py-4 border-b border-l text-slate-900">实际销售额</th>
<th class="px-6 py-4 border-b">单量</th>
<th class="px-6 py-4 border-b">客单价</th>
<!-- 成本 -->
<th class="px-6 py-4 border-b border-l">成本运费</th>
<th class="px-6 py-4 border-b text-rose-600">退款金额</th>
<th class="px-6 py-4 border-b">推广费</th>
<th class="px-6 py-4 border-b">刷单费用</th>
<th class="px-6 py-4 border-b">费比 %</th>
<!-- 盈利 -->
<th class="px-6 py-4 border-b border-l">税前盈亏</th>
<th class="px-6 py-4 border-b text-rose-500 italic">4%税额</th>
<th class="px-6 py-4 border-b font-black text-indigo-700">ROI</th>
<th class="px-6 py-4 border-b bg-emerald-600 text-white font-black">税后盈亏</th>
</tr>
</thead>
<tbody class="divide-y divide-slate-100">
<!-- 演示数据 -->
<tr class="hover:bg-blue-50/50 transition-colors">
<td class="p-6 font-bold text-slate-900 sticky-col shadow-sm">精品家居旗舰店</td>
<!-- 目标 -->
<td class="p-6 font-medium">2,000</td>
<td class="p-6 font-black text-blue-600">85.4%</td>
<td class="p-6 font-medium">¥320,000</td>
<td class="p-6 font-black text-blue-600">92.1%</td>
<!-- 规模 -->
<td class="p-6 font-black">¥294,000</td>
<td class="p-6 font-medium">1,708</td>
<td class="p-6 font-medium">¥172.1</td>
<!-- 成本 -->
<td class="p-6">¥82,400</td>
<td class="p-6 text-rose-600 font-bold">¥12,400</td>
<td class="p-6">¥45,000</td>
<td class="p-6 text-orange-600">¥4,500</td>
<td class="p-6 text-slate-400">15.3%</td>
<!-- 盈利 -->
<td class="p-6 font-bold">¥142,500</td>
<td class="p-6 text-slate-400 italic">¥11,760</td>
<td class="p-6 font-black text-indigo-700">4.21</td>
<td class="p-6 font-black text-emerald-600 bg-emerald-50 text-base">¥124,500</td>
</tr>
<!-- 第二行数据 -->
<tr class="hover:bg-blue-50/50 transition-colors">
<td class="p-6 font-bold text-slate-900 sticky-col shadow-sm">运动户外品牌店</td>
<!-- 目标 -->
<td class="p-6">5,000</td>
<td class="p-6 font-black text-emerald-600">105.2%</td>
<td class="p-6">¥1,000,000</td>
<td class="p-6 font-black text-emerald-600">108.4%</td>
<!-- 规模 -->
<td class="p-6 font-black">¥1,084,000</td>
<td class="p-6">5,210</td>
<td class="p-6">¥208.1</td>
<!-- 成本 -->
<td class="p-6">¥324,000</td>
<td class="p-6 text-rose-600 font-bold">¥42,100</td>
<td class="p-6">¥185,000</td>
<td class="p-6 text-orange-600">¥10,000</td>
<td class="p-6 text-slate-400">17.1%</td>
<!-- 盈利 -->
<td class="p-6 font-bold">¥485,000</td>
<td class="p-6 text-slate-400 italic">¥43,360</td>
<td class="p-6 font-black text-indigo-700">5.85</td>
<td class="p-6 font-black text-emerald-600 bg-emerald-50 text-base">¥441,640</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<script>
// 1. 各店铺排行 (中文优化)
const salesChart = echarts.init(document.getElementById('salesRatioChart'));
salesChart.setOption({
grid: { left: '3%', right: '12%', bottom: '3%', top: '3%', containLabel: true },
tooltip: { trigger: 'axis' },
xAxis: { type: 'value', axisLabel: { show: false }, splitLine: { show: false } },
yAxis: {
type: 'category',
data: ['海外旗舰店', '运动户外店', '潮流男装店', '精品家居店'],
axisLine: { show: false },
axisTick: { show: false },
axisLabel: { fontWeight: 'bold', color: '#1e293b', fontSize: 13 }
},
series: [{
type: 'bar',
data: [420000, 1084000, 1150000, 1284000],
barWidth: 20,
itemStyle: {
borderRadius: [0, 10, 10, 0],
color: new echarts.graphic.LinearGradient(1, 0, 0, 0, [
{ offset: 0, color: '#6366f1' },
{ offset: 1, color: '#a5b4fc' }
])
},
label: { show: true, position: 'right', formatter: '¥{c}', fontWeight: '900', color: '#0f172a' }
}]
});
// 2. 效率象限图 (中文标签)
const efficiencyChart = echarts.init(document.getElementById('efficiencyChart'));
efficiencyChart.setOption({
tooltip: {
formatter: (params) => `<div style="padding:4px font-weight:bold">${params.data[2]}</div><hr/>投资回报率 (ROI): ${params.data[0]}<br/>净利润: ¥${params.data[1]}w`
},
xAxis: {
name: '投资回报率 (ROI)', nameLocation: 'center', nameGap: 35,
axisLabel: { fontWeight: 'bold' },
splitLine: { lineStyle: { type: 'dashed' } }
},
yAxis: {
name: '税后净利润 (单位: 万元)',
axisLabel: { fontWeight: 'bold' },
splitLine: { lineStyle: { type: 'dashed' } }
},
series: [{
type: 'scatter',
symbolSize: 45,
data: [
[4.21, 12.45, '精品家居店'],
[5.85, 44.16, '运动户外店'],
[3.10, 8.20, '潮流男装店'],
[2.10, -5.40, '海外旗舰店']
],
itemStyle: {
color: (p) => {
if (p.data[0] >= 3.5 && p.data[1] >= 10) return '#10b981';
if (p.data[0] < 3 || p.data[1] < 0) return '#f43f5e';
return '#6366f1';
},
shadowBlur: 15,
shadowColor: 'rgba(0,0,0,0.1)'
},
markLine: {
silent: true,
lineStyle: { type: 'dashed', color: '#94a3b8' },
data: [{ xAxis: 3.5 }, { yAxis: 10 }]
}
}]
});
window.onresize = () => { salesChart.resize(); efficiencyChart.resize(); };
</script>
</body>
</html>
@@ -1,284 +0,0 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>店铺经营概览 - 极简毛玻璃版</title>
<script src="https://cdn.tailwindcss.com"></script>
<script src="https://cdn.jsdelivr.net/npm/echarts@5.4.3/dist/echarts.min.js"></script>
<link href="https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;600;700;800&family=Noto+Sans+SC:wght@400;700;900&display=swap" rel="stylesheet">
<style>
body {
font-family: 'Noto Sans SC', 'Plus Jakarta Sans', sans-serif;
background-color: #f8fafc; /* 您要求的背景色 */
color: #0f172a;
}
.glass-card {
background: rgba(255, 255, 255, 0.85);
backdrop-filter: blur(12px);
border: 1px solid rgba(226, 232, 240, 0.8);
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.02);
border-radius: 20px;
}
/* 时间选择器激活状态 */
.time-btn.active { background: white; box-shadow: 0 4px 10px rgba(0,0,0,0.05); color: #3b82f6; }
/* 表格滚动条优化 */
.table-container::-webkit-scrollbar { height: 6px; }
.table-container::-webkit-scrollbar-thumb { background: #e2e8f0; border-radius: 10px; }
/* 固定商品名称列 */
.sticky-col { position: sticky; left: 0; background: white; z-index: 10; border-right: 2px solid #f1f5f9; }
</style>
</head>
<body class="p-4 md:p-8">
<div class="w-full mx-auto space-y-6">
<!-- 头部:标题与时间筛选器 -->
<header class="flex flex-col lg:flex-row justify-between items-start lg:items-center gap-6">
<div>
<h1 class="text-3xl font-black text-slate-900 tracking-tight">店铺经营概览</h1>
<p class="text-slate-500 font-bold mt-1 text-sm italic">数据更新于:今日 20:45:12</p>
</div>
<!-- 时间选择组件 (优化后的 UI) -->
<div class="flex items-center gap-1.5 bg-slate-200/50 p-1 rounded-2xl border border-slate-200">
<div class="flex bg-white/40 rounded-xl p-1 shadow-inner">
<button class="px-5 py-2 text-sm font-bold text-slate-500 hover:text-slate-800 transition">今日</button>
<button class="px-5 py-2 text-sm font-bold text-slate-500 hover:text-slate-800 transition">昨日</button>
<button class="bg-white px-5 py-2 text-sm font-black rounded-lg shadow-sm text-blue-600">近7日</button>
<button class="px-5 py-2 text-sm font-bold text-slate-500 hover:text-slate-800 transition">近30日</button>
</div>
<div class="w-px h-6 bg-slate-300 mx-2"></div>
<div class="flex items-center gap-2 px-3">
<span class="text-xs font-bold text-slate-400">自定义日期</span>
<input type="date" class="bg-transparent text-sm font-bold outline-none cursor-pointer">
</div>
</div>
</header>
<!-- 第一层:核心统计卡片 (基于 OverviewStatistics) -->
<div class="grid grid-cols-1 sm:grid-cols-2 xl:grid-cols-4 gap-6">
<!-- 销售大盘 -->
<div class="glass-card p-6 flex flex-col justify-between">
<div class="flex justify-between items-start mb-4">
<span class="text-xs font-black text-slate-400 uppercase tracking-widest">店铺销售总额</span>
<span class="text-xs font-bold text-emerald-600 bg-emerald-50 px-2 py-1 rounded">增长率 +12.4%</span>
</div>
<div class="text-4xl font-black text-slate-900 leading-none">¥1,284,000</div>
<div class="mt-6 pt-4 border-t border-slate-100 flex justify-between items-center text-xs font-bold">
<span class="text-slate-400">销售额目标达成</span>
<span class="text-blue-600 font-black">96.5%</span>
</div>
</div>
<!-- 订单达成 -->
<div class="glass-card p-6 flex flex-col justify-between">
<div class="text-xs font-black text-slate-400 mb-4 uppercase tracking-widest">订单总量与达成</div>
<div class="text-4xl font-black text-slate-900 leading-none">8,412 <span class="text-sm font-normal text-slate-400 ml-1">单</span></div>
<div class="mt-6">
<div class="flex justify-between text-[10px] font-black text-slate-400 mb-2">
<span>目标: 10,000 单</span>
<span>达成率: 84.1%</span>
</div>
<div class="w-full bg-slate-100 h-2 rounded-full overflow-hidden">
<div class="bg-indigo-500 h-full transition-all duration-1000" style="width: 84.1%"></div>
</div>
</div>
</div>
<!-- 推广效率 -->
<div class="glass-card p-6 flex flex-col justify-between">
<div class="text-xs font-black text-slate-400 mb-4 uppercase tracking-widest">投资回报率 (ROI)</div>
<div class="text-4xl font-black text-indigo-600 leading-none">4.21</div>
<div class="mt-6 pt-4 border-t border-slate-100 space-y-2">
<div class="flex justify-between text-xs font-bold">
<span class="text-slate-400">平均费比</span>
<span class="text-slate-800">23.7%</span>
</div>
</div>
</div>
<!-- 利润汇总 -->
<div class="glass-card p-6 border-l-4 border-l-emerald-500 flex flex-col justify-between">
<div class="text-xs font-black text-emerald-600 mb-4 uppercase tracking-widest">店铺总净利润 (税后)</div>
<div class="text-4xl font-black text-emerald-600 leading-none">¥124,500</div>
<div class="mt-6 pt-4 border-t border-slate-100 flex justify-between text-[11px] font-bold text-slate-400">
<span>已扣除 4% 税额</span>
<span>-¥51,360</span>
</div>
</div>
</div>
<!-- 第二层:趋势与财务拆解 -->
<div class="grid grid-cols-1 xl:grid-cols-3 gap-6">
<!-- 销售额趋势图 -->
<div class="xl:col-span-2 glass-card p-8">
<h3 class="text-lg font-black text-slate-800 mb-6">销售额与单量趋势分析</h3>
<div id="mainTrendChart" style="height: 380px;" class="w-full"></div>
</div>
<!-- 财务全维度损益清单 -->
<div class="glass-card p-8 flex flex-col">
<h3 class="text-lg font-black text-slate-800 mb-6">财务损益全维度 (P&L)</h3>
<div class="space-y-4 text-sm flex-1">
<div class="flex justify-between border-b border-slate-100 pb-2"><span class="text-slate-500">推广费总支出</span><span class="font-bold">-¥305,000</span></div>
<div class="flex justify-between border-b border-slate-100 pb-2"><span class="text-slate-500">客单价 (AOV)</span><span class="font-bold">¥152.80</span></div>
<div class="flex justify-between border-b border-slate-100 pb-2"><span class="text-slate-500">总税后盈亏 (Profit)</span><span class="font-bold text-indigo-600">¥175,860</span></div>
<!-- 扣除项 -->
<div class="bg-slate-50/80 p-4 rounded-2xl space-y-3 mt-4">
<div class="flex justify-between text-xs"><span class="text-slate-400">销售额 4% 税额</span><span class="text-rose-500 font-bold">¥51,360</span></div>
<div class="flex justify-between text-xs"><span class="text-slate-400">较上月同期增长</span><span class="text-emerald-500 font-black">+14.2%</span></div>
</div>
<!-- 最终结果 -->
<div class="mt-auto p-5 rounded-2xl bg-slate-900 text-white flex justify-between items-center shadow-2xl">
<div>
<p class="text-[10px] font-black uppercase opacity-60">Final Net Profit</p>
<p class="text-xs font-bold">税后最终净利</p>
</div>
<div class="text-3xl font-black">¥124,500</div>
</div>
</div>
</div>
</div>
<!-- 第三层:多商品 16 维度横向对比表 (基于 ProductComparison) -->
<div class="glass-card overflow-hidden">
<div class="p-8 border-b border-slate-100 flex justify-between items-center bg-white/40">
<div>
<h3 class="text-xl font-black text-slate-800">核心商品多维度损益对比表</h3>
<p class="text-xs text-slate-400 font-bold mt-1">横向对比各商品规模、成本及 ROI 效率</p>
</div>
<button class="bg-slate-900 text-white px-8 py-3 rounded-2xl text-sm font-black shadow-xl shadow-slate-200 hover:scale-105 active:scale-95 transition-all">导出商品明细报表</button>
</div>
<div class="table-container overflow-x-auto">
<table class="w-full text-left text-sm whitespace-nowrap">
<!-- 分类复合表头 -->
<thead class="bg-slate-50 text-[10px] font-black text-slate-500 uppercase tracking-tighter">
<tr>
<th rowspan="2" class="px-6 py-6 border-b sticky-col text-slate-900 text-sm">商品详情</th>
<th colspan="3" class="px-3 py-3 border-b border-l border-slate-200 text-center bg-slate-100/50">商品规模 (Scale)</th>
<th colspan="4" class="px-3 py-3 border-b border-l border-slate-200 text-center bg-orange-50/50 text-orange-700 italic">费用成本 (Costs)</th>
<th colspan="5" class="px-3 py-3 border-b border-l border-slate-200 text-center bg-emerald-50/50 text-emerald-700 italic">单品损益 (Profitability)</th>
</tr>
<tr class="bg-slate-50/80">
<!-- 规模 -->
<th class="px-6 py-4 border-b border-l">销售额</th>
<th class="px-6 py-4 border-b">单量</th>
<th class="px-6 py-4 border-b">客单价</th>
<!-- 成本 -->
<th class="px-6 py-4 border-b border-l">成本运费</th>
<th class="px-6 py-4 border-b text-rose-600">退款金额</th>
<th class="px-6 py-4 border-b">推广费</th>
<th class="px-6 py-4 border-b">刷单费用</th>
<!-- 损益 -->
<th class="px-6 py-4 border-b border-l">费比 %</th>
<th class="px-6 py-4 border-b text-indigo-700">单品 ROI</th>
<th class="px-6 py-4 border-b">税前盈亏</th>
<th class="px-6 py-4 border-b text-rose-500 italic">4%税额</th>
<th class="px-6 py-4 border-b bg-emerald-600 text-white font-black">税后净利</th>
</tr>
</thead>
<tbody class="divide-y divide-slate-100">
<!-- 演示数据:智能降噪耳机 -->
<tr class="hover:bg-blue-50/30 transition-colors">
<td class="px-6 py-6 font-bold text-slate-900 sticky-col">
<div>智能降噪耳机 G200</div>
<div class="text-[10px] text-slate-300 font-normal">编码: ITEM-99201</div>
</td>
<!-- 规模 -->
<td class="px-6 py-4 font-black">¥428,000</td>
<td class="px-6 py-4 font-medium">1,240</td>
<td class="px-6 py-4">¥345.1</td>
<!-- 成本 -->
<td class="px-6 py-4">¥42,400</td>
<td class="px-6 py-4 text-rose-500 font-bold">¥12,400</td>
<td class="px-6 py-4">¥65,000</td>
<td class="px-6 py-4 text-amber-500">¥4,500</td>
<!-- 损益 -->
<td class="px-6 py-4 text-slate-400">15.1%</td>
<td class="px-6 py-4 font-black text-indigo-700">6.58</td>
<td class="px-6 py-4 font-bold text-slate-600">¥102,500</td>
<td class="px-6 py-4 text-slate-400 italic">¥17,120</td>
<td class="px-6 py-4 font-black text-emerald-600 text-base bg-emerald-50/30">¥85,380</td>
</tr>
<!-- 演示数据:复古相机 -->
<tr class="hover:bg-blue-50/30 transition-colors">
<td class="px-6 py-6 font-bold text-slate-900 sticky-col">
<div>复古数码相机 RX-X</div>
<div class="text-[10px] text-slate-300 font-normal">编码: ITEM-00821</div>
</td>
<td class="px-6 py-4 font-black">¥215,000</td>
<td class="px-6 py-4 font-medium">890</td>
<td class="px-6 py-4">¥241.5</td>
<td class="px-6 py-4">¥28,000</td>
<td class="px-6 py-4 text-rose-500 font-bold">¥32,000</td>
<td class="px-6 py-4">¥82,000</td>
<td class="px-6 py-4 text-amber-500">¥8,500</td>
<td class="px-6 py-4 text-slate-400">38.1%</td>
<td class="px-6 py-4 font-black text-indigo-700">2.62</td>
<td class="px-6 py-4 font-bold text-slate-600">¥12,400</td>
<td class="px-6 py-4 text-slate-400 italic">¥8,600</td>
<td class="px-6 py-4 font-black text-rose-500 text-base bg-rose-50/30">¥3,800</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<script>
// 销售趋势与单量图 (复刻参考图中的顺滑面积图)
const trendChart = echarts.init(document.getElementById('mainTrendChart'));
trendChart.setOption({
grid: { left: '3%', right: '3%', bottom: '3%', top: '5%', containLabel: true },
tooltip: { trigger: 'axis', backgroundColor: '#fff', textStyle: { color: '#000' } },
xAxis: {
type: 'category',
boundaryGap: false,
data: ['10-01', '10-02', '10-03', '10-04', '10-05', '10-06', '10-07'],
axisLine: { lineStyle: { color: '#e2e8f0' } }
},
yAxis: [
{ type: 'value', name: '销售额', splitLine: { lineStyle: { type: 'dashed' } } },
{ type: 'value', name: '单量', position: 'right', splitLine: { show: false } }
],
series: [
{
name: '销售额',
type: 'line',
smooth: true,
symbol: 'none',
lineStyle: { width: 3, color: '#3b82f6' },
areaStyle: {
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
{ offset: 0, color: 'rgba(59, 130, 246, 0.4)' },
{ offset: 1, color: 'rgba(59, 130, 246, 0)' }
])
},
data: [82000, 93000, 90000, 120000, 129000, 133000, 128400]
},
{
name: '日单量',
type: 'line',
yAxisIndex: 1,
smooth: true,
symbol: 'none',
lineStyle: { width: 3, color: '#10b981' },
areaStyle: {
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
{ offset: 0, color: 'rgba(16, 185, 129, 0.2)' },
{ offset: 1, color: 'rgba(16, 185, 129, 0)' }
])
},
data: [520, 610, 580, 720, 850, 890, 812]
}
]
});
window.onresize = () => trendChart.resize();
</script>
</body>
</html>
@@ -1,153 +0,0 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>全店汇总毛玻璃看板</title>
<script src="https://cdn.tailwindcss.com"></script>
<script src="https://cdn.jsdelivr.net/npm/echarts@5.4.3/dist/echarts.min.js"></script>
<link href="https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;600;700&display=swap" rel="stylesheet">
<style>
body {
font-family: 'Plus Jakarta Sans', sans-serif;
background: linear-gradient(135deg, #fef2f2 0%, #eef2ff 50%, #f0fdf4 100%);
min-height: 100vh;
}
.glass {
background: rgba(255, 255, 255, 0.5);
backdrop-filter: blur(20px);
border: 1px solid rgba(255, 255, 255, 0.6);
border-radius: 2rem;
box-shadow: 0 10px 30px rgba(0,0,0,0.02);
}
</style>
</head>
<body class="p-6 md:p-10">
<div class="max-w-[1600px] mx-auto space-y-8">
<!-- 公司级头部 -->
<header class="flex justify-between items-center">
<div>
<h1 class="text-4xl font-black text-slate-800 tracking-tight">全店铺经营大盘</h1>
<p class="text-indigo-600 font-bold">Company Dashboard · 共 8 家在营店铺</p>
</div>
<div class="glass px-6 py-3 flex gap-8 items-center">
<div class="text-center"><div class="text-[10px] uppercase font-bold text-slate-400">汇总 ROI</div><div class="text-lg font-black">4.05</div></div>
<div class="w-px h-8 bg-slate-200"></div>
<div class="text-center"><div class="text-[10px] uppercase font-bold text-slate-400">总税后盈亏</div><div class="text-lg font-black text-emerald-600">¥842,000</div></div>
</div>
</header>
<!-- 汇总卡片 -->
<div class="grid grid-cols-1 md:grid-cols-4 gap-6">
<div class="glass p-8 bg-gradient-to-br from-indigo-500/10 to-transparent">
<div class="text-slate-500 text-sm font-bold">全店总销售额</div>
<div class="text-3xl font-black mt-1">¥4,829,000</div>
<div class="mt-4 text-xs font-bold text-emerald-500 bg-emerald-50 w-fit px-2 py-1 rounded-lg">↑ 18% 较上月同期</div>
</div>
<div class="glass p-8">
<div class="text-slate-500 text-sm font-bold">全店总单量</div>
<div class="text-3xl font-black mt-1">12,408</div>
<div class="mt-4 text-xs font-bold text-slate-400 italic">目标达成率 92%</div>
</div>
<div class="glass p-8">
<div class="text-slate-500 text-sm font-bold">总推广费支出</div>
<div class="text-3xl font-black mt-1">¥1,192,000</div>
<div class="mt-4 text-xs font-bold text-indigo-400">平均费比: 24.6%</div>
</div>
<div class="glass p-8 bg-gradient-to-br from-emerald-500/10 to-transparent">
<div class="text-slate-500 text-sm font-bold">全店总净利 (税后)</div>
<div class="text-3xl font-black mt-1 text-emerald-600">¥842,500</div>
<div class="mt-4 text-xs font-bold text-slate-400">扣除总税额: ¥193,160</div>
</div>
</div>
<!-- 各店对比分析 -->
<div class="grid grid-cols-1 lg:grid-cols-2 gap-8">
<div class="glass p-8">
<h3 class="font-bold text-xl mb-6">各店铺销售占比排行</h3>
<div id="shopBarChart" style="height: 400px;"></div>
</div>
<div class="glass p-8">
<h3 class="font-bold text-xl mb-6">店铺效率象限 (ROI vs 净利)</h3>
<div id="shopScatterChart" style="height: 400px;"></div>
</div>
</div>
<!-- 店铺多维度对比表 (包含16维度) -->
<div class="glass overflow-hidden pb-6">
<div class="p-8 flex justify-between items-center">
<h3 class="font-bold text-xl">多店铺数据横向对比 (全16维度)</h3>
</div>
<div class="overflow-x-auto px-4">
<table class="w-full text-left border-collapse whitespace-nowrap">
<thead class="text-[11px] uppercase text-slate-400 border-b border-white/40">
<tr>
<th class="p-4 font-black">店铺名称</th>
<th class="p-4 font-black">销售额</th>
<th class="p-4 font-black text-indigo-600">ROI</th>
<th class="p-4 font-black">目标达成</th>
<th class="p-4 font-black text-red-400">退款/刷单费</th>
<th class="p-4 font-black">推广费总和</th>
<th class="p-4 font-black text-emerald-600">税后盈亏</th>
</tr>
</thead>
<tbody class="text-sm">
<tr class="hover:bg-white/40 transition">
<td class="p-4 font-bold">旗舰店 A</td>
<td class="p-4">¥1,284,000</td>
<td class="p-4 font-black text-indigo-600">4.21</td>
<td class="p-4"><div class="w-24 bg-slate-200 h-1 rounded-full"><div class="bg-indigo-500 h-full w-[85%]"></div></div></td>
<td class="p-4 text-red-400">¥12,400 / ¥1,500</td>
<td class="p-4">¥305,000</td>
<td class="p-4 font-black text-emerald-600">¥124,500</td>
</tr>
<tr class="hover:bg-white/40 transition border-t border-white/20">
<td class="p-4 font-bold">精品海外店 B</td>
<td class="p-4">¥942,000</td>
<td class="p-4 font-black text-indigo-600">3.85</td>
<td class="p-4"><div class="w-24 bg-slate-200 h-1 rounded-full"><div class="bg-indigo-500 h-full w-[105%]"></div></div></td>
<td class="p-4 text-red-400">¥8,200 / ¥2,100</td>
<td class="p-4">¥240,000</td>
<td class="p-4 font-black text-emerald-600">¥98,000</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<script>
// 店铺排行
const barChart = echarts.init(document.getElementById('shopBarChart'));
barChart.setOption({
tooltip: { trigger: 'axis' },
xAxis: { type: 'value', show: false },
yAxis: { type: 'category', data: ['店 D', '店 C', '店 B', '旗舰店 A'], axisLine: {show: false} },
series: [{
type: 'bar',
data: [420, 780, 942, 1284],
itemStyle: {
color: new echarts.graphic.LinearGradient(1, 0, 0, 0, [{offset: 0, color: '#6366f1'}, {offset: 1, color: '#a5b4fc'}]),
borderRadius: [0, 10, 10, 0]
},
barWidth: 25
}]
});
// 效率象限图
const scatterChart = echarts.init(document.getElementById('shopScatterChart'));
scatterChart.setOption({
grid: { top: '10%', bottom: '10%', left: '10%' },
xAxis: { name: '销售额', splitLine: { lineStyle: { type: 'dashed' } } },
yAxis: { name: 'ROI', splitLine: { lineStyle: { type: 'dashed' } } },
series: [{
type: 'scatter',
symbolSize: 40,
data: [[1284, 4.21], [942, 3.85], [780, 5.2], [420, 2.1]],
itemStyle: { color: '#6366f1', opacity: 0.6 }
}]
});
</script>
</body>
</html>
@@ -1,182 +0,0 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>单店毛玻璃看板 - 时间筛选</title>
<script src="https://cdn.tailwindcss.com"></script>
<script src="https://cdn.jsdelivr.net/npm/echarts@5.4.3/dist/echarts.min.js"></script>
<link href="https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;600;700&display=swap" rel="stylesheet">
<style>
body {
font-family: 'Plus Jakarta Sans', sans-serif;
background: linear-gradient(135deg, #eef2ff 0%, #fae8ff 50%, #f1f5f9 100%);
min-height: 100vh;
color: #1e293b;
}
.glass {
background: rgba(255, 255, 255, 0.4);
backdrop-filter: blur(16px);
-webkit-backdrop-filter: blur(16px);
border: 1px solid rgba(255, 255, 255, 0.5);
box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.05);
}
/* 时间选择器激活状态 */
.time-btn.active {
background: #6366f1;
color: white;
box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}
.time-btn { transition: all 0.3s ease; }
.no-scrollbar::-webkit-scrollbar { display: none; }
</style>
</head>
<body class="p-6">
<div class="max-w-7xl mx-auto space-y-6">
<!-- 头部:店铺信息 & 增强型时间选择器 -->
<header class="flex flex-col lg:flex-row justify-between items-start lg:items-center gap-6 pb-4">
<div>
<h1 class="text-3xl font-black text-slate-800">星辰优选旗舰店</h1>
<p class="text-slate-500 font-medium">数据维度:全方位损益实时统计</p>
</div>
<!-- 时间选择器组件 -->
<div class="glass p-1.5 rounded-2xl flex flex-wrap items-center gap-2">
<div class="flex bg-white/30 rounded-xl p-1">
<button onclick="switchTime(this)" class="time-btn active px-4 py-1.5 rounded-lg text-sm font-bold">今日</button>
<button onclick="switchTime(this)" class="time-btn px-4 py-1.5 rounded-lg text-sm font-bold">昨日</button>
<button onclick="switchTime(this)" class="time-btn px-4 py-1.5 rounded-lg text-sm font-bold">近7日</button>
<button onclick="switchTime(this)" class="time-btn px-4 py-1.5 rounded-lg text-sm font-bold">近30日</button>
</div>
<div class="h-6 w-px bg-slate-300 mx-1"></div>
<!-- 自定义时间 -->
<div class="flex items-center gap-2 px-3 py-1.5 bg-white/30 rounded-xl">
<span class="text-[10px] font-bold text-slate-400 uppercase">自定义</span>
<input type="date" class="bg-transparent text-xs font-bold outline-none border-none cursor-pointer">
<span class="text-slate-400">-</span>
<input type="date" class="bg-transparent text-xs font-bold outline-none border-none cursor-pointer">
</div>
</div>
</header>
<!-- 1. 核心 KPI (覆盖:销售额, ROI, 目标达成, 税后盈亏, 日单量, 客单价) -->
<div class="grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-4">
<div class="glass p-5 rounded-3xl">
<div class="text-[10px] font-bold text-indigo-500 uppercase">销售额</div>
<div class="text-2xl font-black">¥128,400</div>
</div>
<div class="glass p-5 rounded-3xl border-l-4 border-l-indigo-500">
<div class="text-[10px] font-bold text-indigo-500 uppercase">ROI / 费比</div>
<div class="text-2xl font-black">4.21 <span class="text-xs text-slate-400 font-normal">/ 23%</span></div>
</div>
<div class="glass p-5 rounded-3xl">
<div class="text-[10px] font-bold text-indigo-500 uppercase">达成率</div>
<div class="text-2xl font-black text-indigo-600">85.4%</div>
</div>
<div class="glass p-5 rounded-3xl">
<div class="text-[10px] font-bold text-indigo-500 uppercase">单量 / 客单价</div>
<div class="text-2xl font-black">812 <span class="text-xs text-slate-400 font-normal">/ ¥158</span></div>
</div>
<div class="glass p-5 rounded-3xl">
<div class="text-[10px] font-bold text-indigo-500 uppercase">推广费总和</div>
<div class="text-2xl font-black">¥45,000</div>
</div>
<div class="glass p-5 rounded-3xl bg-emerald-500/10 border-l-4 border-l-emerald-500">
<div class="text-[10px] font-bold text-emerald-600 uppercase">税后盈亏</div>
<div class="text-2xl font-black text-emerald-600">¥12,450</div>
</div>
</div>
<!-- 2. 图表与财务损益拆解 -->
<div class="grid grid-cols-1 lg:grid-cols-3 gap-6">
<div class="lg:col-span-2 glass p-6 rounded-[2rem]">
<h3 class="font-bold text-lg mb-4">业绩趋势 (10/05 - 10/11)</h3>
<div id="shopTrend" style="height: 380px;"></div>
</div>
<!-- 16维度损益明细 -->
<div class="glass p-6 rounded-[2rem] flex flex-col">
<h3 class="font-bold text-lg mb-4">财务损益全维度 (P&L)</h3>
<div class="space-y-3 text-sm flex-1 overflow-y-auto pr-2 no-scrollbar">
<div class="flex justify-between p-2 rounded-xl bg-white/20"><span class="opacity-60">目标单量</span><span class="font-bold">2,000 单</span></div>
<div class="flex justify-between p-2"><span class="opacity-60">成本运费</span><span class="font-bold text-red-500">-¥32,400</span></div>
<div class="flex justify-between p-2"><span class="opacity-60">退款金额</span><span class="font-bold text-red-500">-¥8,200</span></div>
<div class="flex justify-between p-2"><span class="opacity-60">推广费用(今日)</span><span class="font-bold">¥3,200</span></div>
<div class="flex justify-between p-2"><span class="opacity-60">刷单费用</span><span class="font-bold text-orange-500">¥1,500</span></div>
<div class="flex justify-between p-2 pt-4 border-t border-white/40"><span class="text-indigo-600 font-bold">税前盈亏</span><span class="font-bold text-indigo-600">¥17,586</span></div>
<div class="flex justify-between p-2"><span class="opacity-40 italic text-xs">销售额 4% 税</span><span class="opacity-40 text-xs">¥5,136</span></div>
<!-- 最终结果 -->
<div class="flex justify-between p-4 rounded-2xl bg-gradient-to-r from-indigo-600 to-indigo-800 text-white shadow-xl shadow-indigo-100 mt-4">
<span class="font-bold uppercase tracking-widest text-xs opacity-80">税后盈亏 (Final)</span>
<span class="text-2xl font-black">¥12,450</span>
</div>
</div>
</div>
</div>
<!-- 3. 商品贡献列表 -->
<div class="glass rounded-[2rem] overflow-hidden">
<div class="p-6 border-b border-white/40">
<h3 class="font-bold text-lg">核心商品利润排名</h3>
</div>
<div class="overflow-x-auto">
<table class="w-full text-left">
<thead>
<tr class="text-[10px] uppercase tracking-widest text-slate-400">
<th class="p-5 font-bold">商品名/SKU</th>
<th class="p-5 font-bold">销售额</th>
<th class="p-5 font-bold">推广费</th>
<th class="p-5 font-bold">ROI</th>
<th class="p-5 font-bold text-emerald-600">单品净利</th>
</tr>
</thead>
<tbody class="text-sm divide-y divide-white/20">
<tr class="hover:bg-white/30 transition">
<td class="p-5 font-bold italic">2023 智能降噪耳机 Pro</td>
<td class="p-5">¥42,000</td>
<td class="p-5">¥5,200</td>
<td class="p-5"><span class="px-3 py-1 bg-indigo-100 text-indigo-600 rounded-lg font-bold">8.1</span></td>
<td class="p-5 font-black text-emerald-600">¥12,400</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<script>
// 时间切换效果
function switchTime(btn) {
document.querySelectorAll('.time-btn').forEach(b => b.classList.remove('active'));
btn.classList.add('active');
}
// Echarts 初始化 (销售趋势图)
const chart = echarts.init(document.getElementById('shopTrend'));
chart.setOption({
grid: { top: 20, left: 40, right: 20, bottom: 40 },
tooltip: { trigger: 'axis', backgroundColor: 'rgba(255,255,255,0.9)' },
xAxis: { type: 'category', data: ['10-05', '10-06', '10-07', '10-08', '10-09', '10-10', '10-11'] },
yAxis: { type: 'value', splitLine: { lineStyle: { type: 'dashed', color: 'rgba(255,255,255,0.5)' } } },
series: [{
name: '销售额',
type: 'line',
smooth: true,
symbol: 'circle',
symbolSize: 10,
lineStyle: { width: 4, color: '#6366f1' },
itemStyle: { color: '#6366f1', borderColor: '#fff', borderWidth: 2 },
areaStyle: {
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
{ offset: 0, color: 'rgba(99, 102, 241, 0.4)' },
{ offset: 1, color: 'rgba(99, 102, 241, 0)' }
])
},
data: [82, 93, 90, 120, 129, 133, 128]
}]
});
window.onresize = chart.resize;
</script>
</body>
</html>
@@ -1,526 +0,0 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<!-- 修改: 禁止缩放,适应移动端全屏体验 -->
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>Grand Luxury Tree (Mouse Wheel Control)</title>
<style>
/* 修改: 禁用默认触摸动作,防止页面滚动 */
body {
margin: 0; overflow: hidden; background-color: #000000; font-family: 'Times New Roman', serif;
touch-action: none;
-webkit-user-select: none;
user-select: none;
}
#canvas-container { width: 100vw; height: 100vh; position: absolute; top: 0; left: 0; z-index: 1; }
/* Loading */
#loader {
position: absolute; top: 0; left: 0; width: 100%; height: 100%;
background: #000; z-index: 100;
display: flex; flex-direction: column; align-items: center; justify-content: center;
transition: opacity 0.8s ease-out;
}
.loader-text {
color: #d4af37; font-size: 14px; letter-spacing: 4px; margin-top: 20px;
text-transform: uppercase; font-weight: 100;
}
.spinner {
width: 40px; height: 40px; border: 1px solid rgba(212, 175, 55, 0.2);
border-top: 1px solid #d4af37; border-radius: 50%;
animation: spin 1s linear infinite;
}
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
#file-input { display: none; }
</style>
<script type="importmap">
{
"imports": {
"three": "https://cdn.jsdelivr.net/npm/three@0.160.0/build/three.module.js",
"three/addons/": "https://cdn.jsdelivr.net/npm/three@0.160.0/examples/jsm/"
}
}
</script>
</head>
<body>
<div id="loader">
<div class="spinner"></div>
<div class="loader-text">Loading Holiday Magic</div>
</div>
<div id="canvas-container"></div>
<input type="file" id="file-input" multiple accept="image/*">
<script type="module">
import * as THREE from 'three';
import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
import { EffectComposer } from 'three/addons/postprocessing/EffectComposer.js';
import { RenderPass } from 'three/addons/postprocessing/RenderPass.js';
import { UnrealBloomPass } from 'three/addons/postprocessing/UnrealBloomPass.js';
import { RoomEnvironment } from 'three/addons/environments/RoomEnvironment.js';
// --- CONFIGURATION ---
const CONFIG = {
colors: {
bg: 0x000000,
champagneGold: 0xffd966,
deepGreen: 0x03180a,
accentRed: 0x990000,
},
particles: {
count: 1500,
dustCount: 2500,
treeHeight: 24,
treeRadius: 8
},
camera: {
z: 50
}
};
const STATE = {
mode: 'TREE',
focusIndex: -1,
focusTarget: null,
rotation: { x: 0, y: 0 },
mouse: { x: 0, y: 0 } // 归一化鼠标坐标 (-1 到 1)
};
let scene, camera, renderer, composer;
let mainGroup;
let clock = new THREE.Clock();
let particleSystem = [];
let photoMeshGroup = new THREE.Group();
let caneTexture;
// Interaction variables
const raycaster = new THREE.Raycaster();
const pointer = new THREE.Vector2();
async function init() {
initThree();
setupEnvironment();
setupLights();
createTextures();
createParticles();
createDust();
createDefaultPhotos();
setupPostProcessing();
setupEvents();
const loader = document.getElementById('loader');
loader.style.opacity = 0;
setTimeout(() => loader.remove(), 800);
animate();
}
function initThree() {
const container = document.getElementById('canvas-container');
scene = new THREE.Scene();
scene.background = new THREE.Color(CONFIG.colors.bg);
scene.fog = new THREE.FogExp2(CONFIG.colors.bg, 0.01);
// 适应移动端纵横比
camera = new THREE.PerspectiveCamera(42, window.innerWidth / window.innerHeight, 0.1, 1000);
camera.position.set(0, 2, CONFIG.camera.z);
renderer = new THREE.WebGLRenderer({ antialias: true, alpha: false, powerPreference: "high-performance" });
renderer.setSize(window.innerWidth, window.innerHeight);
// 限制像素比以提升移动端性能
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
renderer.toneMapping = THREE.ReinhardToneMapping;
renderer.toneMappingExposure = 2.2;
container.appendChild(renderer.domElement);
mainGroup = new THREE.Group();
scene.add(mainGroup);
}
function setupEnvironment() {
const pmremGenerator = new THREE.PMREMGenerator(renderer);
scene.environment = pmremGenerator.fromScene(new RoomEnvironment(), 0.04).texture;
}
function setupLights() {
const ambient = new THREE.AmbientLight(0xffffff, 0.6);
scene.add(ambient);
const innerLight = new THREE.PointLight(0xffaa00, 2, 20);
innerLight.position.set(0, 5, 0);
mainGroup.add(innerLight);
const spotGold = new THREE.SpotLight(0xffcc66, 1200);
spotGold.position.set(30, 40, 40);
spotGold.angle = 0.5;
spotGold.penumbra = 0.5;
scene.add(spotGold);
const spotBlue = new THREE.SpotLight(0x6688ff, 600);
spotBlue.position.set(-30, 20, -30);
scene.add(spotBlue);
const fill = new THREE.DirectionalLight(0xffeebb, 0.8);
fill.position.set(0, 0, 50);
scene.add(fill);
}
function setupPostProcessing() {
const renderScene = new RenderPass(scene, camera);
const bloomPass = new UnrealBloomPass(new THREE.Vector2(window.innerWidth, window.innerHeight), 1.5, 0.4, 0.85);
bloomPass.threshold = 0.7;
bloomPass.strength = 0.45;
bloomPass.radius = 0.4;
composer = new EffectComposer(renderer);
composer.addPass(renderScene);
composer.addPass(bloomPass);
}
function createTextures() {
const canvas = document.createElement('canvas');
canvas.width = 128; canvas.height = 128;
const ctx = canvas.getContext('2d');
ctx.fillStyle = '#ffffff';
ctx.fillRect(0,0,128,128);
ctx.fillStyle = '#880000';
ctx.beginPath();
for(let i=-128; i<256; i+=32) {
ctx.moveTo(i, 0); ctx.lineTo(i+32, 128); ctx.lineTo(i+16, 128); ctx.lineTo(i-16, 0);
}
ctx.fill();
caneTexture = new THREE.CanvasTexture(canvas);
caneTexture.wrapS = THREE.RepeatWrapping;
caneTexture.wrapT = THREE.RepeatWrapping;
caneTexture.repeat.set(3, 3);
}
class Particle {
constructor(mesh, type, isDust = false) {
this.mesh = mesh;
this.type = type;
this.isDust = isDust;
this.posTree = new THREE.Vector3();
this.posScatter = new THREE.Vector3();
this.baseScale = mesh.scale.x;
const speedMult = (type === 'PHOTO') ? 0.3 : 2.0;
this.spinSpeed = new THREE.Vector3(
(Math.random() - 0.5) * speedMult,
(Math.random() - 0.5) * speedMult,
(Math.random() - 0.5) * speedMult
);
this.calculatePositions();
}
calculatePositions() {
const h = CONFIG.particles.treeHeight;
const halfH = h / 2;
let t = Math.random();
t = Math.pow(t, 0.8);
const y = (t * h) - halfH;
let rMax = CONFIG.particles.treeRadius * (1.0 - t);
if (rMax < 0.5) rMax = 0.5;
const angle = t * 50 * Math.PI + Math.random() * Math.PI;
const r = rMax * (0.8 + Math.random() * 0.4);
this.posTree.set(Math.cos(angle) * r, y, Math.sin(angle) * r);
let rScatter = this.isDust ? (12 + Math.random()*20) : (8 + Math.random()*12);
const theta = Math.random() * Math.PI * 2;
const phi = Math.acos(2 * Math.random() - 1);
this.posScatter.set(
rScatter * Math.sin(phi) * Math.cos(theta),
rScatter * Math.sin(phi) * Math.sin(theta),
rScatter * Math.cos(phi)
);
}
update(dt, mode, focusTargetMesh) {
let target = this.posTree;
if (mode === 'SCATTER') target = this.posScatter;
else if (mode === 'FOCUS') {
if (this.mesh === focusTargetMesh) {
const desiredWorldPos = new THREE.Vector3(0, 2, 35);
const invMatrix = new THREE.Matrix4().copy(mainGroup.matrixWorld).invert();
target = desiredWorldPos.applyMatrix4(invMatrix);
} else {
target = this.posScatter;
}
}
const lerpSpeed = (mode === 'FOCUS' && this.mesh === focusTargetMesh) ? 5.0 : 2.0;
this.mesh.position.lerp(target, lerpSpeed * dt);
if (mode === 'SCATTER') {
this.mesh.rotation.x += this.spinSpeed.x * dt;
this.mesh.rotation.y += this.spinSpeed.y * dt;
this.mesh.rotation.z += this.spinSpeed.z * dt;
} else if (mode === 'TREE') {
this.mesh.rotation.x = THREE.MathUtils.lerp(this.mesh.rotation.x, 0, dt);
this.mesh.rotation.z = THREE.MathUtils.lerp(this.mesh.rotation.z, 0, dt);
this.mesh.rotation.y += 0.5 * dt;
}
if (mode === 'FOCUS' && this.mesh === focusTargetMesh) {
this.mesh.lookAt(camera.position);
}
let s = this.baseScale;
if (this.isDust) {
s = this.baseScale * (0.8 + 0.4 * Math.sin(clock.elapsedTime * 4 + this.mesh.id));
if (mode === 'TREE') s = 0;
} else if (mode === 'SCATTER' && this.type === 'PHOTO') {
s = this.baseScale * 2.5;
} else if (mode === 'FOCUS') {
if (this.mesh === focusTargetMesh) s = 4.5;
else s = this.baseScale * 0.8;
}
this.mesh.scale.lerp(new THREE.Vector3(s,s,s), 4*dt);
}
}
// --- CREATION ---
function createParticles() {
const sphereGeo = new THREE.SphereGeometry(0.5, 32, 32);
const boxGeo = new THREE.BoxGeometry(0.55, 0.55, 0.55);
const curve = new THREE.CatmullRomCurve3([
new THREE.Vector3(0, -0.5, 0), new THREE.Vector3(0, 0.3, 0),
new THREE.Vector3(0.1, 0.5, 0), new THREE.Vector3(0.3, 0.4, 0)
]);
const candyGeo = new THREE.TubeGeometry(curve, 16, 0.08, 8, false);
const goldMat = new THREE.MeshStandardMaterial({
color: CONFIG.colors.champagneGold,
metalness: 1.0, roughness: 0.1,
envMapIntensity: 2.0,
emissive: 0x443300,
emissiveIntensity: 0.3
});
const greenMat = new THREE.MeshStandardMaterial({
color: CONFIG.colors.deepGreen,
metalness: 0.2, roughness: 0.8,
emissive: 0x002200,
emissiveIntensity: 0.2
});
const redMat = new THREE.MeshPhysicalMaterial({
color: CONFIG.colors.accentRed,
metalness: 0.3, roughness: 0.2, clearcoat: 1.0,
emissive: 0x330000
});
const candyMat = new THREE.MeshStandardMaterial({ map: caneTexture, roughness: 0.4 });
for (let i = 0; i < CONFIG.particles.count; i++) {
const rand = Math.random();
let mesh, type;
if (rand < 0.40) {
mesh = new THREE.Mesh(boxGeo, greenMat);
type = 'BOX';
} else if (rand < 0.70) {
mesh = new THREE.Mesh(boxGeo, goldMat);
type = 'GOLD_BOX';
} else if (rand < 0.92) {
mesh = new THREE.Mesh(sphereGeo, goldMat);
type = 'GOLD_SPHERE';
} else if (rand < 0.97) {
mesh = new THREE.Mesh(sphereGeo, redMat);
type = 'RED';
} else {
mesh = new THREE.Mesh(candyGeo, candyMat);
type = 'CANE';
}
const s = 0.4 + Math.random() * 0.5;
mesh.scale.set(s,s,s);
mesh.rotation.set(Math.random()*6, Math.random()*6, Math.random()*6);
mainGroup.add(mesh);
particleSystem.push(new Particle(mesh, type, false));
}
const starGeo = new THREE.OctahedronGeometry(1.2, 0);
const starMat = new THREE.MeshStandardMaterial({
color: 0xffdd88, emissive: 0xffaa00, emissiveIntensity: 1.0,
metalness: 1.0, roughness: 0
});
const star = new THREE.Mesh(starGeo, starMat);
star.position.set(0, CONFIG.particles.treeHeight/2 + 1.2, 0);
mainGroup.add(star);
mainGroup.add(photoMeshGroup);
}
function createDust() {
const geo = new THREE.TetrahedronGeometry(0.08, 0);
const mat = new THREE.MeshBasicMaterial({ color: 0xffeebb, transparent: true, opacity: 0.8 });
for(let i=0; i<CONFIG.particles.dustCount; i++) {
const mesh = new THREE.Mesh(geo, mat);
mesh.scale.setScalar(0.5 + Math.random());
mainGroup.add(mesh);
particleSystem.push(new Particle(mesh, 'DUST', true));
}
}
function createDefaultPhotos() {
const canvas = document.createElement('canvas');
canvas.width = 512; canvas.height = 512;
const ctx = canvas.getContext('2d');
ctx.fillStyle = '#050505'; ctx.fillRect(0,0,512,512);
ctx.strokeStyle = '#eebb66'; ctx.lineWidth = 15; ctx.strokeRect(20,20,472,472);
ctx.font = '500 60px Times New Roman'; ctx.fillStyle = '#eebb66';
ctx.textAlign = 'center';
ctx.fillText("JOYEUX", 256, 230);
ctx.fillText("NOEL", 256, 300);
const tex = new THREE.CanvasTexture(canvas);
tex.colorSpace = THREE.SRGBColorSpace;
addPhotoToScene(tex);
}
function addPhotoToScene(texture) {
const frameGeo = new THREE.BoxGeometry(1.4, 1.4, 0.05);
const frameMat = new THREE.MeshStandardMaterial({ color: CONFIG.colors.champagneGold, metalness: 1.0, roughness: 0.1 });
const frame = new THREE.Mesh(frameGeo, frameMat);
const photoGeo = new THREE.PlaneGeometry(1.2, 1.2);
const photoMat = new THREE.MeshBasicMaterial({ map: texture });
const photo = new THREE.Mesh(photoGeo, photoMat);
photo.position.z = 0.04;
const group = new THREE.Group();
group.add(frame);
group.add(photo);
const s = 0.8;
group.scale.set(s,s,s);
photoMeshGroup.add(group);
particleSystem.push(new Particle(group, 'PHOTO', false));
}
// --- INTERACTION ---
function handleImageUpload(e) {
const files = e.target.files;
if(!files.length) return;
Array.from(files).forEach(f => {
const reader = new FileReader();
reader.onload = (ev) => {
new THREE.TextureLoader().load(ev.target.result, (t) => {
t.colorSpace = THREE.SRGBColorSpace;
addPhotoToScene(t);
});
}
reader.readAsDataURL(f);
});
}
function onPointerDown(event) {
// 触摸/点击坐标标准化
pointer.x = (event.clientX / window.innerWidth) * 2 - 1;
pointer.y = - (event.clientY / window.innerHeight) * 2 + 1;
raycaster.setFromCamera(pointer, camera);
const intersects = raycaster.intersectObjects(photoMeshGroup.children, true);
if (intersects.length > 0) {
let target = intersects[0].object;
while(target.parent !== photoMeshGroup && target.parent !== null) {
target = target.parent;
}
if (target.parent === photoMeshGroup) {
STATE.focusTarget = target;
STATE.mode = 'FOCUS';
return;
}
}
if (STATE.mode === 'FOCUS') {
STATE.mode = 'TREE';
STATE.focusTarget = null;
}
}
function onDoubleClick(event) {
// 双击触发文件选择
document.getElementById('file-input').click();
}
function onWheel(event) {
event.preventDefault();
// 滚轮向上:展开(SCATTER模式),滚轮向下:收起(TREE模式)
if (event.deltaY < 0) {
// 向上滚动,切换到 SCATTER 模式
STATE.mode = 'SCATTER';
STATE.focusTarget = null;
} else {
// 向下滚动,切换到 TREE 模式
STATE.mode = 'TREE';
STATE.focusTarget = null;
}
}
function onMouseMove(event) {
// 将鼠标坐标归一化到 -1 到 1 的范围
STATE.mouse.x = (event.clientX / window.innerWidth) * 2 - 1;
STATE.mouse.y = -(event.clientY / window.innerHeight) * 2 + 1;
}
function setupEvents() {
window.addEventListener('resize', () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
composer.setSize(window.innerWidth, window.innerHeight);
});
document.getElementById('file-input').addEventListener('change', handleImageUpload);
window.addEventListener('pointerdown', onPointerDown);
window.addEventListener('dblclick', onDoubleClick);
window.addEventListener('wheel', onWheel, { passive: false });
window.addEventListener('mousemove', onMouseMove);
}
function animate() {
requestAnimationFrame(animate);
const dt = clock.getDelta();
if (STATE.mode === 'SCATTER') {
// SCATTER 模式下,根据鼠标位置控制旋转
const targetRotY = STATE.mouse.x * Math.PI * 0.9;
const targetRotX = STATE.mouse.y * Math.PI * 0.25;
STATE.rotation.y += (targetRotY - STATE.rotation.y) * 3.0 * dt;
STATE.rotation.x += (targetRotX - STATE.rotation.x) * 3.0 * dt;
} else if(STATE.mode === 'TREE') {
STATE.rotation.y += 0.3 * dt;
STATE.rotation.x += (0 - STATE.rotation.x) * 2.0 * dt;
} else {
STATE.rotation.y += 0.1 * dt;
}
mainGroup.rotation.y = STATE.rotation.y;
mainGroup.rotation.x = STATE.rotation.x;
particleSystem.forEach(p => p.update(dt, STATE.mode, STATE.focusTarget));
composer.render();
}
init();
</script>
</body>
</html>
@@ -17,7 +17,7 @@ exports[`defaultPreferences immutability test > should not modify the config obj
"contentPaddingRight": 0,
"contentPaddingTop": 0,
"defaultAvatar": "https://unpkg.com/@vbenjs/static-source@0.1.7/source/avatar-v1.webp",
"defaultHomePath": "/analytics",
"defaultHomePath": "/company-overview",
"dynamicTitle": true,
"enableCheckUpdates": true,
"enablePreferences": true,
@@ -17,7 +17,7 @@ const defaultPreferences: Preferences = {
contentPaddingTop: 0,
defaultAvatar:
'https://unpkg.com/@vbenjs/static-source@0.1.7/source/avatar-v1.webp',
defaultHomePath: '/analytics',
defaultHomePath: '/company-overview',
dynamicTitle: true,
enableCheckUpdates: true,
enablePreferences: true,