Skip to content

Commit

Permalink
添加不可用说明页面
Browse files Browse the repository at this point in the history
  • Loading branch information
ming1016 committed Mar 19, 2024
1 parent ace67ef commit 15eebea
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
14 changes: 12 additions & 2 deletions SwiftPamphletApp/HomeUI/HomeView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,23 @@ struct HomeView: View {
if let link = selectedDataLinkString {
DataLink.viewToShow(for: link, selectInfo: $selectInfo)
} else {
Text("请选择")
ContentUnavailableView {
Label("未选择栏目",
systemImage: "map.circle.fill")
} description: {
Text("请在左侧选择一个栏目")
}
}
} detail: {
if let info = selectInfo {
DetailLink.viewToShow(for: "资料", selectInfo: info)
} else {
Text("请选择")
ContentUnavailableView {
Label("未选",
systemImage: "pencil.tip.crop.circle.badge.plus")
} description: {
Text("请选择或按+号增加一个资料")
}
}
}
.environment(appVM)
Expand Down
2 changes: 1 addition & 1 deletion SwiftPamphletApp/HomeUI/SidebarView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ struct SidebarView: View {
}
}
})
.frame(minWidth: 200)
// .frame(minWidth: 200)
}
}

Expand Down
8 changes: 4 additions & 4 deletions SwiftPamphletApp/InfoOrganizer/Info/EditInfoView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -126,18 +126,18 @@ struct EditInfoView: View {
}

func fetchTitleFromUrl(urlString: String, isFetchContent: Bool = false) async -> (title:String, content:String) {
var title = "没找到标题"
guard let url = URL(string: urlString) else {
return ("","")
return (title,"")
}
guard let (data, _) = try? await URLSession.shared.data(from: url) else {
return ("","")
return (title,"")
}
guard let homepageHTML = String(data: data, encoding: .utf8), let soup = try? SwiftSoup.parse(homepageHTML) else {
return ("","")
return (title,"")
}

// 获取标题
var title = "没找到标题"
let soupTitle = try? soup.title()
let h1Title = try? soup.select("h1").first()?.text()
if let okH1Title = h1Title {
Expand Down

0 comments on commit 15eebea

Please sign in to comment.