代码提交
This commit is contained in:
@@ -10,5 +10,10 @@ export function getWechatStats() {
|
||||
return request("/v1/dashboard/wechat-stats", {}, "GET");
|
||||
}
|
||||
|
||||
// 获取常用功能列表
|
||||
export function getCommonFunctions() {
|
||||
return request("/v1/workbench/common-functions", {}, "GET");
|
||||
}
|
||||
|
||||
// 你可以根据需要继续添加其他接口
|
||||
// 例如:场景获客统计、今日数据统计等
|
||||
|
||||
@@ -52,8 +52,10 @@
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.icon {
|
||||
font-size: 20px;
|
||||
.iconImage {
|
||||
width: 75%;
|
||||
object-fit: contain;
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.featureHeader {
|
||||
|
||||
@@ -1,128 +1,137 @@
|
||||
import React from "react";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { Link } from "react-router-dom";
|
||||
import { Card, Badge } from "antd-mobile";
|
||||
import {
|
||||
LikeOutlined,
|
||||
SendOutlined,
|
||||
TeamOutlined,
|
||||
LinkOutlined,
|
||||
ClockCircleOutlined,
|
||||
ContactsOutlined,
|
||||
BookOutlined,
|
||||
ApartmentOutlined,
|
||||
} from "@ant-design/icons";
|
||||
import { Card, Badge, SpinLoading, Toast } from "antd-mobile";
|
||||
import Layout from "@/components/Layout/Layout";
|
||||
import MeauMobile from "@/components/MeauMobile/MeauMoible";
|
||||
import styles from "./index.module.scss";
|
||||
import NavCommon from "@/components/NavCommon";
|
||||
import { getCommonFunctions } from "./api";
|
||||
|
||||
// 功能key到默认配置的映射(用于降级,当API没有返回icon时使用)
|
||||
const featureConfig: Record<string, {
|
||||
bgColor: string;
|
||||
path: string;
|
||||
}> = {
|
||||
"auto_like": {
|
||||
bgColor: "#fff2f0",
|
||||
path: "/workspace/auto-like",
|
||||
},
|
||||
"moments_sync": {
|
||||
bgColor: "#f9f0ff",
|
||||
path: "/workspace/moments-sync",
|
||||
},
|
||||
"group_push": {
|
||||
bgColor: "#fff7e6",
|
||||
path: "/workspace/group-push",
|
||||
},
|
||||
"auto_group": {
|
||||
bgColor: "#f6ffed",
|
||||
path: "/workspace/auto-group",
|
||||
},
|
||||
"group_create": {
|
||||
bgColor: "#f6ffed",
|
||||
path: "/workspace/group-create",
|
||||
},
|
||||
"traffic_distribution": {
|
||||
bgColor: "#e6f7ff",
|
||||
path: "/workspace/traffic-distribution",
|
||||
},
|
||||
"contact_import": {
|
||||
bgColor: "#f9f0ff",
|
||||
path: "/workspace/contact-import/list",
|
||||
},
|
||||
"ai_knowledge": {
|
||||
bgColor: "#fff7e6",
|
||||
path: "/workspace/ai-knowledge",
|
||||
},
|
||||
"distribution_management": {
|
||||
bgColor: "#f9f0ff",
|
||||
path: "/workspace/distribution-management",
|
||||
},
|
||||
};
|
||||
|
||||
interface CommonFunction {
|
||||
id: number;
|
||||
key: string;
|
||||
name: string;
|
||||
description?: string;
|
||||
icon: React.ReactNode | null;
|
||||
iconUrl?: string | null;
|
||||
path: string;
|
||||
bgColor?: string;
|
||||
isNew?: boolean;
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
const Workspace: React.FC = () => {
|
||||
// 常用功能
|
||||
const commonFeatures = [
|
||||
{
|
||||
id: "auto-like",
|
||||
name: "自动点赞",
|
||||
description: "智能自动点赞互动",
|
||||
icon: (
|
||||
<LikeOutlined className={styles.icon} style={{ color: "#ff4d4f" }} />
|
||||
),
|
||||
path: "/workspace/auto-like",
|
||||
bgColor: "#fff2f0",
|
||||
isNew: true,
|
||||
},
|
||||
{
|
||||
id: "moments-sync",
|
||||
name: "朋友圈同步",
|
||||
description: "自动同步朋友圈内容",
|
||||
icon: (
|
||||
<ClockCircleOutlined
|
||||
className={styles.icon}
|
||||
style={{ color: "#722ed1" }}
|
||||
/>
|
||||
),
|
||||
path: "/workspace/moments-sync",
|
||||
bgColor: "#f9f0ff",
|
||||
},
|
||||
{
|
||||
id: "group-push",
|
||||
name: "群消息推送",
|
||||
description: "智能群发助手",
|
||||
icon: (
|
||||
<SendOutlined className={styles.icon} style={{ color: "#fa8c16" }} />
|
||||
),
|
||||
path: "/workspace/group-push",
|
||||
bgColor: "#fff7e6",
|
||||
},
|
||||
{
|
||||
id: "auto-group",
|
||||
name: "自动建群",
|
||||
description: "智能拉好友建群",
|
||||
icon: (
|
||||
<TeamOutlined className={styles.icon} style={{ color: "#52c41a" }} />
|
||||
),
|
||||
path: "/workspace/auto-group",
|
||||
bgColor: "#f6ffed",
|
||||
},
|
||||
{
|
||||
id: "group-create",
|
||||
name: "自动建群(新版)",
|
||||
description: "智能拉好友建群",
|
||||
icon: (
|
||||
<TeamOutlined className={styles.icon} style={{ color: "#52c41a" }} />
|
||||
),
|
||||
path: "/workspace/group-create",
|
||||
bgColor: "#f6ffed",
|
||||
isNew: true,
|
||||
},
|
||||
{
|
||||
id: "traffic-distribution",
|
||||
name: "流量分发",
|
||||
description: "管理流量分发和分配",
|
||||
icon: (
|
||||
<LinkOutlined className={styles.icon} style={{ color: "#1890ff" }} />
|
||||
),
|
||||
path: "/workspace/traffic-distribution",
|
||||
bgColor: "#e6f7ff",
|
||||
},
|
||||
{
|
||||
id: "contact-import",
|
||||
name: "通讯录导入",
|
||||
description: "批量导入通讯录联系人",
|
||||
icon: (
|
||||
<ContactsOutlined
|
||||
className={styles.icon}
|
||||
style={{ color: "#722ed1" }}
|
||||
/>
|
||||
),
|
||||
path: "/workspace/contact-import/list",
|
||||
bgColor: "#f9f0ff",
|
||||
isNew: true,
|
||||
},
|
||||
{
|
||||
id: "ai-knowledge",
|
||||
name: "AI知识库",
|
||||
description: "管理和配置内容",
|
||||
icon: (
|
||||
<BookOutlined className={styles.icon} style={{ color: "#fa8c16" }} />
|
||||
),
|
||||
path: "/workspace/ai-knowledge",
|
||||
bgColor: "#fff7e6",
|
||||
isNew: true,
|
||||
},
|
||||
{
|
||||
id: "distribution-management",
|
||||
name: "分销管理",
|
||||
description: "管理分销客户和渠道",
|
||||
icon: (
|
||||
<ApartmentOutlined
|
||||
className={styles.icon}
|
||||
style={{ color: "#722ed1" }}
|
||||
/>
|
||||
),
|
||||
path: "/workspace/distribution-management",
|
||||
bgColor: "#f9f0ff",
|
||||
isNew: true,
|
||||
},
|
||||
];
|
||||
const [commonFeatures, setCommonFeatures] = useState<CommonFunction[]>([]);
|
||||
const [loading, setLoading] = useState(true);
|
||||
|
||||
// 从API获取常用功能
|
||||
useEffect(() => {
|
||||
const fetchCommonFunctions = async () => {
|
||||
try {
|
||||
setLoading(true);
|
||||
const res = await getCommonFunctions();
|
||||
// 处理API返回的数据,映射图标和样式
|
||||
const features = (res?.list || res || []).map((item: any) => {
|
||||
const config = featureConfig[item.key];
|
||||
|
||||
// icon是远程图片URL,渲染为img标签
|
||||
const iconElement = item.icon ? (
|
||||
<img
|
||||
src={item.icon}
|
||||
alt={item.title || ""}
|
||||
className={styles.iconImage}
|
||||
onError={(e) => {
|
||||
// 图片加载失败时,隐藏图片
|
||||
const target = e.target as HTMLImageElement;
|
||||
target.style.display = 'none';
|
||||
}}
|
||||
/>
|
||||
) : null;
|
||||
|
||||
return {
|
||||
id: item.id,
|
||||
key: item.key,
|
||||
name: item.title || item.name || "",
|
||||
description: item.subtitle || item.description || item.desc || "",
|
||||
icon: iconElement,
|
||||
iconUrl: item.icon || null, // 保存原始URL
|
||||
path: item.route || item.path || (config?.path) || `/workspace/${item.key?.replace(/_/g, '-')}`,
|
||||
bgColor: item.iconColor || (config?.bgColor) || undefined, // iconColor可以为空
|
||||
isNew: item.isNew || item.is_new || false,
|
||||
};
|
||||
});
|
||||
setCommonFeatures(features);
|
||||
} catch (e: any) {
|
||||
Toast.show({
|
||||
content: e?.message || "获取常用功能失败",
|
||||
position: "top",
|
||||
});
|
||||
// 如果接口失败,使用默认数据(从配置映射表生成)
|
||||
const defaultFeatures = Object.keys(featureConfig).map((key, index) => {
|
||||
const config = featureConfig[key];
|
||||
return {
|
||||
id: index + 1,
|
||||
key,
|
||||
name: key.replace(/_/g, ' '),
|
||||
description: "",
|
||||
icon: null, // 默认没有图标
|
||||
iconUrl: null,
|
||||
path: config.path,
|
||||
bgColor: config.bgColor,
|
||||
isNew: false,
|
||||
};
|
||||
});
|
||||
setCommonFeatures(defaultFeatures);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
fetchCommonFunctions();
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<Layout
|
||||
@@ -133,33 +142,45 @@ const Workspace: React.FC = () => {
|
||||
{/* 常用功能 */}
|
||||
<div className={styles.section}>
|
||||
<h2 className={styles.sectionTitle}>常用功能</h2>
|
||||
<div className={styles.featuresGrid}>
|
||||
{commonFeatures.map(feature => (
|
||||
<Link
|
||||
to={feature.path}
|
||||
key={feature.id}
|
||||
className={styles.featureLink}
|
||||
>
|
||||
<Card className={styles.featureCard}>
|
||||
<div
|
||||
className={styles.featureIcon}
|
||||
style={{ backgroundColor: feature.bgColor }}
|
||||
{loading ? (
|
||||
<div style={{ display: "flex", justifyContent: "center", padding: "40px 0" }}>
|
||||
<SpinLoading style={{ "--size": "32px" }} />
|
||||
</div>
|
||||
) : (
|
||||
<div className={styles.featuresGrid}>
|
||||
{commonFeatures.length > 0 ? (
|
||||
commonFeatures.map(feature => (
|
||||
<Link
|
||||
to={feature.path}
|
||||
key={feature.key || feature.id}
|
||||
className={styles.featureLink}
|
||||
>
|
||||
{feature.icon}
|
||||
</div>
|
||||
<div className={styles.featureHeader}>
|
||||
<div className={styles.featureName}>{feature.name}</div>
|
||||
{feature.isNew && (
|
||||
<Badge content="New" className={styles.newBadge} />
|
||||
)}
|
||||
</div>
|
||||
<div className={styles.featureDescription}>
|
||||
{feature.description}
|
||||
</div>
|
||||
</Card>
|
||||
</Link>
|
||||
))}
|
||||
</div>
|
||||
<Card className={styles.featureCard}>
|
||||
<div
|
||||
className={styles.featureIcon}
|
||||
style={{ backgroundColor: feature.bgColor || "transparent" }}
|
||||
>
|
||||
{feature.icon}
|
||||
</div>
|
||||
<div className={styles.featureHeader}>
|
||||
<div className={styles.featureName}>{feature.name}</div>
|
||||
{feature.isNew && (
|
||||
<Badge content="New" className={styles.newBadge} />
|
||||
)}
|
||||
</div>
|
||||
<div className={styles.featureDescription}>
|
||||
{feature.description}
|
||||
</div>
|
||||
</Card>
|
||||
</Link>
|
||||
))
|
||||
) : (
|
||||
<div style={{ textAlign: "center", padding: "40px 0", color: "#999", width: "100%" }}>
|
||||
暂无常用功能
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* AI智能助手 */}
|
||||
|
||||
@@ -119,6 +119,7 @@ Route::group('v1/', function () {
|
||||
|
||||
Route::get('group-push-stats', 'app\cunkebao\controller\workbench\WorkbenchController@getGroupPushStats'); // 获取群发统计数据
|
||||
Route::get('group-push-history', 'app\cunkebao\controller\workbench\WorkbenchController@getGroupPushHistory'); // 获取推送历史记录列表
|
||||
Route::get('common-functions', 'app\cunkebao\controller\workbench\CommonFunctionsController@getList'); // 获取常用功能列表
|
||||
});
|
||||
|
||||
// 内容库相关
|
||||
@@ -162,11 +163,6 @@ Route::group('v1/', function () {
|
||||
Route::get('userInfoStats', 'app\cunkebao\controller\StatsController@userInfoStats');
|
||||
});
|
||||
|
||||
// 常用功能相关
|
||||
Route::group('common-functions', function () {
|
||||
Route::get('list', 'app\cunkebao\controller\CommonFunctionsController@getList'); // 获取常用功能列表
|
||||
});
|
||||
|
||||
// 算力相关
|
||||
Route::group('tokens', function () {
|
||||
Route::get('list', 'app\cunkebao\controller\TokensController@getList');
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace app\cunkebao\controller;
|
||||
namespace app\cunkebao\controller\workbench;
|
||||
|
||||
use app\cunkebao\controller\BaseController;
|
||||
use library\ResponseHelper;
|
||||
Reference in New Issue
Block a user