Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

copilot系列-思维链组件 #1355

Merged
merged 30 commits into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
42b7721
feat: thought-chain组件开发
Jan 2, 2025
1ff4918
feat: 思考链组件demo及文档完善
Jan 3, 2025
596b8b1
fix: 合并x-components组件
Jan 3, 2025
64a10d8
fix: 修改标题
Jan 3, 2025
c22927b
CascaderPicker引用路径错误修正 (#1343)
dahlzb Jan 7, 2025
337ad4e
fix: popup title cant display in wechat platform (#1358)
rayhomie Jan 7, 2025
e9a2bf4
fix-some-demo-op (#1341)
ajiaberry Jan 7, 2025
c7d2c63
Update the link to the correct migration documentation (#1325)
michaelgichia Jan 7, 2025
6832e64
docs: update doc
rayhomie Jan 7, 2025
937852c
Feat/table ellipse (#1359)
coderrorer Jan 7, 2025
f43ca40
chore(release): v3.0.5 (#1362)
github-actions[bot] Jan 7, 2025
d27f512
Wx problem fix (#1364)
rayhomie Jan 7, 2025
01249e7
Add wx:key (#1370)
rayhomie Jan 8, 2025
ab39e7b
Feat/table ellipse (#1365)
coderrorer Jan 8, 2025
3a7f981
fix: form onValueChange validate time series problem (#1372)
rayhomie Jan 9, 2025
2cc06ea
chore(release): v3.0.6 (#1376)
github-actions[bot] Jan 9, 2025
18b6eb6
fix: card divider (#1377)
rayhomie Jan 10, 2025
1bd7fb9
Fix card divier (#1378)
rayhomie Jan 10, 2025
4e7a329
fix: display range problem (#1383)
rayhomie Jan 16, 2025
cf6c7bf
chore(release): v3.0.7 (#1384)
github-actions[bot] Jan 16, 2025
15b3c0e
feat: 合并master
Jan 20, 2025
4549e1e
Merge branch 'feat/x-components' into feat/copilot-thought-chain
rayhomie Jan 23, 2025
01264e9
docs: adjust doc
rayhomie Jan 23, 2025
5ed99a1
chore: nav 新增功能动效
rayhomie Jan 23, 2025
ff07c9d
chore: nav 新增功能动效
rayhomie Jan 23, 2025
87f6050
fix: 更新chain-thought组件
Jan 23, 2025
fdde783
feat: 优化thought-chain组件
Jan 23, 2025
3fe9bfc
fix: 优化事件和文档
Jan 24, 2025
59c6191
feat: welcome组件
Jan 24, 2025
65f2b85
fix: 文档翻译
Jan 24, 2025
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
74 changes: 65 additions & 9 deletions .dumi/theme/slots/Header/Navigation.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { MenuFoldOutlined } from '@ant-design/icons';
import { css } from '@emotion/react';
import { Player } from '@galacean/effects';
import type { MenuProps } from 'antd';
import { Menu } from 'antd';
import {
Expand All @@ -11,7 +12,7 @@ import {
useSiteData,
} from 'dumi';
import { INavItem } from 'dumi/dist/client/theme-api/types';
import { useCallback, useContext } from 'react';
import { useCallback, useContext, useEffect, useRef } from 'react';
import useAdditionalThemeConfig from '../../hooks/useAdditionalThemeConfig';
import useLocaleValue from '../../hooks/useLocaleValue';
import useSiteToken from '../../hooks/useSiteToken';
Expand Down Expand Up @@ -79,6 +80,18 @@ const useStyle = () => {
text-align: center;
}
`,
navItem: css`
position: relative;
`,
newPlayer: css`
width: 100px;
height: 100px;
position: absolute;
top: 12px;
left: 50%;
transform: translateX(-50%);
z-index: 9;
`,
popoverMenuNav: css`
${antCls}-menu-item,
${antCls}-menu-submenu {
Expand Down Expand Up @@ -112,23 +125,66 @@ export default function Navigation({ isMobile, responsive }: NavigationProps) {
const locale = useLocale();
const moreLinks = useLocaleValue('moreLinks');
const activeMenuItem = pathname.split('/').slice(0, 2).join('/');
const playerDom = useRef<HTMLDivElement>(null);
const timers = useRef<NodeJS.Timeout[]>([]);

useEffect(() => {
if (!playerDom.current) return;

const player = new Player({
container: playerDom.current,
});

const timer1 = setTimeout(() => {
player.loadScene(
'https://mdn.alipayobjects.com/mars/afts/file/A*wKDRRKoA9fcAAAAAAAAAAAAADlB4AQ'
);
player.play();
const timer2 = setTimeout(() => {
player.loadScene(
'https://mdn.alipayobjects.com/mars/afts/file/A*wKDRRKoA9fcAAAAAAAAAAAAADlB4AQ'
);
player.play();
timers.current.push(timer2);
}, 10000);
}, 3000);
timers.current.push(timer1);
return () => {
timers.current.forEach((t) => {
clearTimeout(t);
});
timers.current = [];
};
}, []);

const createMenuItems = (navs: INavItem[]) => {
const style = useStyle();
return navs.map((navItem: INavItem) => {
const linkKeyValue = (navItem.link ?? '')
.split('/')
.slice(0, 2)
.join('/');
return {
// eslint-disable-next-line no-nested-ternary
label: navItem.children ? (
navItem.title
) : isExternalLinks(navItem.link) ? (
<a href={`${navItem.link}${search}`} target="_blank" rel="noreferrer">
{navItem.title}
</a>
) : (
<Link to={`${navItem.link}${search}`}>{navItem.title}</Link>
label: (
<div css={style.navItem}>
{navItem.children ? (
navItem.title
) : isExternalLinks(navItem.link) ? (
<a
href={`${navItem.link}${search}`}
target="_blank"
rel="noreferrer"
>
{navItem.title}
</a>
) : (
<Link to={`${navItem.link}${search}`}>{navItem.title}</Link>
)}
{navItem.isNew ? (
<div ref={playerDom} css={style.newPlayer}></div>
) : null}
</div>
),
key: isExternalLinks(navItem.link) ? navItem.link : linkKeyValue,
children: navItem.children ? createMenuItems(navItem.children) : null,
Expand Down
10 changes: 6 additions & 4 deletions .dumirc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,10 @@ export default defineConfig({
link: '/components/overview',
},
{
title: 'Copilot系列组件',
link: '/copilots/copilot-overview',
title: 'Copilot',
link: '/copilots/conversations',
// @ts-ignore
isNew: true,
},
{
title: '资源',
Expand All @@ -83,8 +85,8 @@ export default defineConfig({
link: '/components/overview-en',
},
{
title: 'Copilot Components',
link: '/copilots/copilot-overview-en',
title: 'Copilot',
link: '/copilots/conversations-en',
},
{
title: 'Resources',
Expand Down
4 changes: 0 additions & 4 deletions copilot-demo/pages/Copilotbutton/index.axml

This file was deleted.

16 changes: 0 additions & 16 deletions copilot-demo/pages/Copilotbutton/index.json5

This file was deleted.

5 changes: 0 additions & 5 deletions copilot-demo/pages/Copilotbutton/index.ts

This file was deleted.

17 changes: 17 additions & 0 deletions copilot-demo/pages/ThoughtChain/index.axml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<view class="navigation-bar" />

<ant-container title="基础用法">
<thought-chain list="{{basicList}}" onContentItemTap="onContentItemTap" />
</ant-container>
<ant-container title="二级节点">
<thought-chain list="{{secondLevelList}}" onContentItemTap="onContentItemTap" />
</ant-container>
<ant-container title="自定义节点内容">
<thought-chain list="{{customList}}" onContentItemTap="onContentItemTap">
<view slot="content" slot-scope="props">
<view a:if="{{props.contentType === 'customType'}}" style="color: red">
customType: {{props.content}}
</view>
</view>
</thought-chain>
</ant-container>
15 changes: 15 additions & 0 deletions copilot-demo/pages/ThoughtChain/index.json5
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
/// #if WECHAT
"navigationBarTitleText": "ThoughtChain 组件",
/// #endif

/// #if ALIPAY
"defaultTitle": "ThoughtChain 组件",
/// #endif

"usingComponents": {
"ant-container": "../../../src/Container/index",
"thought-chain": "../../../src/ThoughtChain/index"
},
"transparentTitle": "always"
}
4 changes: 4 additions & 0 deletions copilot-demo/pages/ThoughtChain/index.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
page {
// background: #f5f5f5;
padding: 12rpx;
}
85 changes: 85 additions & 0 deletions copilot-demo/pages/ThoughtChain/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
//@ts-ignore

Page({
data: {
basicList: [
{
status: 'success',
title: '理解问题',
},
{
status: 'fail',
title: '没有在本地找到结果',
},
{
status: 'loading',
title: '在互联网上搜索问题',
},
],
secondLevelList: [
{
status: 'success',
title: '理解问题',
content: '解析语法结构',
contentType: 'text',
},
{
status: 'loading',
title: '搜索问题',
list: [
{
status: 'success',
title: '理解问题',
},
{
status: 'success',
title: '联网搜索',
content: ['当前主流电脑配置', '黑神话悟空所需显卡', '3A游戏'],
contentType: 'tag',
},
{
status: 'success',
title: '已根据搜索结果精选3篇资料',
contentType: 'link',
content: [
'1. 黑神话悟空介绍',
'2. 对于1080p显示器,4060ti和4060该选哪个?',
'3. 黑神话悟空官方建议配置',
],
},
{
status: 'loading',
title: '联想更多结果',
},
],
},
],
customList: [
{
status: 'success',
title: '理解问题',
content: '这是自定义样式的内容',
contentType: 'customType',
},
{
status: 'success',
title: '搜索问题',
list: [
{
status: 'success',
title:
'搜索中',
content: '子节点中的自定义内容',
contentType: 'customType',
},
],
},
],
},
onContentItemTap(e) {
const { content } = e.target.dataset || {};
my.alert({
content: `点击了内容「${content}」`,
});
},
});
22 changes: 11 additions & 11 deletions copilot/Conversations/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
nav:
path: /copilot
group:
title: 通用
title: Copilot
order: 1
toc: 'content'
---
Expand All @@ -16,10 +16,10 @@ toc: 'content'
```json
"usingComponents": {
#if ALIPAY
"ant-prompts": "antd-mini/es/Conversations/index"
"ant-conversations": "antd-mini/es/Conversations/index"
#endif
#if WECHAT
"ant-prompts": "antd-mini/Conversations/index"
"ant-conversations": "antd-mini/Conversations/index"
#endif
}
```
Expand All @@ -29,18 +29,18 @@ toc: 'content'
### 基本使用

```xml
<ant-conversations
items="{{items}}"
menus="{{menus}}"
<ant-conversations
items="{{items}}"
menus="{{menus}}"
#if ALIPAY
onItemTap="handleItemTap"
onMenuItemTap="handleMenuItemTap"
onItemTap="handleItemTap"
onMenuItemTap="handleMenuItemTap"
#endif
#if WECHAT
binditemtap="handleItemTap"
bindmenuitemtap="handleMenuItemTap"
binditemtap="handleItemTap"
bindmenuitemtap="handleMenuItemTap"
#endif
/>
/>
```

```js
Expand Down
1 change: 0 additions & 1 deletion copilot/Copilotbutton/index.axml

This file was deleted.

Loading
Loading