diff --git a/frontend/src/i18n.ts b/frontend/src/i18n.ts index 038e895..a119c68 100644 --- a/frontend/src/i18n.ts +++ b/frontend/src/i18n.ts @@ -179,6 +179,8 @@ export const i18nData = { "Views Descending": "浏览量降序", "Downloads Ascending": "下载量升序", "Downloads Descending": "下载量降序", + "Release Date Ascending": "发布日期升序", + "Release Date Descending": "发布日期降序", "File Url": "文件链接", "Provide a file url for the server to download, and the file will be moved to the selected storage.": "提供一个文件链接供服务器下载,文件将被移动到选定的存储中。", @@ -446,6 +448,8 @@ export const i18nData = { "Views Descending": "瀏覽量降序", "Downloads Ascending": "下載量升序", "Downloads Descending": "下載量降序", + "Release Date Ascending": "發布日期升序", + "Release Date Descending": "發布日期降序", "File Url": "檔案連結", "Provide a file url for the server to download, and the file will be moved to the selected storage.": "提供一個檔案連結供伺服器下載,檔案將被移動到選定的儲存中。", diff --git a/frontend/src/network/models.ts b/frontend/src/network/models.ts index 0f530a4..4a15852 100644 --- a/frontend/src/network/models.ts +++ b/frontend/src/network/models.ts @@ -197,6 +197,8 @@ export enum RSort { ViewsDesc = 3, DownloadsAsc = 4, DownloadsDesc = 5, + ReleaseDateAsc = 6, + ReleaseDateDesc = 7, } export enum ActivityType { diff --git a/frontend/src/pages/home_page.tsx b/frontend/src/pages/home_page.tsx index dd6ac2a..a278096 100644 --- a/frontend/src/pages/home_page.tsx +++ b/frontend/src/pages/home_page.tsx @@ -48,6 +48,8 @@ export default function HomePage() { t("Views Descending"), t("Downloads Ascending"), t("Downloads Descending"), + t("Release Date Ascending"), + t("Release Date Descending"), ]} current={order} onSelected={(index) => { diff --git a/server/api/resource.go b/server/api/resource.go index 3a1904d..3b668d0 100644 --- a/server/api/resource.go +++ b/server/api/resource.go @@ -109,7 +109,7 @@ func handleListResources(c fiber.Ctx) error { if err != nil { return model.NewRequestError("Invalid sort parameter") } - if sortInt < 0 || sortInt > 5 { + if sortInt < 0 || sortInt > 7 { return model.NewRequestError("Sort parameter out of range") } sort := model.RSort(sortInt) diff --git a/server/dao/resource.go b/server/dao/resource.go index ec77ce2..ca658ad 100644 --- a/server/dao/resource.go +++ b/server/dao/resource.go @@ -99,6 +99,10 @@ func GetResourceList(page, pageSize int, sort model.RSort) ([]model.Resource, in order = "downloads ASC" case model.RSortDownloadsDesc: order = "downloads DESC" + case model.RSortReleaseDateAsc: + order = "release_date ASC" + case model.RSortReleaseDateDesc: + order = "release_date DESC" default: order = "modified_time DESC" // Default sort order } diff --git a/server/model/sort.go b/server/model/sort.go index 9d58742..f8eb700 100644 --- a/server/model/sort.go +++ b/server/model/sort.go @@ -9,4 +9,6 @@ const ( RSortViewsDesc RSortDownloadsAsc RSortDownloadsDesc + RSortReleaseDateAsc + RSortReleaseDateDesc )