sealos-app-builder
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseSealos App Builder
Sealos App Builder
Overview
概述
Use this skill to turn a generic web app into a Sealos app that runs inside Sealos Desktop, or to scaffold a new Sealos app from scratch. Focus on the repeatable parts: SDK initialization, session access, language sync, business-data integration, local debugging through a Desktop test app, and publish readiness.
Prefer a simple, teachable implementation that a beginner can understand and extend.
使用此技能可将通用Web应用转换为可在Sealos Desktop中运行的Sealos应用,或从头搭建一个新的Sealos应用。重点关注可复用部分:SDK初始化、会话访问、语言同步、业务数据集成、通过桌面测试应用进行本地调试,以及发布准备工作。
优先采用初学者易于理解和扩展的简单、可教学的实现方案。
Core Workflow
核心工作流程
1. Identify the starting point
1. 确定起点
Classify the request into one of these paths:
- Create a new Sealos app from scratch.
- Adapt an existing web app to run inside Sealos Desktop.
- Add Sealos identity and business-data integration to an app that already renders.
- Produce documentation or a tutorial instead of code changes.
If the repository already contains Sealos-related code, inspect local sources first. In particular:
- Look for or equivalent SDK sources.
packages/client-sdk - Look for existing provider apps under or similar directories.
providers/ - Reuse the repository's established framework and routing patterns when they are already in place.
If the repository does not contain local Sealos sources, use the bundled references in this skill as the baseline.
将请求归类为以下路径之一:
- 从头创建新的Sealos应用。
- 适配现有Web应用以在Sealos Desktop中运行。
- 为已可渲染的应用添加Sealos身份认证和业务数据集成。
- 生成文档或教程而非修改代码。
如果仓库已包含Sealos相关代码,请先检查本地源码:
- 查找或等效的SDK源码。
packages/client-sdk - 查找或类似目录下的现有提供商应用。
providers/ - 若仓库已确立框架和路由模式,请复用这些模式。
如果仓库不包含本地Sealos源码,请以本技能中的捆绑参考内容为基准。
2. Integrate the Sealos app SDK
2. 集成Sealos应用SDK
Treat Sealos Desktop integration as a root-level concern.
Before using any starter template, install the SDK first:
bash
pnpm add @labring/sealos-desktop-sdkUse or when the project uses a different package manager.
npm install @labring/sealos-desktop-sdkyarn add @labring/sealos-desktop-sdk- Initialize the SDK once in a client-only root component.
- Fetch and
getSession()early.getLanguage() - Store session, language, loading state, and desktop availability in a shared context or store.
- Listen for language changes through when the app needs runtime language sync.
EVENT_NAME.CHANGE_I18N - Add a graceful fallback when the app is opened outside Sealos Desktop.
Read references/minimal-app-template.md before implementing the root integration.
If the app uses Next.js App Router, also read references/nextjs-app-router.md.
Use one of these starter templates:
- assets/templates/react/sealos-provider.tsx for React.
- assets/templates/vue/use-sealos.ts for Vue.
将Sealos Desktop集成视为核心关注点。
在使用任何入门模板之前,先安装SDK:
bash
pnpm add @labring/sealos-desktop-sdk若项目使用其他包管理器,请使用或。
npm install @labring/sealos-desktop-sdkyarn add @labring/sealos-desktop-sdk- 在仅客户端的根组件中初始化SDK一次。
- 尽早获取和
getSession()。getLanguage() - 将会话、语言、加载状态和桌面可用性存储在共享上下文或状态管理库中。
- 当应用需要运行时语言同步时,通过监听语言变化。
EVENT_NAME.CHANGE_I18N - 添加优雅的降级方案,以处理应用在Sealos Desktop外打开的情况。
在实现根集成之前,请阅读references/minimal-app-template.md。
如果应用使用Next.js App Router,还需阅读references/nextjs-app-router.md。
使用以下入门模板之一:
- React框架:assets/templates/react/sealos-provider.tsx
- Vue框架:assets/templates/vue/use-sealos.ts
3. Connect Sealos identity to business data
3. 连接Sealos身份与业务数据
For most apps, the key integration is not the iframe itself but the user mapping.
- Use as the stable app-level user identifier.
session.user.id - Persist display-friendly fields such as ,
name,avatar, andk8sUsernamewhen useful.nsid - Keep business data in the app's own database and API routes.
- Model Sealos user identity as input to your business logic, not as your entire backend.
Read references/data-integration-patterns.md when you need schema or API guidance.
对于大多数应用来说,关键的集成点并非iframe本身,而是用户映射。
- 使用作为稳定的应用级用户标识符。
session.user.id - 按需持久化、
name、avatar和k8sUsername等友好显示字段。nsid - 将业务数据存储在应用自身的数据库和API路由中。
- 将Sealos用户身份建模为业务逻辑的输入,而非整个后端。
当需要 schema 或 API 指导时,请阅读references/data-integration-patterns.md。
4. Prepare local debugging in the real runtime
4. 准备真实运行环境中的本地调试
Do not assume a successful browser render means Sealos integration works.
The app usually needs to be opened by Sealos Desktop in an iframe for SDK calls like to succeed. When local debugging is part of the task, read references/local-debug-and-test-app.md.
getSession()Use these rules:
- Explain clearly when a page is outside Sealos Desktop.
- Prefer a test app inside Sealos Desktop for end-to-end verification.
- Avoid server-side SDK calls.
不要假设浏览器渲染成功就意味着Sealos集成正常工作。
应用通常需要由Sealos Desktop在iframe中打开,才能使等SDK调用成功。如果任务包含本地调试,请阅读references/local-debug-and-test-app.md。
getSession()遵循以下规则:
- 清晰说明页面何时处于Sealos Desktop外部。
- 优先使用Sealos Desktop内的测试应用进行端到端验证。
- 避免在服务器端调用SDK。
5. Prepare for publishing
5. 准备发布
When the user wants deployment or launch readiness:
- Verify environment variables.
- Verify database connectivity and migrations.
- Confirm the app works when launched from Sealos Desktop.
- Confirm any cross-app navigation or event usage is valid.
- Summarize the remaining manual registration or platform configuration steps.
Use references/publish-checklist.md as the release checklist.
当用户需要部署或发布准备时:
- 验证环境变量。
- 验证数据库连接和迁移。
- 确认应用从Sealos Desktop启动时可正常运行。
- 确认任何跨应用导航或事件使用均有效。
- 总结剩余的手动注册或平台配置步骤。
以references/publish-checklist.md作为发布检查清单。
Implementation Rules
实现规则
Keep the integration simple
保持集成简洁
Default to the smallest viable Sealos integration:
- One root provider or store.
- One business identity mapping pattern.
- One fallback path for non-Desktop access.
Avoid spreading SDK initialization across multiple pages or components.
默认采用最小可行的Sealos集成方案:
- 一个根提供者或状态管理库。
- 一种业务身份映射模式。
- 一种针对非桌面访问的降级路径。
避免在多个页面或组件中分散SDK初始化逻辑。
Prefer the repository's real SDK surface
优先使用仓库中的真实SDK接口
If the current workspace contains actual Sealos SDK sources or existing Sealos apps:
- Inspect those sources.
- Follow the real exported APIs and types.
- Call out repository-specific differences from generic examples.
如果当前工作区包含实际的Sealos SDK源码或现有Sealos应用:
- 检查这些源码。
- 遵循实际导出的API和类型。
- 指出仓库特定实现与通用示例的差异。
Use the official SDK package name
使用官方SDK包名
Use in generated examples and starter code by default.
@labring/sealos-desktop-sdkOnly deviate from that if the target repository already has an established local workspace alias and the user explicitly wants to preserve it.
默认在生成的示例和入门代码中使用。
@labring/sealos-desktop-sdk仅当目标仓库已确立本地工作区别名且用户明确要求保留时,才可以偏离此规则。
Decision Guide
决策指南
If the user asks for "How do I build a Sealos app?"
如果用户询问“如何构建Sealos应用?”
Provide:
- A short explanation of the runtime model.
- A minimal SDK integration example.
- A business-data mapping example.
- Local debugging guidance through a Sealos Desktop test app.
提供以下内容:
- 运行时模型的简短说明。
- 最小化SDK集成示例。
- 业务数据映射示例。
- 通过Sealos Desktop测试应用进行本地调试的指南。
If the user asks to modify an existing app
如果用户要求修改现有应用
Do this order:
- Inspect the current app entry point.
- Add or refactor a single root Sealos provider.
- Wire business APIs to .
session.user.id - Verify fallback behavior outside Desktop.
按以下顺序操作:
- 检查当前应用的入口点。
- 添加或重构单个根Sealos提供者。
- 将业务API与关联。
session.user.id - 验证在桌面外的降级行为。
If the user asks for documentation or a tutorial
如果用户要求文档或教程
Structure the output around:
- What a Sealos app is.
- How to initialize the SDK.
- How to obtain and use the session.
- How to integrate business data.
- How to debug through a Desktop test app.
- How to publish and verify.
按以下结构组织输出:
- Sealos应用是什么。
- 如何初始化SDK。
- 如何获取和使用会话。
- 如何集成业务数据。
- 如何通过桌面测试应用进行调试。
- 如何发布和验证。
References
参考资料
Read only the files needed for the task:
- references/sdk-capabilities.md for available SDK APIs and runtime behavior.
- references/minimal-app-template.md for the recommended root integration pattern.
- references/nextjs-app-router.md for a concrete Next.js App Router placement example.
- references/data-integration-patterns.md for user mapping, database schemas, and API shapes.
- references/local-debug-and-test-app.md for iframe-based debugging and Desktop test app setup.
- references/publish-checklist.md for launch-readiness steps.
仅阅读任务所需的文件:
- references/sdk-capabilities.md:查看可用的SDK API和运行时行为。
- references/minimal-app-template.md:推荐的根集成模式。
- references/nextjs-app-router.md:具体的Next.js App Router部署示例。
- references/data-integration-patterns.md:用户映射、数据库schema和API格式。
- references/local-debug-and-test-app.md:基于iframe的调试和桌面测试应用设置。
- references/publish-checklist.md:发布准备步骤。