├── .bunfig.toml
├── .changelogrc.js
├── .commitlintrc.js
├── .editorconfig
├── .eslintignore
├── .eslintrc.js
├── .github
├── ISSUE_TEMPLATE
│ ├── 1_bug_report.yml
│ ├── 2_feature_request.yml
│ ├── 3_question.yml
│ └── other.md
├── PULL_REQUEST_TEMPLATE.md
└── workflows
│ ├── issue-auto-comments.yml
│ ├── issue-check-inactive.yml
│ ├── issue-close-require.yml
│ ├── release.yml
│ └── test.yml
├── .gitignore
├── .husky
├── commit-msg
└── pre-commit
├── .npmrc
├── .prettierignore
├── .prettierrc.js
├── .releaserc.js
├── .remarkrc.js
├── .stylelintrc.js
├── CHANGELOG.md
├── LICENSE
├── README.md
├── docs
├── .dumirc.ts
├── docs
│ ├── changelog.md
│ ├── data.ts
│ ├── demo.tsx
│ └── index.md
├── package.json
└── tsconfig.json
├── next-env.d.ts
├── next.config.mjs
├── package.json
├── public
├── manifest-dev.json
├── manifest-markdown.json
└── manifest-standalone.json
├── renovate.json
├── src
├── components
│ └── Render.tsx
├── data.ts
├── pages
│ ├── _app.tsx
│ ├── api
│ │ ├── clothes-md.ts
│ │ ├── clothes.ts
│ │ └── gateway.ts
│ ├── global.css
│ ├── iframe
│ │ └── index.tsx
│ └── index.tsx
├── services
│ └── clothes.ts
└── type.ts
├── tsconfig.json
└── vitest.config.ts
/.bunfig.toml:
--------------------------------------------------------------------------------
1 | [install.lockfile]
2 |
3 | save = false
4 |
--------------------------------------------------------------------------------
/.changelogrc.js:
--------------------------------------------------------------------------------
1 | module.exports = require('@lobehub/lint').changelog;
2 |
--------------------------------------------------------------------------------
/.commitlintrc.js:
--------------------------------------------------------------------------------
1 | module.exports = require('@lobehub/lint').commitlint;
2 |
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 | # http://editorconfig.org
2 | root = true
3 |
4 | [*]
5 | indent_style = space
6 | indent_size = 2
7 | end_of_line = lf
8 | charset = utf-8
9 | trim_trailing_whitespace = true
10 | insert_final_newline = true
11 |
12 | [*.md]
13 | trim_trailing_whitespace = false
14 |
15 | [Makefile]
16 | indent_style = tab
--------------------------------------------------------------------------------
/.eslintignore:
--------------------------------------------------------------------------------
1 | # Eslintignore for LobeHub
2 | ################################################################
3 |
4 | # dependencies
5 | node_modules
6 |
7 | # ci
8 | coverage
9 | .coverage
10 |
11 | # test
12 | jest*
13 | _test_
14 | __test__
15 |
16 | # umi
17 | .umi
18 | .umi-production
19 | .umi-test
20 | .dumi/tmp*
21 | !.dumirc.ts
22 |
23 | # production
24 | dist
25 | es
26 | lib
27 | logs
28 |
29 | # misc
30 | # add other ignore file below
31 |
--------------------------------------------------------------------------------
/.eslintrc.js:
--------------------------------------------------------------------------------
1 | module.exports = require('@lobehub/lint').eslint;
2 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/1_bug_report.yml:
--------------------------------------------------------------------------------
1 | name: '🐛 反馈缺陷 Bug Report'
2 | description: '反馈一个问题缺陷 | Report an bug'
3 | title: '[Bug] '
4 | labels: '🐛 Bug'
5 | body:
6 | - type: dropdown
7 | attributes:
8 | label: '💻 系统环境 | Operating System'
9 | options:
10 | - Windows
11 | - macOS
12 | - Ubuntu
13 | - Other Linux
14 | - Other
15 | validations:
16 | required: true
17 | - type: dropdown
18 | attributes:
19 | label: '🌐 浏览器 | Browser'
20 | options:
21 | - Chrome
22 | - Edge
23 | - Safari
24 | - Firefox
25 | - Other
26 | validations:
27 | required: true
28 | - type: textarea
29 | attributes:
30 | label: '🐛 问题描述 | Bug Description'
31 | description: A clear and concise description of the bug.
32 | validations:
33 | required: true
34 | - type: textarea
35 | attributes:
36 | label: '🚦 期望结果 | Expected Behavior'
37 | description: A clear and concise description of what you expected to happen.
38 | - type: textarea
39 | attributes:
40 | label: '📷 复现步骤 | Recurrence Steps'
41 | description: A clear and concise description of how to recurrence.
42 | - type: textarea
43 | attributes:
44 | label: '📝 补充信息 | Additional Information'
45 | description: If your problem needs further explanation, or if the issue you're seeing cannot be reproduced in a gist, please add more information here.
46 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/2_feature_request.yml:
--------------------------------------------------------------------------------
1 | name: '🌠 功能需求 Feature Request'
2 | description: '需求或建议 | Suggest an idea'
3 | title: '[Request] '
4 | labels: '🌠 Feature Request'
5 | body:
6 | - type: textarea
7 | attributes:
8 | label: '🥰 需求描述 | Feature Description'
9 | description: Please add a clear and concise description of the problem you are seeking to solve with this feature request.
10 | validations:
11 | required: true
12 | - type: textarea
13 | attributes:
14 | label: '🧐 解决方案 | Proposed Solution'
15 | description: Describe the solution you'd like in a clear and concise manner.
16 | validations:
17 | required: true
18 | - type: textarea
19 | attributes:
20 | label: '📝 补充信息 | Additional Information'
21 | description: Add any other context about the problem here.
22 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/3_question.yml:
--------------------------------------------------------------------------------
1 | name: '😇 疑问或帮助 Help Wanted'
2 | description: '疑问或需要帮助 | Need help'
3 | title: '[Question] '
4 | labels: '😇 Help Wanted'
5 | body:
6 | - type: textarea
7 | attributes:
8 | label: '🧐 问题描述 | Proposed Solution'
9 | description: A clear and concise description of the proplem.
10 | validations:
11 | required: true
12 | - type: textarea
13 | attributes:
14 | label: '📝 补充信息 | Additional Information'
15 | description: Add any other context about the problem here.
16 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/other.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: '📝 其他 Other'
3 | about: '其他问题 | Other issues'
4 | title: ''
5 | labels: ''
6 | assignees: ''
7 | ---
8 |
--------------------------------------------------------------------------------
/.github/PULL_REQUEST_TEMPLATE.md:
--------------------------------------------------------------------------------
1 | #### 💻 变更类型 | Change Type
2 |
3 |
4 |
5 | - [ ] ✨ feat
6 | - [ ] 🐛 fix
7 | - [ ] 💄 style
8 | - [ ] 🔨 chore
9 | - [ ] 📝 docs
10 |
11 | #### 🔀 变更说明 | Description of Change
12 |
13 |
14 |
15 | #### 📝 补充信息 | Additional Information
16 |
17 |
18 |
--------------------------------------------------------------------------------
/.github/workflows/issue-auto-comments.yml:
--------------------------------------------------------------------------------
1 | name: Issue Auto Comment
2 | on:
3 | issues:
4 | types:
5 | - opened
6 | - closed
7 | - assigned
8 | pull_request_target:
9 | types:
10 | - opened
11 | - closed
12 |
13 | permissions:
14 | contents: read
15 |
16 | jobs:
17 | run:
18 | permissions:
19 | issues: write # for actions-cool/issues-helper to update issues
20 | pull-requests: write # for actions-cool/issues-helper to update PRs
21 | runs-on: ubuntu-latest
22 | steps:
23 | - name: Auto Comment on Issues Opened
24 | uses: wow-actions/auto-comment@v1
25 | with:
26 | GITHUB_TOKEN: ${{ secrets.GH_TOKEN}}
27 | issuesOpened: |
28 | 👀 @{{ author }}
29 | Thank you for raising an issue. We will investigate into the matter and get back to you as soon as possible.
30 | Please make sure you have given us as much context as possible.\
31 | 非常感谢您提交 issue。我们会尽快调查此事,并尽快回复您。 请确保您已经提供了尽可能多的背景信息。
32 | - name: Auto Comment on Issues Closed
33 | uses: wow-actions/auto-comment@v1
34 | with:
35 | GITHUB_TOKEN: ${{ secrets.GH_TOKEN}}
36 | issuesClosed: |
37 | ✅ @{{ author }}
38 |
39 | This issue is closed, If you have any questions, you can comment and reply.\
40 | 此问题已经关闭。如果您有任何问题,可以留言并回复。
41 | - name: Auto Comment on Pull Request Opened
42 | uses: wow-actions/auto-comment@v1
43 | with:
44 | GITHUB_TOKEN: ${{ secrets.GH_TOKEN}}
45 | pullRequestOpened: |
46 | 👍 @{{ author }}
47 |
48 | Thank you for raising your pull request and contributing to our Community
49 | Please make sure you have followed our contributing guidelines. We will review it as soon as possible.
50 | If you encounter any problems, please feel free to connect with us.\
51 | 非常感谢您提出拉取请求并为我们的社区做出贡献,请确保您已经遵循了我们的贡献指南,我们会尽快审查它。
52 | 如果您遇到任何问题,请随时与我们联系。
53 | - name: Auto Comment on Pull Request Merged
54 | uses: actions-cool/pr-welcome@main
55 | if: github.event.pull_request.merged == true
56 | with:
57 | token: ${{ secrets.GH_TOKEN }}
58 | comment: |
59 | ❤️ Great PR @${{ github.event.pull_request.user.login }} ❤️
60 |
61 | The growth of project is inseparable from user feedback and contribution, thanks for your contribution!\
62 | 项目的成长离不开用户反馈和贡献,感谢您的贡献!
63 | emoji: 'hooray'
64 | pr-emoji: '+1, heart'
65 | - name: Remove inactive
66 | if: github.event.issue.state == 'open' && github.actor == github.event.issue.user.login
67 | uses: actions-cool/issues-helper@v3
68 | with:
69 | actions: 'remove-labels'
70 | token: ${{ secrets.GH_TOKEN }}
71 | issue-number: ${{ github.event.issue.number }}
72 | labels: 'Inactive'
73 |
--------------------------------------------------------------------------------
/.github/workflows/issue-check-inactive.yml:
--------------------------------------------------------------------------------
1 | name: Issue Check Inactive
2 |
3 | on:
4 | schedule:
5 | - cron: '0 0 */15 * *'
6 |
7 | permissions:
8 | contents: read
9 |
10 | jobs:
11 | issue-check-inactive:
12 | permissions:
13 | issues: write # for actions-cool/issues-helper to update issues
14 | pull-requests: write # for actions-cool/issues-helper to update PRs
15 | runs-on: ubuntu-latest
16 | steps:
17 | - name: check-inactive
18 | uses: actions-cool/issues-helper@v3
19 | with:
20 | actions: 'check-inactive'
21 | token: ${{ secrets.GH_TOKEN }}
22 | inactive-label: 'Inactive'
23 | inactive-day: 30
24 |
--------------------------------------------------------------------------------
/.github/workflows/issue-close-require.yml:
--------------------------------------------------------------------------------
1 | name: Issue Close Require
2 |
3 | on:
4 | schedule:
5 | - cron: '0 0 * * *'
6 |
7 | permissions:
8 | contents: read
9 |
10 | jobs:
11 | issue-close-require:
12 | permissions:
13 | issues: write # for actions-cool/issues-helper to update issues
14 | pull-requests: write # for actions-cool/issues-helper to update PRs
15 | runs-on: ubuntu-latest
16 | steps:
17 | - name: need reproduce
18 | uses: actions-cool/issues-helper@v3
19 | with:
20 | actions: 'close-issues'
21 | token: ${{ secrets.GH_TOKEN }}
22 | labels: '✅ Fixed'
23 | inactive-day: 3
24 | body: |
25 | 👋 @{{ github.event.issue.user.login }}
26 |
27 | Since the issue was labeled with `✅ Fixed`, but no response in 3 days. This issue will be closed. If you have any questions, you can comment and reply.\
28 | 由于该 issue 被标记为已修复,同时 3 天未收到回应。现关闭 issue,若有任何问题,可评论回复。
29 | - name: need reproduce
30 | uses: actions-cool/issues-helper@v3
31 | with:
32 | actions: 'close-issues'
33 | token: ${{ secrets.GH_TOKEN }}
34 | labels: '🤔 Need Reproduce'
35 | inactive-day: 3
36 | body: |
37 | 👋 @{{ github.event.issue.user.login }}
38 |
39 | Since the issue was labeled with `🤔 Need Reproduce`, but no response in 3 days. This issue will be closed. If you have any questions, you can comment and reply.\
40 | 由于该 issue 被标记为需要更多信息,却 3 天未收到回应。现关闭 issue,若有任何问题,可评论回复。
41 | - name: need reproduce
42 | uses: actions-cool/issues-helper@v3
43 | with:
44 | actions: 'close-issues'
45 | token: ${{ secrets.GH_TOKEN }}
46 | labels: "🙅🏻♀️ WON'T DO"
47 | inactive-day: 3
48 | body: |
49 | 👋 @{{ github.event.issue.user.login }}
50 |
51 | Since the issue was labeled with `🙅🏻♀️ WON'T DO`, and no response in 3 days. This issue will be closed. If you have any questions, you can comment and reply.\
52 | 由于该 issue 被标记为暂不处理,同时 3 天未收到回应。现关闭 issue,若有任何问题,可评论回复。
53 |
--------------------------------------------------------------------------------
/.github/workflows/release.yml:
--------------------------------------------------------------------------------
1 | name: Release CI
2 | on:
3 | push:
4 | branches:
5 | - main
6 |
7 | jobs:
8 | release:
9 | name: Release
10 | runs-on: ubuntu-latest
11 | steps:
12 | - uses: actions/checkout@v4
13 |
14 | - name: Install bun
15 | uses: oven-sh/setup-bun@v1
16 |
17 | - name: Install deps
18 | run: bun i
19 |
20 | - name: CI
21 | run: bun run ci
22 |
23 | - name: Test
24 | run: bun run test
25 |
26 | - name: build
27 | run: bun run build
28 |
29 | - name: release
30 | run: bun run release
31 | env:
32 | GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
33 | NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
34 |
--------------------------------------------------------------------------------
/.github/workflows/test.yml:
--------------------------------------------------------------------------------
1 | name: Test CI
2 | on:
3 | pull_request:
4 | push:
5 | branches:
6 | - '!main'
7 | jobs:
8 | test:
9 | runs-on: ubuntu-latest
10 |
11 | steps:
12 | - uses: actions/checkout@v4
13 |
14 | - name: Install bun
15 | uses: oven-sh/setup-bun@v1
16 |
17 | - name: Install deps
18 | run: bun i
19 |
20 | - name: CI
21 | run: bun run ci
22 |
23 | - name: Test and coverage
24 | run: bun run test:coverage
25 |
26 | - name: Upload coverage to Codecov
27 | uses: codecov/codecov-action@v3
28 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Gitignore for LobeHub
2 | ################################################################
3 |
4 | # general
5 | .DS_Store
6 | .idea
7 | .vscode
8 | .history
9 | .temp
10 | .env.local
11 | venv
12 | temp
13 | tmp
14 |
15 | # dependencies
16 | node_modules
17 | *.log
18 | *.lock
19 | package-lock.json
20 |
21 | # ci
22 | coverage
23 | .coverage
24 | .eslintcache
25 | .stylelintcache
26 |
27 | # production
28 | dist
29 | es
30 | lib
31 | logs
32 | test-output
33 |
34 | # umi
35 | .umi
36 | .umi-production
37 | .umi-test
38 | .dumi/tmp*
39 |
40 | # husky
41 | .husky/prepare-commit-msg
42 |
43 | # misc
44 | # add other ignore file below
45 | .vercel
46 | .next
47 | build
48 | public/dist
49 | docs-dist
50 | bun.lockb
51 | docs/.dumi/*
52 | public/docs
--------------------------------------------------------------------------------
/.husky/commit-msg:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 | . "$(dirname -- "$0")/_/husky.sh"
3 |
4 | npx --no -- commitlint --edit ${1}
5 |
--------------------------------------------------------------------------------
/.husky/pre-commit:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 | . "$(dirname -- "$0")/_/husky.sh"
3 |
4 | npx --no-install lint-staged
5 |
--------------------------------------------------------------------------------
/.npmrc:
--------------------------------------------------------------------------------
1 | lockfile=false
2 | resolution-mode=highest
3 | public-hoist-pattern[]=*@umijs/lint*
4 | public-hoist-pattern[]=*changelog*
5 | public-hoist-pattern[]=*commitlint*
6 | public-hoist-pattern[]=*eslint*
7 | public-hoist-pattern[]=*postcss*
8 | public-hoist-pattern[]=*prettier*
9 | public-hoist-pattern[]=*remark*
10 | public-hoist-pattern[]=*semantic-release*
11 | public-hoist-pattern[]=*stylelint*
12 |
--------------------------------------------------------------------------------
/.prettierignore:
--------------------------------------------------------------------------------
1 | # Prettierignore for LobeHub
2 | ################################################################
3 |
4 | # general
5 | .DS_Store
6 | .editorconfig
7 | .idea
8 | .vscode
9 | .history
10 | .temp
11 | .env.local
12 | .husky
13 | .npmrc
14 | .gitkeep
15 | venv
16 | temp
17 | tmp
18 | LICENSE
19 |
20 | # dependencies
21 | node_modules
22 | *.log
23 | *.lock
24 | package-lock.json
25 |
26 | # ci
27 | coverage
28 | .coverage
29 | .eslintcache
30 | .stylelintcache
31 | test-output
32 | __snapshots__
33 | *.snap
34 |
35 | # production
36 | dist
37 | es
38 | lib
39 | logs
40 |
41 | # umi
42 | .umi
43 | .umi-production
44 | .umi-test
45 | .dumi/tmp*
46 |
47 | # ignore files
48 | .*ignore
49 |
50 | # docker
51 | docker
52 | Dockerfile*
53 |
54 | # image
55 | *.webp
56 | *.gif
57 | *.png
58 | *.jpg
59 |
60 | # misc
61 | # add other ignore file below
62 |
--------------------------------------------------------------------------------
/.prettierrc.js:
--------------------------------------------------------------------------------
1 | module.exports = require('@lobehub/lint').prettier;
2 |
--------------------------------------------------------------------------------
/.releaserc.js:
--------------------------------------------------------------------------------
1 | module.exports = require('@lobehub/lint').semanticRelease;
2 |
--------------------------------------------------------------------------------
/.remarkrc.js:
--------------------------------------------------------------------------------
1 | module.exports = require('@lobehub/lint').remarklint;
2 |
--------------------------------------------------------------------------------
/.stylelintrc.js:
--------------------------------------------------------------------------------
1 | module.exports = require('@lobehub/lint').stylelint;
2 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | # Changelog
4 |
5 | ### [Version 1.5.1](https://github.com/lobehub/chat-plugin-template/compare/v1.5.0...v1.5.1)
6 |
7 | Released on **2024-01-11**
8 |
9 | #### 🐛 Bug Fixes
10 |
11 | - **misc**: Fix gateway runtime, fix gateway runtime.
12 |
13 |
14 |
15 |
16 | Improvements and Fixes
17 |
18 | #### What's fixed
19 |
20 | - **misc**: Fix gateway runtime ([f181fa3](https://github.com/lobehub/chat-plugin-template/commit/f181fa3))
21 | - **misc**: Fix gateway runtime, closes [#24](https://github.com/lobehub/chat-plugin-template/issues/24) ([8b1a443](https://github.com/lobehub/chat-plugin-template/commit/8b1a443))
22 |
23 |
24 |
25 |
26 |
27 | [](#readme-top)
28 |
29 |
30 |
31 | ## [Version 1.5.0](https://github.com/lobehub/chat-plugin-template/compare/v1.4.0...v1.5.0)
32 |
33 | Released on **2023-12-30**
34 |
35 | #### ✨ Features
36 |
37 | - **misc**: Support markdown type.
38 |
39 | #### 💄 Styles
40 |
41 | - **misc**: Improve manifest info.
42 |
43 |
44 |
45 |
46 | Improvements and Fixes
47 |
48 | #### What's improved
49 |
50 | - **misc**: Support markdown type ([0a6e154](https://github.com/lobehub/chat-plugin-template/commit/0a6e154))
51 |
52 | #### Styles
53 |
54 | - **misc**: Improve manifest info ([0f51c54](https://github.com/lobehub/chat-plugin-template/commit/0f51c54))
55 |
56 |
57 |
58 |
59 |
60 | [](#readme-top)
61 |
62 |
63 |
64 | ## [Version 1.4.0](https://github.com/lobehub/chat-plugin-template/compare/v1.3.0...v1.4.0)
65 |
66 | Released on **2023-12-02**
67 |
68 | #### ✨ Features
69 |
70 | - **misc**: Add meta into manifest.
71 |
72 |
73 |
74 |
75 | Improvements and Fixes
76 |
77 | #### What's improved
78 |
79 | - **misc**: Add meta into manifest ([48da33e](https://github.com/lobehub/chat-plugin-template/commit/48da33e))
80 |
81 |
82 |
83 |
84 |
85 | [](#readme-top)
86 |
87 |
88 |
89 | ## [Version 1.3.0](https://github.com/lobehub/chat-plugin-template/compare/v1.2.1...v1.3.0)
90 |
91 | Released on **2023-11-16**
92 |
93 | #### ✨ Features
94 |
95 | - **misc**: Update manifest example.
96 |
97 |
98 |
99 |
100 | Improvements and Fixes
101 |
102 | #### What's improved
103 |
104 | - **misc**: Update manifest example, closes [#17](https://github.com/lobehub/chat-plugin-template/issues/17) ([abf44f0](https://github.com/lobehub/chat-plugin-template/commit/abf44f0))
105 |
106 |
107 |
108 |
109 |
110 | [](#readme-top)
111 |
112 |
113 |
114 | ### [Version 1.2.1](https://github.com/lobehub/chat-plugin-template/compare/v1.2.0...v1.2.1)
115 |
116 | Released on **2023-11-06**
117 |
118 | #### ♻ Code Refactoring
119 |
120 | - **misc**: Refactor to use new lobeChat api.
121 |
122 |
123 |
124 |
125 | Improvements and Fixes
126 |
127 | #### Code refactoring
128 |
129 | - **misc**: Refactor to use new lobeChat api ([1f0a533](https://github.com/lobehub/chat-plugin-template/commit/1f0a533))
130 |
131 |
132 |
133 |
134 |
135 | [](#readme-top)
136 |
137 |
138 |
139 | ## [Version 1.2.0](https://github.com/lobehub/chat-plugin-template/compare/v1.1.0...v1.2.0)
140 |
141 | Released on **2023-10-23**
142 |
143 | #### ✨ Features
144 |
145 | - **misc**: Add standalone type.
146 |
147 |
148 |
149 |
150 | Improvements and Fixes
151 |
152 | #### What's improved
153 |
154 | - **misc**: Add standalone type ([3a432f5](https://github.com/lobehub/chat-plugin-template/commit/3a432f5))
155 |
156 |
157 |
158 |
159 |
160 | [](#readme-top)
161 |
162 |
163 |
164 | ## [Version 1.1.0](https://github.com/lobehub/chat-plugin-template/compare/v1.0.0...v1.1.0)
165 |
166 | Released on **2023-09-09**
167 |
168 | #### ✨ Features
169 |
170 | - **misc**: 新增展示文档.
171 |
172 |
173 |
174 |
175 | Improvements and Fixes
176 |
177 | #### What's improved
178 |
179 | - **misc**: 新增展示文档 ([fdff07f](https://github.com/lobehub/chat-plugin-template/commit/fdff07f))
180 |
181 |
182 |
183 |
184 |
185 | [](#readme-top)
186 |
187 |
188 |
189 | ## Version 1.0.0
190 |
191 | Released on **2023-09-08**
192 |
193 | #### ✨ Features
194 |
195 | - **misc**: 完善插件开发模板的基础内容.
196 |
197 | #### 🐛 Bug Fixes
198 |
199 | - **misc**: Fix ci, Fix import.
200 |
201 | #### 💄 Styles
202 |
203 | - **misc**: Update lint, 优化暗色主题表现.
204 |
205 |
206 |
207 |
208 | Improvements and Fixes
209 |
210 | #### What's improved
211 |
212 | - **misc**: 完善插件开发模板的基础内容 ([8d354b4](https://github.com/lobehub/chat-plugin-template/commit/8d354b4))
213 |
214 | #### What's fixed
215 |
216 | - **misc**: Fix ci ([34fe03a](https://github.com/lobehub/chat-plugin-template/commit/34fe03a))
217 | - **misc**: Fix import ([d8473af](https://github.com/lobehub/chat-plugin-template/commit/d8473af))
218 |
219 | #### Styles
220 |
221 | - **misc**: Update lint ([d48fb19](https://github.com/lobehub/chat-plugin-template/commit/d48fb19))
222 | - **misc**: 优化暗色主题表现 ([47004c5](https://github.com/lobehub/chat-plugin-template/commit/47004c5))
223 |
224 |
225 |
226 |
227 |
228 | [](#readme-top)
229 |
230 |
231 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2023 LobeHub
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
Plugin TemplateLobeChat Plugin
10 |
11 | This is the plugin template for LobeChat plugin development
12 |
13 | [![][🤯-🧩-lobehub-shield]][🤯-🧩-lobehub-link]
14 | [![][github-release-shield]][github-release-link]
15 | [![][github-releasedate-shield]][github-releasedate-link]
16 | [![][github-action-test-shield]][github-action-test-link]
17 | [![][github-action-release-shield]][github-action-release-link]
18 | [![][github-contributors-shield]][github-contributors-link]
19 | [![][github-forks-shield]][github-forks-link]
20 | [![][github-stars-shield]][github-stars-link]
21 | [![][github-issues-shield]][github-issues-link]
22 | [![][github-license-shield]][github-license-link]
23 |
24 | [Changelog](./CHANGELOG.md) · [Report Bug][github-issues-link] · [Request Feature][github-issues-link]
25 |
26 | 
27 |
28 |
29 |
30 |
31 | Table of contents
32 |
33 | #### TOC
34 |
35 | - [🌟 Features](#-features)
36 | - [🤯 Usage](#-usage)
37 | - [⌨️ Local Development](#️-local-development)
38 | - [🤝 Contributing](#-contributing)
39 | - [🔗 Links](#-links)
40 |
41 | ####
42 |
43 |
44 |
45 | ## 🌟 Features
46 |
47 | - [x] 💨 **Quick start with low learning curve**: This template provides a quick start option, allowing users to get started quickly. Additionally, the template includes detailed documentation to help users understand and use the features easily.
48 | - [x] 📚 **Beautiful and comprehensive documentation**: The template aims for aesthetics, with carefully designed interfaces and layouts that make the documentation more intuitive, readable, and user-friendly. Moreover, the template offers a wide range of styles and components for users to customize the appearance and functionality of their documentation.
49 | - [x] 🔄 **Complete workflow, automatic publishing and partner updates**: The template provides a complete workflow, including automatic publishing and automatic partner updates. Users can easily complete the publishing and updating tasks by following the specified steps.
50 | - [x] 🖱️ **One-click document generation**: The template offers a one-click document generation feature, allowing users to quickly generate complete documentation with simple operations. This saves users a significant amount of time and effort, allowing them to focus on improving the content and quality of their documentation.
51 |
52 |
53 |
54 | [![][back-to-top]](#readme-top)
55 |
56 |
57 |
58 | ## 🤯 Usage
59 |
60 | > [!IMPORTANT]\
61 | > See detail on [📘 Template usage](https://chat-plugin-sdk.lobehub.com/guides/template)
62 |
63 | > [!Note]\
64 | > Plugins provide a means to extend the [Function Calling][fc-link] capabilities of LobeChat. They can be used to introduce new function calls, and even new ways to render message results. If you are interested in plugin development, please refer to our [📘 Plugin Development Guide](https://github.com/lobehub/lobe-chat/wiki/Plugin-Development) in the Wiki.
65 | >
66 | > - [@lobehub/lobe-chat-plugins][lobe-chat-plugins]: This is the plugin index for LobeChat. It accesses index.json from this repository to display a list of available plugins for LobeChat to the user.
67 | > - [@lobehub/chat-plugin-sdk][chat-plugin-sdk]: The LobeChat Plugin SDK assists you in creating exceptional chat plugins for Lobe Chat.
68 | > - [@lobehub/chat-plugins-gateway][chat-plugins-gateway]: The LobeChat Plugins Gateway is a backend service that serves as a gateway for LobeChat plugins. We deploy this service using Vercel. The primary API POST /api/v1/runner is deployed as an Edge Function.
69 |
70 | | Official Plugin | Description |
71 | | ----------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
72 | | [SearchEngine][chat-plugin-search-engine] | This plugin allows for the use of the SerpApi search engine. |
73 | | [RealtimeWeather][chat-plugin-realtime-weather] | This plugin provides practical weather information by obtaining real-time weather data and can automatically update based on the user's location. |
74 | | [WebsiteCrawler][chat-plugin-web-crawler] | This plugin automatically crawls the main content of a specified URL webpage and uses it as context input. |
75 |
76 |
77 |
78 | [![][back-to-top]](#readme-top)
79 |
80 |
81 |
82 | ## ⌨️ Local Development
83 |
84 | You can use Github Codespaces for online development:
85 |
86 | [![][github-codespace-shield]][github-codespace-link]
87 |
88 | Or clone it for local development:
89 |
90 | [![][bun-shield]][bun-link]
91 |
92 | ```bash
93 | $ git clone https://github.com/lobehub/chat-plugin-template.git
94 | $ cd chat-plugin-template
95 | $ bun install
96 | $ bun dev
97 | ```
98 |
99 |
100 |
101 | [![][back-to-top]](#readme-top)
102 |
103 |
104 |
105 | ## 🤝 Contributing
106 |
107 | Contributions of all types are more than welcome, if you are interested in contributing plugin, feel free to show us what you’re made of.
108 |
109 | [![][pr-welcome-shield]][pr-welcome-link]
110 |
111 | [![][github-contrib-shield]][github-contrib-link]
112 |
113 |
114 |
115 | [![][back-to-top]](#readme-top)
116 |
117 |
118 |
119 | ## 🔗 Links
120 |
121 | - **[🤖 Lobe Chat](https://github.com/lobehub/lobe-chat)** - An open-source, extensible (Function Calling), high-performance chatbot framework. It supports one-click free deployment of your private ChatGPT/LLM web application.
122 | - **[🧩 / 🏪 Plugin Index](https://github.com/lobehub/lobe-chat-plugins)** - This is the plugin index for LobeChat. It accesses index.json from this repository to display a list of available plugins for Function Calling to the user.
123 |
124 |
125 |
126 | [![][back-to-top]](#readme-top)
127 |
128 |
129 |
130 | ---
131 |
132 | #### 📝 License
133 |
134 | Copyright © 2023 [LobeHub][profile-url].
135 | This project is [MIT](./LICENSE) licensed.
136 |
137 |
138 |
139 | [🤯-🧩-lobehub-link]: https://github.com/lobehub/lobe-chat-plugins
140 | [🤯-🧩-lobehub-shield]: https://img.shields.io/badge/%F0%9F%A4%AF%20%26%20%F0%9F%A7%A9%20LobeHub-Plugin-95f3d9?labelColor=black&style=flat-square
141 | [back-to-top]: https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square
142 | [bun-link]: https://bun.sh
143 | [bun-shield]: https://img.shields.io/badge/-speedup%20with%20bun-black?logo=bun&style=for-the-badge
144 | [chat-plugin-realtime-weather]: https://github.com/lobehub/chat-plugin-realtime-weather
145 | [chat-plugin-sdk]: https://github.com/lobehub/chat-plugin-sdk
146 | [chat-plugin-search-engine]: https://github.com/lobehub/chat-plugin-search-engine
147 | [chat-plugin-web-crawler]: https://github.com/lobehub/chat-plugin-web-crawler
148 | [chat-plugins-gateway]: https://github.com/lobehub/chat-plugins-gateway
149 | [fc-link]: https://sspai.com/post/81986
150 | [github-action-release-link]: https://github.com/lobehub/chat-plugin-template/actions/workflows/release.yml
151 | [github-action-release-shield]: https://img.shields.io/github/actions/workflow/status/lobehub/chat-plugin-template/release.yml?label=release&labelColor=black&logo=githubactions&logoColor=white&style=flat-square
152 | [github-action-test-link]: https://github.com/lobehub/chat-plugin-template/actions/workflows/test.yml
153 | [github-action-test-shield]: https://img.shields.io/github/actions/workflow/status/lobehub/chat-plugin-template/test.yml?label=test&labelColor=black&logo=githubactions&logoColor=white&style=flat-square
154 | [github-codespace-link]: https://codespaces.new/lobehub/chat-plugin-template
155 | [github-codespace-shield]: https://github.com/codespaces/badge.svg
156 | [github-contrib-link]: https://github.com/lobehub/chat-plugin-template/graphs/contributors
157 | [github-contrib-shield]: https://contrib.rocks/image?repo=lobehub%2Fchat-plugin-template
158 | [github-contributors-link]: https://github.com/lobehub/chat-plugin-template/graphs/contributors
159 | [github-contributors-shield]: https://img.shields.io/github/contributors/lobehub/chat-plugin-template?color=c4f042&labelColor=black&style=flat-square
160 | [github-forks-link]: https://github.com/lobehub/chat-plugin-template/network/members
161 | [github-forks-shield]: https://img.shields.io/github/forks/lobehub/chat-plugin-template?color=8ae8ff&labelColor=black&style=flat-square
162 | [github-issues-link]: https://github.com/lobehub/chat-plugin-template/issues
163 | [github-issues-shield]: https://img.shields.io/github/issues/lobehub/chat-plugin-template?color=ff80eb&labelColor=black&style=flat-square
164 | [github-license-link]: https://github.com/lobehub/chat-plugin-template/blob/main/LICENSE
165 | [github-license-shield]: https://img.shields.io/github/license/lobehub/chat-plugin-template?color=white&labelColor=black&style=flat-square
166 | [github-release-link]: https://github.com/lobehub/chat-plugin-template/releases
167 | [github-release-shield]: https://img.shields.io/github/v/release/lobehub/chat-plugin-template?color=369eff&labelColor=black&logo=github&style=flat-square
168 | [github-releasedate-link]: https://github.com/lobehub/chat-plugin-template/releases
169 | [github-releasedate-shield]: https://img.shields.io/github/release-date/lobehub/chat-plugin-template?labelColor=black&style=flat-square
170 | [github-stars-link]: https://github.com/lobehub/chat-plugin-template/network/stargazers
171 | [github-stars-shield]: https://img.shields.io/github/stars/lobehub/chat-plugin-template?color=ffcb47&labelColor=black&style=flat-square
172 | [lobe-chat-plugins]: https://github.com/lobehub/lobe-chat-plugins
173 | [pr-welcome-link]: https://github.com/lobehub/chat-plugin-template/pulls
174 | [pr-welcome-shield]: https://img.shields.io/badge/%F0%9F%A4%AF%20PR%20WELCOME-%E2%86%92-ffcb47?labelColor=black&style=for-the-badge
175 | [profile-url]: https://github.com/lobehub
176 |
--------------------------------------------------------------------------------
/docs/.dumirc.ts:
--------------------------------------------------------------------------------
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: 'Project Template',
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: 'Project Template - Lobe Chat Plugin',
56 | });
57 |
--------------------------------------------------------------------------------
/docs/docs/changelog.md:
--------------------------------------------------------------------------------
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 |
10 |
--------------------------------------------------------------------------------
/docs/docs/data.ts:
--------------------------------------------------------------------------------
1 | import { manClothes } from '@/data';
2 |
3 | export const data = {
4 | clothes: manClothes['happy'],
5 | mood: 'happy',
6 | today: Date.now(),
7 | };
8 |
--------------------------------------------------------------------------------
/docs/docs/demo.tsx:
--------------------------------------------------------------------------------
1 | import Render from '@/components/Render';
2 |
3 | import { data } from './data';
4 |
5 | export default () => {
6 | return ;
7 | };
8 |
--------------------------------------------------------------------------------
/docs/docs/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | hero:
3 | title: Project Template
4 | description: This is the plugin template for LobeChat plugin development
5 | ---
6 |
7 |
8 |
--------------------------------------------------------------------------------
/docs/package.json:
--------------------------------------------------------------------------------
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 | }
15 |
--------------------------------------------------------------------------------
/docs/tsconfig.json:
--------------------------------------------------------------------------------
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": [".", ".dumirc.ts", "../src"]
29 | }
30 |
--------------------------------------------------------------------------------
/next-env.d.ts:
--------------------------------------------------------------------------------
1 | ///
2 | ///
3 |
4 | // NOTE: This file should not be edited
5 | // see https://nextjs.org/docs/basic-features/typescript for more information.
6 |
--------------------------------------------------------------------------------
/next.config.mjs:
--------------------------------------------------------------------------------
1 | /** @type {import('next').NextConfig} */
2 | const nextConfig = {
3 | reactStrictMode: true,
4 | transpilePackages: ['@lobehub/ui'],
5 | async headers() {
6 | return [
7 | {
8 | // matching all API routes
9 | source: '/:path*',
10 | headers: [
11 | { key: 'Access-Control-Allow-Credentials', value: 'true' },
12 | { key: 'Access-Control-Allow-Origin', value: '*' },
13 | { key: 'Access-Control-Allow-Methods', value: 'GET,OPTIONS,PATCH,DELETE,POST,PUT' },
14 | {
15 | key: 'Access-Control-Allow-Headers',
16 | value:
17 | 'X-CSRF-Token, X-Requested-With, Accept, Accept-Version, Content-Length, Content-MD5, Content-Type, Date, X-Api-Version',
18 | },
19 | ],
20 | },
21 | ];
22 | },
23 | };
24 |
25 | export default nextConfig;
26 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "plugin-identifier",
3 | "version": "1.5.1",
4 | "private": true,
5 | "description": "This is the plugin template for LobeChat plugin development",
6 | "homepage": "https://github.com/lobehub/chat-plugin-template",
7 | "repository": "https://github.com/lobehub/chat-plugin-template.git",
8 | "workspaces": [
9 | "docs/*",
10 | "./*"
11 | ],
12 | "scripts": {
13 | "build": "npm run docs:build && next build",
14 | "ci": "npm run lint && npm run type-check",
15 | "dev": "next dev -p 3400",
16 | "docs:build": "cd docs && npm run build",
17 | "docs:dev": "cd docs && npm run dev",
18 | "lint": "eslint \"{src,api,docs}/**/*.{js,jsx,ts,tsx}\" --fix",
19 | "lint:md": "remark . --quiet --frail --output",
20 | "lint:style": "stylelint \"src/**/*.{js,jsx,ts,tsx}\" --fix",
21 | "prepare": "husky install",
22 | "prepublishOnly": "npm run doctor && npm run build",
23 | "prettier": "prettier -c --write \"**/**\"",
24 | "release": "semantic-release",
25 | "start": "next start",
26 | "test": "vitest --passWithNoTests",
27 | "test:coverage": "vitest --coverage --passWithNoTests",
28 | "type-check": "tsc --noEmit"
29 | },
30 | "lint-staged": {
31 | "*.md": [
32 | "remark --quiet --output --",
33 | "prettier --write --no-error-on-unmatched-pattern"
34 | ],
35 | "*.json": [
36 | "prettier --write --no-error-on-unmatched-pattern"
37 | ],
38 | "*.{js,jsx}": [
39 | "prettier --write",
40 | "stylelint --fix",
41 | "eslint --fix"
42 | ],
43 | "*.{ts,tsx}": [
44 | "prettier --parser=typescript --write",
45 | "stylelint --fix",
46 | "eslint --fix"
47 | ]
48 | },
49 | "browserslist": [
50 | "> 1%",
51 | "last 2 versions",
52 | "not ie <= 10"
53 | ],
54 | "dependencies": {
55 | "@lobehub/chat-plugin-sdk": "^1",
56 | "@lobehub/chat-plugins-gateway": "^1",
57 | "@lobehub/ui": "latest",
58 | "antd": "^5",
59 | "antd-style": "^3",
60 | "dayjs": "^1",
61 | "next": "13.4.7",
62 | "react": "^18",
63 | "react-dom": "^18",
64 | "react-layout-kit": "^1"
65 | },
66 | "devDependencies": {
67 | "@commitlint/cli": "^18",
68 | "@lobehub/lint": "latest",
69 | "@types/react": "18",
70 | "@vercel/node": "^2",
71 | "@vitest/coverage-v8": "latest",
72 | "commitlint": "^18",
73 | "cross-env": "^7",
74 | "eslint": "^8",
75 | "father": "4.3.1",
76 | "husky": "^8",
77 | "lint-staged": "^15",
78 | "prettier": "^3",
79 | "remark": "^14",
80 | "remark-cli": "^11",
81 | "semantic-release": "^21",
82 | "stylelint": "^15",
83 | "typescript": "^5",
84 | "vitest": "latest"
85 | },
86 | "peerDependencies": {
87 | "react": ">=18",
88 | "react-dom": ">=18"
89 | }
90 | }
91 |
--------------------------------------------------------------------------------
/public/manifest-dev.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "../node_modules/@lobehub/chat-plugin-sdk/schema.json",
3 | "api": [
4 | {
5 | "url": "http://localhost:3400/api/clothes",
6 | "name": "recommendClothes",
7 | "description": "根据用户的心情,给用户推荐他有的衣服",
8 | "parameters": {
9 | "properties": {
10 | "mood": {
11 | "description": "用户当前的心情,可选值有:开心(happy), 难过(sad),生气 (anger),害怕(fear),惊喜( surprise),厌恶 (disgust)",
12 | "enum": ["happy", "sad", "anger", "fear", "surprise", "disgust"],
13 | "type": "string"
14 | },
15 | "gender": {
16 | "type": "string",
17 | "enum": ["man", "woman"],
18 | "description": "对话用户的性别,需要询问用户后才知道这个信息"
19 | }
20 | },
21 | "required": ["mood", "gender"],
22 | "type": "object"
23 | }
24 | }
25 | ],
26 | "author": "LobeHub",
27 | "createdAt": "2023-09-03",
28 | "gateway": "http://localhost:3400/api/gateway",
29 | "homepage": "https://github.com/lobehub/chat-plugin-template",
30 | "identifier": "plugin-identifier",
31 | "meta": {
32 | "avatar": "🚀",
33 | "tags": ["template"],
34 | "title": "Chat Plugin Template",
35 | "description": "This is the plugin template for LobeChat plugin development"
36 | },
37 | "ui": {
38 | "url": "http://localhost:3400",
39 | "height": 200
40 | },
41 | "version": "1"
42 | }
43 |
--------------------------------------------------------------------------------
/public/manifest-markdown.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "../node_modules/@lobehub/chat-plugin-sdk/schema.json",
3 | "api": [
4 | {
5 | "url": "http://localhost:3400/api/clothes-md",
6 | "name": "recommendClothes",
7 | "description": "根据用户的心情,给用户推荐他有的衣服",
8 | "parameters": {
9 | "properties": {
10 | "mood": {
11 | "description": "用户当前的心情,可选值有:开心(happy), 难过(sad),生气 (anger),害怕(fear),惊喜( surprise),厌恶 (disgust)",
12 | "enum": ["happy", "sad", "anger", "fear", "surprise", "disgust"],
13 | "type": "string"
14 | },
15 | "gender": {
16 | "type": "string",
17 | "enum": ["man", "woman"],
18 | "description": "对话用户的性别,需要询问用户后才知道这个信息"
19 | }
20 | },
21 | "required": ["mood", "gender"],
22 | "type": "object"
23 | }
24 | }
25 | ],
26 | "author": "LobeHub",
27 | "createdAt": "2023-09-03",
28 | "identifier": "plugin-identifier-markdown",
29 | "meta": {
30 | "avatar": "🚀",
31 | "tags": ["template"],
32 | "title": "Chat Plugin Template",
33 | "description": "This is the plugin template for LobeChat plugin development"
34 | },
35 | "systemRole": "根据用户的心情,给用户推荐适合他穿的衣服,你需要知道他的性别后才进行推荐,否则推荐不准确。",
36 | "type": "markdown",
37 | "version": "1"
38 | }
39 |
--------------------------------------------------------------------------------
/public/manifest-standalone.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "../node_modules/@lobehub/chat-plugin-sdk/schema.json",
3 | "api": [
4 | {
5 | "url": "http://localhost:3400/api/clothes",
6 | "name": "recommendClothes",
7 | "description": "根据用户的心情,给用户推荐他有的衣服",
8 | "parameters": {
9 | "properties": {
10 | "mood": {
11 | "description": "用户当前的心情,可选值有:开心(happy), 难过(sad),生气 (anger),害怕(fear),惊喜( surprise),厌恶 (disgust)",
12 | "enum": ["happy", "sad", "anger", "fear", "surprise", "disgust"],
13 | "type": "string"
14 | },
15 | "gender": {
16 | "type": "string",
17 | "enum": ["man", "woman"],
18 | "description": "对话用户的性别,需要询问用户后才知道这个信息"
19 | }
20 | },
21 | "required": ["mood", "gender"],
22 | "type": "object"
23 | }
24 | }
25 | ],
26 | "author": "LobeHub",
27 | "createdAt": "2023-09-03",
28 | "identifier": "plugin-identifier-standalone",
29 | "meta": {
30 | "avatar": "🚀",
31 | "tags": ["template"],
32 | "title": "Chat Plugin Template",
33 | "description": "This is the plugin template for LobeChat plugin development"
34 | },
35 | "type": "standalone",
36 | "ui": {
37 | "url": "http://localhost:3400/iframe",
38 | "height": 200
39 | },
40 | "version": "1"
41 | }
42 |
--------------------------------------------------------------------------------
/renovate.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://docs.renovatebot.com/renovate-schema.json",
3 | "automerge": false,
4 | "dependencyDashboard": true,
5 | "ignoreDeps": [],
6 | "labels": ["dependencies"],
7 | "postUpdateOptions": ["yarnDedupeHighest"],
8 | "prConcurrentLimit": 30,
9 | "prHourlyLimit": 0,
10 | "rebaseWhen": "conflicted",
11 | "schedule": "on sunday before 6:00am",
12 | "timezone": "UTC"
13 | }
14 |
--------------------------------------------------------------------------------
/src/components/Render.tsx:
--------------------------------------------------------------------------------
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>(({ mood, clothes, today }) => {
16 | const { styles } = useStyles();
17 |
18 | return (
19 |
20 |
21 | 🌟心情:{mood}
22 | {dayjs(today).format('YYYY/MM/DD')}
23 |
24 |
25 | 推荐衣物
26 |
27 | {clothes?.map((item) => (
28 |
29 | {item.description}
30 |
31 | ))}
32 |
33 |
34 |
35 | );
36 | });
37 |
38 | export default Render;
39 |
--------------------------------------------------------------------------------
/src/data.ts:
--------------------------------------------------------------------------------
1 | export const manClothes = {
2 | anger: [
3 | {
4 | description: '这款黑色皮夹克可以让你在生气时释放压力。',
5 | name: '黑色皮夹克',
6 | },
7 | {
8 | description: '这款深红色的衬衫可以让你在生气时感到力量。',
9 | name: '深红色长袖衬衫',
10 | },
11 | {
12 | description: '这款军绿色的工装裤可以让你在生气时感到坚韧。',
13 | name: '军绿色工装裤',
14 | },
15 | ],
16 | disgust: [
17 | {
18 | description: '这款黑色的T恤可以让你在厌恶时感到冷静。',
19 | name: '黑色修身T恤',
20 | },
21 | {
22 | description: '这款深色的裤子可以让你在厌恶时感到自在。',
23 | name: '深色直筒休闲裤',
24 | },
25 | {
26 | description: '这款军绿色的夹克可以让你在厌恶时感到坚定。',
27 | name: '军绿色工装夹克',
28 | },
29 | ],
30 | fear: [
31 | {
32 | description: '这款宽松的卫衣可以让你在害怕时感到安全。',
33 | name: '灰色宽松连帽卫衣',
34 | },
35 | {
36 | description: '这款黑色的裤子可以让你在害怕时感到舒适。',
37 | name: '黑色直筒休闲裤',
38 | },
39 | {
40 | description: '这款深色的夹克可以让你在害怕时感到保护。',
41 | name: '深蓝色牛仔夹克',
42 | },
43 | ],
44 | happy: [
45 | {
46 | description: '这款明亮的T恤可以增强你的快乐气氛。',
47 | name: '亮黄色夏日T恤',
48 | },
49 | {
50 | description: '这款活泼的短裤可以让你的心情保持愉快。',
51 | name: '卡通图案运动短裤',
52 | },
53 | {
54 | description: '这款色彩明亮的衬衫可以让你看起来更加开朗。',
55 | name: '彩色条纹休闲衬衫',
56 | },
57 | ],
58 | sad: [
59 | {
60 | description: '舒适的卫衣可以让你在难过的时候感到舒适。',
61 | name: '深色宽松卫衣',
62 | },
63 | {
64 | description: '这款深色的夹克可以让你在难过的时候感到安慰。',
65 | name: '黑色牛仔夹克',
66 | },
67 | {
68 | description: '简单的黑色T恤可以让你在难过的时候感到平静。',
69 | name: '简洁黑色长袖T恤',
70 | },
71 | ],
72 | surprise: [
73 | {
74 | description: '这款亮色的T恤可以让你在惊喜时感到愉悦。',
75 | name: '亮色图案T恤',
76 | },
77 | {
78 | description: '这款鲜艳的短裤可以让你在惊喜时感到活力。',
79 | name: '鲜艳色彩运动短裤',
80 | },
81 | {
82 | description: '这款多彩条纹的衬衫可以让你在惊喜时感到快乐。',
83 | name: '多彩条纹衬衫',
84 | },
85 | ],
86 | };
87 |
88 | export const womanClothes = {
89 | anger: [
90 | {
91 | description: '这款黑色皮夹克可以让你在生气时释放压力。',
92 | name: '黑色皮夹克',
93 | },
94 | {
95 | description: '这款深红色的衬衫可以让你在生气时感到力量。',
96 | name: '深红色长袖衬衫',
97 | },
98 | {
99 | description: '这款军绿色的工装裤可以让你在生气时感到坚韧。',
100 | name: '军绿色工装裤',
101 | },
102 | ],
103 | disgust: [
104 | {
105 | description: '这款黑色的连衣裙可以让你在厌恶时感到冷静。',
106 | name: '黑色修身连衣裙',
107 | },
108 | {
109 | description: '这款深色的裤子可以让你在厌恶时感到自在。',
110 | name: '深色直筒休闲裤',
111 | },
112 | {
113 | description: '这款军绿色的夹克可以让你在厌恶时感到坚定。',
114 | name: '军绿色工装夹克',
115 | },
116 | ],
117 | fear: [
118 | {
119 | description: '这款宽松的卫衣可以让你在害怕时感到安全。',
120 | name: '灰色宽松连帽卫衣',
121 | },
122 | {
123 | description: '这款黑色的裤子可以让你在害怕时感到舒适。',
124 | name: '黑色直筒休闲裤',
125 | },
126 | {
127 | description: '这款深色的夹克可以让你在害怕时感到保护。',
128 | name: '深蓝色牛仔夹克',
129 | },
130 | ],
131 | happy: [
132 | {
133 | description: '这款明亮的连衣裙可以增强你的快乐气氛。',
134 | name: '亮黄色夏日连衣裙',
135 | },
136 | {
137 | description: '这款活泼的短裤可以让你的心情保持愉快。',
138 | name: '卡通图案运动短裤',
139 | },
140 | {
141 | description: '这款色彩明亮的衬衫可以让你看起来更加开朗。',
142 | name: '彩色条纹休闲衬衫',
143 | },
144 | ],
145 | sad: [
146 | {
147 | description: '舒适的连衣裙可以让你在难过的时候感到舒适。',
148 | name: '深色宽松连衣裙',
149 | },
150 | {
151 | description: '这款深色的夹克可以让你在难过的时候感到安慰。',
152 | name: '黑色牛仔夹克',
153 | },
154 | {
155 | description: '简单的黑色T恤可以让你在难过的时候感到平静。',
156 | name: '简洁黑色长袖T恤',
157 | },
158 | ],
159 | surprise: [
160 | {
161 | description: '这款亮色的连衣裙可以让你在惊喜时感到愉悦。',
162 | name: '亮色图案连衣裙',
163 | },
164 | {
165 | description: '这款鲜艳的短裤可以让你在惊喜时感到活力。',
166 | name: '鲜艳色彩运动短裤',
167 | },
168 | {
169 | description: '这款多彩条纹的衬衫可以让你在惊喜时感到快乐。',
170 | name: '多彩条纹衬衫',
171 | },
172 | ],
173 | };
174 |
--------------------------------------------------------------------------------
/src/pages/_app.tsx:
--------------------------------------------------------------------------------
1 | import { ThemeProvider } from '@lobehub/ui';
2 | import type { AppProps } from 'next/app';
3 |
4 | import './global.css';
5 |
6 | export default function App({ Component, pageProps }: AppProps) {
7 | return (
8 |
9 |
10 |
11 | );
12 | }
13 |
--------------------------------------------------------------------------------
/src/pages/api/clothes-md.ts:
--------------------------------------------------------------------------------
1 | import { PluginErrorType, createErrorResponse } from '@lobehub/chat-plugin-sdk';
2 |
3 | import { manClothes, womanClothes } from '@/data';
4 | import { RequestData, ResponseData } from '@/type';
5 |
6 | export const config = {
7 | runtime: 'edge',
8 | };
9 |
10 | export default async (req: Request) => {
11 | if (req.method !== 'POST') return createErrorResponse(PluginErrorType.MethodNotAllowed);
12 |
13 | const { gender, mood } = (await req.json()) as RequestData;
14 |
15 | const clothes = gender === 'man' ? manClothes : womanClothes;
16 |
17 | const result: ResponseData = {
18 | clothes: mood ? clothes[mood] : Object.values(clothes).flat(),
19 | mood,
20 | today: Date.now(),
21 | };
22 |
23 | return new Response(
24 | `由于你的心情是${result.mood},我推荐你穿 ${result.clothes.map((c) => c.name).join('、')}。`,
25 | );
26 | };
27 |
--------------------------------------------------------------------------------
/src/pages/api/clothes.ts:
--------------------------------------------------------------------------------
1 | import { PluginErrorType, createErrorResponse } from '@lobehub/chat-plugin-sdk';
2 |
3 | import { manClothes, womanClothes } from '@/data';
4 | import { RequestData, ResponseData } from '@/type';
5 |
6 | export const config = {
7 | runtime: 'edge',
8 | };
9 |
10 | export default async (req: Request) => {
11 | if (req.method !== 'POST') return createErrorResponse(PluginErrorType.MethodNotAllowed);
12 |
13 | const { gender, mood } = (await req.json()) as RequestData;
14 |
15 | const clothes = gender === 'man' ? manClothes : womanClothes;
16 |
17 | const result: ResponseData = {
18 | clothes: mood ? clothes[mood] : Object.values(clothes).flat(),
19 | mood,
20 | today: Date.now(),
21 | };
22 |
23 | return new Response(JSON.stringify(result));
24 | };
25 |
--------------------------------------------------------------------------------
/src/pages/api/gateway.ts:
--------------------------------------------------------------------------------
1 | export const config = {
2 | runtime: 'edge',
3 | };
4 |
5 | export default async (req: Request) => {
6 | if (process.env.NODE_ENV === 'development') {
7 | const { createGatewayOnEdgeRuntime } = await import('@lobehub/chat-plugins-gateway');
8 |
9 | return createGatewayOnEdgeRuntime()(req);
10 | }
11 |
12 | return new Response('gateway');
13 | };
14 |
--------------------------------------------------------------------------------
/src/pages/global.css:
--------------------------------------------------------------------------------
1 | html,
2 | body {
3 | background: transparent !important;
4 |
5 | /*
6 | When using iframe embedding, if you still need to keep the transparent background in dark mode
7 | you need to force the color-scheme to light
8 |
9 | 使用 iframe 嵌入时,如果在暗色模式下仍需要保持透明背景,需要强制设定 color-scheme 为 light
10 | */
11 | color-scheme: light !important;
12 | }
13 |
--------------------------------------------------------------------------------
/src/pages/iframe/index.tsx:
--------------------------------------------------------------------------------
1 | import { lobeChat } from '@lobehub/chat-plugin-sdk/client';
2 | import { Button } from 'antd';
3 | import { memo, useEffect, useState } from 'react';
4 | import { Center } from 'react-layout-kit';
5 |
6 | import Data from '@/components/Render';
7 | import { fetchClothes } from '@/services/clothes';
8 | import { ResponseData } from '@/type';
9 |
10 | const Render = memo(() => {
11 | // 初始化渲染状态
12 | const [data, setData] = useState();
13 |
14 | // 初始化时从主应用同步状态
15 | useEffect(() => {
16 | lobeChat.getPluginMessage().then(setData);
17 | }, []);
18 |
19 | // 记录请求参数
20 | const [payload, setPayload] = useState();
21 |
22 | useEffect(() => {
23 | lobeChat.getPluginPayload().then((payload) => {
24 | if (payload.name === 'recommendClothes') {
25 | setPayload(payload.arguments);
26 | }
27 | });
28 | }, []);
29 |
30 | const fetchData = async () => {
31 | const data = await fetchClothes(payload);
32 | setData(data);
33 | lobeChat.setPluginMessage(data);
34 | };
35 |
36 | return data ? (
37 |
38 | ) : (
39 |
40 | {
43 | fetchData();
44 | }}
45 | type={'primary'}
46 | >
47 | 查询衣物
48 |
49 |
50 | );
51 | });
52 |
53 | export default Render;
54 |
--------------------------------------------------------------------------------
/src/pages/index.tsx:
--------------------------------------------------------------------------------
1 | import { lobeChat } from '@lobehub/chat-plugin-sdk/client';
2 | import { memo, useEffect, useState } from 'react';
3 |
4 | import Data from '@/components/Render';
5 | import { ResponseData } from '@/type';
6 |
7 | const Render = memo(() => {
8 | const [data, setData] = useState();
9 |
10 | useEffect(() => {
11 | lobeChat.getPluginMessage().then((e: ResponseData) => {
12 | setData(e);
13 | });
14 | }, []);
15 |
16 | return ;
17 | });
18 |
19 | export default Render;
20 |
--------------------------------------------------------------------------------
/src/services/clothes.ts:
--------------------------------------------------------------------------------
1 | import { RequestData } from '@/type';
2 |
3 | export const fetchClothes = async (params: RequestData) => {
4 | const res = await fetch('/api/clothes', {
5 | body: JSON.stringify(params),
6 | method: 'POST',
7 | });
8 |
9 | return res.json();
10 | };
11 |
--------------------------------------------------------------------------------
/src/type.ts:
--------------------------------------------------------------------------------
1 | export interface ClothesItem {
2 | description: string;
3 | name: string;
4 | }
5 | type Mood = 'happy' | 'sad' | 'anger' | 'fear' | 'surprise' | 'disgust';
6 |
7 | export interface ResponseData {
8 | clothes: ClothesItem[];
9 | mood: Mood;
10 | today: number;
11 | }
12 |
13 | export interface RequestData {
14 | gender: 'man' | 'woman';
15 | mood: Mood;
16 | }
17 |
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "module": "CommonJS",
4 | "target": "ES5",
5 | "lib": ["dom", "dom.iterable", "esnext"],
6 | "sourceMap": true,
7 | "skipDefaultLibCheck": true,
8 | "jsx": "preserve",
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 | "@/*": ["src/*"]
20 | },
21 | "types": ["vitest/globals"],
22 | "allowJs": true,
23 | "noEmit": true,
24 | "incremental": true,
25 | "esModuleInterop": true,
26 | "isolatedModules": true
27 | },
28 | "exclude": ["node_modules"],
29 | "include": ["src", "next-env.d.ts", "*.ts"]
30 | }
31 |
--------------------------------------------------------------------------------
/vitest.config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vitest/config';
2 |
3 | export default defineConfig({
4 | test: {
5 | environment: 'node',
6 | globals: true,
7 | },
8 | });
9 |
--------------------------------------------------------------------------------