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系列组件 #1390

Merged
merged 40 commits into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
Changes from 33 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
af09893
feat: 尝试删除compiled
Nov 26, 2024
8b62eb8
feat: 改造compiled
Nov 26, 2024
99d3649
feat: 修改real_release.yml文件
Nov 26, 2024
a601414
fix: eslintignore
Nov 27, 2024
1358c68
fix: 修改beta版本号
Nov 27, 2024
2ff2296
fix: release时不再需要重复run build
Nov 27, 2024
7ce5106
feat: 将几处demo页面列表及组件列表的配置文件改为动态生成
Nov 28, 2024
b38f81b
fix: 合并master
Nov 28, 2024
4add3a1
fix: rm app.json
Nov 28, 2024
5b22f3e
fix: 合并Master迭代
Dec 3, 2024
995f1ad
fix: 提示优化
Dec 3, 2024
fbefbd2
fix: 更改beta版本号
Dec 4, 2024
f42707c
feat: 引入copilot系列组件
Dec 5, 2024
9875266
fix: 合并master
Dec 9, 2024
bd90c2a
feat: Copilot组件框架
Dec 11, 2024
566a68d
fix: 增加编译流程
Dec 12, 2024
ab37591
feat: 升级copilot架构
Dec 12, 2024
8101338
prompts 组件 (#1345)
Ray0329 Jan 2, 2025
55a9907
Merge branch 'master' into feat/x-components
rayhomie Jan 2, 2025
08d59f1
feat: copilot suggestion dev
rayhomie Jan 2, 2025
1ce04c8
Copilot suggestion dev (#1356)
rayhomie Jan 7, 2025
3c21d95
feat: merge prompts & suggestion (#1381)
rayhomie Jan 14, 2025
ddaf664
Feat Conversations (#1388)
rayhomie Jan 23, 2025
7999320
feat: Add copilot components
anotherso1a Jan 23, 2025
52437e4
chore: solve conflicts
anotherso1a Jan 23, 2025
233a610
feat: add dark mode
anotherso1a Jan 23, 2025
d48cf36
copilot系列-思维链组件 (#1355)
coderrorer Jan 24, 2025
7505b83
优化思维链组件 (#1389)
coderrorer Jan 24, 2025
4d4a4a7
fix: adjust wx
anotherso1a Jan 24, 2025
9f7e994
chore: solve conflicts
anotherso1a Jan 24, 2025
187331b
chore: solve conflicts
anotherso1a Jan 24, 2025
3987495
fix: add demos
anotherso1a Jan 24, 2025
d6c92c8
style: change text
anotherso1a Jan 24, 2025
8bdf40d
fix: 修复微信编译问题
Jan 24, 2025
312acb2
fix: fix props & doc contents
anotherso1a Jan 24, 2025
3fd007e
fix: 修复微信兼容问题
Jan 24, 2025
1e2d7c7
fix: merge
Jan 24, 2025
724dee4
fix: 修复demo问题
Jan 24, 2025
005f29b
fix: 更新文档
Jan 24, 2025
cb61254
fix: update doc
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
7 changes: 5 additions & 2 deletions .dumi/theme/common/Sim/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function buildUrl(
const DefaultPlatform = 'alipay';

function getSupportPlatform(platform: string) {
const supportWechat = true
const supportWechat = true;
if (!supportWechat && platform === 'wechat') {
return {
platform: DefaultPlatform,
Expand Down Expand Up @@ -83,7 +83,10 @@ const Previewer: React.FC<IProps> = () => {
const matchedRoute = useMatchedRoute();

const isShowSim = useMemo(() => {
return matchedRoute?.meta?.frontmatter?.nav?.path === '/components';
return (
matchedRoute?.meta?.frontmatter?.nav?.path === '/components' ||
matchedRoute?.meta?.frontmatter?.nav?.path === '/copilot'
);
}, [matchedRoute]);

const basicUrl =
Expand Down
6 changes: 4 additions & 2 deletions .dumi/theme/slots/Content/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,14 @@ const useStyle = ({ isOverview, isShowSim }) => {
const Content: React.FC<{ children: React.ReactNode }> = ({ children }) => {
const isOverview =
window.location.pathname === '/components/overview' ||
window.location.pathname === '/components/overview-en';
window.location.pathname === '/components/overview-en' ||
window.location.pathname === '/copilots/copilot-overview' ||
window.location.pathname === '/copilots/copilot-overview-en';

const matchedRoute = useMatchedRoute();

const isShowSim = useMemo(() => {
return matchedRoute?.meta?.frontmatter?.nav?.path === '/components';
return matchedRoute?.meta?.frontmatter?.nav?.path === '/components' || matchedRoute?.meta?.frontmatter?.nav?.path === '/copilot';
}, [matchedRoute]);

const meta = useRouteMeta();
Expand Down
102 changes: 93 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,8 @@ import {
useSiteData,
} from 'dumi';
import { INavItem } from 'dumi/dist/client/theme-api/types';
import { useCallback, useContext } from 'react';
import { motion } from 'framer-motion';
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 +81,27 @@ const useStyle = () => {
text-align: center;
}
`,
navItem: css`
position: relative;
display: flex;
align-items: center;
justify-content: center;
`,
newPlayer: css`
width: 100px;
height: 100px;
position: absolute;
top: 12px;
left: 50%;
transform: translateX(-50%);
z-index: 9;
pointer-events: none;
`,
rightIcon: css`
margin-left: 8px;
width: 16px;
height: 16px;
`,
popoverMenuNav: css`
${antCls}-menu-item,
${antCls}-menu-submenu {
Expand Down Expand Up @@ -112,23 +135,84 @@ 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}
{navItem.rightIcon && (
<motion.div
style={{ display: 'inline-block' }}
animate={{
rotate: [-5, 5, -5, 5, 0], // 轻微旋转
x: [-2, 2, -2, 2, 0], // 轻微水平移动
y: [-1, 1, -1, 1, 0], // 轻微垂直移动
transition: {
duration: 1.0, // 增加持续时间,使晃动更加平滑
repeat: Infinity, // 无限循环
ease: 'easeInOut', // 使用平滑的缓动函数
repeatDelay: 3,
},
}}
>
<img css={style.rightIcon} src={navItem.rightIcon} alt="" />
</motion.div>
)}
</div>
),
key: isExternalLinks(navItem.link) ? navItem.link : linkKeyValue,
children: navItem.children ? createMenuItems(navItem.children) : null,
Expand Down
6 changes: 4 additions & 2 deletions .dumi/theme/slots/Sidebar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ const useStyle = (isShowPlatfromSwitch) => {
padding: 3px;
.item {
height: 27px;
border-radius:1px;
border-radius: 1px;
display: flex;
align-items: center;
justify-content: center;
Expand Down Expand Up @@ -250,7 +250,9 @@ const Sidebar: FC = () => {
const { pathname } = window.location;
return (
pathname.startsWith('/components/') ||
matchedRoute?.meta?.frontmatter?.nav?.path === '/components'
matchedRoute?.meta?.frontmatter?.nav?.path === '/components' ||
pathname.startsWith('/copilots/') ||
matchedRoute?.meta?.frontmatter?.nav?.path === '/copilot'
);
}, [matchedRoute]);

Expand Down
24 changes: 24 additions & 0 deletions .dumirc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@ export default defineConfig({
title: '组件',
link: '/components/overview',
},
{
title: 'Copilot',
link: '/copilots/conversations',
// @ts-ignore
isNew: true,
rightIcon:
'https://mdn.alipayobjects.com/huamei_2jrq4g/afts/img/A*iiKoT73_9ucAAAAAAAAAAAAAetF8AQ/original',
},
{
title: '资源',
link: '/resources',
Expand All @@ -78,6 +86,10 @@ export default defineConfig({
title: 'Components',
link: '/components/overview-en',
},
{
title: 'Copilot',
link: '/copilots/conversations-en',
},
{
title: 'Resources',
link: '/resources-en',
Expand Down Expand Up @@ -563,4 +575,16 @@ export default defineConfig({
{ id: 'zh-CN', name: '中文', suffix: '' },
{ id: 'en', name: 'English', suffix: '-en' },
],
resolve: {
atomDirs: [
{
type: 'component',
dir: 'src',
},
{
type: 'copilot',
dir: 'copilot',
},
],
},
});
20 changes: 20 additions & 0 deletions copilot-demo/pages/Actions/index.axml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<ant-container title="基础用法">
<ant-actions items="{{basicActions}}" onItemTap="handleTapAction" />
</ant-container>

<ant-container title="配合bubble使用">
<ant-switch checked="{{ showBubble }}" onChange="toggleBubble" />
<ant-bubble
a:if="{{ showBubble }}"
content="永和九年,岁在癸丑,暮春之初,会于会稽山阴之兰亭,修禊事也。群贤毕至,少长咸集。此地有崇山峻岭,茂林修竹,又有清流激湍,映带左右,引以为流觞曲水,列坐其次。虽无丝竹管弦之盛,一觞一咏,亦足以畅叙幽情。"
typing="{{ { step: 2, interval: 50 } }}"
onTypingComplete="onTypingComplete"
>
<ant-actions
a:if="{{ loaded }}"
slot="footer"
items="{{bubbleActions}}"
onItemTap="handleBubbleAction"
/>
</ant-bubble>
</ant-container>
16 changes: 16 additions & 0 deletions copilot-demo/pages/Actions/index.json5
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
/// #if WECHAT
"navigationBarTitleText": "Actions",
/// #endif

/// #if ALIPAY
"defaultTitle": "Actions",
/// #endif

"usingComponents": {
"ant-actions": "../../../src/Actions/index",
"ant-bubble": "../../../src/Bubble/index",
"ant-switch": "../../../src/Switch/index",
"ant-container": "../../../src/Container/index"
}
}
Empty file.
94 changes: 94 additions & 0 deletions copilot-demo/pages/Actions/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
Page({
data: {
liked: false,
loaded: false,
showBubble: true,
basicActions: [
{
label: 'copy',
icon: 'TextOutline',
},
{
label: 'like',
icon: 'LikeOutline',
},
{
label: 'collect',
icon: 'StarOutline',
},
{
label: 'edit',
icon: 'EditSOutline',
},
],
bubbleActions: [
{
label: 'copy',
icon: 'TextOutline',
},
{
label: 'collect',
icon: 'StarOutline',
},
],
},

handleTapAction(item) {
/// #if WECHAT
// @ts-ignore
item = item.detail;
/// #endif
const basicActions = [...this.data.basicActions];
if (item.label === 'like') {
this.setData({
liked: !this.data.liked,
});
basicActions.find((action) => action.label === 'like').icon = this.data.liked
? 'https://mdn.alipayobjects.com/huamei_bsws4g/afts/img/JmVoRp-2UwMAAAAAAAAAAAAADoEQAQFr/original'
: 'LikeOutline';
} else {
/// #if ALIPAY
my.showToast({
content: `${item.label} tapped`,
});
/// #endif
/// #if WECHAT
// @ts-ignore
wx.showToast({
title: `${item.label} tapped`,
});
/// #endif
}
this.setData({
basicActions,
});
},
handleBubbleAction(item) {
/// #if WECHAT
// @ts-ignore
item = item.detail;
/// #endif
/// #if ALIPAY
my.showToast({
content: `${item.label} tapped`,
});
/// #endif
/// #if WECHAT
// @ts-ignore
wx.showToast({
title: `${item.label} tapped`,
});
/// #endif
},
onTypingComplete() {
this.setData({
loaded: true,
});
},
toggleBubble() {
this.setData({
showBubble: !this.data.showBubble,
loaded: false,
});
},
});
Loading
Loading