Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions himarket-web/himarket-admin/bin/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ fi
sed -i "s|{{ HIMARKET_SERVER }}|${HIMARKET_SERVER}|g" /etc/nginx/default.d/proxy.conf

nginx
echo "Himarket Admin started successfully"
tail -f /var/log/nginx/access.log
echo "HiMarket Admin started successfully"
tail -f /var/log/nginx/access.log
2 changes: 1 addition & 1 deletion himarket-web/himarket-admin/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/logo.png" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Himarket</title>
<title>HiMarket</title>
</head>
<body>
<div id="root"></div>
Expand Down
16 changes: 8 additions & 8 deletions himarket-web/himarket-admin/src/components/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ const Layout: React.FC = () => {
const hasToken = isAuthenticated()
setIsLoggedIn(hasToken)
}

checkAuthStatus()
// 监听 storage 变化(当其他标签页登录/登出时)
window.addEventListener('storage', checkAuthStatus)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

应使用防抖函数优化 storage 事件监听器,避免频繁触发认证状态检查。

🟡 Major | 🧹 Code Smells

📋 问题详情

当前代码在每次 storage 事件触发时都会调用 checkAuthStatus 函数,这可能导致在多个标签页同时操作 localStorage 时产生性能问题或不必要的重复请求。建议使用防抖(debounce)技术来限制函数执行频率。

💡 解决方案

引入防抖函数以减少高频触发带来的性能损耗。

+ // 使用防抖函数包装 checkAuthStatus
+ const debouncedCheckAuthStatus = debounce(checkAuthStatus, 300);
- window.addEventListener('storage', checkAuthStatus)
+ window.addEventListener('storage', debouncedCheckAuthStatus);

您的反馈对我们很重要!(建议右键在新标签页中打开以下链接)

有用意见👍无用意见👎错误意见❌

