From 20eba9c7e10564c6a068796a372d9d46a017be75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=88=B4=E9=93=AD?= Date: Wed, 13 Mar 2024 17:49:19 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E8=A1=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SwiftPamphletApp/InfoOrganizer/Info/InfoListView.swift | 5 +++++ .../InfoOrganizer/Info/InfosFilterWithCateView.swift | 2 +- SwiftPamphletApp/InfoOrganizer/Info/InfosView.swift | 2 +- SwiftPamphletApp/InfoOrganizer/Model/InfoDataModel.swift | 6 +++--- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/SwiftPamphletApp/InfoOrganizer/Info/InfoListView.swift b/SwiftPamphletApp/InfoOrganizer/Info/InfoListView.swift index b9b5da774..7ac09d7ef 100644 --- a/SwiftPamphletApp/InfoOrganizer/Info/InfoListView.swift +++ b/SwiftPamphletApp/InfoOrganizer/Info/InfoListView.swift @@ -29,6 +29,9 @@ struct InfoListView: View { Menu("Sort", systemImage: "tag") { Picker("分类", selection: $filterCate) { + Text("全部") + .tag("") + ForEach(cates) { cate in Text(cate.name) .tag(cate.name) @@ -71,6 +74,8 @@ struct InfoListView: View { ToolbarItem(placement: .navigation) { Menu("Sort", systemImage: "tag") { Picker("分类", selection: $filterCate) { + Text("全部") + .tag("") ForEach(cates) { cate in Text(cate.name) .tag(cate.name) diff --git a/SwiftPamphletApp/InfoOrganizer/Info/InfosFilterWithCateView.swift b/SwiftPamphletApp/InfoOrganizer/Info/InfosFilterWithCateView.swift index 0320006ac..153a1db2b 100644 --- a/SwiftPamphletApp/InfoOrganizer/Info/InfosFilterWithCateView.swift +++ b/SwiftPamphletApp/InfoOrganizer/Info/InfosFilterWithCateView.swift @@ -22,7 +22,7 @@ struct InfosFilterWithCateView: View { info.category?.name == filterCateName } }, sortBy: sortOrder) - fd.fetchLimit = 1000 + fd.fetchLimit = 10000 _infos = Query(fd) self._selectInfo = selectInfo diff --git a/SwiftPamphletApp/InfoOrganizer/Info/InfosView.swift b/SwiftPamphletApp/InfoOrganizer/Info/InfosView.swift index f747ac738..38dae7730 100644 --- a/SwiftPamphletApp/InfoOrganizer/Info/InfosView.swift +++ b/SwiftPamphletApp/InfoOrganizer/Info/InfosView.swift @@ -23,7 +23,7 @@ struct InfosView: View { || info.des.localizedStandardContains(searchString) } }, sortBy: sortOrder) - fd.fetchLimit = 1000 + fd.fetchLimit = 10000 _infos = Query(fd) self._selectInfo = selectInfo diff --git a/SwiftPamphletApp/InfoOrganizer/Model/InfoDataModel.swift b/SwiftPamphletApp/InfoOrganizer/Model/InfoDataModel.swift index 59674edee..8f7a69ac5 100644 --- a/SwiftPamphletApp/InfoOrganizer/Model/InfoDataModel.swift +++ b/SwiftPamphletApp/InfoOrganizer/Model/InfoDataModel.swift @@ -13,7 +13,7 @@ final class IOInfo { var name: String = "" var url: String = "" var des: String = "" - var category: IOCategory? + var category: IOCategory? = nil// 关系字段,链接 IOCategory var createDate: Date = Date.now var updateDate: Date = Date.now @@ -43,7 +43,7 @@ final class IOInfo { @Model class IOCategory { var name: String = "" - var infos: [IOInfo]? = [IOInfo]() + var infos: [IOInfo]? = [IOInfo]() // 关系字段,链接 IOInfo var createDate: Date = Date.now var updateDate: Date = Date.now @@ -58,7 +58,7 @@ class IOCategory { } static var all: FetchDescriptor { - var fd = FetchDescriptor(sortBy: [SortDescriptor(\IOCategory.updateDate, order: .reverse)]) + let fd = FetchDescriptor(sortBy: [SortDescriptor(\IOCategory.updateDate, order: .reverse)]) return fd }