Home.vue
27.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
<script setup lang="ts">
import type { GlobalState } from '@/qiankun';
import { onMounted, onUnmounted, ref } from 'vue';
// 按需引入 @venus/common-ui-vue 组件库的按钮组件
import { GLButton } from '@venus/common-ui-vue';
import { getdataBoard } from '@/api/test';
import { waitForConfigReady } from '@/config/center';
import { broadcast, communicationManager, microApps } from '@/qiankun';
import {
Check,
Delete,
Edit,
Message,
Search,
Star,
} from '@element-plus/icons-vue';
const apps = microApps;
// 全局状态
const globalState = ref<GlobalState | null>(null);
// 消息输入
const messageTitle = ref('来自主应用的消息');
const messageContent = ref('Hello from Main App!');
// 监听器的取消函数
let unsubscribe: (() => void) | null = null;
// GLButton 组件演示相关状态
const buttonLoading = ref(false);
const clickCount = ref(0);
// 初始化:获取全局状态并监听变化
onMounted(async () => {
// 等待配置加载完成后再发起请求
try {
await waitForConfigReady();
console.log('[Home] 配置已就绪,开始请求数据看板...');
const res = await getdataBoard({
merchantNos: '',
dateType: '1',
startDate: '',
endDate: '',
});
console.log('[Home] 数据看板请求成功:', res);
} catch (error: any) {
console.error('[Home] 数据看板请求失败:', error);
}
// 获取当前全局状态
globalState.value = communicationManager.getGlobalState();
// 监听全局状态变化
unsubscribe = communicationManager.onStateChange((state) => {
globalState.value = state;
});
});
// 组件卸载时取消监听
onUnmounted(() => {
if (unsubscribe) {
unsubscribe();
}
});
// 发送成功消息
const sendSuccessMessage = () => {
broadcast('success', '操作成功', '这是一条来自主应用的成功消息!');
};
// 发送自定义消息
const sendCustomMessage = () => {
if (!messageTitle.value || !messageContent.value) {
broadcast('error', '发送失败', '标题和内容不能为空!');
return;
}
communicationManager.addNotification({
type: 'info',
title: messageTitle.value,
message: messageContent.value,
from: '主应用',
});
messageTitle.value = '';
messageContent.value = '';
};
// 切换主题
const toggleTheme = () => {
const currentTheme = globalState.value?.theme.mode || 'light';
const newTheme = currentTheme === 'light' ? 'dark' : 'light';
communicationManager.updateTheme({
mode: newTheme,
});
broadcast(
'success',
'主题切换',
`已切换到${newTheme === 'dark' ? '深色' : '浅色'}模式`,
);
};
// 更新用户信息
const updateUserInfo = () => {
const newUser = {
id: '001',
name: '李四',
avatar: '👨💻',
role: 'developer',
permissions: ['read', 'write'],
};
communicationManager.updateUser(newUser);
broadcast('success', '用户更新', `用户信息已更新为: ${newUser.name}`);
};
// 清空所有通知
const clearAllNotifications = () => {
communicationManager.clearNotifications();
};
// 删除单个通知
const removeNotification = (id: string) => {
communicationManager.removeNotification(id);
};
// 格式化时间
const formatTime = (timestamp: number) => {
const date = new Date(timestamp);
return date.toLocaleTimeString('zh-CN');
};
// GLButton 组件演示方法
// 模拟异步操作
const handleAsyncClick = async () => {
buttonLoading.value = true;
broadcast('info', '异步操作', '正在处理异步操作...');
// 模拟 2 秒的异步操作
await new Promise((resolve) => setTimeout(resolve, 2000));
buttonLoading.value = false;
broadcast('success', '操作成功', '异步操作已完成!');
};
// 确认操作
const handleConfirmClick = () => {
broadcast('success', '确认成功', '你已确认执行该操作');
};
// 删除操作
const handleDeleteClick = () => {
broadcast('success', '删除成功', '删除操作已执行');
};
// 防抖点击
const handleDebounceClick = () => {
clickCount.value++;
broadcast('info', '防抖按钮', `第 ${clickCount.value} 次有效点击`);
};
</script>
<template>
<div class="home-page">
<div class="welcome-section">
<h1 class="title">欢迎使用 SCRM 微前端平台</h1>
<p class="subtitle">基于 qiankun + Vue3 + Vite 构建的微前端主应用</p>
</div>
<div class="feature-section">
<div class="feature-card">
<div class="feature-icon">微</div>
<h3 class="feature-title">微前端架构</h3>
<p class="feature-desc">
使用 qiankun 实现微前端架构,支持多业务线独立开发与部署。
</p>
</div>
<div class="feature-card">
<div class="feature-icon">速</div>
<h3 class="feature-title">Vue3 + Vite</h3>
<p class="feature-desc">
结合 Vue3 组合式 API 与 Vite 极致构建体验,显著提升开发效率。
</p>
</div>
<div class="feature-card">
<div class="feature-icon">拓</div>
<h3 class="feature-title">灵活扩展</h3>
<p class="feature-desc">
支持动态注册微应用,可按需扩展业务模块与发布策略。
</p>
</div>
<div class="feature-card">
<div class="feature-icon">稳</div>
<h3 class="feature-title">稳定可靠</h3>
<p class="feature-desc">
提供完善的权限体系与平台级监控,保障微前端运行稳定。
</p>
</div>
</div>
<div class="info-section">
<div class="info-card">
<h3>快速开始</h3>
<ul class="info-list">
<li>1. 执行 <code>pnpm install</code> 安装依赖</li>
<li>2. 运行 <code>pnpm dev</code> 启动主应用</li>
<li>3. 启动所需的微应用服务</li>
<li>4. 在 <code>src/qiankun/apps.ts</code> 中注册微应用</li>
</ul>
</div>
<div class="info-card">
<h3>微应用列表</h3>
<ul class="app-list">
<li v-for="app in apps" :key="app.name" class="app-item">
<span class="app-name">{{ app.name }}</span>
<span class="app-port">{{ app.entry }}</span>
<router-link
v-if="typeof app.activeRule === 'string'"
:to="app.activeRule"
class="app-link"
>
进入 >
</router-link>
<span v-else class="app-link disabled">暂不可用</span>
</li>
</ul>
</div>
</div>
<!-- 通信示例区域 -->
<div class="communication-section">
<h2 class="section-title">
<span class="title-icon">📡</span>
主应用 ↔ 微应用通讯演示
</h2>
<div class="communication-content">
<!-- 左侧:全局状态展示 -->
<div class="state-panel">
<h3 class="panel-title">全局共享状态</h3>
<div v-if="globalState" class="state-content">
<!-- 用户信息 -->
<div class="state-item">
<div class="state-label">👤 当前用户</div>
<div class="state-value">
<span class="user-avatar">{{ globalState.user?.avatar }}</span>
<span
>{{ globalState.user?.name }} ({{
globalState.user?.role
}})</span
>
</div>
</div>
<!-- 主题 -->
<div class="state-item">
<div class="state-label">🎨 主题模式</div>
<div class="state-value">
{{
globalState.theme.mode === 'light' ? '浅色模式' : '深色模式'
}}
<span
class="theme-color"
:style="{ backgroundColor: globalState.theme.primaryColor }"
></span>
</div>
</div>
<!-- 通知数量 -->
<div class="state-item">
<div class="state-label">🔔 通知数量</div>
<div class="state-value">
<span class="notification-badge">{{
globalState.notifications.length
}}</span>
</div>
</div>
<!-- API 配置 -->
<div class="state-item">
<div class="state-label">⚙️ API 配置</div>
<div class="state-value state-value-small">
{{ globalState.config.apiBaseUrl }}
</div>
</div>
</div>
<div v-else class="state-loading">加载中...</div>
</div>
<!-- 右侧:通信操作区 -->
<div class="action-panel">
<h3 class="panel-title">通信操作</h3>
<!-- 快速发送消息 -->
<div class="action-group">
<div class="action-label">快速发送消息到微应用:</div>
<div class="button-group">
<button
class="action-btn success-btn"
@click="sendSuccessMessage"
>
✓ 发送成功消息
</button>
</div>
</div>
<!-- 自定义消息 -->
<div class="action-group">
<div class="action-label">自定义消息:</div>
<input
v-model="messageTitle"
type="text"
class="input-field"
placeholder="消息标题"
/>
<textarea
v-model="messageContent"
class="textarea-field"
placeholder="消息内容"
rows="3"
></textarea>
<button class="action-btn primary-btn" @click="sendCustomMessage">
📤 发送自定义消息
</button>
</div>
<!-- 状态更新操作 -->
<div class="action-group">
<div class="action-label">更新全局状态:</div>
<div class="button-group">
<button class="action-btn theme-btn" @click="toggleTheme">
🎨 切换主题
</button>
<button class="action-btn user-btn" @click="updateUserInfo">
👤 更新用户
</button>
</div>
</div>
</div>
</div>
<!-- 通知消息列表 -->
<div class="notification-panel">
<div class="notification-header">
<h3 class="panel-title">📬 消息通知列表</h3>
<button
v-if="globalState?.notifications.length"
class="clear-btn"
@click="clearAllNotifications"
>
清空全部
</button>
</div>
<div v-if="globalState?.notifications.length" class="notification-list">
<div
v-for="notification in globalState.notifications"
:key="notification.id"
class="notification-item"
:class="[`notification-${notification.type}`]"
>
<div class="notification-icon">
<span v-if="notification.type === 'success'">✓</span>
<span v-else-if="notification.type === 'warning'">⚠</span>
<span v-else-if="notification.type === 'error'">✕</span>
<span v-else>ℹ</span>
</div>
<div class="notification-content">
<div class="notification-title">{{ notification.title }}</div>
<div class="notification-message">{{ notification.message }}</div>
<div class="notification-meta">
<span v-if="notification.from" class="notification-from"
>来自: {{ notification.from }}</span
>
<span class="notification-time">{{
formatTime(notification.timestamp)
}}</span>
</div>
</div>
<button
class="notification-close"
@click="removeNotification(notification.id)"
>
✕
</button>
</div>
</div>
<div v-else class="notification-empty">
<div class="empty-icon">📭</div>
<div class="empty-text">暂无消息通知</div>
<div class="empty-hint">
点击上方按钮发送消息,微应用也可以发送消息到这里
</div>
</div>
</div>
<!-- 使用说明 -->
<div class="usage-tips">
<h4>💡 使用说明</h4>
<ul>
<li>
<strong>全局状态:</strong
>主应用和微应用共享的状态,任何一方修改都会实时同步。
</li>
<li>
<strong>消息通知:</strong
>主应用可以发送通知给微应用,微应用也可以发送通知给主应用。
</li>
<li>
<strong>实时监听:</strong
>状态变化会实时反映在界面上,打开控制台可以看到详细日志。
</li>
<li>
<strong>微应用接入:</strong>微应用通过 props 接收 actions,可以调用
<code>actions.setGlobalState()</code> 和
<code>actions.onGlobalStateChange()</code> 进行通信。
</li>
</ul>
</div>
<!-- Element Plus 原生按钮示例 -->
<div class="component-demo">
<h4 class="demo-title">📦 Element Plus 原生按钮</h4>
<div class="button-demo-group">
<el-button type="primary">Primary</el-button>
<el-button type="success">Success</el-button>
<el-button type="info">Info</el-button>
<el-button type="warning">Warning</el-button>
<el-button type="danger">Danger</el-button>
</div>
</div>
<!-- GLButton 组件库按钮示例 -->
<div class="component-demo">
<h4 class="demo-title">🎨 @venus/common-ui-vue GLButton 组件</h4>
<!-- 基础按钮 -->
<div class="demo-section">
<h5 class="section-subtitle">基础样式</h5>
<div class="button-demo-group">
<GLButton type="primary">主要按钮</GLButton>
<GLButton type="success">成功按钮</GLButton>
<GLButton type="info">信息按钮</GLButton>
<GLButton type="warning">警告按钮</GLButton>
<GLButton type="danger">危险按钮</GLButton>
</div>
</div>
<!-- 加载状态 -->
<div class="demo-section">
<h5 class="section-subtitle">加载状态</h5>
<div class="button-demo-group">
<GLButton type="primary" loading>加载中</GLButton>
<GLButton
type="success"
:loading="buttonLoading"
@click="handleAsyncClick"
>
点击模拟异步操作
</GLButton>
</div>
</div>
<!-- 禁用状态 -->
<div class="demo-section">
<h5 class="section-subtitle">禁用状态</h5>
<div class="button-demo-group">
<GLButton type="primary" disabled>禁用按钮</GLButton>
<GLButton type="success" disabled>禁用按钮</GLButton>
</div>
</div>
<!-- 确认提示 -->
<div class="demo-section">
<h5 class="section-subtitle">确认提示</h5>
<div class="button-demo-group">
<GLButton
type="warning"
confirm-text="确定要执行这个操作吗?"
@click="handleConfirmClick"
>
点击需要确认
</GLButton>
<GLButton
type="danger"
confirm-text="确定要删除吗?此操作不可恢复!"
@click="handleDeleteClick"
>
删除操作
</GLButton>
</div>
</div>
<!-- 防抖 -->
<div class="demo-section">
<h5 class="section-subtitle">防抖功能(1秒)</h5>
<div class="button-demo-group">
<GLButton
type="primary"
:debounce="1000"
@click="handleDebounceClick"
>
防抖按钮 (1s)
</GLButton>
<span class="demo-tip">点击次数: {{ clickCount }}</span>
</div>
</div>
<!-- 图标按钮 -->
<div class="demo-section">
<h5 class="section-subtitle">图标按钮</h5>
<div class="button-demo-group">
<GLButton type="primary" :icon="Search">搜索</GLButton>
<GLButton type="success" :icon="Check">确认</GLButton>
<GLButton type="warning" :icon="Edit">编辑</GLButton>
<GLButton type="danger" :icon="Delete">删除</GLButton>
<GLButton type="info" :icon="Message" circle />
<GLButton type="primary" :icon="Star" circle />
</div>
</div>
<!-- 插槽 -->
<div class="demo-section">
<h5 class="section-subtitle">防抖功能(1秒)</h5>
<div class="button-demo-group">
<GLButton
type="primary"
:debounce="1000"
@click="handleDebounceClick"
>
<template #icon>
<span>这是图标</span>
</template>
防抖按钮 (1s)
</GLButton>
<span class="demo-tip">点击次数: {{ clickCount }}</span>
</div>
</div>
</div>
</div>
</div>
</template>
<style scoped>
@keyframes slide-in {
from {
opacity: 0;
transform: translateX(-20px);
}
to {
opacity: 1;
transform: translateX(0);
}
}
.home-page {
padding: 40px;
}
.welcome-section {
margin-bottom: 60px;
text-align: center;
}
.title {
margin-bottom: 16px;
font-size: 36px;
font-weight: 600;
color: #1890ff;
}
.subtitle {
font-size: 18px;
color: #666;
}
.feature-section {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
gap: 24px;
margin-bottom: 60px;
}
.feature-card {
padding: 32px 24px;
color: #fff;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
border-radius: 8px;
transition: transform 0.3s;
}
.feature-card:nth-child(2) {
background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}
.feature-card:nth-child(3) {
background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}
.feature-card:nth-child(4) {
background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
}
.feature-card:hover {
transform: translateY(-4px);
}
.feature-icon {
margin-bottom: 16px;
font-size: 48px;
}
.feature-title {
margin-bottom: 12px;
font-size: 20px;
font-weight: 600;
}
.feature-desc {
font-size: 14px;
line-height: 1.6;
opacity: 0.9;
}
.info-section {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
gap: 24px;
}
.info-card {
padding: 24px;
background: #f9f9f9;
border: 1px solid #e8e8e8;
border-radius: 8px;
}
.info-card h3 {
margin-bottom: 16px;
font-size: 18px;
font-weight: 600;
color: #333;
}
.info-list {
list-style: none;
}
.info-list li {
padding: 8px 0;
line-height: 1.8;
color: #666;
}
.info-list code {
padding: 2px 8px;
font-family: 'Courier New', monospace;
color: #1890ff;
background: #fff;
border: 1px solid #d9d9d9;
border-radius: 4px;
}
.app-list {
list-style: none;
}
.app-item {
display: flex;
gap: 16px;
align-items: center;
padding: 12px;
margin-bottom: 8px;
background: #fff;
border: 1px solid #e8e8e8;
border-radius: 4px;
}
.app-name {
min-width: 120px;
font-weight: 600;
color: #333;
}
.app-port {
flex: 1;
font-size: 13px;
color: #999;
}
.app-link {
font-weight: 500;
color: #1890ff;
transition: color 0.3s;
}
.app-link:hover {
color: #40a9ff;
}
.app-link.disabled {
color: #d9d9d9;
pointer-events: none;
cursor: not-allowed;
}
/* 通信示例区域 */
.communication-section {
padding: 32px;
margin-top: 60px;
background: linear-gradient(135deg, #667eea15 0%, #764ba215 100%);
border: 2px solid #667eea30;
border-radius: 12px;
}
.section-title {
display: flex;
gap: 12px;
align-items: center;
margin-bottom: 24px;
font-size: 28px;
font-weight: 600;
color: #333;
}
.title-icon {
font-size: 32px;
}
.communication-content {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 24px;
margin-bottom: 24px;
}
/* 状态面板 */
.state-panel,
.action-panel {
padding: 24px;
background: #fff;
border-radius: 8px;
box-shadow: 0 2px 8px rgb(0 0 0 / 8%);
}
.panel-title {
padding-bottom: 12px;
margin-bottom: 20px;
font-size: 18px;
font-weight: 600;
color: #333;
border-bottom: 2px solid #f0f0f0;
}
.state-content {
display: flex;
flex-direction: column;
gap: 16px;
}
.state-item {
display: flex;
align-items: center;
justify-content: space-between;
padding: 12px;
background: #f9f9f9;
border-radius: 6px;
}
.state-label {
font-size: 14px;
font-weight: 500;
color: #666;
}
.state-value {
display: flex;
gap: 8px;
align-items: center;
font-size: 14px;
font-weight: 600;
color: #333;
}
.state-value-small {
font-size: 12px;
font-weight: normal;
color: #999;
}
.user-avatar {
font-size: 20px;
}
.theme-color {
display: inline-block;
width: 20px;
height: 20px;
border: 2px solid #fff;
border-radius: 50%;
box-shadow: 0 0 4px rgb(0 0 0 / 20%);
}
.notification-badge {
padding: 4px 12px;
font-size: 14px;
font-weight: 600;
color: #fff;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
border-radius: 12px;
}
.state-loading {
padding: 40px;
color: #999;
text-align: center;
}
/* 操作面板 */
.action-group {
margin-bottom: 24px;
}
.action-group:last-child {
margin-bottom: 0;
}
.action-label {
margin-bottom: 12px;
font-size: 14px;
font-weight: 500;
color: #666;
}
.button-group {
display: flex;
flex-wrap: wrap;
gap: 12px;
}
.action-btn {
padding: 10px 20px;
font-size: 14px;
font-weight: 500;
color: #fff;
cursor: pointer;
border: none;
border-radius: 6px;
transition: all 0.3s;
}
.action-btn:hover {
box-shadow: 0 4px 12px rgb(0 0 0 / 15%);
transform: translateY(-2px);
}
.success-btn {
background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
}
.warning-btn {
background: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
}
.primary-btn {
width: 100%;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}
.theme-btn {
background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}
.user-btn {
background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}
.input-field,
.textarea-field {
width: 100%;
padding: 10px 12px;
margin-bottom: 12px;
font-family: inherit;
font-size: 14px;
border: 1px solid #d9d9d9;
border-radius: 6px;
transition: border-color 0.3s;
}
.input-field:focus,
.textarea-field:focus {
outline: none;
border-color: #667eea;
}
.textarea-field {
min-height: 80px;
resize: vertical;
}
/* 通知面板 */
.notification-panel {
padding: 24px;
margin-bottom: 24px;
background: #fff;
border-radius: 8px;
box-shadow: 0 2px 8px rgb(0 0 0 / 8%);
}
.notification-header {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 20px;
}
.notification-header .panel-title {
padding-bottom: 0;
margin-bottom: 0;
border-bottom: none;
}
.clear-btn {
padding: 6px 16px;
font-size: 13px;
color: #fff;
cursor: pointer;
background: #ff4d4f;
border: none;
border-radius: 4px;
transition: all 0.3s;
}
.clear-btn:hover {
background: #ff7875;
transform: translateY(-1px);
}
.notification-list {
display: flex;
flex-direction: column;
gap: 12px;
max-height: 400px;
overflow-y: auto;
}
.notification-item {
display: flex;
gap: 16px;
padding: 16px;
background: #fff;
border-left: 4px solid;
border-radius: 8px;
box-shadow: 0 2px 8px rgb(0 0 0 / 6%);
transition: all 0.3s;
animation: slide-in 0.3s ease-out;
}
.notification-item:hover {
box-shadow: 0 4px 12px rgb(0 0 0 / 10%);
}
.notification-success {
background: #f6ffed;
border-left-color: #52c41a;
}
.notification-warning {
background: #fffbe6;
border-left-color: #faad14;
}
.notification-error {
background: #fff2f0;
border-left-color: #ff4d4f;
}
.notification-info {
background: #e6f7ff;
border-left-color: #1890ff;
}
.notification-icon {
display: flex;
flex-shrink: 0;
align-items: center;
justify-content: center;
width: 32px;
height: 32px;
font-size: 20px;
font-weight: bold;
border-radius: 50%;
}
.notification-success .notification-icon {
color: #52c41a;
background: #b7eb8f30;
}
.notification-warning .notification-icon {
color: #faad14;
background: #ffe58f30;
}
.notification-error .notification-icon {
color: #ff4d4f;
background: #ffccc730;
}
.notification-info .notification-icon {
color: #1890ff;
background: #91d5ff30;
}
.notification-content {
flex: 1;
}
.notification-title {
margin-bottom: 4px;
font-size: 15px;
font-weight: 600;
color: #333;
}
.notification-message {
margin-bottom: 8px;
font-size: 14px;
line-height: 1.6;
color: #666;
}
.notification-meta {
display: flex;
gap: 12px;
font-size: 12px;
color: #999;
}
.notification-from {
font-weight: 500;
}
.notification-close {
display: flex;
flex-shrink: 0;
align-items: center;
justify-content: center;
width: 24px;
height: 24px;
padding: 4px;
font-size: 16px;
color: #999;
cursor: pointer;
background: none;
border: none;
border-radius: 4px;
transition: all 0.3s;
}
.notification-close:hover {
color: #ff4d4f;
background: #f5f5f5;
}
.notification-empty {
padding: 60px 20px;
color: #999;
text-align: center;
}
.empty-icon {
margin-bottom: 16px;
font-size: 64px;
opacity: 0.6;
}
.empty-text {
margin-bottom: 8px;
font-size: 16px;
font-weight: 500;
color: #666;
}
.empty-hint {
font-size: 13px;
color: #999;
}
/* 使用说明 */
.usage-tips {
padding: 24px;
background: #fff;
border-radius: 8px;
box-shadow: 0 2px 8px rgb(0 0 0 / 8%);
}
.usage-tips h4 {
margin-bottom: 16px;
font-size: 16px;
font-weight: 600;
color: #333;
}
.usage-tips ul {
padding: 0;
list-style: none;
}
.usage-tips li {
position: relative;
padding: 10px 0;
padding-left: 20px;
font-size: 14px;
line-height: 1.8;
color: #666;
}
.usage-tips li::before {
position: absolute;
left: 0;
font-size: 18px;
font-weight: bold;
color: #667eea;
content: '•';
}
.usage-tips code {
padding: 2px 6px;
font-family: 'Courier New', monospace;
font-size: 13px;
color: #667eea;
background: #f0f0f0;
border-radius: 3px;
}
/* 组件演示样式 */
.component-demo {
padding: 24px;
margin-bottom: 24px;
background: #fff;
border-radius: 8px;
box-shadow: 0 2px 8px rgb(0 0 0 / 8%);
}
.demo-title {
padding-bottom: 12px;
margin-bottom: 20px;
font-size: 18px;
font-weight: 600;
color: #333;
border-bottom: 2px solid #f0f0f0;
}
.demo-section {
margin-bottom: 24px;
}
.demo-section:last-child {
margin-bottom: 0;
}
.section-subtitle {
margin-bottom: 12px;
font-size: 14px;
font-weight: 600;
color: #666;
}
.button-demo-group {
display: flex;
flex-wrap: wrap;
gap: 12px;
align-items: center;
}
.demo-tip {
padding: 6px 12px;
margin-left: 8px;
font-size: 14px;
color: #666;
background: #f0f0f0;
border-radius: 4px;
}
</style>