mirror of
https://github.com/ialley-workshop-open/uni-halo.git
synced 2026-09-12 16:40:40 +08:00
refactor: 架构升级
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
# Build Optimization | 构建优化
|
||||
|
||||
## Instructions
|
||||
|
||||
This example demonstrates how to optimize UniAppX builds with uView Pro.
|
||||
|
||||
### Key Concepts
|
||||
|
||||
- Code splitting
|
||||
- Tree shaking
|
||||
- Component lazy loading
|
||||
- Build configuration
|
||||
|
||||
### Example: Component Lazy Loading
|
||||
|
||||
```vue
|
||||
<!-- pages/index/index.vue -->
|
||||
<template>
|
||||
<view>
|
||||
<u-button @click="showModal = true">打开弹窗</u-button>
|
||||
<u-modal v-if="showModal" v-model="showModal">
|
||||
<view>内容</view>
|
||||
</u-modal>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue'
|
||||
|
||||
const showModal = ref(false)
|
||||
</script>
|
||||
```
|
||||
|
||||
### Example: Conditional Component Loading
|
||||
|
||||
```vue
|
||||
<template>
|
||||
<view>
|
||||
<!-- #ifdef H5 -->
|
||||
<u-upload :file-list="fileList" />
|
||||
<!-- #endif -->
|
||||
|
||||
<!-- #ifdef MP-WEIXIN -->
|
||||
<u-upload :file-list="fileList" />
|
||||
<!-- #endif -->
|
||||
</view>
|
||||
</template>
|
||||
```
|
||||
|
||||
### Key Points
|
||||
|
||||
- Use conditional compilation to exclude unused components
|
||||
- Lazy load heavy components
|
||||
- Optimize images and assets
|
||||
- Use tree shaking for unused code
|
||||
- Configure build options in manifest.json
|
||||
- Test build size on each platform
|
||||
@@ -0,0 +1,55 @@
|
||||
# Custom Theme | 自定义主题
|
||||
|
||||
## Instructions
|
||||
|
||||
This example demonstrates how to customize uView Pro theme in UniAppX projects.
|
||||
|
||||
### Key Concepts
|
||||
|
||||
- Theme variable customization
|
||||
- SCSS variable override
|
||||
- Global theme configuration
|
||||
- Component-specific styling
|
||||
|
||||
### Example: Custom Theme Variables
|
||||
|
||||
```scss
|
||||
/* uni.scss */
|
||||
// Override uView Pro theme variables
|
||||
$u-primary: #409EFF;
|
||||
$u-success: #67C23A;
|
||||
$u-warning: #E6A23C;
|
||||
$u-error: #F56C6C;
|
||||
$u-info: #909399;
|
||||
|
||||
// Import uView Pro theme
|
||||
@import "uview-pro/theme.scss";
|
||||
```
|
||||
|
||||
### Example: Component-Specific Styling
|
||||
|
||||
```vue
|
||||
<!-- pages/index/index.vue -->
|
||||
<template>
|
||||
<view>
|
||||
<u-button type="primary" custom-style="background: #ff0000;">
|
||||
自定义按钮
|
||||
</u-button>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
// Component-specific styles
|
||||
:deep(.u-button) {
|
||||
border-radius: 20rpx;
|
||||
}
|
||||
</style>
|
||||
```
|
||||
|
||||
### Key Points
|
||||
|
||||
- Override theme variables in uni.scss
|
||||
- Use custom-style prop for inline styles
|
||||
- Use :deep() for component style override
|
||||
- Test theme changes on all platforms
|
||||
- Maintain consistency across components
|
||||
@@ -0,0 +1,82 @@
|
||||
# Multi-Platform Deployment | 多平台部署
|
||||
|
||||
## Instructions
|
||||
|
||||
This example demonstrates multi-platform deployment strategies for UniAppX projects with uView Pro.
|
||||
|
||||
### Key Concepts
|
||||
|
||||
- Platform-specific builds
|
||||
- Conditional compilation
|
||||
- Platform testing
|
||||
- Deployment configuration
|
||||
|
||||
### Example: Platform-Specific Code
|
||||
|
||||
```vue
|
||||
<!-- pages/index/index.vue -->
|
||||
<template>
|
||||
<view>
|
||||
<!-- #ifdef H5 -->
|
||||
<u-button type="primary">H5 按钮</u-button>
|
||||
<!-- #endif -->
|
||||
|
||||
<!-- #ifdef MP-WEIXIN -->
|
||||
<u-button type="primary">微信小程序按钮</u-button>
|
||||
<!-- #endif -->
|
||||
|
||||
<!-- #ifdef APP-PLUS -->
|
||||
<u-button type="primary">App 按钮</u-button>
|
||||
<!-- #endif -->
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
// #ifdef H5
|
||||
// H5 specific code
|
||||
const h5Function = () => {
|
||||
console.log('H5 only')
|
||||
}
|
||||
// #endif
|
||||
|
||||
// #ifdef MP-WEIXIN
|
||||
// WeChat mini-program specific code
|
||||
const mpFunction = () => {
|
||||
console.log('MP only')
|
||||
}
|
||||
// #endif
|
||||
</script>
|
||||
```
|
||||
|
||||
### Example: Platform Testing Checklist
|
||||
|
||||
```markdown
|
||||
## Testing Checklist
|
||||
|
||||
### H5
|
||||
- [ ] Test in Chrome
|
||||
- [ ] Test in Safari
|
||||
- [ ] Test responsive design
|
||||
- [ ] Test browser compatibility
|
||||
|
||||
### Mini-Program
|
||||
- [ ] Test in WeChat DevTools
|
||||
- [ ] Test on actual device
|
||||
- [ ] Check code size
|
||||
- [ ] Test performance
|
||||
|
||||
### App
|
||||
- [ ] Test on Android device
|
||||
- [ ] Test on iOS device
|
||||
- [ ] Test native features
|
||||
- [ ] Test performance
|
||||
```
|
||||
|
||||
### Key Points
|
||||
|
||||
- Use conditional compilation for platform-specific code
|
||||
- Test on all target platforms
|
||||
- Configure platform-specific settings in manifest.json
|
||||
- Optimize for each platform's requirements
|
||||
- Handle platform differences gracefully
|
||||
- Document platform-specific behaviors
|
||||
Reference in New Issue
Block a user