用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/OneKeyHQ/app-monorepo --skill 1k-cross-platform命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
Analyze accumulated bug fix cases and propose updates to the self-testing checklist. Use periodically (weekly/monthly) to evolve quality checks based on real issues.
OneKey i18n and Lokalise workflow for searching, adding, updating, pulling, and using translation keys. Verify the target project and full locale coverage; never edit generated translation files.
Review OneKey PRs and diffs for security, correctness, concurrency, React/RN pitfalls, and repository-specific regressions. Use for code review or 审查 PR.
基于 SOC 职业分类
正在显示 SKILL.md
| name | 1k-cross-platform |
| description | OneKey cross-platform patterns, platform files, platformEnv, and supported OS/SDK requirements. |
| allowed-tools | Read, Grep, Glob, Bash |
Patterns for writing platform-specific code in OneKey.
Use platform extensions for platform-specific implementations:
| Extension | Platform |
|---|---|
.native.ts | React Native (iOS/Android) |
.web.ts | Web platform |
.desktop.ts | Desktop (Electron) |
.ext.ts | Browser extension |
ALWAYS use platformEnv for platform detection:
// ✅ CORRECT
import platformEnv from '@onekeyhq/shared/src/platformEnv';
if (platformEnv.isNative) {
// React Native specific code
}
if (platformEnv.isWeb) {
// Web specific code
}
if (platformEnv.isDesktop) {
// Desktop (Electron) specific code
}
if (platformEnv.isExtension) {
// Browser extension specific code
}
// ❌ FORBIDDEN - Direct platform checks
if (typeof window !== 'undefined') { }
if (process.env.REACT_APP_PLATFORM === 'web') { }
platformEnv.isNative // React Native (iOS or Android)
platformEnv.isWeb // Web browser
platformEnv.isDesktop // Electron desktop app
platformEnv.isExtension // Browser extension
platformEnv.isIOS // iOS specifically
platformEnv.isAndroid // Android specifically
platformEnv.isWebEmbed // Embedded web components
MyComponent/
├── index.ts # Main entry, common logic
├── MyComponent.tsx # Shared component
├── MyComponent.native.tsx # React Native specific
├── MyComponent.web.tsx # Web specific
├── MyComponent.desktop.tsx # Desktop specific
└── MyComponent.ext.tsx # Extension specific
The bundler automatically resolves the correct file based on platform.
// storage.ts - shared interface
export interface IStorage {
get(key: string): Promise<string | null>;
set(key: string, value: string): Promise<void>;
}
// storage.native.ts
import AsyncStorage from '@react-native-async-storage/async-storage';
export const storage: IStorage = {
get: (key) => AsyncStorage.getItem(key),
set: (key, value) => AsyncStorage.setItem(key, value),
};
// storage.web.ts
export const storage: IStorage = {
get: async (key) => localStorage.getItem(key),
set: async (key, value) => localStorage.setItem(key, value),
};
// storage.desktop.ts
import { ipcRenderer } ;
: = {
: ipcRenderer.(, key),
: ipcRenderer.(, key, value),
};
For comprehensive cross-platform patterns and platform considerations, see cross-platform.md.
For current development tool and minimum platform versions, see platform-requirements.md. Verify version values against the referenced repository files before relying on them.
Topics covered:
platformEnvplatformEnv instead of direct checks/1k-coding-patterns - General coding patterns/1k-architecture - Project structure and imports