- public/articles/mcp-guide.md(11.5KB 九节):MCP 概念与米剪 10 工具 总览、端点/Bearer 令牌说明、Claude Desktop/Claude Code/Cursor/Hermes 四种接入模板、工具参数按 mcp/server.py 源码核实、一句话生成视频 实战链、curl 握手自检、.env 自部署配置、8 条常见问题 - Header.tsx nav 加「MCP 使用说明」→ /article/mcp-guide(使用教程之后, 当前页高亮沿用既有 activeClassName) - index.json 新增 mcp-guide 条目;CHANGELOG 记录 - 构建部署 + 线上 md/index.json/浏览器渲染验证通过
177 lines
6.1 KiB
TypeScript
177 lines
6.1 KiB
TypeScript
import React, { useReducer, useEffect, useState } from 'react';
|
|
import styles from './header.module.less';
|
|
import { NavLink, Link, withRouter } from 'react-router-dom';
|
|
import { observer } from 'mobx-react';
|
|
import { user } from '@stores/user';
|
|
import logoImg from '@images/logo2.png';
|
|
import { Button, Popover, Avatar, Space, Toast } from '@douyinfe/semi-ui';
|
|
import Login from '@components/login';
|
|
import User from './user/User';
|
|
import { config } from '@config/index';
|
|
import { theme, ThemeName } from '@theme';
|
|
import { layout } from '@stores/layout';
|
|
import { IconDuration, IconSun } from '@douyinfe/semi-icons';
|
|
import { getInitData } from '@config/initData';
|
|
import { server } from './server';
|
|
import { pubsub } from '@utils/pubsub';
|
|
import Intl from '@language/Intl';
|
|
import { language } from '@language/language';
|
|
import { AllApplication, Box, International } from '@icon-park/react';
|
|
import classNames from 'classnames';
|
|
import { reURL } from '@utils/util';
|
|
import VipRecharge from '@pages/editor/components/header/VipRecharge';
|
|
import CreditRecharge from '@pages/editor/components/header/CreditRecharge';
|
|
import HubStatus from '@components/hub';
|
|
|
|
export interface IProps {
|
|
componentName?: string;
|
|
match?: any;
|
|
navs?: any[];
|
|
}
|
|
|
|
const Header = (props: IProps) => {
|
|
// const [, forceUpdate] = useReducer(x => x + 1, 0);
|
|
const [cid = '', cname = ''] = props.match.params.cid?.split('_') || [];
|
|
const [vipRechargeVisible, setVipRechargeVisible] = useState(false);
|
|
const [creditRechargeVisible, setCreditRechargeVisible] = useState(false);
|
|
|
|
// 创建视频
|
|
const createVideo = async () => {
|
|
const initData = getInitData();
|
|
if (cid) {
|
|
initData.category_id = cid;
|
|
}
|
|
const [res, err] = await server.createVideo(initData);
|
|
if (err) {
|
|
Toast.error(err);
|
|
return;
|
|
}
|
|
location.href = `${config.editorHost}/${res.id}`;
|
|
};
|
|
|
|
useEffect(() => {
|
|
const vipSub = pubsub.subscribe('showVipRecharge', () => {
|
|
setVipRechargeVisible(true);
|
|
});
|
|
const creditSub = pubsub.subscribe('showCreditRecharge', () => {
|
|
setCreditRechargeVisible(true);
|
|
});
|
|
return () => {
|
|
pubsub.unsubscribe('showVipRecharge');
|
|
pubsub.unsubscribe('showCreditRecharge');
|
|
};
|
|
}, []);
|
|
|
|
const languageType = language.getLanguage();
|
|
|
|
return (
|
|
<div className={styles.header}>
|
|
<div className={styles.logoNav}>
|
|
<Link to="/">
|
|
<div
|
|
className={classNames({
|
|
[styles.logoen]: true,
|
|
})}
|
|
></div>
|
|
</Link>
|
|
<div className={styles.nav}>
|
|
<NavLink
|
|
to="/"
|
|
className={styles.text}
|
|
activeClassName={styles.active}
|
|
isActive={(match, location) => {
|
|
if (location.pathname === '/') {
|
|
return true;
|
|
}
|
|
}}
|
|
>
|
|
<Intl name="common_home" />
|
|
</NavLink>
|
|
{props.navs?.map((item, index) => (
|
|
<a key={index} href={item.to} className={styles.text}>
|
|
{item.name}
|
|
</a>
|
|
))}
|
|
{/* <NavLink to="/article/vip" className={styles.text} activeClassName={styles.active}>
|
|
会员中心
|
|
</NavLink> */}
|
|
{/* <NavLink to="/tools" className={styles.text} activeClassName={styles.active}>
|
|
<Intl name="common_tools" />
|
|
</NavLink> */}
|
|
<NavLink to="/article/about" className={styles.text} activeClassName={styles.active}>
|
|
<Intl name="common_about_us" />
|
|
</NavLink>
|
|
{/* 详情页优先:教程入口直接指向一篇具体文章,相关文章在页尾互相串联 */}
|
|
<NavLink
|
|
to="/article/local-deploy-guide"
|
|
className={styles.text}
|
|
activeClassName={styles.active}
|
|
>
|
|
使用教程
|
|
</NavLink>
|
|
<NavLink
|
|
to="/article/mcp-guide"
|
|
className={styles.text}
|
|
activeClassName={styles.active}
|
|
>
|
|
MCP 使用说明
|
|
</NavLink>
|
|
{/* <a
|
|
href={languageType === 'en-US' ? '/docs/en' : '/docs'}
|
|
target="_blank"
|
|
className={styles.text}
|
|
>
|
|
<Intl name="common_tech_docs" />
|
|
</a> */}
|
|
</div>
|
|
</div>
|
|
<Space spacing={20}>
|
|
{/* 右上角:当前版本 + 新版本提示 + 公告(数据来自授权中心,拿不到就安静降级) */}
|
|
<HubStatus />
|
|
{/* <a
|
|
className={styles.space}
|
|
onClick={() => {
|
|
if (language.getLanguage() === 'en-US') {
|
|
language.setLanguage('zh-CN');
|
|
} else {
|
|
language.setLanguage('en-US');
|
|
}
|
|
}}
|
|
>
|
|
<Intl name="user_language" />
|
|
</a> */}
|
|
{!!user.info && (
|
|
<>
|
|
<Link to="/workspace/material" className={styles.space}>
|
|
{/* <Intl name="user_workspace" /> */}
|
|
<Box theme="outline" size="20" fill="var(--theme-icon)" />
|
|
素材
|
|
</Link>
|
|
<Link to="/workspace/draft" className={styles.space + ' ' + styles.active2}>
|
|
{/* <Intl name="user_workspace" /> */}
|
|
<AllApplication theme="outline" size="20" fill="var(--theme-icon)" />
|
|
项目
|
|
</Link>
|
|
</>
|
|
)}
|
|
{/* <a className={styles.createVideoBtn} onClick={createVideo}>
|
|
<Button theme="solid" type="primary" className={styles.create}>
|
|
<Intl name="common_create_video" />
|
|
</Button>
|
|
</a> */}
|
|
{user.info && !user.info.guest ? (
|
|
<Popover content={<User />} position="bottomRight" trigger="hover">
|
|
<Avatar src={reURL(user.info.avatar, config.resourcesHost)} size="small" color="blue" alt="Lisa LeBlanc">
|
|
{user.info.name.toUpperCase().split('')[0]}
|
|
</Avatar>
|
|
</Popover>
|
|
) : null}
|
|
</Space>
|
|
<VipRecharge visible={vipRechargeVisible} onCancel={() => setVipRechargeVisible(false)} />
|
|
<CreditRecharge visible={creditRechargeVisible} onCancel={() => setCreditRechargeVisible(false)} />
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export default withRouter(observer(Header));
|