Skip to content

Commit fdff07f

Browse files
committed
✨ feat: 新增展示文档
1 parent d5be83d commit fdff07f

File tree

12 files changed

+179
-34
lines changed

12 files changed

+179
-34
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
<h1>Project Template<br/><sup>LobeChat Plugin</sup></h1>
1010

11-
This is the plugin template for LobeChat plugin development, see detail on [template usage](https://chat-plugin-sdk.lobehub.com/guides/template)
11+
This is the plugin template for LobeChat plugin development
1212

1313
[Changelog](./CHANGELOG.md) · [Report Bug][issues-url] · [Request Feature][issues-url]
1414

@@ -50,7 +50,7 @@ This is the plugin template for LobeChat plugin development, see detail on [temp
5050

5151
## 🤯 Usage
5252

53-
This is a function calling plugin for [Lobe Chat](https://github.com/lobehub/lobe-chat), you can install it in plugin setting page.
53+
see detail on [template usage](https://chat-plugin-sdk.lobehub.com/guides/template)
5454

5555
<div align="right">
5656

docs/.dumirc.ts

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import { defineConfig } from 'dumi';
2+
import path from 'node:path';
3+
4+
import { homepage } from '../package.json';
5+
6+
const isWin = process.platform === 'win32';
7+
8+
const isProd = process.env.NODE_ENV === 'production';
9+
10+
const themeConfig = {
11+
actions: [
12+
{
13+
link: homepage,
14+
openExternal: true,
15+
text: 'Github',
16+
},
17+
{
18+
link: 'https://github.com/lobehub/lobe-chat',
19+
text: 'Try it on LobeChat',
20+
type: 'primary',
21+
},
22+
],
23+
footer: 'Made with 🤯 by LobeHub',
24+
name: 'Realtime Weather',
25+
socialLinks: {
26+
discord: 'https://discord.gg/AYFPHvv2jT',
27+
github: homepage,
28+
},
29+
};
30+
31+
export default defineConfig({
32+
alias: {
33+
'@': path.join(__dirname, '../src'),
34+
},
35+
base: isProd ? '/docs/' : '/',
36+
extraBabelPlugins: ['babel-plugin-antd-style'],
37+
favicons: [
38+
'https://registry.npmmirror.com/@lobehub/assets-emoji/1.3.0/files/assets/package.webp',
39+
],
40+
mfsu: isWin ? undefined : {},
41+
npmClient: 'pnpm',
42+
outputPath: '../public/docs',
43+
44+
publicPath: isProd ? '/docs/' : '/',
45+
// ssr: isProduction ? {} : false,
46+
styles: [
47+
`html, body { background: transparent; }
48+
49+
@media (prefers-color-scheme: dark) {
50+
html, body { background: #000; }
51+
}`,
52+
],
53+
54+
themeConfig,
55+
title: 'RealTime Weather - Lobe Chat Plugin',
56+
});

docs/docs/changelog.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
title: Changelog
3+
description: New updates and improvements to @lobehub/chat-plugin-realtime-weather
4+
nav:
5+
title: Changelog
6+
order: 999
7+
---
8+
9+
<embed src="../../CHANGELOG.md"></embed>

docs/docs/data.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { manClothes } from '@/data';
2+
3+
export const data = {
4+
clothes: manClothes['happy'],
5+
mood: 'happy',
6+
today: Date.now(),
7+
};

docs/docs/demo.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import Render from '@/components/Render';
2+
3+
import { data } from './data';
4+
5+
export default () => {
6+
return <Render {...data} />;
7+
};

docs/docs/index.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
hero:
3+
title: Project <b>Template</b>
4+
description: This is the plugin template for LobeChat plugin development
5+
---
6+
7+
<code src="./demo.tsx" inline></code>

docs/package.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"name": "docs",
3+
"version": "0.0.0",
4+
"private": true,
5+
"scripts": {
6+
"build": "dumi build",
7+
"dev": "dumi dev"
8+
},
9+
"devDependencies": {
10+
"babel-plugin-antd-style": "^1",
11+
"dumi": "^2",
12+
"dumi-theme-lobehub": "latest"
13+
}
14+
}

docs/tsconfig.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"compilerOptions": {
3+
"module": "CommonJS",
4+
"target": "ES5",
5+
"lib": ["dom", "dom.iterable", "esnext"],
6+
"sourceMap": true,
7+
"skipDefaultLibCheck": true,
8+
"jsx": "react-jsx",
9+
"baseUrl": ".",
10+
"allowSyntheticDefaultImports": true,
11+
"moduleResolution": "node",
12+
"forceConsistentCasingInFileNames": true,
13+
"noImplicitReturns": true,
14+
"noUnusedLocals": true,
15+
"resolveJsonModule": true,
16+
"skipLibCheck": true,
17+
"strict": true,
18+
"paths": {
19+
"@@/*": ["./dumi/tmp/*"],
20+
"@/*": ["../src/*"]
21+
},
22+
"noEmit": true,
23+
"incremental": true,
24+
"esModuleInterop": true,
25+
"isolatedModules": true
26+
},
27+
"exclude": ["node_modules"],
28+
"include": [".", ".dumi/**/*", ".dumirc.ts", "../src"]
29+
}

package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@
66
"homepage": "https://github.com/lobehub/chat-plugin-template",
77
"repository": "https://github.com/lobehub/chat-plugin-template.git",
88
"scripts": {
9-
"build": "next build",
9+
"build": "npm run docs:build && next build",
1010
"ci": "npm run lint && npm run type-check",
1111
"dev": "next dev -p 3400",
12+
"docs:build": "cd docs && npm run build",
13+
"docs:dev": "npm run dev --prefix ./docs",
1214
"lint": "eslint \"{src,api,docs}/**/*.{js,jsx,ts,tsx}\" --fix",
1315
"lint:md": "remark . --quiet --frail --output",
1416
"lint:style": "stylelint \"src/**/*.{js,jsx,ts,tsx}\" --fix",
@@ -46,13 +48,13 @@
4648
"not ie <= 10"
4749
],
4850
"dependencies": {
49-
"@lobehub/chat-plugin-sdk": "^1",
51+
"@lobehub/chat-plugin-sdk": "^1.17.7",
5052
"@lobehub/chat-plugins-gateway": "^1",
5153
"@lobehub/ui": "latest",
5254
"antd": "^5",
5355
"antd-style": "^3",
5456
"dayjs": "^1",
55-
"next": "13",
57+
"next": "13.4.7",
5658
"react": "^18",
5759
"react-dom": "^18",
5860
"react-layout-kit": "^1"

pnpm-workspace.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
packages:
2+
- 'docs'
3+
- .

src/components/Render.tsx

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import { Card } from 'antd';
2+
import { createStyles } from 'antd-style';
3+
import dayjs from 'dayjs';
4+
import { memo } from 'react';
5+
import { Flexbox } from 'react-layout-kit';
6+
7+
import { ResponseData } from '@/type';
8+
9+
const useStyles = createStyles(({ css, token }) => ({
10+
date: css`
11+
color: ${token.colorTextQuaternary};
12+
`,
13+
}));
14+
15+
const Render = memo<Partial<ResponseData>>(({ mood, clothes, today }) => {
16+
const { styles } = useStyles();
17+
18+
return (
19+
<Flexbox gap={24}>
20+
<Flexbox distribution={'space-between'} horizontal>
21+
🌟心情:{mood}
22+
<span className={styles.date}>{dayjs(today).format('YYYY/MM/DD')}</span>
23+
</Flexbox>
24+
<Flexbox gap={8}>
25+
推荐衣物
26+
<Flexbox gap={12} horizontal>
27+
{clothes?.map((item) => (
28+
<Card key={item.name} size={'small'} title={item.name}>
29+
{item.description}
30+
</Card>
31+
))}
32+
</Flexbox>
33+
</Flexbox>
34+
</Flexbox>
35+
);
36+
});
37+
38+
export default Render;

src/pages/index.tsx

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,19 @@
11
import { fetchPluginMessage } from '@lobehub/chat-plugin-sdk/client';
2-
import { Card } from 'antd';
3-
import { createStyles } from 'antd-style';
4-
import dayjs from 'dayjs';
52
import { memo, useEffect, useState } from 'react';
6-
import { Flexbox } from 'react-layout-kit';
73

4+
import Data from '@/components/Render';
85
import { ResponseData } from '@/type';
96

10-
const useStyles = createStyles(({ css, token }) => ({
11-
date: css`
12-
color: ${token.colorTextQuaternary};
13-
`,
14-
}));
15-
167
const Render = memo(() => {
178
const [data, setData] = useState<ResponseData>();
18-
const { styles } = useStyles();
199

2010
useEffect(() => {
2111
fetchPluginMessage().then((e: ResponseData) => {
2212
setData(e);
2313
});
2414
}, []);
2515

26-
return (
27-
<Flexbox gap={24}>
28-
<Flexbox distribution={'space-between'} horizontal>
29-
🌟心情:{data?.mood}
30-
<span className={styles.date}>{dayjs(data?.today).format('YYYY/MM/DD')}</span>
31-
</Flexbox>
32-
<Flexbox gap={8}>
33-
推荐衣物
34-
<Flexbox gap={12} horizontal>
35-
{data?.clothes?.map((item) => (
36-
<Card key={item.name} size={'small'} title={item.name}>
37-
{item.description}
38-
</Card>
39-
))}
40-
</Flexbox>
41-
</Flexbox>
42-
</Flexbox>
43-
);
16+
return <Data {...data}></Data>;
4417
});
4518

4619
export default Render;

0 commit comments

Comments
 (0)