Skip to content

Commit 3477aba

Browse files
committed
优化内容样式;无token可查看仓库;生成DMG下载
1 parent 8728efe commit 3477aba

16 files changed

+124
-120
lines changed

SwiftPamphletApp.xcodeproj/project.pbxproj

+4-4
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,11 @@
114114
0844902C279ECEFB00B61353 /* 100.md in Resources */ = {isa = PBXBuildFile; fileRef = 0844902B279ECEFB00B61353 /* 100.md */; };
115115
0844902E279ECF1C00B61353 /* 92.md in Resources */ = {isa = PBXBuildFile; fileRef = 0844902D279ECF1C00B61353 /* 92.md */; };
116116
08449030279ECF7D00B61353 /* 1.md in Resources */ = {isa = PBXBuildFile; fileRef = 0844902F279ECF7D00B61353 /* 1.md */; };
117+
08449034279F6D0D00B61353 /* RepoWebView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 08449033279F6D0D00B61353 /* RepoWebView.swift */; };
117118
086A5F072744E88E00FECE02 /* SwiftPamphletAppApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 086A5F062744E88E00FECE02 /* SwiftPamphletAppApp.swift */; };
118119
086A5F0B2744E89100FECE02 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 086A5F0A2744E89100FECE02 /* Assets.xcassets */; };
119120
086A5F0E2744E89100FECE02 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 086A5F0D2744E89100FECE02 /* Preview Assets.xcassets */; };
120121
086A5F2E2744ED8600FECE02 /* ActiveDeveloperListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 086A5F2A2744ED8600FECE02 /* ActiveDeveloperListView.swift */; };
121-
086A5F2F2744ED8600FECE02 /* SPIssuesListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 086A5F2B2744ED8600FECE02 /* SPIssuesListView.swift */; };
122122
086A5F302744ED8600FECE02 /* IssuesListFromCustomView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 086A5F2C2744ED8600FECE02 /* IssuesListFromCustomView.swift */; };
123123
086A5F352744ED9600FECE02 /* IssueView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 086A5F322744ED9600FECE02 /* IssueView.swift */; };
124124
086A5F362744ED9600FECE02 /* RepoView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 086A5F332744ED9600FECE02 /* RepoView.swift */; };
@@ -279,13 +279,13 @@
279279
0844902B279ECEFB00B61353 /* 100.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = 100.md; sourceTree = "<group>"; };
280280
0844902D279ECF1C00B61353 /* 92.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = 92.md; sourceTree = "<group>"; };
281281
0844902F279ECF7D00B61353 /* 1.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = 1.md; sourceTree = "<group>"; };
282+
08449033279F6D0D00B61353 /* RepoWebView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RepoWebView.swift; sourceTree = "<group>"; };
282283
086A5F032744E88E00FECE02 /* 戴铭的Swift小册子.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "戴铭的Swift小册子.app"; sourceTree = BUILT_PRODUCTS_DIR; };
283284
086A5F062744E88E00FECE02 /* SwiftPamphletAppApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftPamphletAppApp.swift; sourceTree = "<group>"; };
284285
086A5F0A2744E89100FECE02 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
285286
086A5F0D2744E89100FECE02 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = "<group>"; };
286287
086A5F0F2744E89100FECE02 /* SwiftPamphletApp.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = SwiftPamphletApp.entitlements; sourceTree = "<group>"; };
287288
086A5F2A2744ED8600FECE02 /* ActiveDeveloperListView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ActiveDeveloperListView.swift; sourceTree = "<group>"; };
288-
086A5F2B2744ED8600FECE02 /* SPIssuesListView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SPIssuesListView.swift; sourceTree = "<group>"; };
289289
086A5F2C2744ED8600FECE02 /* IssuesListFromCustomView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = IssuesListFromCustomView.swift; sourceTree = "<group>"; };
290290
086A5F322744ED9600FECE02 /* IssueView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = IssueView.swift; sourceTree = "<group>"; };
291291
086A5F332744ED9600FECE02 /* RepoView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RepoView.swift; sourceTree = "<group>"; };
@@ -749,7 +749,6 @@
749749
children = (
750750
086A5F2A2744ED8600FECE02 /* ActiveDeveloperListView.swift */,
751751
086A5F2C2744ED8600FECE02 /* IssuesListFromCustomView.swift */,
752-
086A5F2B2744ED8600FECE02 /* SPIssuesListView.swift */,
753752
08BF26D7276B5D7F0064DDAC /* ExploreRepoListView.swift */,
754753
);
755754
path = ListView;
@@ -762,6 +761,7 @@
762761
086A5F332744ED9600FECE02 /* RepoView.swift */,
763762
086A5F342744ED9600FECE02 /* UserView.swift */,
764763
08448F4A279E872B00B61353 /* GuideView.swift */,
764+
08449033279F6D0D00B61353 /* RepoWebView.swift */,
765765
);
766766
path = DetailView;
767767
sourceTree = "<group>";
@@ -1172,6 +1172,7 @@
11721172
086A5F362744ED9600FECE02 /* RepoView.swift in Sources */,
11731173
086A5F302744ED8600FECE02 /* IssuesListFromCustomView.swift in Sources */,
11741174
08CD61F927758AF0008C0935 /* ParseStandXMLTagTokens.swift in Sources */,
1175+
08449034279F6D0D00B61353 /* RepoWebView.swift in Sources */,
11751176
086A5F3B2744EDA500FECE02 /* GitHubAPIModel.swift in Sources */,
11761177
086A5F072744E88E00FECE02 /* SwiftPamphletAppApp.swift in Sources */,
11771178
08AEAEDB277EA5C300B969E2 /* RSSModel.swift in Sources */,
@@ -1192,7 +1193,6 @@
11921193
08D4F0FE275F728C005FC997 /* LinkView.swift in Sources */,
11931194
08AEAEE1277EA70500B969E2 /* DBRepoStore.swift in Sources */,
11941195
08CD61FA27758AF0008C0935 /* ParseStandXML.swift in Sources */,
1195-
086A5F2F2744ED8600FECE02 /* SPIssuesListView.swift in Sources */,
11961196
);
11971197
runOnlyForDeploymentPostprocessing = 0;
11981198
};

