feat(miniprogram): 通用组件 + 页面接入 — Chunk 7
- 创建 EmptyState/ErrorState/Loading 三个通用组件 - 8个列表页面接入通用组件替换内联空状态/loading - app.config.ts 添加 login 页面路由
This commit is contained in:
32
apps/miniprogram/src/components/ErrorState/index.scss
Normal file
32
apps/miniprogram/src/components/ErrorState/index.scss
Normal file
@@ -0,0 +1,32 @@
|
||||
@import '../../styles/variables.scss';
|
||||
|
||||
.error-state {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 120px 40px;
|
||||
}
|
||||
|
||||
.error-state-icon {
|
||||
font-size: 80px;
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
|
||||
.error-state-text {
|
||||
font-size: 28px;
|
||||
color: $tx2;
|
||||
margin-bottom: 32px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.error-state-retry {
|
||||
background: $pri;
|
||||
border-radius: 40px;
|
||||
padding: 16px 48px;
|
||||
}
|
||||
|
||||
.error-state-retry-text {
|
||||
font-size: 28px;
|
||||
color: #fff;
|
||||
}
|
||||
25
apps/miniprogram/src/components/ErrorState/index.tsx
Normal file
25
apps/miniprogram/src/components/ErrorState/index.tsx
Normal file
@@ -0,0 +1,25 @@
|
||||
import React from 'react';
|
||||
import { View, Text } from '@tarojs/components';
|
||||
import './index.scss';
|
||||
|
||||
interface ErrorStateProps {
|
||||
text?: string;
|
||||
onRetry?: () => void;
|
||||
}
|
||||
|
||||
export default function ErrorState({
|
||||
text = '加载失败,请稍后重试',
|
||||
onRetry,
|
||||
}: ErrorStateProps) {
|
||||
return (
|
||||
<View className='error-state'>
|
||||
<Text className='error-state-icon'>⚠️</Text>
|
||||
<Text className='error-state-text'>{text}</Text>
|
||||
{onRetry && (
|
||||
<View className='error-state-retry' onClick={onRetry}>
|
||||
<Text className='error-state-retry-text'>重新加载</Text>
|
||||
</View>
|
||||
)}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user