@appthen/cli 1.2.11 → 1.2.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/main.js +47 -0
- package/dist/index.js +6165 -14980
- package/package.json +8 -1
- package/tests/test-app/.appthen/shadow-space-100001-test-app-e99876b1.json +1197 -741
- package/tests/test-app/.appthen/space-config.json +2 -2
- package/tests/test-app/src/components/MessageCenter.tsx +506 -0
- package/tests/test-app/src/pages/CustomerManagement.tsx +535 -0
- package/tests/test-app/src/pages/CyberpunkDashboard.tsx +348 -0
- package/tests/test-app/src/pages/CyberpunkProductManagement.tsx +637 -0
- package/tests/test-app/src/pages/CyberpunkUserList.tsx +316 -0
- package/tests/test-app/src/pages/DashboardV2.tsx +334 -0
- package/tests/test-app/src/pages/DataReport.tsx +298 -0
- package/tests/test-app/src/pages/DataStatistics.tsx +317 -0
- package/tests/test-app/src/pages/DepartmentManagement.tsx +503 -0
- package/tests/test-app/src/pages/FileExplorer.tsx +441 -0
- package/tests/test-app/src/pages/OrderDetail.tsx +393 -0
- package/tests/test-app/src/pages/ProductManagement.tsx +521 -0
- package/tests/test-app/src/pages/ProjectTimeline.tsx +395 -0
- package/tests/test-app/src/pages/RoleManagement.tsx +523 -0
- package/tests/test-app/src/pages/StaticCyberpunkDashboard.tsx +462 -0
- package/tests/test-app/src/pages/StaticCyberpunkUserList.tsx +567 -0
- package/tests/test-app/src/pages/StudentWeaknessList.tsx +547 -0
- package/tests/test-app/src/pages/SystemSettings.tsx +422 -0
- package/tests/test-app/src/pages/TaskManagement.tsx +467 -0
- package/tests/test-app/src/pages/TicketManagement.tsx +402 -0
- package/tests/test-app/src/pages/UserProfile.tsx +404 -0
- package/tests/test-app/src/pages/WorkflowDesigner.tsx +434 -0
- package/tests/test-app/src/pages/admin/dashboard.tsx +591 -0
- package/tests/test-app/src/pages/article-list.tsx +222 -0
- package/tests/test-app/src/pages/babyProductRecommendationPage.tsx +168 -0
- package/tests/test-app/src/pages/category-list.tsx +179 -0
- package/tests/test-app/src/pages/comment-list.tsx +194 -0
- package/tests/test-app/src/pages/cyberpunk/cyberpunkCRMPage.tsx +1299 -0
- package/tests/test-app/src/pages/data-analytics.tsx +1872 -0
- package/tests/test-app/src/pages/data-overview.tsx +600 -0
- package/tests/test-app/src/pages/demo-error-page.tsx +119 -0
- package/tests/test-app/src/pages/department-list.tsx +183 -0
- package/tests/test-app/src/pages/goods-list.tsx +233 -0
- package/tests/test-app/src/pages/housekeeping/adminDashboardPage.tsx +880 -0
- package/tests/test-app/src/pages/mobile_terminal/uiHandsOnPractice.tsx +1 -1
- package/tests/test-app/src/pages/notice-list.tsx +217 -0
- package/tests/test-app/src/pages/order-detail.tsx +330 -0
- package/tests/test-app/src/pages/order-list.tsx +195 -0
- package/tests/test-app/src/pages/order-management.tsx +563 -0
- package/tests/test-app/src/pages/page/OrderList.tsx +230 -0
- package/tests/test-app/src/pages/role-list.tsx +184 -0
- package/tests/test-app/src/pages/simple/simplePage.tsx +92 -0
- package/tests/test-app/src/pages/simple-page.tsx +43 -0
- package/tests/test-app/src/pages/test-destructure.tsx +44 -0
- package/tests/test-app/src/pages/test-error-page.tsx +75 -0
- package/tests/test-app/src/pages/test-page-with-errors.tsx +51 -0
- package/tests/test-app/src/pages/test-page.tsx +101 -0
- package/tests/test-app/src/pages/test-render.tsx +52 -0
- package/tests/test-app/src/pages/test-return-type.tsx +41 -0
- package/tests/test-app/src/pages/test-type-assertion.tsx +37 -0
- package/tests/test-app/src/pages/ui/styleSelectorPage.tsx +1554 -0
- package/tests/test-app/src/pages/user-list.tsx +212 -0
- package/tests/test-app/src/pages/wrong-page.tsx +50 -0
- package/tests/test-app/.appthen/shadow-space-unknown-user-test-app-e99876b1.json +0 -1060
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 文章列表
|
|
3
|
+
* 查看和管理所有文章内容
|
|
4
|
+
*
|
|
5
|
+
* @type Page
|
|
6
|
+
* @route /articles
|
|
7
|
+
* @screen 1920w
|
|
8
|
+
* @frames web
|
|
9
|
+
*/
|
|
10
|
+
import React from 'react';
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class IProps {}
|
|
15
|
+
|
|
16
|
+
/*
|
|
17
|
+
* 数据与接口请求定义
|
|
18
|
+
*/
|
|
19
|
+
class IState {
|
|
20
|
+
articles?: {
|
|
21
|
+
/* @example 1 */id?: number,
|
|
22
|
+
/* @example 如何使用React构建高性能应用 */title?: string,
|
|
23
|
+
/* @example 张三 */author?: string,
|
|
24
|
+
/* @example 技术 */category?: string,
|
|
25
|
+
/* @example 1520 */views?: number,
|
|
26
|
+
/* @example published */status?: string,
|
|
27
|
+
/* @example 2024-01-15 */createTime?: string,
|
|
28
|
+
}[];
|
|
29
|
+
loading?: boolean;
|
|
30
|
+
searchKeyword?: string;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
class Document extends React.Component<IProps, IState> {
|
|
34
|
+
state = {
|
|
35
|
+
articles: [
|
|
36
|
+
{
|
|
37
|
+
id: 1,
|
|
38
|
+
title: '如何使用React构建高性能应用',
|
|
39
|
+
author: '张三',
|
|
40
|
+
category: '技术',
|
|
41
|
+
views: 1520,
|
|
42
|
+
status: 'published',
|
|
43
|
+
createTime: '2024-01-15',
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
id: 2,
|
|
47
|
+
title: '2024年前端发展趋势预测',
|
|
48
|
+
author: '李四',
|
|
49
|
+
category: '资讯',
|
|
50
|
+
views: 3280,
|
|
51
|
+
status: 'published',
|
|
52
|
+
createTime: '2024-02-20',
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
id: 3,
|
|
56
|
+
title: 'JavaScript高级特性解析',
|
|
57
|
+
author: '王五',
|
|
58
|
+
category: '教程',
|
|
59
|
+
views: 890,
|
|
60
|
+
status: 'draft',
|
|
61
|
+
createTime: '2024-03-10',
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
id: 4,
|
|
65
|
+
title: 'Vue3 Composition API最佳实践',
|
|
66
|
+
author: '赵六',
|
|
67
|
+
category: '教程',
|
|
68
|
+
views: 2150,
|
|
69
|
+
status: 'published',
|
|
70
|
+
createTime: '2024-04-05',
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
id: 5,
|
|
74
|
+
title: 'TypeScript入门指南',
|
|
75
|
+
author: '钱七',
|
|
76
|
+
category: '教程',
|
|
77
|
+
views: 4560,
|
|
78
|
+
status: 'published',
|
|
79
|
+
createTime: '2024-05-12',
|
|
80
|
+
},
|
|
81
|
+
],
|
|
82
|
+
loading: false,
|
|
83
|
+
searchKeyword: '',
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
handleSearch(value) {
|
|
87
|
+
this.setState({
|
|
88
|
+
searchKeyword: value,
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
handleAdd() {
|
|
93
|
+
console.log('添加文章');
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
handleEdit(record) {
|
|
97
|
+
console.log('编辑文章', record);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
handleDelete(record) {
|
|
101
|
+
console.log('删除文章', record);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
getStatusTag(status) {
|
|
105
|
+
if (status === 'published') {
|
|
106
|
+
return <Tag color="green">已发布</Tag>;
|
|
107
|
+
}
|
|
108
|
+
if (status === 'draft') {
|
|
109
|
+
return <Tag color="orange">草稿</Tag>;
|
|
110
|
+
}
|
|
111
|
+
return <Tag color="gray">下架</Tag>;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
getCategoryTag(category) {
|
|
115
|
+
const config = {
|
|
116
|
+
技术: {
|
|
117
|
+
text: '技术',
|
|
118
|
+
color: 'blue',
|
|
119
|
+
},
|
|
120
|
+
资讯: {
|
|
121
|
+
text: '资讯',
|
|
122
|
+
color: 'purple',
|
|
123
|
+
},
|
|
124
|
+
教程: {
|
|
125
|
+
text: '教程',
|
|
126
|
+
color: 'cyan',
|
|
127
|
+
},
|
|
128
|
+
分享: {
|
|
129
|
+
text: '分享',
|
|
130
|
+
color: 'green',
|
|
131
|
+
},
|
|
132
|
+
};
|
|
133
|
+
const configItem = config[category] || {
|
|
134
|
+
text: category,
|
|
135
|
+
color: 'default',
|
|
136
|
+
};
|
|
137
|
+
return <Tag color={configItem.color}>{configItem.text}</Tag>;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
render() {
|
|
141
|
+
return (
|
|
142
|
+
<Page className="p-[24px] bg-[var(--gray-50)] min-h-screen">
|
|
143
|
+
<View className="mb-[24px]">
|
|
144
|
+
<h1 className="text-2xl font-bold text-[#1f2937]">文章列表</h1>
|
|
145
|
+
<p className="text-[#6b7280] text-sm mt-[4px]">
|
|
146
|
+
管理系统中的所有文章内容
|
|
147
|
+
</p>
|
|
148
|
+
</View>
|
|
149
|
+
<Card className="mb-[24px]">
|
|
150
|
+
<View className="flex items-center justify-between">
|
|
151
|
+
<Input
|
|
152
|
+
placeholder="搜索文章标题/作者"
|
|
153
|
+
value={this.state.searchKeyword}
|
|
154
|
+
onChange={e => this.handleSearch(e.target.value)}
|
|
155
|
+
prefix="🔍"
|
|
156
|
+
className=""
|
|
157
|
+
/>
|
|
158
|
+
<Button type="primary" onClick={() => this.handleAdd()}>
|
|
159
|
+
+ 新增文章
|
|
160
|
+
</Button>
|
|
161
|
+
</View>
|
|
162
|
+
</Card>
|
|
163
|
+
<Card>
|
|
164
|
+
<Table
|
|
165
|
+
loading={this.state.loading}
|
|
166
|
+
columns={[
|
|
167
|
+
{ title: 'ID', dataIndex: 'id', key: 'id', width: 80 },
|
|
168
|
+
{ title: '文章标题', dataIndex: 'title', key: 'title' },
|
|
169
|
+
{ title: '作者', dataIndex: 'author', key: 'author' },
|
|
170
|
+
{
|
|
171
|
+
title: '分类',
|
|
172
|
+
dataIndex: 'category',
|
|
173
|
+
key: 'category',
|
|
174
|
+
render: function (text) {
|
|
175
|
+
return this.getCategoryTag(text);
|
|
176
|
+
},
|
|
177
|
+
},
|
|
178
|
+
{ title: '阅读量', dataIndex: 'views', key: 'views' },
|
|
179
|
+
{
|
|
180
|
+
title: '状态',
|
|
181
|
+
dataIndex: 'status',
|
|
182
|
+
key: 'status',
|
|
183
|
+
render: function (text) {
|
|
184
|
+
return this.getStatusTag(text);
|
|
185
|
+
},
|
|
186
|
+
},
|
|
187
|
+
{ title: '创建时间', dataIndex: 'createTime', key: 'createTime' },
|
|
188
|
+
{
|
|
189
|
+
title: '操作',
|
|
190
|
+
key: 'action',
|
|
191
|
+
render: (text, record) => (
|
|
192
|
+
<Space>
|
|
193
|
+
<Button type="link" onClick={() => this.handleEdit(record)}>
|
|
194
|
+
编辑
|
|
195
|
+
</Button>
|
|
196
|
+
<Button
|
|
197
|
+
type="link"
|
|
198
|
+
danger={true}
|
|
199
|
+
onClick={() => this.handleDelete(record)}
|
|
200
|
+
>
|
|
201
|
+
删除
|
|
202
|
+
</Button>
|
|
203
|
+
</Space>
|
|
204
|
+
),
|
|
205
|
+
},
|
|
206
|
+
]}
|
|
207
|
+
dataSource={this.state.articles}
|
|
208
|
+
rowKey="id"
|
|
209
|
+
pagination={{
|
|
210
|
+
pageSize: 10,
|
|
211
|
+
showTotal: function (total) {
|
|
212
|
+
return `共 ${total} 条`;
|
|
213
|
+
},
|
|
214
|
+
}}
|
|
215
|
+
/>
|
|
216
|
+
</Card>
|
|
217
|
+
</Page>
|
|
218
|
+
);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
export default Document;
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 3岁宝宝商品推荐页面 - iPad App 单页应用
|
|
3
|
+
* @type Page
|
|
4
|
+
* @route /baby-products
|
|
5
|
+
* @screen 1400x900 #f5f5f7
|
|
6
|
+
* @frames web
|
|
7
|
+
*/
|
|
8
|
+
import React from 'react';
|
|
9
|
+
import { Page, Text, View } from '@appthen/react';
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class IProps {
|
|
13
|
+
/* 页面标题 */
|
|
14
|
+
title?: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/*
|
|
18
|
+
* 数据与接口请求定义
|
|
19
|
+
*/
|
|
20
|
+
class IState {
|
|
21
|
+
/* 商品列表 */
|
|
22
|
+
products?: {
|
|
23
|
+
/* @example 1 */id?: number,
|
|
24
|
+
/* @example 乐高得宝系列 积木桶 */name?: string,
|
|
25
|
+
/* @example 299 */price?: number,
|
|
26
|
+
/* @example 益智玩具 */category?: string,
|
|
27
|
+
tags?: string[],
|
|
28
|
+
/* @example 4.8 */rating?: number,
|
|
29
|
+
/* @example 5200 */sales?: number,
|
|
30
|
+
/* @example 专为1-5岁儿童设计的大颗粒积木,色彩鲜艳,材质安全,锻炼宝宝手眼协调能力和创造力。 */description?: string,
|
|
31
|
+
/* @example 🧱 */image?: string,
|
|
32
|
+
}[];
|
|
33
|
+
/* 选中的分类 */
|
|
34
|
+
selectedCategory?: string;
|
|
35
|
+
/* 搜索关键词 */
|
|
36
|
+
searchKeyword?: string;
|
|
37
|
+
/* 模态框显示状态 */
|
|
38
|
+
modalVisible?: boolean;
|
|
39
|
+
/* 当前查看的商品 */
|
|
40
|
+
currentProduct?: any;
|
|
41
|
+
/* 购物车数量 */
|
|
42
|
+
cartCount?: number;
|
|
43
|
+
/* 当前激活的页面 */
|
|
44
|
+
activePage?: string;
|
|
45
|
+
/* 收藏的商品列表 */
|
|
46
|
+
favorites?: string[];
|
|
47
|
+
/* 购物车商品列表 */
|
|
48
|
+
cartItems?: string[];
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
class Document extends React.Component<IProps, IState> {
|
|
53
|
+
state = {"products": [{"id": 1, "name": "乐高得宝系列 积木桶", "price": 299, "category": "益智玩具", "tags": ["大颗粒", "安全材质"], "rating": 4.8, "sales": 5200, "description": "专为1-5岁儿童设计的大颗粒积木,色彩鲜艳,材质安全,锻炼宝宝手眼协调能力和创造力。", "image": "🧱"}, {"id": 2, "name": "小猪佩奇精装绘本套装", "price": 158, "category": "儿童绘本", "tags": ["精装", "双语"], "rating": 4.9, "sales": 8900, "description": "包含20册经典小猪佩奇故事,中英双语对照,精装印刷,培养宝宝阅读兴趣和语言能力。", "image": "📚"}, {"id": 3, "name": "纯棉卡通连体衣", "price": 89, "category": "童装", "tags": ["纯棉", "透气"], "rating": 4.7, "sales": 3200, "description": "100%纯棉材质,柔软舒适,卡通印花可爱,适合3岁宝宝日常穿着。", "image": "👕"}, {"id": 4, "name": "儿童平衡车", "price": 399, "category": "运动玩具", "tags": ["可调节", "防滑"], "rating": 4.8, "sales": 4100, "description": "无脚踏设计,锻炼宝宝平衡能力,座椅高度可调节,防滑轮胎更安全。", "image": "🚲"}, {"id": 5, "name": "磁性拼图玩具", "price": 129, "category": "益智玩具", "tags": ["磁性", "益智"], "rating": 4.6, "sales": 2800, "description": "磁性拼图板,包含动物、水果等多种图案,锻炼宝宝认知能力和动手能力。", "image": "🧩"}, {"id": 6, "name": "儿童水彩笔套装", "price": 59, "category": "艺术启蒙", "tags": ["可水洗", "无毒"], "rating": 4.7, "sales": 4500, "description": "24色可水洗水彩笔,无毒安全,让宝宝尽情发挥创造力。", "image": "🎨"}, {"id": 7, "name": "毛绒安抚玩具熊", "price": 169, "category": "安抚玩具", "tags": ["柔软", "可机洗"], "rating": 4.9, "sales": 6700, "description": "超柔软毛绒材质,可爱造型,给宝宝温暖的陪伴感。", "image": "🧸"}, {"id": 8, "name": "儿童安全剪刀", "price": 29, "category": "艺术启蒙", "tags": ["圆头", "安全"], "rating": 4.5, "sales": 3900, "description": "专为儿童设计的安全剪刀,圆头设计,保护宝宝手指安全。", "image": "✂️"}], "selectedCategory": "全部", "searchKeyword": "", "modalVisible": false, "cartCount": 0, "activePage": "home", "favorites": [], "cartItems": []}
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
handleCategoryChange(category) {
|
|
57
|
+
this.setState({
|
|
58
|
+
selectedCategory: category
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
handleSearch(keyword) {
|
|
64
|
+
this.setState({
|
|
65
|
+
searchKeyword: keyword
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
handleViewDetail(product) {
|
|
71
|
+
this.setState({
|
|
72
|
+
modalVisible: true,
|
|
73
|
+
currentProduct: product
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
handleModalClose() {
|
|
79
|
+
this.setState({
|
|
80
|
+
modalVisible: false
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
handleAddToCart(product) {
|
|
86
|
+
const existingItem = this.state.cartItems.find(item => item.id === product.id);
|
|
87
|
+
if (existingItem) {
|
|
88
|
+
this.setState(prevState => ({
|
|
89
|
+
cartItems: prevState.cartItems.map(item => item.id === product.id ? {
|
|
90
|
+
...item,
|
|
91
|
+
quantity: item.quantity + 1
|
|
92
|
+
} : item),
|
|
93
|
+
cartCount: prevState.cartCount + 1
|
|
94
|
+
}));
|
|
95
|
+
} else {
|
|
96
|
+
this.setState(prevState => ({
|
|
97
|
+
cartItems: [...prevState.cartItems, {
|
|
98
|
+
...product,
|
|
99
|
+
quantity: 1
|
|
100
|
+
}],
|
|
101
|
+
cartCount: prevState.cartCount + 1
|
|
102
|
+
}));
|
|
103
|
+
}
|
|
104
|
+
this.utils.toast(`已将 "${product.name}" 加入购物车`);
|
|
105
|
+
this.handleModalClose();
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
handleToggleFavorite(product) {
|
|
110
|
+
const exists = this.state.favorites.find(f => f.id === product.id);
|
|
111
|
+
if (exists) {
|
|
112
|
+
this.setState(prevState => ({
|
|
113
|
+
favorites: prevState.favorites.filter(f => f.id !== product.id)
|
|
114
|
+
}));
|
|
115
|
+
this.utils.toast('已取消收藏');
|
|
116
|
+
} else {
|
|
117
|
+
this.setState(prevState => ({
|
|
118
|
+
favorites: [...prevState.favorites, product]
|
|
119
|
+
}));
|
|
120
|
+
this.utils.toast('已收藏');
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
handleRemoveFromCart(productId) {
|
|
126
|
+
const item = this.state.cartItems.find(i => i.id === productId);
|
|
127
|
+
this.setState(prevState => ({
|
|
128
|
+
cartItems: prevState.cartItems.filter(i => i.id !== productId),
|
|
129
|
+
cartCount: prevState.cartCount - (item?.quantity || 0)
|
|
130
|
+
}));
|
|
131
|
+
this.utils.toast('已从购物车移除');
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
handlePageChange(page) {
|
|
136
|
+
this.setState({
|
|
137
|
+
activePage: page
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
getFilteredProducts() {
|
|
143
|
+
let products = this.state.products || [];
|
|
144
|
+
if (this.state.selectedCategory !== '全部') {
|
|
145
|
+
products = products.filter(p => p.category === this.state.selectedCategory);
|
|
146
|
+
}
|
|
147
|
+
if (this.state.searchKeyword) {
|
|
148
|
+
const keyword = this.state.searchKeyword.toLowerCase();
|
|
149
|
+
products = products.filter(p => p.name.toLowerCase().includes(keyword) || p.category.toLowerCase().includes(keyword));
|
|
150
|
+
}
|
|
151
|
+
return products;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
render() {
|
|
155
|
+
const filteredProducts = this.getFilteredProducts();
|
|
156
|
+
const isFavorite = product => this.state.favorites?.find(f => f.id === product.id);
|
|
157
|
+
return (<Page className="bg-gradient-to-br from-[#fdf2f8] via-purple-50 to-blue-50 min-h-screen flex"><View className="bg-white/80 backdrop-blur-md w-[256px] shadow-[0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1)] flex flex-col"><View className="border-gray-100 p-[24px] border-b-[1px] border-b-solid"><h1 className="bg-gradient-to-r from-[#ec4899] to-purple-500 [WebkitBackgroundClip:text] [WebkitTextFillColor:transparent] [backgroundClip:text] [backgroundClip:text] [WebkitBackgroundClip:text] text-[transparent] text-2xl font-bold">👶 宝宝好物</h1><p className="text-[#6b7280] text-sm mt-[4px]">3岁宝宝专属商城</p></View><nav className="space-y-2 flex-1 p-[16px]"><button onClick={() => this.handlePageChange('home')} className={`w-full flex items-center space-x-3 px-4 py-3 rounded-xl transition-all ${this.state.activePage === "home" ? "bg-gradient-to-r from-pink-500 to-purple-500 text-white shadow-md" : "text-gray-600 hover:bg-pink-50"}`}><Text className="text-xl">🏠</Text><Text className="font-medium">首页推荐</Text></button><button onClick={() => this.handlePageChange('categories')} className={`w-full flex items-center space-x-3 px-4 py-3 rounded-xl transition-all ${this.state.activePage === "categories" ? "bg-gradient-to-r from-pink-500 to-purple-500 text-white shadow-md" : "text-gray-600 hover:bg-pink-50"}`}><Text className="text-xl">📂</Text><Text className="font-medium">商品分类</Text></button><button onClick={() => this.handlePageChange('favorites')} className={`w-full flex items-center space-x-3 px-4 py-3 rounded-xl transition-all ${this.state.activePage === "favorites" ? "bg-gradient-to-r from-pink-500 to-purple-500 text-white shadow-md" : "text-gray-600 hover:bg-pink-50"}`}><Text className="text-xl">❤️</Text><Text className="font-medium">我的收藏</Text>{!!(this.state.favorites?.length > 0) && (<Text className="ml-[auto] bg-[#ef4444] text-[#ffffff] text-xs pl-[8px] pr-[8px] pt-[0px] pb-[0px] rounded-full">{this.state.favorites.length}</Text>)}</button><button onClick={() => this.handlePageChange('cart')} className={`w-full flex items-center space-x-3 px-4 py-3 rounded-xl transition-all ${this.state.activePage === "cart" ? "bg-gradient-to-r from-pink-500 to-purple-500 text-white shadow-md" : "text-gray-600 hover:bg-pink-50"}`}><Text className="text-xl">🛒</Text><Text className="font-medium">购物车</Text>{!!(this.state.cartCount > 0) && (<Text className="ml-[auto] bg-[#ef4444] text-[#ffffff] text-xs pl-[8px] pr-[8px] pt-[0px] pb-[0px] rounded-full">{this.state.cartCount}</Text>)}</button><button onClick={() => this.handlePageChange('profile')} className={`w-full flex items-center space-x-3 px-4 py-3 rounded-xl transition-all ${this.state.activePage === "profile" ? "bg-gradient-to-r from-pink-500 to-purple-500 text-white shadow-md" : "text-gray-600 hover:bg-pink-50"}`}><Text className="text-xl">👤</Text><Text className="font-medium">个人中心</Text></button></nav><View className="border-gray-100 p-[16px] border-t border-t-solid"><View className="text-xs text-[var(--center)]">© 2024 宝宝好物商城</View></View></View><View className="flex-1 overflow-hidden flex flex-col"><View className="bg-white/80 backdrop-blur-md shadow-[0 1px 2px 0 rgb(0 0 0 / 0.05)] pl-[32px] pr-[32px] pt-[16px] pb-[16px]"><View className="flex items-center justify-between"><View className="relative w-[384px]"><input type="text" placeholder="搜索商品..." value={this.state.searchKeyword} onChange={(e) => this.handleSearch(e.target.value)} className="focus:outline-none focus:ring-2 focus:ring-pink-300 w-full pl-[48px] pr-[16px] pt-[12px] pb-[12px] bg-[#f3f4f6] rounded-2xl" /><Text className="top-1/2 transform -translate-y-1/2 absolute left-[16px] text-[#9ca3af]">🔍</Text></View><View className="space-x-4 flex items-center"><button className="text-gray-500 hover:text-pink-500 transition-colors p-[8px]">🔔</button><View className="bg-gradient-to-r from-[#ec4899] to-purple-500 w-[40px] h-[40px] rounded-full flex items-center justify-center text-[#ffffff] font-bold">B</View></View></View></View><View className="flex-1 overflow-y-auto p-[32px]">{!!(this.state.activePage === 'home') && (<View><View className="bg-gradient-to-r from-[#ec4899] to-purple-500 rounded-3xl p-[32px] mb-[32px] text-[#ffffff]"><h2 className="text-3xl font-bold mb-[8px]">精选好物推荐</h2><p className="text-[var(--pink-100)]">为3岁宝宝挑选的优质商品</p></View><View className="space-x-3 flex items-center mb-[24px]">{(this.categories).map((category, index) => (<button key={category} onClick={() => this.handleCategoryChange(category)} className={`px-5 py-2 rounded-full text-sm font-medium transition-all whitespace-nowrap ${this.state.selectedCategory === category ? "bg-gradient-to-r from-pink-500 to-purple-500 text-white shadow-md" : "bg-white text-gray-600 border border-gray-200 hover:border-pink-300"}`}><Text>{category}</Text></button>))}</View>{!!(filteredProducts.length === 0) && (<View className="text-[var(--center)] pt-[80px] pb-[80px]"><Text className="text-6xl">🔍</Text><p className="text-[#6b7280] mt-[16px]">没有找到相关商品</p></View>)}{(!(filteredProducts.length === 0)) && (<View className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6">{(filteredProducts).map((product, index) => (<View key={product.id} className="shadow-lg hover:shadow-2xl transition-all duration-300 transform hover:-translate-y-2 group bg-[#ffffff] rounded-2xl overflow-hidden cursor-pointer"><View className="bg-gradient-to-br from-[#fce7f3] to-purple-100 h-[192px] flex items-center justify-center relative overflow-hidden"><Text className="group-hover:scale-110 transition-transform duration-300 text-[72px]">{product.image}</Text><View className="bg-white/90 backdrop-blur-sm absolute top-[12px] right-[12px] pl-[12px] pr-[12px] pt-[4px] pb-[4px] rounded-full text-xs font-medium text-[#ec4899]"><Text>{product.category}</Text></View><button onClick={(e) => {e.stopPropagation();
|
|
158
|
+
this.handleToggleFavorite(product);}} className="bg-white/90 backdrop-blur-sm hover:scale-110 transition-transform absolute top-[12px] left-[12px] w-[40px] h-[40px] rounded-full flex items-center justify-center"><Text className={isFavorite(product) ? "text-red-500" : "text-gray-300"}>{isFavorite(product) ? '❤️' : '🤍'}</Text></button></View><View className="p-[16px]"><h3 className="line-clamp-2 font-bold text-[#1f2937] text-lg mb-[8px]">{product.name}</h3><View className="gap-2 flex flex-wrap mb-[12px]">{(product.tags).map((tag, index) => (<Text key={tag} className="pl-[8px] pr-[8px] pt-[4px] pb-[4px] bg-[var(--pink-50)] text-[var(--pink-600)] text-xs rounded-full">{tag}</Text>))}</View><View className="flex items-center justify-between mb-[12px]"><View className="space-x-1 flex items-center"><Text className="text-[var(--yellow-400)]">⭐</Text><Text className="text-sm font-medium text-[#374151]">{product.rating}</Text></View><Text className="text-xs text-[#9ca3af]">已售{product.sales > 1000 ? (product.sales / 1000).toFixed(1) + 'k' : product.sales}</Text></View><View className="flex items-center justify-between"><View className="flex items-baseline"><Text className="text-2xl font-bold text-[#ec4899]">¥{product.price}</Text></View><button onClick={(e) => {e.stopPropagation();
|
|
159
|
+
this.handleAddToCart(product);}} className="hover:shadow-lg transition-all bg-gradient-to-r from-[#ec4899] to-purple-500 pl-[16px] pr-[16px] pt-[8px] pb-[8px] text-[#ffffff] rounded-full text-sm font-medium">加入购物车</button></View></View></View>))}</View>)}</View>)}{!!(this.state.activePage === 'categories') && (<View><h2 className="text-2xl font-bold text-[#1f2937] mb-[24px]">商品分类</h2><View className="grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-4">{(this.categories.filter(c => c !== '全部')).map((category, index) => (<View key={category} onClick={() => {this.handleCategoryChange(category);
|
|
160
|
+
this.handlePageChange('home');}} className="shadow-lg hover:shadow-2xl transition-all group bg-[#ffffff] rounded-2xl p-[24px] cursor-pointer text-[var(--center)]"><Text className="block group-hover:scale-110 transition-transform text-5xl mb-[16px]">{category === '益智玩具' ? '🧩' : category === '儿童绘本' ? '📚' : category === '童装' ? '👕' : category === '运动玩具' ? '🚲' : category === '艺术启蒙' ? '🎨' : '🧸'}</Text><h3 className="font-bold text-[#1f2937]">{category}</h3><p className="text-sm text-[#6b7280] mt-[4px]">{this.state.products?.filter(function (p) {
|
|
161
|
+
return p.category === category;
|
|
162
|
+
}).length}件商品</p></View>))}</View></View>)}{!!(this.state.activePage === 'favorites') && (<View><h2 className="text-2xl font-bold text-[#1f2937] mb-[24px]">我的收藏</h2>{!!(this.state.favorites?.length === 0) && (<View className="text-[var(--center)] pt-[80px] pb-[80px]"><Text className="text-6xl">❤️</Text><p className="text-[#6b7280] mt-[16px]">还没有收藏商品</p></View>)}{(!(this.state.favorites?.length === 0)) && (<View className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6">{(this.state.favorites).map((product, index) => (<View key={product.id} className="shadow-lg hover:shadow-2xl transition-all duration-300 transform hover:-translate-y-2 group bg-[#ffffff] rounded-2xl overflow-hidden cursor-pointer"><View className="bg-gradient-to-br from-[#fce7f3] to-purple-100 h-[192px] flex items-center justify-center relative overflow-hidden"><Text className="group-hover:scale-110 transition-transform duration-300 text-[72px]">{product.image}</Text><View className="bg-white/90 backdrop-blur-sm absolute top-[12px] right-[12px] pl-[12px] pr-[12px] pt-[4px] pb-[4px] rounded-full text-xs font-medium text-[#ec4899]"><Text>{product.category}</Text></View><button onClick={(e) => {e.stopPropagation();
|
|
163
|
+
this.handleToggleFavorite(product);}} className="bg-white/90 backdrop-blur-sm hover:scale-110 transition-transform absolute top-[12px] left-[12px] w-[40px] h-[40px] rounded-full flex items-center justify-center"><Text className="text-[#ef4444]">❤️</Text></button></View><View className="p-[16px]"><h3 className="line-clamp-2 font-bold text-[#1f2937] text-lg mb-[8px]">{product.name}</h3><View className="gap-2 flex flex-wrap mb-[12px]">{(product.tags).map((tag, index) => (<Text key={tag} className="pl-[8px] pr-[8px] pt-[4px] pb-[4px] bg-[var(--pink-50)] text-[var(--pink-600)] text-xs rounded-full">{tag}</Text>))}</View><View className="flex items-center justify-between mb-[12px]"><View className="space-x-1 flex items-center"><Text className="text-[var(--yellow-400)]">⭐</Text><Text className="text-sm font-medium text-[#374151]">{product.rating}</Text></View><Text className="text-xs text-[#9ca3af]">已售{product.sales > 1000 ? (product.sales / 1000).toFixed(1) + 'k' : product.sales}</Text></View><View className="flex items-center justify-between"><View className="flex items-baseline"><Text className="text-2xl font-bold text-[#ec4899]">¥{product.price}</Text></View><button onClick={(e) => {e.stopPropagation();
|
|
164
|
+
this.handleAddToCart(product);}} className="hover:shadow-lg transition-all bg-gradient-to-r from-[#ec4899] to-purple-500 pl-[16px] pr-[16px] pt-[8px] pb-[8px] text-[#ffffff] rounded-full text-sm font-medium">加入购物车</button></View></View></View>))}</View>)}</View>)}{!!(this.state.activePage === 'cart') && (<View><h2 className="text-2xl font-bold text-[#1f2937] mb-[24px]">购物车</h2>{!!(this.state.cartItems?.length === 0) && (<View className="text-[var(--center)] pt-[80px] pb-[80px] flex flex-col justify-center items-center"><Text className="text-6xl">🛒</Text><p className="text-[#6b7280] mt-[16px]">购物车是空的</p></View>)}{(!(this.state.cartItems?.length === 0)) && (<View className="space-y-4">{(this.state.cartItems).map((item, index) => (<View key={item.id} className="space-x-6 bg-[#ffffff] rounded-2xl p-[24px] shadow-[0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1)] flex items-center"><View className="bg-gradient-to-br from-[#fce7f3] to-purple-100 w-[96px] h-[96px] rounded-xl flex items-center justify-center"><Text className="text-5xl">{item.image}</Text></View><View className="flex-1"><h3 className="font-bold text-[#1f2937] text-lg mb-[8px]">{item.name}</h3><View className="space-x-2 flex items-center"><Text className="pl-[12px] pr-[12px] pt-[4px] pb-[4px] bg-[var(--pink-100)] text-[var(--pink-600)] rounded-full text-xs">{item.category}</Text><Text className="text-sm text-[#6b7280]">数量:{item.quantity}</Text></View></View><View className="text-[var(--right)]"><View className="text-2xl font-bold text-[#ec4899]">¥<Text>{item.price * item.quantity}</Text></View><button onClick={() => this.handleRemoveFromCart(item.id)} className="text-sm text-red-500 hover:text-red-700 mt-[8px]">移除</button></View></View>))}<View className="bg-[#ffffff] rounded-2xl p-[24px] shadow-[0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1)] mt-[24px]"><View className="flex items-center justify-between"><Text className="text-xl font-bold text-[#1f2937]">总计</Text><Text className="text-3xl font-bold text-[#ec4899]">¥{this.state.cartItems?.reduce((sum, this.item) => sum + this.item.price * this.item.quantity, 0)}</Text></View><button className="hover:shadow-lg transition-all bg-gradient-to-r from-[#ec4899] to-purple-500 w-full mt-[16px] pt-[16px] pb-[16px] text-[#ffffff] rounded-2xl font-bold text-lg">去结算</button></View></View>)}</View>)}{!!(this.state.activePage === 'profile') && (<View><View className="bg-[#ffffff] rounded-2xl p-[32px] shadow-[0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1)] mb-[24px]"><View className="space-x-6 flex items-center"><View className="bg-gradient-to-r from-[#ec4899] to-purple-500 w-[80px] h-[80px] rounded-full flex items-center justify-center text-[#ffffff] text-3xl font-bold">B</View><View><h2 className="text-2xl font-bold text-[#1f2937]">宝妈用户</h2><p className="text-[#6b7280]">3岁宝宝的妈妈</p></View></View></View><View className="grid grid-cols-1 md:grid-cols-2 gap-6"><View className="bg-[#ffffff] rounded-2xl p-[24px] shadow-[0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1)]"><h3 className="font-bold text-[#1f2937] mb-[16px]">我的订单</h3><View className="space-y-3"><View className="border-gray-100 flex items-center justify-between pt-[12px] pb-[12px] border-b-[1px] border-b-solid"><Text className="text-[#4b5563]">待付款</Text><Text className="text-[#ec4899] font-bold">0</Text></View><View className="border-gray-100 flex items-center justify-between pt-[12px] pb-[12px] border-b-[1px] border-b-solid"><Text className="text-[#4b5563]">待发货</Text><Text className="text-[#ec4899] font-bold">0</Text></View><View className="border-gray-100 flex items-center justify-between pt-[12px] pb-[12px] border-b-[1px] border-b-solid"><Text className="text-[#4b5563]">待收货</Text><Text className="text-[#ec4899] font-bold">0</Text></View><View className="flex items-center justify-between pt-[12px] pb-[12px]"><Text className="text-[#4b5563]">已完成</Text><Text className="text-[#ec4899] font-bold">0</Text></View></View></View><View className="bg-[#ffffff] rounded-2xl p-[24px] shadow-[0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1)]"><h3 className="font-bold text-[#1f2937] mb-[16px]">账户设置</h3><View className="space-y-3"><button className="border-gray-100 hover:bg-gray-50 w-full flex items-center justify-between pt-[12px] pb-[12px] border-b-[1px] border-b-solid rounded-lg pl-[12px] pr-[12px]"><Text className="text-[#4b5563]">收货地址</Text><Text className="text-[#9ca3af]">›</Text></button><button className="border-gray-100 hover:bg-gray-50 w-full flex items-center justify-between pt-[12px] pb-[12px] border-b-[1px] border-b-solid rounded-lg pl-[12px] pr-[12px]"><Text className="text-[#4b5563]">优惠券</Text><Text className="text-[#9ca3af]">›</Text></button><button className="border-gray-100 hover:bg-gray-50 w-full flex items-center justify-between pt-[12px] pb-[12px] border-b-[1px] border-b-solid rounded-lg pl-[12px] pr-[12px]"><Text className="text-[#4b5563]">消息通知</Text><Text className="text-[#9ca3af]">›</Text></button><button className="hover:bg-gray-50 w-full flex items-center justify-between pt-[12px] pb-[12px] rounded-lg pl-[12px] pr-[12px]"><Text className="text-[#4b5563]">帮助中心</Text><Text className="text-[#9ca3af]">›</Text></button></View></View></View></View>)}</View></View>{(!!this.state.modalVisible && this.state.currentProduct) && (<View className="inset-0 bg-black/50 backdrop-blur-sm fixed flex items-center justify-center z-50 p-[16px]"><View className="bg-[#ffffff] rounded-3xl shadow-[0 25px 50px -12px rgb(0 0 0 / 0.25)] w-full max-h-90vh overflow-y-auto"><View className="relative"><View className="bg-gradient-to-br from-[#fce7f3] to-purple-100 h-[256px] flex items-center justify-center"><Text className="text-[128px]">{this.state.currentProduct.image}</Text></View><button onClick={() => this.handleModalClose()} className="bg-white/90 backdrop-blur-sm hover:bg-white transition-colors absolute top-[16px] right-[16px] w-[40px] h-[40px] rounded-full flex items-center justify-center shadow-[0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1)]">✕</button></View><View className="p-[24px]"><View className="flex items-start justify-between mb-[16px]"><View className="flex-1"><h2 className="text-2xl font-bold text-[#1f2937] mb-[8px]">{this.state.currentProduct.name}</h2><View className="space-x-2 flex items-center"><Text className="pl-[12px] pr-[12px] pt-[4px] pb-[4px] bg-[var(--pink-100)] text-[var(--pink-600)] rounded-full text-sm">{this.state.currentProduct.category}</Text><View className="space-x-1 flex items-center"><Text className="text-[var(--yellow-400)]">⭐</Text><Text className="text-sm font-medium text-[#374151]">{this.state.currentProduct.rating}</Text></View></View></View><View className="text-[var(--right)]"><View className="text-3xl font-bold text-[#ec4899]">¥<Text>{this.state.currentProduct.price}</Text></View><View className="text-sm text-[#9ca3af] mt-[4px]">已售{this.state.currentProduct.sales > 1000 ? (this.state.currentProduct.sales / 1000).toFixed(1) + "k" : this.state.currentProduct.sales}</View></View></View><View className="gap-2 flex flex-wrap mb-[24px]">{(this.state.currentProduct.tags).map((tag, index) => (<Text key={tag} className="pl-[12px] pr-[12px] pt-[4px] pb-[4px] bg-[var(--purple-50)] text-[var(--purple-600)] rounded-full text-sm">{tag}</Text>))}</View><View className="mb-[24px]"><h3 className="font-bold text-[#1f2937] mb-[8px]">商品介绍</h3><p className="text-[#4b5563] [lineHeight:1.625]">{this.state.currentProduct.description}</p></View><View className="space-x-4 flex"><button onClick={() => this.handleAddToCart(this.state.currentProduct)} className="hover:shadow-lg transition-all bg-gradient-to-r from-[#ec4899] to-purple-500 flex-1 pt-[12px] pb-[12px] text-[#ffffff] rounded-xl font-bold">🛒 加入购物车</button><button onClick={() => this.handleToggleFavorite(this.state.currentProduct)} className="border-2 border-pink-300 hover:bg-pink-50 transition-colors flex-1 pt-[12px] pb-[12px] text-[#ec4899] rounded-xl font-bold">{isFavorite(this.state.currentProduct) ? "❤️ 已收藏" : "🤍 收藏"}</button></View></View></View></View>)}</Page>);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
export default Document;
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 分类列表
|
|
3
|
+
* 查看和管理所有商品分类
|
|
4
|
+
*
|
|
5
|
+
* @type Page
|
|
6
|
+
* @route /categories
|
|
7
|
+
* @screen 1920w
|
|
8
|
+
* @frames web
|
|
9
|
+
*/
|
|
10
|
+
import React from 'react';
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class IProps {}
|
|
15
|
+
|
|
16
|
+
/*
|
|
17
|
+
* 数据与接口请求定义
|
|
18
|
+
*/
|
|
19
|
+
class IState {
|
|
20
|
+
categories?: {
|
|
21
|
+
/* @example 1 */id?: number,
|
|
22
|
+
/* @example 手机数码 */name?: string,
|
|
23
|
+
/* @example 无 */parent?: string,
|
|
24
|
+
/* @example 2580 */goodsCount?: number,
|
|
25
|
+
/* @example enabled */status?: string,
|
|
26
|
+
/* @example 2024-01-15 */createTime?: string,
|
|
27
|
+
}[];
|
|
28
|
+
loading?: boolean;
|
|
29
|
+
searchKeyword?: string;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
class Document extends React.Component<IProps, IState> {
|
|
33
|
+
state = {
|
|
34
|
+
categories: [
|
|
35
|
+
{
|
|
36
|
+
id: 1,
|
|
37
|
+
name: '手机数码',
|
|
38
|
+
parent: '无',
|
|
39
|
+
goodsCount: 2580,
|
|
40
|
+
status: 'enabled',
|
|
41
|
+
createTime: '2024-01-15',
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
id: 2,
|
|
45
|
+
name: '电脑办公',
|
|
46
|
+
parent: '无',
|
|
47
|
+
goodsCount: 1680,
|
|
48
|
+
status: 'enabled',
|
|
49
|
+
createTime: '2024-02-20',
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
id: 3,
|
|
53
|
+
name: '手机',
|
|
54
|
+
parent: '手机数码',
|
|
55
|
+
goodsCount: 1280,
|
|
56
|
+
status: 'enabled',
|
|
57
|
+
createTime: '2024-03-10',
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
id: 4,
|
|
61
|
+
name: '笔记本电脑',
|
|
62
|
+
parent: '电脑办公',
|
|
63
|
+
goodsCount: 980,
|
|
64
|
+
status: 'enabled',
|
|
65
|
+
createTime: '2024-04-05',
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
id: 5,
|
|
69
|
+
name: '服装鞋帽',
|
|
70
|
+
parent: '无',
|
|
71
|
+
goodsCount: 5860,
|
|
72
|
+
status: 'enabled',
|
|
73
|
+
createTime: '2024-05-12',
|
|
74
|
+
},
|
|
75
|
+
],
|
|
76
|
+
loading: false,
|
|
77
|
+
searchKeyword: '',
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
handleSearch(value) {
|
|
81
|
+
this.setState({
|
|
82
|
+
searchKeyword: value,
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
handleAdd() {
|
|
87
|
+
console.log('添加分类');
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
handleEdit(record) {
|
|
91
|
+
console.log('编辑分类', record);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
handleDelete(record) {
|
|
95
|
+
console.log('删除分类', record);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
getStatusTag(status) {
|
|
99
|
+
if (status === 'enabled') {
|
|
100
|
+
return <Tag color="green">启用</Tag>;
|
|
101
|
+
}
|
|
102
|
+
return <Tag color="gray">禁用</Tag>;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
render() {
|
|
106
|
+
return (
|
|
107
|
+
<Page className="p-[24px] bg-[var(--gray-50)] min-h-screen">
|
|
108
|
+
<View className="mb-[24px]">
|
|
109
|
+
<h1 className="text-2xl font-bold text-[#1f2937]">分类列表</h1>
|
|
110
|
+
<p className="text-[#6b7280] text-sm mt-[4px]">
|
|
111
|
+
管理系统中的所有商品分类
|
|
112
|
+
</p>
|
|
113
|
+
</View>
|
|
114
|
+
<Card className="mb-[24px]">
|
|
115
|
+
<View className="flex items-center justify-between">
|
|
116
|
+
<Input
|
|
117
|
+
placeholder="搜索分类名称"
|
|
118
|
+
value={this.state.searchKeyword}
|
|
119
|
+
onChange={e => this.handleSearch(e.target.value)}
|
|
120
|
+
prefix="🔍"
|
|
121
|
+
className=""
|
|
122
|
+
/>
|
|
123
|
+
<Button type="primary" onClick={() => this.handleAdd()}>
|
|
124
|
+
+ 新增分类
|
|
125
|
+
</Button>
|
|
126
|
+
</View>
|
|
127
|
+
</Card>
|
|
128
|
+
<Card>
|
|
129
|
+
<Table
|
|
130
|
+
loading={this.state.loading}
|
|
131
|
+
columns={[
|
|
132
|
+
{ title: 'ID', dataIndex: 'id', key: 'id', width: 80 },
|
|
133
|
+
{ title: '分类名称', dataIndex: 'name', key: 'name' },
|
|
134
|
+
{ title: '父级分类', dataIndex: 'parent', key: 'parent' },
|
|
135
|
+
{ title: '商品数量', dataIndex: 'goodsCount', key: 'goodsCount' },
|
|
136
|
+
{
|
|
137
|
+
title: '状态',
|
|
138
|
+
dataIndex: 'status',
|
|
139
|
+
key: 'status',
|
|
140
|
+
render: function (text) {
|
|
141
|
+
return this.getStatusTag(text);
|
|
142
|
+
},
|
|
143
|
+
},
|
|
144
|
+
{ title: '创建时间', dataIndex: 'createTime', key: 'createTime' },
|
|
145
|
+
{
|
|
146
|
+
title: '操作',
|
|
147
|
+
key: 'action',
|
|
148
|
+
render: (text, record) => (
|
|
149
|
+
<Space>
|
|
150
|
+
<Button type="link" onClick={() => this.handleEdit(record)}>
|
|
151
|
+
编辑
|
|
152
|
+
</Button>
|
|
153
|
+
<Button
|
|
154
|
+
type="link"
|
|
155
|
+
danger={true}
|
|
156
|
+
onClick={() => this.handleDelete(record)}
|
|
157
|
+
>
|
|
158
|
+
删除
|
|
159
|
+
</Button>
|
|
160
|
+
</Space>
|
|
161
|
+
),
|
|
162
|
+
},
|
|
163
|
+
]}
|
|
164
|
+
dataSource={this.state.categories}
|
|
165
|
+
rowKey="id"
|
|
166
|
+
pagination={{
|
|
167
|
+
pageSize: 10,
|
|
168
|
+
showTotal: function (total) {
|
|
169
|
+
return `共 ${total} 条`;
|
|
170
|
+
},
|
|
171
|
+
}}
|
|
172
|
+
/>
|
|
173
|
+
</Card>
|
|
174
|
+
</Page>
|
|
175
|
+
);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
export default Document;
|