return () => {
window.removeEventListener('storage', checkAuthStatus)
}
Expand All @@ -47,10 +47,10 @@ const Layout: React.FC = () => {
{ name: 'Portal', cn: '门户', href: '/portals', icon: GlobalOutlined },
{ name: 'API Products', cn: 'API产品', href: '/api-products', icon: AppstoreOutlined },
{ name: 'Categories', cn: '产品类别', href: '/product-categories', icon: FolderOutlined },
{
name: '实例管理',
cn: '实例管理',
href: '/consoles',
{
name: '实例管理',
cn: '实例管理',
href: '/consoles',
icon: SettingOutlined,
children: [
{ name: 'Nacos实例', cn: 'Nacos实例', href: '/consoles/nacos', icon: DesktopOutlined },
Expand Down Expand Up @@ -134,7 +134,7 @@ const Layout: React.FC = () => {
className="hover:bg-gray-100"
/>
</div>
<span className="text-2xl font-bold">Himarket</span>
<span className="text-2xl font-bold">HiMarket</span>
</div>
{/* 顶部右侧用户信息或登录按钮 */}
{isLoggedIn ? (
Expand Down Expand Up @@ -175,4 +175,4 @@ const Layout: React.FC = () => {
)
}

export default Layout
export default Layout
2 changes: 1 addition & 1 deletion himarket-web/himarket-frontend/CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co

## Project Overview

Himarket API Portal Frontend - A React-based developer portal for managing API products, MCP servers, AI agents, and AI models. The portal allows developers to browse, subscribe to, and manage various API products with OAuth/OIDC authentication.
HiMarket API Portal Frontend - A React-based developer portal for managing API products, MCP servers, AI agents, and AI models. The portal allows developers to browse, subscribe to, and manage various API products with OAuth/OIDC authentication.

## Tech Stack

Expand Down
2 changes: 1 addition & 1 deletion himarket-web/himarket-frontend/IMPLEMENTATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
- ✅ 更新开发环境代理配置(`vite.config.ts`)
- ✅ API 请求拦截器自动添加 Authorization header

### 2. Square 页面(体验中心
### 2. Square 页面(HiChat
- ✅ 从真实 API 获取模型列表(`GET /products?type=MODEL_API`)
- ✅ 添加加载状态和错误处理
- ✅ 点击"立即体验"跳转到 Chat 页面并传递产品信息
Expand Down
4 changes: 2 additions & 2 deletions himarket-web/himarket-frontend/bin/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ fi
sed -i "s|{{ HIMARKET_SERVER }}|${HIMARKET_SERVER}|g" /etc/nginx/default.d/proxy.conf

nginx
echo "Himarket Frontend started successfully"
tail -f /var/log/nginx/access.log
echo "HiMarket Frontend started successfully"
tail -f /var/log/nginx/access.log
2 changes: 1 addition & 1 deletion himarket-web/himarket-frontend/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/logo.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Himarket</title>
<title>HiMarket</title>
</head>
<body>
<div id="root"></div>
Expand Down
1 change: 1 addition & 0 deletions himarket-web/himarket-frontend/src/aliyunThemeToken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export const colors = {
"colorPrimaryBg": "#EEF2FF",
"colorPrimaryBgHover": "#E0E7FF",
"colorPrimarySecondary": "#C7D2FE",
"colorPrimaryHoverLight": "#EFF4FF",
"colorTextSecondaryCustom": "#A3A3A3",
"colorPrimaryBorderHover": "#A5B4FC",
"subTitle": "#737373",
Expand Down
10 changes: 5 additions & 5 deletions himarket-web/himarket-frontend/src/components/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Link, useLocation } from "react-router-dom";
import { useState, useEffect } from "react";
import { UserInfo } from "./UserInfo";
import { Himarket, Logo } from "./icon";
import { HiMarket, Logo } from "./icon";


export function Header() {
Expand All @@ -18,11 +18,11 @@ export function Header() {
}, []);

const tabs = [
{ path: "/models", label: "模型" },
{ path: "/mcp", label: "MCP" },
{ path: "/chat", label: "HiChat" },
{ path: "/agents", label: "智能体" },
{ path: "/mcp", label: "MCP" },
{ path: "/models", label: "模型" },
{ path: "/apis", label: "API" },
{ path: "/chat", label: "体验中心" },
];

const isActiveTab = (path: string) => {
Expand All @@ -47,7 +47,7 @@ export function Header() {
{/* LOGO区域 */}
<Logo className="w-6 h-6" />
</div>
<Himarket />
<HiMarket />
</Link>
<div className="h-6 w-[1px] bg-gray-200 mx-5"></div>
{/* Tab 区域 */}
Expand Down
58 changes: 29 additions & 29 deletions himarket-web/himarket-frontend/src/components/Navigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ interface NavigationProps {

export function Navigation({ loading = false }: NavigationProps) {
const location = useLocation();

const isActive = (path: string) => {
if (path === '/') {
return location.pathname === '/';
Expand All @@ -18,29 +18,29 @@ export function Navigation({ loading = false }: NavigationProps) {
};

const navigationItems = [
{
path: '/apis',
icon: <ApiOutlined />,
title: 'APIs',
subtitle: 'REST接口'
{
path: '/apis',
icon: <ApiOutlined />,
title: 'APIs',
subtitle: 'REST接口'
},
{
path: '/mcp',
icon: <ToolOutlined />,
title: 'MCP',
subtitle: '工具集成'
{
path: '/mcp',
icon: <ToolOutlined />,
title: 'MCP',
subtitle: '工具集成'
},
{
path: '/models',
icon: <BulbOutlined />,
title: 'Model',
subtitle: 'AI模型'
{
path: '/models',
icon: <BulbOutlined />,
title: 'Model',
subtitle: 'AI模型'
},
{
path: '/agents',
icon: <RobotOutlined />,
title: 'Agent',
subtitle: '智能助手'
{
path: '/agents',
icon: <RobotOutlined />,
title: 'Agent',
subtitle: '智能助手'
}
];

Expand All @@ -65,11 +65,11 @@ export function Navigation({ loading = false }: NavigationProps) {
style={{ display: "block" }}
/>
</div>
<span className="text-xl font-bold text-gray-900">Himarket</span>
<span className="text-xl font-bold text-gray-900">HiMarket</span>
</Link>
)}
</div>

<div className="hidden md:flex items-center absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2">
{loading ? (
<div className="flex space-x-3">
Expand All @@ -81,12 +81,12 @@ export function Navigation({ loading = false }: NavigationProps) {
) : (
<div className="flex space-x-3">
{navigationItems.map((item) => (
<Link
<Link
key={item.path}
to={item.path}
to={item.path}
className={`px-4 py-3 rounded-lg font-medium transition-all duration-200 flex flex-col items-center justify-center min-w-[100px] ${
isActive(item.path)
? 'bg-blue-50/80 text-blue-700 border border-blue-200/50 shadow-sm'
isActive(item.path)
? 'bg-blue-50/80 text-blue-700 border border-blue-200/50 shadow-sm'
: 'text-gray-700 hover:text-gray-900 hover:bg-gray-50/50 border border-transparent'
}`}
>
Expand All @@ -106,7 +106,7 @@ export function Navigation({ loading = false }: NavigationProps) {
</div>
)}
</div>

<div className="flex items-center space-x-4">
{loading ? (
<Skeleton.Avatar size={32} active />
Expand All @@ -118,4 +118,4 @@ export function Navigation({ loading = false }: NavigationProps) {
</div>
</nav>
);
}
}
6 changes: 4 additions & 2 deletions himarket-web/himarket-frontend/src/components/UserInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,9 @@ export function UserInfo() {
menu={{ items: menuItems }}
placement="bottomRight"
trigger={['hover']}
overlayClassName="user-dropdown"
classNames={{
root: "user-dropdown"
}}
>
<div className="flex items-center space-x-2 cursor-pointer hover:opacity-80 transition-opacity px-2 py-1 rounded-full">
{userInfo.avatar ? (
Expand All @@ -185,4 +187,4 @@ export function UserInfo() {
登录
</Button>
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ function HomeAPICard() {
{
[
<Type />,
<Image />,
<Image className="fill-[#0A0A0A] w-5 h-5" />,
<SquarePlay />,
<AudioLines />,
].map((icon, i) => (
Expand Down Expand Up @@ -131,4 +131,4 @@ function Terminal(props: React.PropsWithChildren<{ className?: string }>) {
)
}

export default HomeAPICard;
export default HomeAPICard;
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function HomeChatCard() {
/>
<div className="h-full relative z-[3] flex flex-col justify-between p-6">
<div className="flex flex-col gap-4">
<div className="font-medium animate-[fadeInLeft_0.6s_ease-out_0.3s_both]">体验中心</div>
<div className="font-medium animate-[fadeInLeft_0.6s_ease-out_0.3s_both]">HiChat</div>
<div className="mt-[10%]">
<img className="absolute w-[150%] max-w-[150%] animate-[fadeInScale_0.8s_ease-out_0.5s_both] group-hover:scale-105 transition-transform duration-500" src={ChatThum} />
<img className="absolute z-[2] bottom-[12%] left-[20%] animate-[slideInUp_0.7s_ease-out_0.7s_both] group-hover:bottom-[10%] group-hover:left-[22%] transition-all duration-500" src={ChatThumCard} />
Expand All @@ -34,4 +34,4 @@ function HomeChatCard() {
)
}

export default HomeChatCard;
export default HomeChatCard;
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ export function ChatArea(props: ChatAreaProps) {
<h1 className="text-2xl font-medium text-gray-900 mb-2">
您好,欢迎来到 <span className="text-colorPrimary">
<TextType
text={["Himarket 体验中心"]}
text={["HiMarket HiChat"]}
typingSpeed={100}
showCursor={true}
cursorCharacter="_"
Expand Down
Loading
Loading