@lobehub/lobehub 2.0.0-next.353 → 2.0.0-next.354
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.agents/skills/add-provider-doc/SKILL.md +90 -0
- package/.agents/skills/add-setting-env/SKILL.md +106 -0
- package/.agents/skills/debug/SKILL.md +66 -0
- package/.agents/skills/desktop/SKILL.md +78 -0
- package/.agents/skills/desktop/references/feature-implementation.md +99 -0
- package/.agents/skills/desktop/references/local-tools.md +133 -0
- package/.agents/skills/desktop/references/menu-config.md +103 -0
- package/.agents/skills/desktop/references/window-management.md +143 -0
- package/.agents/skills/drizzle/SKILL.md +129 -0
- package/.agents/skills/drizzle/references/db-migrations.md +50 -0
- package/.agents/skills/hotkey/SKILL.md +90 -0
- package/{.cursor/rules/i18n.mdc → .agents/skills/i18n/SKILL.md} +14 -23
- package/.agents/skills/linear/SKILL.md +51 -0
- package/.agents/skills/microcopy/SKILL.md +83 -0
- package/.agents/skills/modal/SKILL.md +102 -0
- package/{.cursor/rules/project-structure.mdc → .agents/skills/project-overview/SKILL.md} +65 -37
- package/.agents/skills/react/SKILL.md +73 -0
- package/.agents/skills/react/references/layout-kit.md +100 -0
- package/.agents/skills/recent-data/SKILL.md +108 -0
- package/.agents/skills/testing/SKILL.md +89 -0
- package/.agents/skills/testing/references/agent-runtime-e2e.md +126 -0
- package/.agents/skills/testing/references/db-model-test.md +124 -0
- package/.agents/skills/testing/references/desktop-controller-test.md +124 -0
- package/.agents/skills/testing/references/electron-ipc-test.md +63 -0
- package/.agents/skills/testing/references/zustand-store-action-test.md +150 -0
- package/.agents/skills/typescript/SKILL.md +52 -0
- package/.agents/skills/zustand/SKILL.md +78 -0
- package/.agents/skills/zustand/references/action-patterns.md +125 -0
- package/.agents/skills/zustand/references/slice-organization.md +125 -0
- package/AGENTS.md +42 -55
- package/CHANGELOG.md +33 -0
- package/CLAUDE.md +57 -46
- package/GEMINI.md +47 -39
- package/changelog/v1.json +9 -0
- package/package.json +1 -1
- package/src/features/FileViewer/Renderer/PDF/index.tsx +2 -3
- package/src/features/ShareModal/SharePdf/PdfPreview.tsx +1 -2
- package/src/libs/pdfjs/index.tsx +25 -0
- package/src/store/test-coverage.md +5 -5
- package/.cursor/rules/add-provider-doc.mdc +0 -183
- package/.cursor/rules/add-setting-env.mdc +0 -175
- package/.cursor/rules/cursor-rules.mdc +0 -28
- package/.cursor/rules/db-migrations.mdc +0 -46
- package/.cursor/rules/debug-usage.mdc +0 -86
- package/.cursor/rules/desktop-controller-tests.mdc +0 -189
- package/.cursor/rules/desktop-feature-implementation.mdc +0 -155
- package/.cursor/rules/desktop-local-tools-implement.mdc +0 -81
- package/.cursor/rules/desktop-menu-configuration.mdc +0 -209
- package/.cursor/rules/desktop-window-management.mdc +0 -301
- package/.cursor/rules/drizzle-schema-style-guide.mdc +0 -218
- package/.cursor/rules/hotkey.mdc +0 -162
- package/.cursor/rules/linear.mdc +0 -53
- package/.cursor/rules/microcopy-cn.mdc +0 -158
- package/.cursor/rules/microcopy-en.mdc +0 -148
- package/.cursor/rules/modal-imperative.mdc +0 -162
- package/.cursor/rules/packages/react-layout-kit.mdc +0 -122
- package/.cursor/rules/project-introduce.mdc +0 -36
- package/.cursor/rules/react.mdc +0 -169
- package/.cursor/rules/recent-data-usage.mdc +0 -139
- package/.cursor/rules/rules-index.mdc +0 -44
- package/.cursor/rules/testing-guide/agent-runtime-e2e.mdc +0 -285
- package/.cursor/rules/testing-guide/db-model-test.mdc +0 -455
- package/.cursor/rules/testing-guide/electron-ipc-test.mdc +0 -80
- package/.cursor/rules/testing-guide/testing-guide.mdc +0 -534
- package/.cursor/rules/testing-guide/zustand-store-action-test.mdc +0 -574
- package/.cursor/rules/typescript.mdc +0 -55
- package/.cursor/rules/zustand-action-patterns.mdc +0 -328
- package/.cursor/rules/zustand-slice-organization.mdc +0 -308
- package/src/libs/pdfjs/pdf.worker.ts +0 -1
- package/src/libs/pdfjs/worker.ts +0 -12
- /package/.agents/{vercel-react-best-practices → skills/vercel-react-best-practices}/AGENTS.md +0 -0
- /package/.agents/{vercel-react-best-practices → skills/vercel-react-best-practices}/SKILL.md +0 -0
- /package/.agents/{vercel-react-best-practices → skills/vercel-react-best-practices}/rules/advanced-event-handler-refs.md +0 -0
- /package/.agents/{vercel-react-best-practices → skills/vercel-react-best-practices}/rules/advanced-use-latest.md +0 -0
- /package/.agents/{vercel-react-best-practices → skills/vercel-react-best-practices}/rules/async-api-routes.md +0 -0
- /package/.agents/{vercel-react-best-practices → skills/vercel-react-best-practices}/rules/async-defer-await.md +0 -0
- /package/.agents/{vercel-react-best-practices → skills/vercel-react-best-practices}/rules/async-dependencies.md +0 -0
- /package/.agents/{vercel-react-best-practices → skills/vercel-react-best-practices}/rules/async-parallel.md +0 -0
- /package/.agents/{vercel-react-best-practices → skills/vercel-react-best-practices}/rules/async-suspense-boundaries.md +0 -0
- /package/.agents/{vercel-react-best-practices → skills/vercel-react-best-practices}/rules/bundle-barrel-imports.md +0 -0
- /package/.agents/{vercel-react-best-practices → skills/vercel-react-best-practices}/rules/bundle-conditional.md +0 -0
- /package/.agents/{vercel-react-best-practices → skills/vercel-react-best-practices}/rules/bundle-defer-third-party.md +0 -0
- /package/.agents/{vercel-react-best-practices → skills/vercel-react-best-practices}/rules/bundle-dynamic-imports.md +0 -0
- /package/.agents/{vercel-react-best-practices → skills/vercel-react-best-practices}/rules/bundle-preload.md +0 -0
- /package/.agents/{vercel-react-best-practices → skills/vercel-react-best-practices}/rules/client-event-listeners.md +0 -0
- /package/.agents/{vercel-react-best-practices → skills/vercel-react-best-practices}/rules/client-localstorage-schema.md +0 -0
- /package/.agents/{vercel-react-best-practices → skills/vercel-react-best-practices}/rules/client-passive-event-listeners.md +0 -0
- /package/.agents/{vercel-react-best-practices → skills/vercel-react-best-practices}/rules/client-swr-dedup.md +0 -0
- /package/.agents/{vercel-react-best-practices → skills/vercel-react-best-practices}/rules/js-batch-dom-css.md +0 -0
- /package/.agents/{vercel-react-best-practices → skills/vercel-react-best-practices}/rules/js-cache-function-results.md +0 -0
- /package/.agents/{vercel-react-best-practices → skills/vercel-react-best-practices}/rules/js-cache-property-access.md +0 -0
- /package/.agents/{vercel-react-best-practices → skills/vercel-react-best-practices}/rules/js-cache-storage.md +0 -0
- /package/.agents/{vercel-react-best-practices → skills/vercel-react-best-practices}/rules/js-combine-iterations.md +0 -0
- /package/.agents/{vercel-react-best-practices → skills/vercel-react-best-practices}/rules/js-early-exit.md +0 -0
- /package/.agents/{vercel-react-best-practices → skills/vercel-react-best-practices}/rules/js-hoist-regexp.md +0 -0
- /package/.agents/{vercel-react-best-practices → skills/vercel-react-best-practices}/rules/js-index-maps.md +0 -0
- /package/.agents/{vercel-react-best-practices → skills/vercel-react-best-practices}/rules/js-length-check-first.md +0 -0
- /package/.agents/{vercel-react-best-practices → skills/vercel-react-best-practices}/rules/js-min-max-loop.md +0 -0
- /package/.agents/{vercel-react-best-practices → skills/vercel-react-best-practices}/rules/js-set-map-lookups.md +0 -0
- /package/.agents/{vercel-react-best-practices → skills/vercel-react-best-practices}/rules/js-tosorted-immutable.md +0 -0
- /package/.agents/{vercel-react-best-practices → skills/vercel-react-best-practices}/rules/rendering-activity.md +0 -0
- /package/.agents/{vercel-react-best-practices → skills/vercel-react-best-practices}/rules/rendering-animate-svg-wrapper.md +0 -0
- /package/.agents/{vercel-react-best-practices → skills/vercel-react-best-practices}/rules/rendering-conditional-render.md +0 -0
- /package/.agents/{vercel-react-best-practices → skills/vercel-react-best-practices}/rules/rendering-content-visibility.md +0 -0
- /package/.agents/{vercel-react-best-practices → skills/vercel-react-best-practices}/rules/rendering-hoist-jsx.md +0 -0
- /package/.agents/{vercel-react-best-practices → skills/vercel-react-best-practices}/rules/rendering-hydration-no-flicker.md +0 -0
- /package/.agents/{vercel-react-best-practices → skills/vercel-react-best-practices}/rules/rendering-svg-precision.md +0 -0
- /package/.agents/{vercel-react-best-practices → skills/vercel-react-best-practices}/rules/rerender-defer-reads.md +0 -0
- /package/.agents/{vercel-react-best-practices → skills/vercel-react-best-practices}/rules/rerender-dependencies.md +0 -0
- /package/.agents/{vercel-react-best-practices → skills/vercel-react-best-practices}/rules/rerender-derived-state.md +0 -0
- /package/.agents/{vercel-react-best-practices → skills/vercel-react-best-practices}/rules/rerender-functional-setstate.md +0 -0
- /package/.agents/{vercel-react-best-practices → skills/vercel-react-best-practices}/rules/rerender-lazy-state-init.md +0 -0
- /package/.agents/{vercel-react-best-practices → skills/vercel-react-best-practices}/rules/rerender-memo.md +0 -0
- /package/.agents/{vercel-react-best-practices → skills/vercel-react-best-practices}/rules/rerender-transitions.md +0 -0
- /package/.agents/{vercel-react-best-practices → skills/vercel-react-best-practices}/rules/server-after-nonblocking.md +0 -0
- /package/.agents/{vercel-react-best-practices → skills/vercel-react-best-practices}/rules/server-cache-lru.md +0 -0
- /package/.agents/{vercel-react-best-practices → skills/vercel-react-best-practices}/rules/server-cache-react.md +0 -0
- /package/.agents/{vercel-react-best-practices → skills/vercel-react-best-practices}/rules/server-parallel-fetching.md +0 -0
- /package/.agents/{vercel-react-best-practices → skills/vercel-react-best-practices}/rules/server-serialization.md +0 -0
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
globs: src/locales/default/*
|
|
3
|
-
alwaysApply: false
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
You are **LobeHub’s English UI Copy & Microcopy Specialist**.
|
|
7
|
-
|
|
8
|
-
LobeHub is an assistant workspace: users can create **Agents** and **Agent Teams** so people↔agents and agent↔agent can collaborate to improve productivity in work and life. Brand vibe: youthful, friendly, modern on the surface; professional, reliable, productivity- and controllability-first underneath. Overall style reference: Notion / Figma / Apple / Discord / OpenAI / Gemini — clear, restrained, trustworthy, human but not cheesy.
|
|
9
|
-
|
|
10
|
-
Product slogan: **Where Agents Collaborate**. Your copy must continuously reinforce that LobeHub is not about “generation”, but about a **collaborative agent system**: shareable context, traceable outcomes, replayable runs, evolvable setup, and **human-in-the-loop**.
|
|
11
|
-
|
|
12
|
-
---
|
|
13
|
-
|
|
14
|
-
## 1) Fixed Terminology (must follow)
|
|
15
|
-
|
|
16
|
-
Use **exactly** these English terms across the product. Do not mix synonyms for the same concept.
|
|
17
|
-
|
|
18
|
-
- 空间: **Workspace**
|
|
19
|
-
- 助理: **Agent**
|
|
20
|
-
- 群组: **Group**
|
|
21
|
-
- 上下文: **Context**
|
|
22
|
-
- 记忆: **Memory**
|
|
23
|
-
- 连接器: **Integration**
|
|
24
|
-
- 技能/tool/plugin: **Skill**
|
|
25
|
-
- 助理档案: **Agent Profile**
|
|
26
|
-
- 话题: **Topic**
|
|
27
|
-
- 文稿: **Page**
|
|
28
|
-
- 社区: **Community**
|
|
29
|
-
- 资源: **Resource**
|
|
30
|
-
- 库: **Library**
|
|
31
|
-
- MCP: **MCP**
|
|
32
|
-
- 模型服务商: **Provider**
|
|
33
|
-
|
|
34
|
-
Terminology rule: one concept = one term site-wide. Never alternate with “bot/assistant/AI agent/team/workspace” variations.
|
|
35
|
-
|
|
36
|
-
---
|
|
37
|
-
|
|
38
|
-
## 2) Your Responsibilities
|
|
39
|
-
|
|
40
|
-
- Improve, rewrite, or create from scratch any **English UI copy**: titles, buttons, form labels/help text, placeholders, onboarding, empty states, toasts, modals, errors, permission prompts, settings, creation/run flows, collaboration and Agent Team pages, etc.
|
|
41
|
-
- Copy must work for both:
|
|
42
|
-
- general users (immediately understandable)
|
|
43
|
-
- power users (not childish)
|
|
44
|
-
- It must fit both playful and serious contexts.
|
|
45
|
-
- Avoid overclaiming AI capabilities; add human warmth at the right moments.
|
|
46
|
-
|
|
47
|
-
---
|
|
48
|
-
|
|
49
|
-
## 3) The Three Brand Principles (bake into structure & wording)
|
|
50
|
-
|
|
51
|
-
- **Create**: create an Agent in one sentence; clear next step from idea → usable.
|
|
52
|
-
- **Collaborate**: multi-agent collaboration; align info and outputs; share Context (controlled, manageable).
|
|
53
|
-
- **Evolve**: Agents can remember preferences **only with user consent**; become more helpful over time; emphasize explainability, settings, and replay.
|
|
54
|
-
|
|
55
|
-
---
|
|
56
|
-
|
|
57
|
-
## 4) Writing Rules (actionable)
|
|
58
|
-
|
|
59
|
-
1. **Clarity first**: short sentences, strong verbs, minimal adjectives. Avoid hype (“revolutionary”, “epic”, “100%”).
|
|
60
|
-
2. **Layered messaging (single version for everyone)**:
|
|
61
|
-
- Main line: simple and actionable
|
|
62
|
-
- Optional second line: more precise / technical / boundary-setting (subtitle, helper text, tooltip, collapsible)
|
|
63
|
-
- Do not produce “Pro vs Lite” variants; one main + optional detail
|
|
64
|
-
3. **Use terms sparingly but correctly**: prefer plain words (“connect”, “run”, “context”) unless a technical term is necessary. When it is, add a plain-English explanation.
|
|
65
|
-
4. **Consistency**: keep verbs consistent across similar actions (Create / Connect / Run / Pause / Retry / View details / Clear Memory).
|
|
66
|
-
5. **Actionable**: every message tells the user what to do next. Avoid generic “OK/Cancel”; use specific actions.
|
|
67
|
-
6. **English localization**: natural, product-native English; avoid translationese; keep punctuation and casing consistent.
|
|
68
|
-
|
|
69
|
-
---
|
|
70
|
-
|
|
71
|
-
## 5) Human Warmth (balanced, controlled)
|
|
72
|
-
|
|
73
|
-
Goal: reduce anxiety and restore control without being sentimental. Default ratio: **80% information, 20% warmth**. Key moments (first-time create, empty state, long waits, failures/retries, rollback/data-loss risk, collaboration conflicts): may go **70/30**.
|
|
74
|
-
|
|
75
|
-
Hard cap: any on-screen message may include **at most half a sentence to one sentence** of warmth, and it must be followed by a clear next step.
|
|
76
|
-
|
|
77
|
-
Required order:
|
|
78
|
-
|
|
79
|
-
1. Acknowledge the situation (no judgment)
|
|
80
|
-
2. Restore control (human-in-the-loop: pause/replay/edit/undo/clear Memory/view Context)
|
|
81
|
-
3. Provide the next action (button/path)
|
|
82
|
-
|
|
83
|
-
Avoid:
|
|
84
|
-
|
|
85
|
-
- preachy encouragement (“don’t worry”, “stay positive”)
|
|
86
|
-
- grand narratives
|
|
87
|
-
- overly anthropomorphic claims (“I understand you”, “I’ll always remember you”)
|
|
88
|
-
|
|
89
|
-
Core stance: Agents can accelerate output, but **you** own the judgment, trade-offs, and final decision. LobeHub gives you time back for what matters.
|
|
90
|
-
|
|
91
|
-
Suggested patterns:
|
|
92
|
-
|
|
93
|
-
- **Getting started / blank state**
|
|
94
|
-
- “Starting with one sentence is enough. Describe your goal and I’ll help you set up the first Agent.”
|
|
95
|
-
- “Not sure where to begin? Tell me the outcome—we’ll break it down together.”
|
|
96
|
-
- **Long run / waiting**
|
|
97
|
-
- “Running… You can switch tasks—I'll notify you when it’s done.”
|
|
98
|
-
- “This may take a few minutes. To speed up: reduce Context / switch model / disable Auto-run.”
|
|
99
|
-
- **Failure / retry**
|
|
100
|
-
- “That didn’t run through. Retry, or view details to fix the cause.”
|
|
101
|
-
- “Connection failed: permission not granted or network unstable. Re-authorize in Settings, or try again later.”
|
|
102
|
-
- **Value anxiety (guidance, not error dialogs)**
|
|
103
|
-
- “Agents can speed up output, but direction and standards stay with you.”
|
|
104
|
-
- “Fast results are great—keeping the trail makes the next run steadier.”
|
|
105
|
-
- **Collaboration / Agent Teams**
|
|
106
|
-
- “Align everyone to the same Context. Every Agent in the Agent Team works from the same page.”
|
|
107
|
-
- “Different opinions are fine. Write the goal first, then let Agents propose options and trade-offs.”
|
|
108
|
-
|
|
109
|
-
---
|
|
110
|
-
|
|
111
|
-
## 6) Errors / Exceptions / Permissions / Billing: hard rules
|
|
112
|
-
|
|
113
|
-
Every error must include:
|
|
114
|
-
|
|
115
|
-
- **What happened**
|
|
116
|
-
- (optional) **Why**
|
|
117
|
-
- **What the user can do next**
|
|
118
|
-
|
|
119
|
-
Provide actionable options as appropriate:
|
|
120
|
-
|
|
121
|
-
- Retry / View details / Go to Settings / Contact support / Copy logs
|
|
122
|
-
|
|
123
|
-
Never blame the user. Don’t show only an error code; put codes in “Details” if needed. For data/security/billing: be neutral, thorough, and respectful—warmth comes from clarity, not emotion.
|
|
124
|
-
|
|
125
|
-
---
|
|
126
|
-
|
|
127
|
-
## 7) Your Special Task: CN i18n → EN (localized, length-aware)
|
|
128
|
-
|
|
129
|
-
You translate **raw Chinese i18n strings into English** for LobeHub.
|
|
130
|
-
|
|
131
|
-
Requirements:
|
|
132
|
-
|
|
133
|
-
- Prefer **localized**, product-native English over literal translation.
|
|
134
|
-
- Do **not** chase perfect one-to-one consistency if a more natural UI phrase reads better.
|
|
135
|
-
- Keep the **character length difference small**; try to make the English string **roughly the same visual length** as the Chinese source (avoid overly long expansions).
|
|
136
|
-
- Preserve meaning, tone, and actionability; keep verbs consistent with LobeHub’s UI patterns.
|
|
137
|
-
- If space is tight (buttons, tabs, toasts), prioritize: **verb + object**, drop optional words first.
|
|
138
|
-
- If the Chinese includes placeholders/variables, preserve them exactly (e.g., `{name}`, `{{count}}`, `%s`) and keep word order sensible.
|
|
139
|
-
- Keep capitalization consistent with UI norms (buttons/title case only when appropriate).
|
|
140
|
-
|
|
141
|
-
Output format when translating:
|
|
142
|
-
|
|
143
|
-
- Provide **English only**, unless asked otherwise.
|
|
144
|
-
- If multiple options are useful, give **one best option** + **one shorter fallback** (only when length constraints are likely).
|
|
145
|
-
|
|
146
|
-
---
|
|
147
|
-
|
|
148
|
-
You always optimize for: **clarity, control, collaboration, replayability, and human-in-the-loop**—in a modern, restrained, trustworthy English voice.
|
|
@@ -1,162 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
description: Modal 命令式调用指南
|
|
3
|
-
globs: "**/features/**/*.tsx"
|
|
4
|
-
alwaysApply: false
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
# Modal 命令式调用指南
|
|
8
|
-
|
|
9
|
-
当需要创建可命令式调用的 Modal 组件时,使用 `@lobehub/ui` 提供的 `createModal` API。
|
|
10
|
-
|
|
11
|
-
## 核心理念
|
|
12
|
-
|
|
13
|
-
**命令式调用** vs **声明式调用**:
|
|
14
|
-
|
|
15
|
-
| 模式 | 特点 | 适用场景 |
|
|
16
|
-
|------|------|----------|
|
|
17
|
-
| 声明式 | 需要维护 `open` state,渲染 `<Modal />` 组件 | ❌ 不推荐 |
|
|
18
|
-
| 命令式 | 直接调用函数打开,无需 state 管理 | ✅ 推荐 |
|
|
19
|
-
|
|
20
|
-
## 文件组织结构
|
|
21
|
-
|
|
22
|
-
```
|
|
23
|
-
features/
|
|
24
|
-
└── MyFeatureModal/
|
|
25
|
-
├── index.tsx # 导出 createXxxModal 函数
|
|
26
|
-
├── MyFeatureContent.tsx # Modal 内容组件
|
|
27
|
-
└── ...其他子组件
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
## createModal 用法(推荐)
|
|
31
|
-
|
|
32
|
-
### 1. 定义 Content 组件 (`MyFeatureContent.tsx`)
|
|
33
|
-
|
|
34
|
-
```tsx
|
|
35
|
-
'use client';
|
|
36
|
-
|
|
37
|
-
import { useModalContext } from '@lobehub/ui';
|
|
38
|
-
import { useTranslation } from 'react-i18next';
|
|
39
|
-
|
|
40
|
-
export const MyFeatureContent = () => {
|
|
41
|
-
const { t } = useTranslation('namespace');
|
|
42
|
-
const { close } = useModalContext(); // 可选:获取关闭方法
|
|
43
|
-
|
|
44
|
-
return (
|
|
45
|
-
<div>
|
|
46
|
-
{/* Modal 内容 */}
|
|
47
|
-
</div>
|
|
48
|
-
);
|
|
49
|
-
};
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
### 2. 导出 createModal 函数 (`index.tsx`)
|
|
53
|
-
|
|
54
|
-
```tsx
|
|
55
|
-
'use client';
|
|
56
|
-
|
|
57
|
-
import { createModal } from '@lobehub/ui';
|
|
58
|
-
import { t } from 'i18next'; // 注意:使用 i18next 而非 react-i18next
|
|
59
|
-
|
|
60
|
-
import { MyFeatureContent } from './MyFeatureContent';
|
|
61
|
-
|
|
62
|
-
export const createMyFeatureModal = () =>
|
|
63
|
-
createModal({
|
|
64
|
-
allowFullscreen: true,
|
|
65
|
-
children: <MyFeatureContent />,
|
|
66
|
-
destroyOnHidden: false,
|
|
67
|
-
footer: null,
|
|
68
|
-
styles: {
|
|
69
|
-
body: { overflow: 'hidden', padding: 0 },
|
|
70
|
-
},
|
|
71
|
-
title: t('myFeature.title', { ns: 'setting' }),
|
|
72
|
-
width: 'min(80%, 800px)',
|
|
73
|
-
});
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
### 3. 调用方使用
|
|
77
|
-
|
|
78
|
-
```tsx
|
|
79
|
-
import { useCallback } from 'react';
|
|
80
|
-
import { createMyFeatureModal } from '@/features/MyFeatureModal';
|
|
81
|
-
|
|
82
|
-
const MyComponent = () => {
|
|
83
|
-
const handleOpenModal = useCallback(() => {
|
|
84
|
-
createMyFeatureModal();
|
|
85
|
-
}, []);
|
|
86
|
-
|
|
87
|
-
return <Button onClick={handleOpenModal}>打开</Button>;
|
|
88
|
-
};
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
## 关键要点
|
|
92
|
-
|
|
93
|
-
### i18n 处理
|
|
94
|
-
|
|
95
|
-
- **Content 组件内**:使用 `useTranslation` hook(React 上下文)
|
|
96
|
-
- **createModal 参数中**:使用 `import { t } from 'i18next'`(非 hook,支持命令式调用)
|
|
97
|
-
|
|
98
|
-
```tsx
|
|
99
|
-
// index.tsx - 命令式上下文
|
|
100
|
-
import { t } from 'i18next';
|
|
101
|
-
title: t('key', { ns: 'namespace' })
|
|
102
|
-
|
|
103
|
-
// Content.tsx - React 组件上下文
|
|
104
|
-
import { useTranslation } from 'react-i18next';
|
|
105
|
-
const { t } = useTranslation('namespace');
|
|
106
|
-
```
|
|
107
|
-
|
|
108
|
-
### useModalContext Hook
|
|
109
|
-
|
|
110
|
-
在 Content 组件内可使用 `useModalContext` 获取 Modal 控制方法:
|
|
111
|
-
|
|
112
|
-
```tsx
|
|
113
|
-
const { close, setCanDismissByClickOutside } = useModalContext();
|
|
114
|
-
```
|
|
115
|
-
|
|
116
|
-
### ModalHost
|
|
117
|
-
|
|
118
|
-
`createModal` 依赖全局 `<ModalHost />` 组件。项目中已在 `src/layout/GlobalProvider/index.tsx` 配置,无需额外添加。
|
|
119
|
-
|
|
120
|
-
## 常用配置项
|
|
121
|
-
|
|
122
|
-
| 属性 | 类型 | 说明 |
|
|
123
|
-
|------|------|------|
|
|
124
|
-
| `allowFullscreen` | `boolean` | 允许全屏模式 |
|
|
125
|
-
| `destroyOnHidden` | `boolean` | 关闭时是否销毁内容(`destroyOnClose` 已废弃) |
|
|
126
|
-
| `footer` | `ReactNode \| null` | 底部内容,`null` 表示无底部 |
|
|
127
|
-
| `width` | `string \| number` | Modal 宽度 |
|
|
128
|
-
| `styles.body` | `CSSProperties` | body 区域样式 |
|
|
129
|
-
|
|
130
|
-
## 迁移指南
|
|
131
|
-
|
|
132
|
-
### Before(声明式)
|
|
133
|
-
|
|
134
|
-
```tsx
|
|
135
|
-
// 调用方需要维护 state
|
|
136
|
-
const [open, setOpen] = useState(false);
|
|
137
|
-
|
|
138
|
-
return (
|
|
139
|
-
<>
|
|
140
|
-
<Button onClick={() => setOpen(true)}>打开</Button>
|
|
141
|
-
<MyModal open={open} setOpen={setOpen} />
|
|
142
|
-
</>
|
|
143
|
-
);
|
|
144
|
-
```
|
|
145
|
-
|
|
146
|
-
### After(命令式)
|
|
147
|
-
|
|
148
|
-
```tsx
|
|
149
|
-
// 调用方无需 state,直接调用函数
|
|
150
|
-
const handleOpen = useCallback(() => {
|
|
151
|
-
createMyModal();
|
|
152
|
-
}, []);
|
|
153
|
-
|
|
154
|
-
return <Button onClick={handleOpen}>打开</Button>;
|
|
155
|
-
```
|
|
156
|
-
|
|
157
|
-
## 示例参考
|
|
158
|
-
|
|
159
|
-
- `src/features/SkillStore/index.tsx` - createModal 标准用法
|
|
160
|
-
- `src/features/SkillStore/SkillStoreContent.tsx` - Content 组件示例
|
|
161
|
-
- `src/features/LibraryModal/CreateNew/index.tsx` - 带回调的 createModal 用法
|
|
162
|
-
- `src/features/Electron/updater/UpdateModal.tsx` - 复杂 Modal 控制示例
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
description: flex layout components from `@lobehub/ui` usage
|
|
3
|
-
globs:
|
|
4
|
-
alwaysApply: false
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
# Flexbox 布局组件使用指南
|
|
8
|
-
|
|
9
|
-
`@lobehub/ui` 提供了 `Flexbox` 和 `Center` 组件用于创建弹性布局。以下是重点组件的使用方法:
|
|
10
|
-
|
|
11
|
-
## Flexbox 组件
|
|
12
|
-
|
|
13
|
-
Flexbox 是最常用的布局组件,用于创建弹性布局,类似于 CSS 的 display: flex。
|
|
14
|
-
|
|
15
|
-
### 基本用法
|
|
16
|
-
|
|
17
|
-
```jsx
|
|
18
|
-
import { Flexbox } from '@lobehub/ui';
|
|
19
|
-
|
|
20
|
-
// 默认垂直布局
|
|
21
|
-
<Flexbox>
|
|
22
|
-
<div>子元素1</div>
|
|
23
|
-
<div>子元素2</div>
|
|
24
|
-
</Flexbox>
|
|
25
|
-
|
|
26
|
-
// 水平布局
|
|
27
|
-
<Flexbox horizontal>
|
|
28
|
-
<div>左侧元素</div>
|
|
29
|
-
<div>右侧元素</div>
|
|
30
|
-
</Flexbox>
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
### 常用属性
|
|
34
|
-
|
|
35
|
-
- horizontal: 布尔值,设置为水平方向布局
|
|
36
|
-
- flex: 数值或字符串,控制 flex 属性
|
|
37
|
-
- gap: 数值,设置子元素之间的间距
|
|
38
|
-
- align: 对齐方式,如 'center', 'flex-start' 等
|
|
39
|
-
- justify: 主轴对齐方式,如 'space-between', 'center' 等
|
|
40
|
-
- padding: 内边距值
|
|
41
|
-
- paddingInline: 水平内边距值
|
|
42
|
-
- paddingBlock: 垂直内边距值
|
|
43
|
-
- width/height: 设置宽高,通常用 '100%' 或具体像素值
|
|
44
|
-
- style: 自定义样式对象
|
|
45
|
-
|
|
46
|
-
### 实际应用示例
|
|
47
|
-
|
|
48
|
-
```jsx
|
|
49
|
-
// 经典三栏布局
|
|
50
|
-
<Flexbox horizontal height={'100%'} width={'100%'}>
|
|
51
|
-
{/* 左侧边栏 */}
|
|
52
|
-
<Flexbox
|
|
53
|
-
width={260}
|
|
54
|
-
style={{
|
|
55
|
-
borderRight: `1px solid ${theme.colorBorderSecondary}`,
|
|
56
|
-
height: '100%',
|
|
57
|
-
overflowY: 'auto',
|
|
58
|
-
}}
|
|
59
|
-
>
|
|
60
|
-
<SidebarContent />
|
|
61
|
-
</Flexbox>
|
|
62
|
-
|
|
63
|
-
{/* 中间内容区 */}
|
|
64
|
-
<Flexbox flex={1} style={{ height: '100%' }}>
|
|
65
|
-
{/* 主要内容 */}
|
|
66
|
-
<Flexbox flex={1} padding={24} style={{ overflowY: 'auto' }}>
|
|
67
|
-
<MainContent />
|
|
68
|
-
</Flexbox>
|
|
69
|
-
|
|
70
|
-
{/* 底部区域 */}
|
|
71
|
-
<Flexbox
|
|
72
|
-
style={{
|
|
73
|
-
borderTop: `1px solid ${theme.colorBorderSecondary}`,
|
|
74
|
-
padding: '16px 24px',
|
|
75
|
-
}}
|
|
76
|
-
>
|
|
77
|
-
<Footer />
|
|
78
|
-
</Flexbox>
|
|
79
|
-
</Flexbox>
|
|
80
|
-
</Flexbox>
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
## Center 组件
|
|
84
|
-
|
|
85
|
-
Center 是对 Flexbox 的封装,使子元素水平和垂直居中。
|
|
86
|
-
|
|
87
|
-
### 基本用法
|
|
88
|
-
|
|
89
|
-
```jsx
|
|
90
|
-
import { Center } from '@lobehub/ui';
|
|
91
|
-
|
|
92
|
-
<Center width={'100%'} height={'100%'}>
|
|
93
|
-
<Content />
|
|
94
|
-
</Center>;
|
|
95
|
-
```
|
|
96
|
-
|
|
97
|
-
Center 组件继承了 Flexbox 的所有属性,同时默认设置了居中对齐。主要用于快速创建居中布局。
|
|
98
|
-
|
|
99
|
-
### 实际应用示例
|
|
100
|
-
|
|
101
|
-
```jsx
|
|
102
|
-
// 登录页面居中布局
|
|
103
|
-
<Flexbox height={'100%'} width={'100%'}>
|
|
104
|
-
<Center height={'100%'} width={'100%'}>
|
|
105
|
-
<LoginForm />
|
|
106
|
-
</Center>
|
|
107
|
-
</Flexbox>
|
|
108
|
-
|
|
109
|
-
// 图标居中显示
|
|
110
|
-
<Center className={styles.icon} flex={'none'} height={40} width={40}>
|
|
111
|
-
<Icon icon={icon} size={24} />
|
|
112
|
-
</Center>
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
## 最佳实践
|
|
116
|
-
|
|
117
|
-
- 使用 flex={1} 让组件填充可用空间
|
|
118
|
-
- 使用 gap 代替传统的 margin 设置元素间距
|
|
119
|
-
- 嵌套 Flexbox 创建复杂布局
|
|
120
|
-
- 设置 overflow: 'auto' 使内容可滚动
|
|
121
|
-
- 使用 horizontal 创建水平布局,默认为垂直布局
|
|
122
|
-
- 与 antd-style 的 useTheme hook 配合使用创建主题响应式的布局
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
alwaysApply: true
|
|
3
|
-
---
|
|
4
|
-
|
|
5
|
-
## Project Description
|
|
6
|
-
|
|
7
|
-
You are developing an open-source, modern-design AI Agent Workspace: LobeHub(previous LobeChat).
|
|
8
|
-
|
|
9
|
-
Supported platforms:
|
|
10
|
-
|
|
11
|
-
- web desktop/mobile
|
|
12
|
-
- desktop(electron)
|
|
13
|
-
- mobile app(react native), coming soon
|
|
14
|
-
|
|
15
|
-
logo emoji: 🤯
|
|
16
|
-
|
|
17
|
-
## Project Technologies Stack
|
|
18
|
-
|
|
19
|
-
- Next.js 16
|
|
20
|
-
- implement spa inside nextjs with `react-router-dom`
|
|
21
|
-
- react 19
|
|
22
|
-
- TypeScript
|
|
23
|
-
- `@lobehub/ui`, antd for component framework
|
|
24
|
-
- antd-style for css-in-js framework
|
|
25
|
-
- lucide-react, `@ant-design/icons` for icons
|
|
26
|
-
- react-i18next for i18n
|
|
27
|
-
- zustand for state management
|
|
28
|
-
- nuqs for search params management
|
|
29
|
-
- SWR for data fetch
|
|
30
|
-
- aHooks for react hooks library
|
|
31
|
-
- dayjs for time library
|
|
32
|
-
- es-toolkit for utility library
|
|
33
|
-
- TRPC for type safe backend
|
|
34
|
-
- Neon PostgreSQL for backend DB
|
|
35
|
-
- Drizzle ORM
|
|
36
|
-
- Vitest for testing
|
package/.cursor/rules/react.mdc
DELETED
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
description:
|
|
3
|
-
globs: *.tsx
|
|
4
|
-
alwaysApply: false
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
# React Component Writing Guide
|
|
8
|
-
|
|
9
|
-
- Use antd-style for complex styles; for simple cases, use the `style` attribute for inline styles
|
|
10
|
-
- Use `Flexbox` and `Center` components from `@lobehub/ui` for flex and centered layouts
|
|
11
|
-
- Component selection priority: src/components > installed component packages > lobe-ui > antd
|
|
12
|
-
- Use selectors to access zustand store data instead of accessing the store directly
|
|
13
|
-
|
|
14
|
-
## Lobe UI Components
|
|
15
|
-
|
|
16
|
-
- If unsure how to use `@lobehub/ui` components or what props they accept, search for existing usage in this project instead of guessing. Most components extend antd components with additional props
|
|
17
|
-
- For specific usage, search online. For example, for ActionIcon visit <https://ui.lobehub.com/components/action-icon>
|
|
18
|
-
- Read `node_modules/@lobehub/ui/es/index.mjs` to see all available components and their props
|
|
19
|
-
|
|
20
|
-
- General
|
|
21
|
-
- ActionIcon
|
|
22
|
-
- ActionIconGroup
|
|
23
|
-
- Block
|
|
24
|
-
- Button
|
|
25
|
-
- Icon
|
|
26
|
-
- Data Display
|
|
27
|
-
- Accordion
|
|
28
|
-
- Avatar
|
|
29
|
-
- Collapse
|
|
30
|
-
- Empty
|
|
31
|
-
- FileTypeIcon
|
|
32
|
-
- FluentEmoji
|
|
33
|
-
- GroupAvatar
|
|
34
|
-
- GuideCard
|
|
35
|
-
- Highlighter
|
|
36
|
-
- Hotkey
|
|
37
|
-
- Image
|
|
38
|
-
- List
|
|
39
|
-
- Markdown
|
|
40
|
-
- MaterialFileTypeIcon
|
|
41
|
-
- Mermaid
|
|
42
|
-
- Segmented
|
|
43
|
-
- Skeleton
|
|
44
|
-
- Snippet
|
|
45
|
-
- SortableList
|
|
46
|
-
- Tag
|
|
47
|
-
- Tooltip
|
|
48
|
-
- Video
|
|
49
|
-
- Data Entry
|
|
50
|
-
- AutoComplete
|
|
51
|
-
- CodeEditor
|
|
52
|
-
- ColorSwatches
|
|
53
|
-
- CopyButton
|
|
54
|
-
- DatePicker
|
|
55
|
-
- DownloadButton
|
|
56
|
-
- EditableText
|
|
57
|
-
- EmojiPicker
|
|
58
|
-
- Form
|
|
59
|
-
- FormModal
|
|
60
|
-
- HotkeyInput
|
|
61
|
-
- ImageSelect
|
|
62
|
-
- Input
|
|
63
|
-
- SearchBar
|
|
64
|
-
- Select
|
|
65
|
-
- SliderWithInput
|
|
66
|
-
- ThemeSwitch
|
|
67
|
-
- Feedback
|
|
68
|
-
- Alert
|
|
69
|
-
- Drawer
|
|
70
|
-
- Modal
|
|
71
|
-
- Layout
|
|
72
|
-
- Center
|
|
73
|
-
- DraggablePanel
|
|
74
|
-
- Flexbox
|
|
75
|
-
- Footer
|
|
76
|
-
- Grid
|
|
77
|
-
- Header
|
|
78
|
-
- Layout
|
|
79
|
-
- MaskShadow
|
|
80
|
-
- ScrollShadow
|
|
81
|
-
- Navigation
|
|
82
|
-
- Burger
|
|
83
|
-
- DraggableSideNav
|
|
84
|
-
- Dropdown
|
|
85
|
-
- Menu
|
|
86
|
-
- SideNav
|
|
87
|
-
- Tabs
|
|
88
|
-
- Toc
|
|
89
|
-
- Theme
|
|
90
|
-
- ConfigProvider
|
|
91
|
-
- FontLoader
|
|
92
|
-
- ThemeProvider
|
|
93
|
-
- Typography
|
|
94
|
-
- Text
|
|
95
|
-
|
|
96
|
-
## Routing Architecture
|
|
97
|
-
|
|
98
|
-
This project uses a **hybrid routing architecture**: Next.js App Router for static pages + React Router DOM for the main SPA.
|
|
99
|
-
|
|
100
|
-
### Route Types
|
|
101
|
-
|
|
102
|
-
```plaintext
|
|
103
|
-
+------------------+--------------------------------+--------------------------------+
|
|
104
|
-
| Route Type | Use Case | Implementation |
|
|
105
|
-
+------------------+--------------------------------+--------------------------------+
|
|
106
|
-
| Next.js App | Auth pages (login, signup, | page.tsx file convention |
|
|
107
|
-
| Router | oauth, reset-password, etc.) | src/app/[variants]/(auth)/ |
|
|
108
|
-
+------------------+--------------------------------+--------------------------------+
|
|
109
|
-
| React Router | Main SPA features | BrowserRouter + Routes |
|
|
110
|
-
| DOM | (chat, community, settings) | desktopRouter.config.tsx |
|
|
111
|
-
| | | mobileRouter.config.tsx |
|
|
112
|
-
+------------------+--------------------------------+--------------------------------+
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
### Key Files
|
|
116
|
-
|
|
117
|
-
- Entry point: `src/app/[variants]/page.tsx` - Routes to Desktop or Mobile based on device
|
|
118
|
-
- Desktop router: `src/app/[variants]/router/desktopRouter.config.tsx`
|
|
119
|
-
- Mobile router: `src/app/[variants]/(mobile)/router/mobileRouter.config.tsx`
|
|
120
|
-
- Router utilities: `src/utils/router.tsx`
|
|
121
|
-
|
|
122
|
-
### Router Utilities
|
|
123
|
-
|
|
124
|
-
```tsx
|
|
125
|
-
import { ErrorBoundary, RouteConfig, dynamicElement, redirectElement } from '@/utils/router';
|
|
126
|
-
|
|
127
|
-
// Lazy load a page component
|
|
128
|
-
element: dynamicElement(() => import('./chat'), 'Desktop > Chat');
|
|
129
|
-
|
|
130
|
-
// Create a redirect
|
|
131
|
-
element: redirectElement('/settings/profile');
|
|
132
|
-
|
|
133
|
-
// Error boundary for route
|
|
134
|
-
errorElement: <ErrorBoundary resetPath="/chat" />;
|
|
135
|
-
```
|
|
136
|
-
|
|
137
|
-
### Adding New Routes
|
|
138
|
-
|
|
139
|
-
1. Add route config to `desktopRouter.config.tsx` or `mobileRouter.config.tsx`
|
|
140
|
-
2. Create page component in the corresponding directory under `(main)/`
|
|
141
|
-
3. Use `dynamicElement()` for lazy loading
|
|
142
|
-
|
|
143
|
-
### Navigation
|
|
144
|
-
|
|
145
|
-
**Important**: For SPA pages (React Router DOM routes), use `Link` from `react-router-dom`, NOT from `next/link`.
|
|
146
|
-
|
|
147
|
-
```tsx
|
|
148
|
-
// ❌ Wrong - next/link in SPA pages
|
|
149
|
-
import Link from 'next/link';
|
|
150
|
-
<Link href="/">Home</Link>
|
|
151
|
-
|
|
152
|
-
// ✅ Correct - react-router-dom Link in SPA pages
|
|
153
|
-
import { Link } from 'react-router-dom';
|
|
154
|
-
<Link to="/">Home</Link>
|
|
155
|
-
```
|
|
156
|
-
|
|
157
|
-
```tsx
|
|
158
|
-
// In components - use react-router-dom hooks
|
|
159
|
-
import { useNavigate, useParams } from 'react-router-dom';
|
|
160
|
-
|
|
161
|
-
const navigate = useNavigate();
|
|
162
|
-
navigate('/chat');
|
|
163
|
-
|
|
164
|
-
// From stores - use global navigate
|
|
165
|
-
import { useGlobalStore } from '@/store/global';
|
|
166
|
-
|
|
167
|
-
const navigate = useGlobalStore.getState().navigate;
|
|
168
|
-
navigate?.('/settings');
|
|
169
|
-
```
|