SwiftPamphletApp/AppVM.swift

+10
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ final class AppVM: ObservableObject {
3939
private var stepCountExp = 0
4040
private var expNotisKeys = [String]()
4141

42+
// MARK: WebLink
43+
@MainActor
44+
func updateWebLink(s: String) {
45+
webLinkStr = s
46+
}
47+
4248
// MARK: - RSS 读取
4349
func rssFetch() {
4450
Task {
@@ -230,6 +236,7 @@ final class AppVM: ObservableObject {
230236
func onAppearEvent() {
231237
nsck()
232238
// 开发者数据读取
239+
refreshDev()
233240
loadDBDevsLoal()
234241
// 探索更多库
235242
loadDBExpLoal()
@@ -347,6 +354,9 @@ final class AppVM: ObservableObject {
347354
// MARK: - 计算通知数量
348355
@MainActor
349356
func calculateExpCountNotis() {
357+
if SPC.gitHubAccessToken.isEmpty == true {
358+
return
359+
}
350360
var count = 0
351361
for i in expNotis {
352362
count += i.value.unRead

SwiftPamphletApp/Core/FundationFunction.swift

+8-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import SwiftDate
1414

1515
// MARK: - Web
1616
func wrapperHtmlContent(content: String, codeStyle: String = "lioshi.min") -> String {
17-
return """
17+
let reStr = """
1818
<html lang="zh-Hans" data-darkmode="auto">
1919
\(SPC.rssStyle())
2020
<body>
@@ -24,9 +24,11 @@ func wrapperHtmlContent(content: String, codeStyle: String = "lioshi.min") -> St
2424
</article>
2525
</main>
2626
</body>
27-
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.4.0/styles/\(codeStyle).css">
2827
</html>
2928
"""
29+
// <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.4.0/styles/\(codeStyle).css">
30+
// writeToDownload(fileName: "a.html", content: reStr)
31+
return reStr
3032
}
3133

3234
// MARK: - 时间
@@ -112,6 +114,10 @@ func validHTTPUrlStrFromUrlStr(urlStr: String) -> String {
112114

113115

114116
// MARK: - 文件
117+
// just for test
118+
func writeToDownload(fileName: String, content: String) {
119+
try! content.write(toFile: "/Users/mingdai/Downloads/\(fileName)", atomically: true, encoding: String.Encoding.utf8)
120+
}
115121

116122
// 从Bundle中读取并解析JSON文件生成Model
117123
func loadBundleJSONFile<T: Decodable>(_ filename: String) -> T {

SwiftPamphletApp/GItHubAPI/DetailView/GuideView.swift

+1-4
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,7 @@ struct GuideView: View {
1414
var body: some View {
1515
WebUIView(html: wrapperHtmlContent(content: MarkdownParser().html(from: "\(loadBundleString("\(number)" + ".md"))")), baseURLStr: "")
1616
.onAppear {
17-
appVM.webLinkStr = "https://github.com/\(SPC.pamphletIssueRepoName)/issues/" + "\(number)"
18-
}
19-
.onDisappear {
20-
appVM.webLinkStr = ""
17+
appVM.updateWebLink(s: "https://github.com/\(SPC.pamphletIssueRepoName)/issues/" + "\(number)")
2118
}
2219
}
2320
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//
2+
// RepoWebView.swift
3+
// SwiftPamphletApp
4+
//
5+
// Created by Ming Dai on 2022/1/25.
6+
//
7+
8+
import SwiftUI
9+
10+
struct RepoWebView: View {
11+
@EnvironmentObject var appVM: AppVM
12+
var urlStr: String
13+
var body: some View {
14+
WebView(urlStr: urlStr)
15+
.onAppear {
16+
appVM.updateWebLink(s: urlStr)
17+
}
18+
}
19+
}
20+
21+

SwiftPamphletApp/GItHubAPI/ListView/ExploreRepoListView.swift

+24-11
Original file line numberDiff line numberDiff line change
@@ -9,30 +9,40 @@ import SwiftUI
99

1010
struct ExploreRepoListView: View {
1111
@EnvironmentObject var appVM: AppVM
12-
@State private var isExpended = false
12+
@State var isExpanded = true
1313
var body: some View {
1414
List {
15-
Section {
16-
ForEach(appVM.exps) { er in
17-
ForEach(er.repos) { r in
18-
ExpListUnreadLinkView(r: r)
15+
if SPC.gitHubAccessToken.isEmpty == false {
16+
DisclosureGroup(isExpanded: $isExpanded) {
17+
ForEach(appVM.exps) { er in
18+
ForEach(er.repos) { r in
19+
ExpListUnreadLinkView(r: r)
20+
}
1921
}
22+
} label: {
23+
Text("刚更新的").font(.title3)
2024
}
21-
} header: {
22-
Text("刚更新的").font(.title)
2325
}
26+
2427
// end Section
2528
ForEach(appVM.exps) { er in
26-
2729
DisclosureGroup {
2830
ForEach(er.repos) { r in
29-
if (appVM.expNotis[r.id]?.unRead ?? 0) > 0 {
31+
32+
if SPC.gitHubAccessToken.isEmpty == false {
33+
if (appVM.expNotis[r.id]?.unRead ?? 0) > 0 {
34+
35+
} else {
36+
NavigationLink(destination: RepoView(vm: RepoVM(repoName: r.id))) {
37+
ExpListLinkView(r: r)
38+
}
39+
} // end if
3040

3141
} else {
32-
NavigationLink(destination: RepoView(vm: RepoVM(repoName: r.id))) {
42+
NavigationLink(destination: RepoWebView(urlStr: SPC.githubHost + r.id)) {
3343
ExpListLinkView(r: r)
3444
}
35-
} // end if
45+
} // end if token
3646
} // end ForEach
3747
} label: {
3848
Text(er.name).font(.title3)
@@ -44,6 +54,9 @@ struct ExploreRepoListView: View {
4454
.onAppear {
4555
appVM.loadExpFromServer()
4656
}
57+
.onDisappear {
58+
appVM.updateWebLink(s: "")
59+
}
4760
}
4861
}
4962

SwiftPamphletApp/GItHubAPI/ListView/IssuesListFromCustomView.swift

+4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import SwiftUI
99

1010
struct IssuesListFromCustomView: View {
11+
@EnvironmentObject var appVM: AppVM
1112
@StateObject var vm: IssueVM
1213
var body: some View {
1314
List {
@@ -31,6 +32,9 @@ struct IssuesListFromCustomView: View {
3132
.onAppear {
3233
vm.doing(.customIssues)
3334
}
35+
.onDisappear {
36+
appVM.updateWebLink(s: "")
37+
}
3438
}
3539
}
3640

SwiftPamphletApp/GItHubAPI/ListView/SPIssuesListView.swift

-39
This file was deleted.

SwiftPamphletApp/RSSReader/View/RSSItemContentView.swift

+1-4
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,7 @@ struct RSSItemContentView: View {
1616
WebUIView(html:wrapperHtmlContent(content: "<h1><a href=\"\(rssItemModel.link.replacingOccurrences(of: "http://", with: "https://"))\">\(rssItemModel.title)</a></h1>" + (rssItemModel.content.isEmpty ? rssItemModel.description : rssItemModel.content) + "<p><a href=\"\(rssItemModel.link.replacingOccurrences(of: "http://", with: "https://"))\">阅读原文</a></p>"), baseURLStr: rssItemModel.link)
1717
.onAppear {
1818
vm.readContent(linkStr: rssItemModel.link, rssLinkStr: rssLink)
19-
appVM.webLinkStr = rssItemModel.link
20-
}
21-
.onDisappear {
22-
appVM.webLinkStr = ""
19+
appVM.updateWebLink(s: rssItemModel.link)
2320
}
2421
}
2522
}

SwiftPamphletApp/RSSReader/View/RSSItemsView.swift

+4-1
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
import SwiftUI
99

1010
struct RSSItemsView: View {
11+
@EnvironmentObject var appVM: AppVM
1112
@EnvironmentObject var vm: RSSVM
1213
var rssLink: String
1314

1415
var body: some View {
1516
HStack {
16-
1717
Button {
1818
vm.markAllAsRead(rssLink: rssLink)
1919
} label: {
@@ -48,6 +48,9 @@ struct RSSItemsView: View {
4848
.onAppear {
4949
vm.showItems(rssLink: rssLink)
5050
}
51+
.onDisappear {
52+
appVM.updateWebLink(s: "")
53+
}
5154
}
5255
}
5356

SwiftPamphletApp/Resource/Archive/archiveRepos.json

+10
Original file line numberDiff line numberDiff line change
@@ -169,5 +169,15 @@
169169
"des":"一个基于Linux的iOS和SwiftUI服务器监控工具,使用远程proc文件系统和脚本执行。"
170170
}
171171
]
172+
},
173+
{
174+
"name":"待分类",
175+
"id":2201250515,
176+
"repos":[
177+
{
178+
"id":"alaskasquirrel/Lisp-China",
179+
"des":"Lisp 资料"
180+
}
181+
]
172182
}
173183
]

SwiftPamphletApp/Resource/Style/css_cn.html

+2-15
Original file line numberDiff line numberDiff line change
@@ -861,19 +861,6 @@
861861
background-color: #ededed;
862862
}
863863
.container {
864-
box-sizing: border-box;
865-
width: 80%;
866-
min-width: 640px;
867-
max-width: 768px;
868-
margin-block-start: 48px;
869-
margin-block-end: 72px;
870-
margin-inline-start: auto;
871-
margin-inline-end: auto;
872-
padding-block-start: 48px;
873-
padding-block-end: 48px;
874-
padding-inline-start: 48px;
875-
padding-inline-end: 48px;
876-
border-radius: 2px;
877864
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.32);
878865
background-color: white;
879866
}
@@ -910,7 +897,7 @@
910897
}
911898

912899
[data-darkmode="dark"] body {
913-
background-color: #3d3d3d;
900+
background-color: #292929;
914901
}
915902

916903
[data-darkmode="dark"] a {
@@ -932,7 +919,7 @@
932919

933920
@media (prefers-color-scheme: dark) {
934921
[data-darkmode="auto"] body {
935-
background-color: #3d3d3d;
922+
background-color: #292929;
936923
}
937924
[data-darkmode="auto"] a {
938925
color: #6b90cc;

0 commit comments

Comments
 (0)