1k-cross-platform
1
总安装量
1
周安装量
#46213
全站排名
安装命令
npx skills add https://github.com/majiayu000/claude-skill-registry --skill 1k-cross-platform
Agent 安装分布
replit
1
amp
1
trae-cn
1
kimi-cli
1
codex
1
Skill 文档
OneKey Cross-Platform Development
Platform Extensions
Use platform extensions for platform-specific implementations:
.native.tsfor React Native (iOS/Android).web.tsfor web platform.desktop.tsfor desktop platform.ext.tsfor browser extension
Platform Detection
Use import platformEnv from '@onekeyhq/shared/src/platformEnv' for platform detection:
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
}
Key Principles
- UI components should work consistently across all platforms
- Keep platform-specific code in separate files with appropriate extensions
- Minimize platform-specific code by keeping common logic separate
- Test across all target platforms
Common Patterns
Platform-Specific File Structure
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
Conditional Platform Logic
// GOOD: Use platformEnv
import platformEnv from '@onekeyhq/shared/src/platformEnv';
function getStoragePath() {
if (platformEnv.isNative) {
return 'file://...';
}
if (platformEnv.isDesktop) {
return '/path/to/storage';
}
return 'indexeddb://...';
}
// BAD: Direct platform checks
if (typeof window !== 'undefined') { } // â
if (process.env.REACT_APP_PLATFORM === 'web') { } // â
Platform-Specific Imports
// index.ts - Auto-resolves based on platform
export * from './MyComponent';
// The bundler will automatically pick:
// - MyComponent.native.ts on mobile
// - MyComponent.web.ts on web
// - MyComponent.desktop.ts on desktop
// - MyComponent.ext.ts on extension
Platform Considerations
Extension (Chrome, Firefox, Edge, Brave)
- MV3/service worker lifetimes
- Permissions and CSP
- Background script limitations
- Cross-origin restrictions
Mobile (iOS/Android)
- WebView limitations
- Native modules
- Background/foreground states
- Deep linking
Desktop (Electron)
- Security boundaries
- IPC communication
- nodeIntegration settings
- File system access
Web
- CORS restrictions
- Storage limitations (localStorage, IndexedDB)
- XSS prevention
- Bundle size optimization