You've already forked DataMate
refactor(home): 移除外部链接跳转功能并优化路由导航
- 移除百度链接跳转功能,改为内部路由导航到内容生成页面 - 删除无用的 isChecking 状态和 handleChatClick 处理函数 - 移除菜单项中的 externalLink 属性配置 - 简化侧边栏点击事件处理逻辑,移除外部链接检查代码 - 添加内容生成页面的路由配置
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
* 内容生成页面
|
||||
* 通过 iframe 加载外部页面
|
||||
*/
|
||||
export default function ContentGenerationPage() {
|
||||
const iframeUrl = "https://www.baidu.com";
|
||||
|
||||
return (
|
||||
<div className="h-full w-full flex flex-col">
|
||||
<div className="flex items-center justify-between mb-4">
|
||||
<h1 className="text-xl font-bold">内容生成</h1>
|
||||
</div>
|
||||
<div className="flex-1 border rounded-lg overflow-hidden">
|
||||
<iframe
|
||||
src={iframeUrl}
|
||||
className="w-full h-full border-0"
|
||||
title="内容生成"
|
||||
sandbox="allow-same-origin allow-scripts allow-popups allow-forms allow-downloads"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -10,21 +10,11 @@ import {
|
||||
GitBranch,
|
||||
} from "lucide-react";
|
||||
import { features, menuItems } from "../Layout/menu";
|
||||
import { useState } from 'react';
|
||||
import { useNavigate } from "react-router";
|
||||
import { Card } from "antd";
|
||||
|
||||
export default function WelcomePage() {
|
||||
const navigate = useNavigate();
|
||||
const [isChecking, setIsChecking] = useState(false);
|
||||
|
||||
const handleChatClick = async () => {
|
||||
if (isChecking) return; // 防止重复点击
|
||||
|
||||
setIsChecking(true);
|
||||
|
||||
window.open('https://baidu.com')
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="min-h-screen bg-gradient-to-br from-blue-50 to-indigo-100">
|
||||
@@ -51,11 +41,11 @@ export default function WelcomePage() {
|
||||
开始使用
|
||||
</span>
|
||||
<span
|
||||
onClick={handleChatClick}
|
||||
className="cursor-pointer rounded px-4 py-2 inline-flex items-center bg-gradient-to-r from-purple-600 to-pink-600 hover:from-purple-700 hover:to-pink-700 text-white shadow-lg disabled:opacity-50 disabled:cursor-not-allowed"
|
||||
onClick={() => navigate("/data/content-generation")}
|
||||
className="cursor-pointer rounded px-4 py-2 inline-flex items-center bg-gradient-to-r from-purple-600 to-pink-600 hover:from-purple-700 hover:to-pink-700 text-white shadow-lg"
|
||||
>
|
||||
<MessageSquare className="mr-2 w-4 h-4" />
|
||||
内容生成
|
||||
内容生成
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
@@ -89,13 +79,7 @@ export default function WelcomePage() {
|
||||
{menuItems.map((item) => (
|
||||
<Card
|
||||
key={item.id}
|
||||
onClick={() => {
|
||||
if (item.externalLink) {
|
||||
window.open(item.externalLink, "_blank");
|
||||
return;
|
||||
}
|
||||
navigate(item.children ? `/data/${item.children[0].id}`: `/data/${item.id}`);
|
||||
}}
|
||||
onClick={() => navigate(item.children ? `/data/${item.children[0].id}`: `/data/${item.id}`)}
|
||||
className="cursor-pointer hover:shadow-lg transition-all duration-200 border-0 shadow-md relative overflow-hidden group w-full md:w-[calc(50%-12px)] lg:w-[280px]"
|
||||
>
|
||||
<div className="text-center relative">
|
||||
|
||||
@@ -108,12 +108,6 @@ const AsiderAndHeaderLayout = () => {
|
||||
selectedKeys={[activeItem]}
|
||||
defaultOpenKeys={["synthesis"]}
|
||||
onClick={({ key }) => {
|
||||
// 查找菜单项,检查是否有外部链接
|
||||
const menuItem = menuItems.find((item) => item.id === key);
|
||||
if (menuItem?.externalLink) {
|
||||
window.open(menuItem.externalLink, "_blank");
|
||||
return;
|
||||
}
|
||||
setActiveItem(key);
|
||||
navigate(`/data/${key}`);
|
||||
}}
|
||||
|
||||
@@ -49,7 +49,6 @@ export const menuItems = [
|
||||
icon: Sparkles,
|
||||
description: "智能内容生成与创作",
|
||||
color: "bg-purple-500",
|
||||
externalLink: "https://www.baidu.com",
|
||||
},
|
||||
// {
|
||||
// id: "synthesis",
|
||||
|
||||
@@ -44,6 +44,7 @@ import SynthFileTask from "@/pages/SynthesisTask/SynthFileTask.tsx";
|
||||
import EvaluationDetailPage from "@/pages/DataEvaluation/Detail/TaskDetail.tsx";
|
||||
import SynthDataDetail from "@/pages/SynthesisTask/SynthDataDetail.tsx";
|
||||
import Home from "@/pages/Home/Home";
|
||||
import ContentGenerationPage from "@/pages/ContentGeneration/ContentGenerationPage";
|
||||
|
||||
const router = createBrowserRouter([
|
||||
{
|
||||
@@ -152,6 +153,10 @@ const router = createBrowserRouter([
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
path: "content-generation",
|
||||
Component: ContentGenerationPage,
|
||||
},
|
||||
{
|
||||
path: "synthesis/task",
|
||||
children: [
|
||||
|
||||
Reference in New Issue
Block a user