Просмотр исходного кода

✨ feat(settings/announcements): sort by publishDate desc

Add reverse-chronological sorting for the announcements list so that the newest
items appear first in the dashboard.

No API changes; this only affects front-end display and user notifications.
t0ng7u 8 месяцев назад
Родитель
Сommit
d487be0029

+ 4 - 4
web/src/components/settings/DashboardSetting.js

@@ -121,14 +121,14 @@ const DashboardSetting = () => {
           <SettingsDataDashboard options={inputs} refresh={onRefresh} />
         </Card>
 
-        {/* API信息管理 */}
+        {/* 系统公告管理 */}
         <Card style={{ marginTop: '10px' }}>
-          <SettingsAPIInfo options={inputs} refresh={onRefresh} />
+          <SettingsAnnouncements options={inputs} refresh={onRefresh} />
         </Card>
 
-        {/* 系统公告管理 */}
+        {/* API信息管理 */}
         <Card style={{ marginTop: '10px' }}>
-          <SettingsAnnouncements options={inputs} refresh={onRefresh} />
+          <SettingsAPIInfo options={inputs} refresh={onRefresh} />
         </Card>
 
         {/* 常见问答管理 */}

+ 8 - 2
web/src/pages/Setting/Dashboard/SettingsAnnouncements.js

@@ -388,11 +388,17 @@ const SettingsAnnouncements = ({ options, refresh }) => {
     </div>
   );
 
-  // 计算当前页显示的数据
+  // 计算当前页显示的数据(按发布时间倒序排序,最新优先显示)
   const getCurrentPageData = () => {
+    const sortedList = [...announcementsList].sort((a, b) => {
+      const dateA = new Date(a.publishDate).getTime();
+      const dateB = new Date(b.publishDate).getTime();
+      return dateB - dateA; // 倒序,最新的排在前面
+    });
+
     const startIndex = (currentPage - 1) * pageSize;
     const endIndex = startIndex + pageSize;
-    return announcementsList.slice(startIndex, endIndex);
+    return sortedList.slice(startIndex, endIndex);
   };
 
   const rowSelection = {