index.vue
47.9 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
<template>
<div class="flex h-screen overflow-hidden">
<!-- 侧边栏 -->
<siderbar />
<!-- 主内容区 -->
<div class="flex-1 flex flex-col overflow-hidden">
<!-- 顶部导航 -->
<header class="bg-white shadow-sm z-10">
<div class="flex items-center justify-between p-4">
<div class="flex items-center">
<button class="md:hidden mr-4 text-gray-500 hover:text-dark" id="mobile-menu-button"
@click="toggleMobileMenu">
<i class="fa fa-bars text-xl"></i>
</button>
<div class="relative">
<input type="text" placeholder="搜索..."
class="pl-10 pr-4 py-2 rounded-lg border border-gray-200 focus:outline-none focus:ring-2 focus:ring-primary/30 focus:border-primary w-64">
<i
class="fa fa-search absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400"></i>
</div>
</div>
<div class="flex items-center space-x-4">
<button class="relative text-gray-500 hover:text-dark transition-colors" title="通知">
<i class="fa fa-bell text-xl"></i>
<span
class="absolute -top-1 -right-1 w-4 h-4 bg-danger rounded-full text-white text-xs flex items-center justify-center">3</span>
</button>
<button class="relative text-gray-500 hover:text-dark transition-colors" title="消息">
<i class="fa fa-envelope text-xl"></i>
<span
class="absolute -top-1 -right-1 w-4 h-4 bg-primary rounded-full text-white text-xs flex items-center justify-center">5</span>
</button>
<div class="hidden md:block h-6 w-px bg-gray-200"></div>
<!-- 个人信息下拉菜单 -->
<div class="relative" id="user-menu-container">
<button class="flex items-center space-x-2 focus:outline-none" id="user-menu-button"
@click="toggleUserDropdown">
<img src="https://picsum.photos/id/1005/200/200" alt="用户头像"
class="w-8 h-8 rounded-full object-cover md:hidden">
<span class="hidden md:inline text-sm font-medium">张经理</span>
<i class="fa fa-angle-down text-gray-500"></i>
</button>
<!-- 下拉菜单内容 -->
<div class="absolute right-0 mt-2 w-48 bg-white rounded-lg shadow-lg py-1 z-50 transition-all duration-200"
id="user-dropdown"
:class="userDropdownOpen ? 'opacity-100 visible translate-y-0' : 'opacity-0 invisible -translate-y-2'">
<a href="profile.html" class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100">
<i class="fa fa-user mr-2"></i>个人资料
</a>
<a href="account-settings.html"
class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100">
<i class="fa fa-cog mr-2"></i>账户设置
</a>
<a href="subscription.html"
class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100">
<i class="fa fa-subscription mr-2"></i>会员订阅
</a>
<div class="border-t border-gray-100 my-1"></div>
<a href="login.html" class="block px-4 py-2 text-sm text-danger hover:bg-gray-100">
<i class="fa fa-sign-out mr-2"></i>退出登录
</a>
</div>
</div>
</div>
</div>
</header>
<!-- 页面内容 -->
<main class="flex-1 overflow-y-auto p-4 md:p-6 scrollbar-hide bg-gray-50">
<div class="mb-6">
<h2 class="text-[clamp(1.5rem,3vw,2rem)] font-bold">控制台</h2>
<p class="text-gray-500 mt-1">欢迎回来,今天是 <span class="font-medium" id="current-date">{{ currentDate
}}</span>
</p>
</div>
<!-- 数据概览卡片 -->
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4 mb-6">
<div class="bg-white rounded-xl shadow-sm p-5 card-hover">
<div class="flex items-start justify-between">
<div>
<p class="text-gray-500 text-sm">已生成软文</p>
<h3 class="text-2xl font-bold mt-1">248</h3>
<p class="text-success text-sm mt-2 flex items-center">
<i class="fa fa-arrow-up mr-1"></i> 12.5% <span
class="text-gray-500 ml-1">较上月</span>
</p>
</div>
<div
class="w-12 h-12 rounded-lg bg-primary/10 flex items-center justify-center text-primary">
<i class="fa fa-file-text-o text-xl"></i>
</div>
</div>
</div>
<div class="bg-white rounded-xl shadow-sm p-5 card-hover">
<div class="flex items-start justify-between">
<div>
<p class="text-gray-500 text-sm">已发布</p>
<h3 class="text-2xl font-bold mt-1">196</h3>
<p class="text-success text-sm mt-2 flex items-center">
<i class="fa fa-arrow-up mr-1"></i> 8.3% <span class="text-gray-500 ml-1">较上月</span>
</p>
</div>
<div
class="w-12 h-12 rounded-lg bg-success/10 flex items-center justify-center text-success">
<i class="fa fa-check-circle-o text-xl"></i>
</div>
</div>
</div>
<div class="bg-white rounded-xl shadow-sm p-5 card-hover">
<div class="flex items-start justify-between">
<div>
<p class="text-gray-500 text-sm">知识库文档</p>
<h3 class="text-2xl font-bold mt-1">156</h3>
<p class="text-success text-sm mt-2 flex items-center">
<i class="fa fa-arrow-up mr-1"></i> 15.2% <span
class="text-gray-500 ml-1">较上月</span>
</p>
</div>
<div
class="w-12 h-12 rounded-lg bg-secondary/10 flex items-center justify-center text-secondary">
<i class="fa fa-book text-xl"></i>
</div>
</div>
</div>
<div class="bg-white rounded-xl shadow-sm p-5 card-hover">
<div class="flex items-start justify-between">
<div>
<p class="text-gray-500 text-sm">平均阅读量</p>
<h3 class="text-2xl font-bold mt-1">2.4k</h3>
<p class="text-danger text-sm mt-2 flex items-center">
<i class="fa fa-arrow-down mr-1"></i> 3.1% <span
class="text-gray-500 ml-1">较上月</span>
</p>
</div>
<div
class="w-12 h-12 rounded-lg bg-warning/10 flex items-center justify-center text-warning">
<i class="fa fa-eye text-xl"></i>
</div>
</div>
</div>
</div>
<!-- 图表和最近活动 -->
<div class="grid grid-cols-1 lg:grid-cols-3 gap-6 mb-6">
<!-- 内容趋势图表 -->
<div class="bg-white rounded-xl shadow-sm p-5 lg:col-span-2 card-hover">
<div class="flex items-center justify-between mb-6">
<h3 class="font-bold text-lg">内容趋势</h3>
<div class="flex space-x-2">
<button class="px-3 py-1 text-sm bg-primary/10 text-primary rounded-lg">周</button>
<button class="px-3 py-1 text-sm text-gray-500 hover:bg-gray-100 rounded-lg">月</button>
<button class="px-3 py-1 text-sm text-gray-500 hover:bg-gray-100 rounded-lg">年</button>
</div>
</div>
<div class="h-64">
<canvas id="contentTrendChart"></canvas>
</div>
</div>
<!-- 最近活动 -->
<div class="bg-white rounded-xl shadow-sm p-5 card-hover">
<div class="flex items-center justify-between mb-6">
<h3 class="font-bold text-lg">最近活动</h3>
<a href="activity-log.html" class="text-primary text-sm hover:underline">查看全部</a>
</div>
<div class="space-y-4 max-h-64 overflow-y-auto scrollbar-hide">
<div class="flex items-start space-x-3" v-for="activity in recentActivities"
:key="activity.id">
<div class="w-8 h-8 rounded-full" :class="activity.bgClass">
<i class="fa" :class="activity.iconClass"></i>
</div>
<div>
<p class="text-sm">{{ activity.description }}</p>
<p class="text-gray-500 text-xs mt-1">{{ activity.time }}</p>
</div>
</div>
</div>
</div>
</div>
<!-- 核心功能区 -->
<div class="grid grid-cols-1 md:grid-cols-2 gap-6 mb-6">
<!-- 软文生成 -->
<div class="bg-white rounded-xl shadow-sm overflow-hidden card-hover">
<div class="h-32 bg-gradient-to-r from-primary to-primary/70 relative">
<div class="absolute right-0 top-0 opacity-10">
<i class="fa fa-file-text text-[150px] text-white"></i>
</div>
<div class="p-5 relative z-10">
<h3 class="text-white font-bold text-xl">软文生成</h3>
<p class="text-white/80 text-sm mt-1">基于AI和知识库,快速生成高质量软文</p>
</div>
</div>
<div class="p-5">
<div class="mb-4">
<label class="block text-sm font-medium text-gray-700 mb-1">生成主题</label>
<input type="text" placeholder="输入您想要生成的软文主题..."
class="w-full px-4 py-2 rounded-lg border border-gray-200 focus:outline-none focus:ring-2 focus:ring-primary/30 focus:border-primary"
v-model="articleGeneration.topic">
</div>
<div class="grid grid-cols-2 gap-3 mb-4">
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">文章风格</label>
<select
class="w-full px-4 py-2 rounded-lg border border-gray-200 focus:outline-none focus:ring-2 focus:ring-primary/30 focus:border-primary"
v-model="articleGeneration.style">
<option>专业严谨</option>
<option>轻松活泼</option>
<option>幽默风趣</option>
<option>简洁明了</option>
</select>
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">参考知识库</label>
<select
class="w-full px-4 py-2 rounded-lg border border-gray-200 focus:outline-none focus:ring-2 focus:ring-primary/30 focus:border-primary"
v-model="articleGeneration.knowledgeBase">
<option>全部文档</option>
<option>产品手册</option>
<option>行业报告</option>
<option>营销素材</option>
</select>
</div>
</div>
<button class="w-full btn-primary flex items-center justify-center"
id="generate-article-button" @click="generateArticle">
<i class="fa fa-magic mr-2"></i> 立即生成
</button>
</div>
</div>
<!-- 发布计划 -->
<div class="bg-white rounded-xl shadow-sm overflow-hidden card-hover">
<div class="h-32 bg-gradient-to-r from-secondary to-secondary/70 relative">
<div class="absolute right-0 top-0 opacity-10">
<i class="fa fa-calendar-check-o text-[150px] text-white"></i>
</div>
<div class="p-5 relative z-10">
<h3 class="text-white font-bold text-xl">发布计划</h3>
<p class="text-white/80 text-sm mt-1">设置全年发布计划,自动定时发布</p>
</div>
</div>
<div class="p-5">
<div class="mb-4">
<label class="block text-sm font-medium text-gray-700 mb-1">发布平台</label>
<div class="flex flex-wrap gap-2">
<label
class="inline-flex items-center px-3 py-1 border border-gray-200 rounded-full text-sm cursor-pointer hover:bg-gray-50"
v-for="platform in publishPlatforms" :key="platform.id">
<input type="checkbox" class="form-checkbox text-primary h-4 w-4 mr-2"
v-model="platform.checked">
<span>{{ platform.name }}</span>
</label>
</div>
</div>
<div class="mb-4">
<label class="block text-sm font-medium text-gray-700 mb-1">发布频率</label>
<div class="flex items-center">
<input type="number" v-model="publishFrequency.count" min="1" max="10"
class="w-16 px-3 py-2 rounded-lg border border-gray-200 focus:outline-none focus:ring-2 focus:ring-primary/30 focus:border-primary">
<span class="mx-2 text-gray-500">篇/天</span>
<select
class="flex-1 ml-2 px-3 py-2 rounded-lg border border-gray-200 focus:outline-none focus:ring-2 focus:ring-primary/30 focus:border-primary"
v-model="publishFrequency.period">
<option>工作日发布</option>
<option>每日发布</option>
<option>自定义日期</option>
</select>
</div>
</div>
<button class="w-full btn-primary flex items-center justify-center"
id="setup-schedule-button" @click="setupSchedule">
<i class="fa fa-calendar-plus-o mr-2"></i> 设置计划
</button>
</div>
</div>
</div>
<!-- 知识库和待发布 -->
<div class="grid grid-cols-1 lg:grid-cols-3 gap-6">
<!-- 知识库管理 -->
<div class="bg-white rounded-xl shadow-sm p-5 card-hover">
<div class="flex items-center justify-between mb-4">
<h3 class="font-bold text-lg">知识库管理</h3>
<button class="btn-secondary text-sm py-1" id="add-knowledge-button"
@click="openModal('add-knowledge-modal')">
<i class="fa fa-plus mr-1"></i> 新增
</button>
</div>
<div class="space-y-3 max-h-72 overflow-y-auto scrollbar-hide">
<div class="flex items-center justify-between p-3 border border-gray-100 rounded-lg hover:bg-gray-50"
v-for="doc in knowledgeDocs" :key="doc.id">
<div class="flex items-center space-x-3">
<div class="w-10 h-10 rounded" :class="doc.iconBgClass">
<i class="fa" :class="doc.iconClass"></i>
</div>
<div>
<p class="text-sm font-medium">{{ doc.name }}</p>
<p class="text-gray-500 text-xs">{{ doc.size }} · {{ doc.date }}</p>
</div>
</div>
<div class="flex space-x-1">
<button class="text-gray-400 hover:text-primary p-1" title="编辑"
@click="editKnowledgeDoc(doc.id)">
<i class="fa fa-pencil"></i>
</button>
<button class="text-gray-400 hover:text-danger p-1" title="删除"
@click="deleteKnowledgeDoc(doc.id)">
<i class="fa fa-trash"></i>
</button>
</div>
</div>
</div>
<div class="mt-4 text-center">
<a href="knowledge-base.html" class="text-primary text-sm hover:underline">查看所有文档</a>
</div>
</div>
<!-- 待发布文章 -->
<div class="bg-white rounded-xl shadow-sm p-5 lg:col-span-2 card-hover">
<div class="flex items-center justify-between mb-4">
<h3 class="font-bold text-lg">待发布文章</h3>
<div class="flex space-x-2">
<button class="btn-secondary text-sm py-1">
<i class="fa fa-calendar mr-1"></i> 查看计划
</button>
<button class="btn-primary text-sm py-1" id="add-article-button"
@click="openModal('add-article-modal')">
<i class="fa fa-plus mr-1"></i> 新增文章
</button>
</div>
</div>
<div class="overflow-x-auto">
<table class="min-w-full">
<thead>
<tr class="text-left text-gray-500 text-sm border-b">
<th class="pb-3 font-medium">标题</th>
<th class="pb-3 font-medium">发布平台</th>
<th class="pb-3 font-medium">发布时间</th>
<th class="pb-3 font-medium">状态</th>
<th class="pb-3 font-medium text-right">操作</th>
</tr>
</thead>
<tbody>
<tr class="border-b border-gray-100 hover:bg-gray-50"
v-for="article in pendingArticles" :key="article.id">
<td class="py-3 text-sm">
<p class="font-medium">{{ article.title }}</p>
</td>
<td class="py-3 text-sm">
<span v-for="platform in article.platforms" :key="platform.id"
:class="platform.badgeClass"
class="inline-flex items-center px-2 py-1 rounded-full text-xs mr-1">
{{ platform.name }}
</span>
</td>
<td class="py-3 text-sm text-gray-500">{{ article.publishTime }}</td>
<td class="py-3 text-sm">
<span
class="inline-flex items-center px-2 py-1 bg-green-50 text-green-600 rounded-full text-xs">
<i class="fa fa-clock-o mr-1"></i> 已排期
</span>
</td>
<td class="py-3 text-sm text-right">
<div class="flex justify-end space-x-2">
<button class="text-primary hover:text-primary/80" title="编辑"
@click="editArticle(article.id)">
<i class="fa fa-pencil"></i>
</button>
<button class="text-warning hover:text-warning/80" title="调整时间"
@click="adjustArticleTime(article.id)">
<i class="fa fa-calendar"></i>
</button>
<button class="text-danger hover:text-danger/80" title="取消发布"
@click="cancelArticle(article.id)">
<i class="fa fa-trash"></i>
</button>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<div class="mt-4 text-center">
<a href="pending-articles.html" class="text-primary text-sm hover:underline">查看所有待发布文章</a>
</div>
</div>
</div>
</main>
</div>
</div>
<!-- 新增文章弹窗 -->
<div class="fixed inset-0 bg-black/50 z-50 flex items-center justify-center transition-all duration-300"
id="add-article-modal"
:class="activeModal === 'add-article-modal' ? 'opacity-100 visible' : 'opacity-0 invisible'">
<div class="bg-white rounded-xl shadow-xl w-full max-w-2xl max-h-[90vh] overflow-y-auto transform transition-all duration-300"
id="add-article-modal-content"
:class="activeModal === 'add-article-modal' ? 'opacity-100 translate-y-0' : 'opacity-0 translate-y-8'">
<div class="p-6 border-b">
<div class="flex items-center justify-between">
<h3 class="text-xl font-bold">新增文章</h3>
<button class="text-gray-500 hover:text-gray-700" @click="closeModal">
<i class="fa fa-times text-xl"></i>
</button>
</div>
</div>
<div class="p-6">
<div class="mb-4">
<label class="block text-sm font-medium text-gray-700 mb-1">文章标题</label>
<input type="text" placeholder="输入文章标题..."
class="w-full px-4 py-2 rounded-lg border border-gray-200 focus:outline-none focus:ring-2 focus:ring-primary/30 focus:border-primary"
v-model="newArticle.title">
</div>
<div class="mb-4">
<label class="block text-sm font-medium text-gray-700 mb-1">文章内容</label>
<textarea rows="8" placeholder="输入文章内容..."
class="w-full px-4 py-2 rounded-lg border border-gray-200 focus:outline-none focus:ring-2 focus:ring-primary/30 focus:border-primary"
v-model="newArticle.content"></textarea>
</div>
<div class="mb-4">
<label class="block text-sm font-medium text-gray-700 mb-1">文章分类</label>
<select
class="w-full px-4 py-2 rounded-lg border border-gray-200 focus:outline-none focus:ring-2 focus:ring-primary/30 focus:border-primary"
v-model="newArticle.category">
<option>产品介绍</option>
<option>行业资讯</option>
<option>技术分享</option>
<option>客户案例</option>
<option>活动推广</option>
</select>
</div>
<div class="mb-4">
<label class="block text-sm font-medium text-gray-700 mb-1">发布平台</label>
<div class="flex flex-wrap gap-2">
<label
class="inline-flex items-center px-3 py-1 border border-gray-200 rounded-full text-sm cursor-pointer hover:bg-gray-50"
v-for="platform in newArticlePlatforms" :key="platform.id">
<input type="checkbox" class="form-checkbox text-primary h-4 w-4 mr-2"
v-model="platform.checked">
<span>{{ platform.name }}</span>
</label>
</div>
</div>
<div class="mb-4">
<label class="block text-sm font-medium text-gray-700 mb-1">发布时间</label>
<input type="datetime-local"
class="w-full px-4 py-2 rounded-lg border border-gray-200 focus:outline-none focus:ring-2 focus:ring-primary/30 focus:border-primary"
v-model="newArticle.publishTime">
</div>
<div class="mb-4">
<label class="block text-sm font-medium text-gray-700 mb-1">SEO设置</label>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
<div>
<label class="block text-xs text-gray-500 mb-1">关键词</label>
<input type="text" placeholder="输入关键词,用逗号分隔"
class="w-full px-4 py-2 rounded-lg border border-gray-200 focus:outline-none focus:ring-2 focus:ring-primary/30 focus:border-primary"
v-model="newArticle.seo.keywords">
</div>
<div>
<label class="block text-xs text-gray-500 mb-1">描述</label>
<input type="text" placeholder="输入描述信息"
class="w-full px-4 py-2 rounded-lg border border-gray-200 focus:outline-none focus:ring-2 focus:ring-primary/30 focus:border-primary"
v-model="newArticle.seo.description">
</div>
</div>
</div>
</div>
<div class="p-6 border-t flex justify-end space-x-3">
<button class="btn-secondary" @click="closeModal">取消</button>
<button class="btn-primary" @click="saveNewArticle">保存并发布</button>
</div>
</div>
</div>
<!-- 新增知识库文档弹窗 -->
<div class="fixed inset-0 bg-black/50 z-50 flex items-center justify-center transition-all duration-300"
id="add-knowledge-modal" v-show="showKnowledgeModal"
:class="activeModal === 'add-knowledge-modal' ? 'opacity-100 visible' : 'opacity-0 invisible'">
<div class="bg-white rounded-xl shadow-xl w-full max-w-md max-h-[90vh] overflow-y-auto transform transition-all duration-300"
id="add-knowledge-modal-content"
:class="activeModal === 'add-knowledge-modal' ? 'opacity-100 translate-y-0' : 'opacity-0 translate-y-8'">
<div class="p-6 border-b">
<div class="flex items-center justify-between">
<h3 class="text-xl font-bold">新增知识库文档</h3>
<button class="text-gray-500 hover:text-gray-700" @click="closeModal">
<i class="fa fa-times text-xl"></i>
</button>
</div>
</div>
<div class="p-6">
<div class="mb-4">
<label class="block text-sm font-medium text-gray-700 mb-1">文档标题</label>
<input type="text" placeholder="输入文档标题..."
class="w-full px-4 py-2 rounded-lg border border-gray-200 focus:outline-none focus:ring-2 focus:ring-primary/30 focus:border-primary"
v-model="newKnowledgeDoc.title">
</div>
<div class="mb-4">
<label class="block text-sm font-medium text-gray-700 mb-1">文档分类</label>
<select
class="w-full px-4 py-2 rounded-lg border border-gray-200 focus:outline-none focus:ring-2 focus:ring-primary/30 focus:border-primary"
v-model="newKnowledgeDoc.category">
<option>产品手册</option>
<option>行业报告</option>
<option>客户案例</option>
<option>营销素材</option>
<option>其他文档</option>
</select>
</div>
<div class="mb-4">
<label class="block text-sm font-medium text-gray-700 mb-1">上传文档</label>
<div
class="border-2 border-dashed border-gray-200 rounded-lg p-6 text-center hover:bg-gray-50 cursor-pointer">
<i class="fa fa-cloud-upload text-3xl text-gray-400 mb-2"></i>
<p class="text-sm text-gray-500">点击或拖拽文件至此处上传</p>
<p class="text-xs text-gray-400 mt-1">支持 PDF, Word, Excel, PPT 格式</p>
<input type="file" class="hidden" id="file-upload" @change="handleFileUpload">
</div>
<p class="text-xs text-gray-500 mt-2" v-if="newKnowledgeDoc.fileName">{{ newKnowledgeDoc.fileName }}
</p>
</div>
</div>
<div class="p-6 border-t flex justify-end space-x-3">
<button class="btn-secondary" @click="closeModal">取消</button>
<button class="btn-primary" @click="saveNewKnowledgeDoc"
:disabled="!newKnowledgeDoc.fileName">上传文档</button>
</div>
</div>
</div>
</template>
<script setup>
import siderbar from '@/components/siderbar.vue';
import { ref, onMounted } from 'vue';
import { Chart, registerables } from 'chart.js';
Chart.register(...registerables);
// 状态管理
const userDropdownOpen = ref(false);
const mobileMenuOpen = ref(false);
const activeModal = ref('');
const currentDate = ref('');
const showKnowledgeModal = ref(false);
// 文章生成表单数据
const articleGeneration = ref({
topic: '',
style: '专业严谨',
knowledgeBase: '全部文档'
});
// 发布平台数据
const publishPlatforms = ref([
{ id: 1, name: '官网博客', checked: true },
{ id: 2, name: '微信公众号', checked: true },
{ id: 3, name: '今日头条', checked: false }
]);
// 发布频率数据
const publishFrequency = ref({
count: 2,
period: '工作日发布'
});
// 最近活动数据
const recentActivities = ref([
{
id: 1,
description: '生成了2篇关于"夏季促销"的软文',
time: '今天 09:45',
bgClass: 'bg-primary/10 flex items-center justify-center text-primary flex-shrink-0',
iconClass: 'fa-file-text-o'
},
{
id: 2,
description: '成功发布3篇文章到官网博客',
time: '昨天 15:30',
bgClass: 'bg-success/10 flex items-center justify-center text-success flex-shrink-0',
iconClass: 'fa-check-circle-o'
},
{
id: 3,
description: '上传了5份产品手册到知识库',
time: '昨天 10:15',
bgClass: 'bg-secondary/10 flex items-center justify-center text-secondary flex-shrink-0',
iconClass: 'fa-upload'
},
{
id: 4,
description: '设置了未来7天的发布计划',
time: '2023-06-12 16:40',
bgClass: 'bg-warning/10 flex items-center justify-center text-warning flex-shrink-0',
iconClass: 'fa-calendar'
},
{
id: 5,
description: '2篇文章发布失败,请检查',
time: '2023-06-11 08:25',
bgClass: 'bg-danger/10 flex items-center justify-center text-danger flex-shrink-0',
iconClass: 'fa-exclamation-circle'
}
]);
// 知识库文档数据
const knowledgeDocs = ref([
{
id: 1,
name: '2023产品手册.pdf',
size: '2.4MB',
date: '2023-05-18',
iconBgClass: 'bg-primary/10 flex items-center justify-center text-primary',
iconClass: 'fa-file-pdf-o'
},
{
id: 2,
name: '行业分析报告.docx',
size: '1.8MB',
date: '2023-06-02',
iconBgClass: 'bg-secondary/10 flex items-center justify-center text-secondary',
iconClass: 'fa-file-word-o'
},
{
id: 3,
name: '客户案例数据.xlsx',
size: '3.2MB',
date: '2023-06-05',
iconBgClass: 'bg-warning/10 flex items-center justify-center text-warning',
iconClass: 'fa-file-excel-o'
},
{
id: 4,
name: '产品介绍.pptx',
size: '5.7MB',
date: '2023-06-10',
iconBgClass: 'bg-success/10 flex items-center justify-center text-success',
iconClass: 'fa-file-powerpoint-o'
}
]);
// 待发布文章数据
const pendingArticles = ref([
{
id: 1,
title: '2023夏季新品发布会亮点回顾',
platforms: [
{ id: 1, name: '官网博客', badgeClass: 'bg-blue-50 text-blue-600' }
],
publishTime: '2023-06-15 10:00'
},
{
id: 2,
title: '如何选择适合您的产品解决方案',
platforms: [
{ id: 2, name: '微信公众号', badgeClass: 'bg-green-50 text-green-600' }
],
publishTime: '2023-06-15 15:30'
},
{
id: 3,
title: '行业趋势分析:未来五年发展预测',
platforms: [
{ id: 1, name: '官网博客', badgeClass: 'bg-blue-50 text-blue-600' },
{ id: 3, name: '今日头条', badgeClass: 'bg-orange-50 text-orange-600' }
],
publishTime: '2023-06-16 09:30'
}
]);
// 新文章表单数据
const newArticle = ref({
title: '',
content: '',
category: '产品介绍',
publishTime: '',
seo: {
keywords: '',
description: ''
}
});
// 新文章发布平台
const newArticlePlatforms = ref([
{ id: 1, name: '官网博客', checked: true },
{ id: 2, name: '微信公众号', checked: true },
{ id: 3, name: '今日头条', checked: false },
{ id: 4, name: '微博', checked: false }
]);
// 新知识库文档数据
const newKnowledgeDoc = ref({
title: '',
category: '产品手册',
fileName: ''
});
// 方法
const toggleUserDropdown = () => {
userDropdownOpen.value = !userDropdownOpen.value;
};
const toggleMobileMenu = () => {
mobileMenuOpen.value = !mobileMenuOpen.value;
};
const openModal = (modalId) => {
activeModal.value = modalId;
// 设置默认发布时间为当前时间加1小时
if (modalId === 'add-article-modal') {
const now = new Date();
now.setHours(now.getHours() + 1);
newArticle.value.publishTime = now.toISOString().slice(0, 16);
}
};
const closeModal = () => {
activeModal.value = '';
};
const generateArticle = () => {
// 生成文章逻辑
alert(`正在生成关于"${articleGeneration.value.topic}"的${articleGeneration.value.style}风格文章...`);
};
const setupSchedule = () => {
// 设置发布计划逻辑
// const platforms = publishPlatforms.value
// .filter(p => p.checked)
// .map(p => p.name)
// .join(', ');
// alert(`已设置发布计划:每天${publishFrequency.value.count}篇,发布到${platforms},${publishFrequency.value.period}`);
showKnowledgeModal.value = true
};
const editKnowledgeDoc = (id) => {
// 编辑知识库文档逻辑
const doc = knowledgeDocs.value.find(d => d.id === id);
alert(`编辑文档:${doc.name}`);
};
const deleteKnowledgeDoc = (id) => {
// 删除知识库文档逻辑
const doc = knowledgeDocs.value.find(d => d.id === id);
if (confirm(`确定要删除文档"${doc.name}"吗?`)) {
knowledgeDocs.value = knowledgeDocs.value.filter(d => d.id !== id);
}
};
const editArticle = (id) => {
// 编辑文章逻辑
const article = pendingArticles.value.find(a => a.id === id);
alert(`编辑文章:${article.title}`);
};
const adjustArticleTime = (id) => {
// 调整文章发布时间逻辑
const article = pendingArticles.value.find(a => a.id === id);
alert(`调整文章"${article.title}"的发布时间,当前时间:${article.publishTime}`);
};
const cancelArticle = (id) => {
// 取消发布文章逻辑
const article = pendingArticles.value.find(a => a.id === id);
if (confirm(`确定要取消发布文章"${article.title}"吗?`)) {
pendingArticles.value = pendingArticles.value.filter(a => a.id !== id);
}
};
const saveNewArticle = () => {
// 保存新文章逻辑
if (!newArticle.value.title) {
alert('请输入文章标题');
return;
}
if (!newArticle.value.content) {
alert('请输入文章内容');
return;
}
const selectedPlatforms = newArticlePlatforms.value
.filter(p => p.checked)
.map(p => ({
id: p.id,
name: p.name,
badgeClass: p.id === 1 ? 'bg-blue-50 text-blue-600' :
p.id === 2 ? 'bg-green-50 text-green-600' :
p.id === 3 ? 'bg-orange-50 text-orange-600' :
'bg-purple-50 text-purple-600'
}));
if (selectedPlatforms.length === 0) {
alert('请至少选择一个发布平台');
return;
}
pendingArticles.value.push({
id: pendingArticles.value.length + 1,
title: newArticle.value.title,
platforms: selectedPlatforms,
publishTime: newArticle.value.publishTime
});
// 重置表单并关闭弹窗
newArticle.value = {
title: '',
content: '',
category: '产品介绍',
publishTime: '',
seo: {
keywords: '',
description: ''
}
};
newArticlePlatforms.value.forEach(p => p.checked = false);
closeModal();
alert('文章已保存并加入发布计划');
};
const handleFileUpload = (e) => {
// 处理文件上传逻辑
if (e.target.files && e.target.files[0]) {
newKnowledgeDoc.value.fileName = e.target.files[0].name;
}
};
const saveNewKnowledgeDoc = () => {
// 保存新知识库文档逻辑
if (!newKnowledgeDoc.value.title) {
alert('请输入文档标题');
return;
}
if (!newKnowledgeDoc.value.fileName) {
alert('请上传文档');
return;
}
// 确定图标样式
let iconBgClass, iconClass;
if (newKnowledgeDoc.value.fileName.endsWith('.pdf')) {
iconBgClass = 'bg-primary/10 flex items-center justify-center text-primary';
iconClass = 'fa-file-pdf-o';
} else if (newKnowledgeDoc.value.fileName.endsWith('.docx') || newKnowledgeDoc.value.fileName.endsWith('.doc')) {
iconBgClass = 'bg-secondary/10 flex items-center justify-center text-secondary';
iconClass = 'fa-file-word-o';
} else if (newKnowledgeDoc.value.fileName.endsWith('.xlsx') || newKnowledgeDoc.value.fileName.endsWith('.xls')) {
iconBgClass = 'bg-warning/10 flex items-center justify-center text-warning';
iconClass = 'fa-file-excel-o';
} else if (newKnowledgeDoc.value.fileName.endsWith('.pptx') || newKnowledgeDoc.value.fileName.endsWith('.ppt')) {
iconBgClass = 'bg-success/10 flex items-center justify-center text-success';
iconClass = 'fa-file-powerpoint-o';
} else {
iconBgClass = 'bg-gray-100 flex items-center justify-center text-gray-500';
iconClass = 'fa-file-o';
}
// 添加到知识库
knowledgeDocs.value.push({
id: knowledgeDocs.value.length + 1,
name: newKnowledgeDoc.value.fileName,
size: '2.1MB', // 示例大小
date: new Date().toISOString().split('T')[0],
iconBgClass,
iconClass
});
// 重置表单并关闭弹窗
newKnowledgeDoc.value = {
title: '',
category: '产品手册',
fileName: ''
};
document.getElementById('file-upload').value = '';
closeModal();
alert('文档已上传到知识库');
};
// 初始化日期显示
const formatDate = (date) => {
const options = { year: 'numeric', month: 'long', day: 'numeric', weekday: 'long' };
return date.toLocaleDateString('zh-CN', options);
};
// 初始化图表
const initChart = () => {
const ctx = document.getElementById('contentTrendChart').getContext('2d');
// 生成过去7天的日期标签
const labels = [];
const today = new Date();
for (let i = 6; i >= 0; i--) {
const date = new Date(today);
date.setDate(today.getDate() - i);
labels.push(date.toLocaleDateString('zh-CN', { month: 'short', day: 'numeric' }));
}
new Chart(ctx, {
type: 'line',
data: {
labels: labels,
datasets: [
{
label: '生成文章',
data: [12, 19, 15, 20, 18, 25, 22],
borderColor: '#165DFF',
backgroundColor: 'rgba(22, 93, 255, 0.1)',
tension: 0.4,
fill: true
},
{
label: '发布文章',
data: [8, 15, 10, 18, 14, 20, 16],
borderColor: '#36CFC9',
backgroundColor: 'rgba(54, 207, 201, 0.1)',
tension: 0.4,
fill: true
}
]
},
options: {
responsive: true,
maintainAspectRatio: false,
plugins: {
legend: {
position: 'top',
}
},
scales: {
y: {
beginAtZero: true,
grid: {
drawBorder: false
}
},
x: {
grid: {
display: false
}
}
}
}
});
};
// 挂载时初始化
onMounted(() => {
currentDate.value = formatDate(new Date());
initChart();
// 点击外部关闭下拉菜单
document.addEventListener('click', (e) => {
const userMenu = document.getElementById('user-menu-container');
if (!userMenu.contains(e.target)) {
userDropdownOpen.value = false;
}
});
});
tailwind.config = {
theme: {
extend: {
colors: {
primary: '#165DFF',
secondary: '#36CFC9',
success: '#52C41A',
warning: '#FAAD14',
danger: '#FF4D4F',
dark: '#1D2129',
'gray-light': '#F2F3F5',
'gray-medium': '#C9CDD4'
},
fontFamily: {
inter: ['Inter', 'system-ui', 'sans-serif'],
},
},
}
}
</script>
<style scoped>
@import 'tailwindcss/base';
@import 'tailwindcss/components';
@import 'tailwindcss/utilities';
@layer utilities {
.content-auto {
content-visibility: auto;
}
.sidebar-item-active {
@apply bg-primary/10 text-primary border-l-4 border-primary;
}
.card-hover {
@apply transition-all duration-300 hover:shadow-lg hover:-translate-y-1;
}
.btn-primary {
@apply bg-primary text-white px-4 py-2 rounded-lg hover:bg-primary/90 transition-all duration-200 shadow-md hover:shadow-lg;
}
.btn-secondary {
@apply bg-white text-primary border border-primary px-4 py-2 rounded-lg hover:bg-primary/5 transition-all duration-200;
}
.scrollbar-hide {
scrollbar-width: none;
-ms-overflow-style: none;
}
.scrollbar-hide::-webkit-scrollbar {
display: none;
}
.dropdown-active {
@apply opacity-100 visible translate-y-0;
}
.modal-active {
@apply opacity-100 visible;
}
.modal-content-active {
@apply opacity-100 translate-y-0;
}
}
.btn-primary {
background-color: rgb(0, 119, 255);
}
</style>