Skip to content

Commit 305020c

Browse files
committed
Switch replies api
1 parent e7695a1 commit 305020c

File tree

6 files changed

+158
-189
lines changed

6 files changed

+158
-189
lines changed

README.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# <img width="50" src="/V2exOS/Assets.xcassets/AppIcon.appiconset/icon_256.png" /> V2exOS <a href="https://apps.apple.com/cn/app/v2exos/id6443544914?mt=12"><img align="right" src="https://user-images.githubusercontent.com/2088605/192413562-5e123118-bd2c-4710-9b68-872ffe61ae4d.png" height="50"></a>
22

3-
43
一个用 SwiftUI 编写的 V2ex macOS 客户端。
54

65
![screenshot](https://user-images.githubusercontent.com/2088605/192312063-def16466-052b-457a-9b4c-856b2afb3a42.png#gh-dark-mode-only)
@@ -10,7 +9,7 @@
109

1110
- 目标打造一个 macOS 平台原生极致体验的 V2ex 客户端
1211
- 使用 SwiftUI 开发,尽量利用系统和语言新特性,最低适配 macOS 12+
13-
- 开发过程中抽象出可复用的 V2ex API 网络层为 Swift Package - [V2exAPI](https://github.com/isaced/V2exAPI)
12+
- 开发过程中抽象出可复用的 V2ex API 网络层为 Swift Package - [V2exAPI](https://github.com/isaced/V2exAPI)
1413

1514
## 功能
1615

@@ -45,14 +44,16 @@
4544

4645
> 当然部分不需要鉴权的功能不登陆也是可以直接使用的
4746
48-
**为什么看不到帖子的回复?**
49-
50-
[获取指定主题下的回复](https://v2ex.com/help/api#get-topic-replies) API 需要认证,参考上述 Personal Access Token 认证登录后即可看到回复列表了。
51-
5247
## 贡献
5348

5449
- 欢迎大家添砖加瓦,需要某个功能可以先提交 [issue](https://github.com/isaced/V2exOS/issues) 讨论,当然也可以直接 [fork](https://github.com/isaced/V2exOS/fork) 仓库,修改代码提交 PR。
5550

51+
直接通过 Xcode 打开本项目即可,如果遇到 SPM 依赖拉取不下来,可以尝试通过 `xcodebuild` 命令更新:
52+
53+
```shell
54+
xcodebuild -resolvePackageDependencies -scmProvider system
55+
```
56+
5657
## 感谢
5758

5859
本项目建立在以下开源库之上,感谢这些优秀的项目:

V2exOS.xcodeproj/project.pbxproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,7 @@
491491
repositoryURL = "https://github.com/isaced/V2exAPI.git";
492492
requirement = {
493493
kind = upToNextMajorVersion;
494-
minimumVersion = 1.0.3;
494+
minimumVersion = 1.1.0;
495495
};
496496
};
497497
0D8F3351288D243A00C27AF1 /* XCRemoteSwiftPackageReference "MarkdownUI" */ = {
@@ -514,8 +514,8 @@
514514
isa = XCRemoteSwiftPackageReference;
515515
repositoryURL = "https://github.com/kishikawakatsumi/KeychainAccess";
516516
requirement = {
517-
branch = master;
518-
kind = branch;
517+
kind = upToNextMajorVersion;
518+
minimumVersion = 4.0.0;
519519
};
520520
};
521521
/* End XCRemoteSwiftPackageReference section */

V2exOS.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved

Lines changed: 11 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

V2exOS.xcodeproj/xcshareddata/xcschemes/V2exOS.xcscheme

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
</Testables>
3232
</TestAction>
3333
<LaunchAction
34-
buildConfiguration = "Debug"
34+
buildConfiguration = "Release"
3535
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
3636
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
3737
launchStyle = "0"

V2exOS/Views/TopicDetail/CommentListView.swift

Lines changed: 61 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -11,84 +11,74 @@ import MarkdownUI
1111
import Kingfisher
1212

1313
struct CommentListView: View {
14-
15-
@EnvironmentObject private var currentUser: CurrentUserStore
16-
17-
var commentCount: Int?
18-
var commentList: [V2Comment]?
19-
20-
var body: some View {
21-
Label("\(commentCount ?? 0) 条回复", systemImage: "bubble.middle.bottom.fill")
2214

23-
if (currentUser.user == nil) {
24-
25-
Divider()
26-
27-
Text("请先登录后才能读取回复列表")
28-
.foregroundColor(.secondary)
29-
30-
} else {
31-
if let commentList {
32-
ForEach(commentList) { comment in
33-
34-
Divider()
35-
36-
HStack(alignment: .top) {
37-
if let avatarUrl = comment.member.avatar {
38-
KFImage.url(URL(string: avatarUrl))
39-
.resizable()
40-
.fade(duration: 0.25)
41-
.scaledToFit()
42-
.frame(width: 40, height: 40)
43-
.mask(RoundedRectangle(cornerRadius: 4))
44-
}
45-
46-
VStack(alignment: .leading, spacing: 6) {
47-
HStack {
48-
if let username = comment.member.username {
49-
UserName(username)
50-
}
15+
@EnvironmentObject private var currentUser: CurrentUserStore
16+
17+
var commentCount: Int?
18+
var commentList: [V2Comment]?
19+
20+
var body: some View {
21+
Label("\(commentCount ?? 0) 条回复", systemImage: "bubble.middle.bottom.fill")
22+
23+
if let commentList {
24+
ForEach(commentList) { comment in
5125

52-
if let created = comment.created {
53-
Text(Date(timeIntervalSince1970: TimeInterval(created)).fromNow())
26+
Divider()
27+
28+
HStack(alignment: .top) {
29+
if let avatarUrl = comment.member.avatarLarge {
30+
KFImage.url(URL(string: avatarUrl))
31+
.resizable()
32+
.fade(duration: 0.25)
33+
.scaledToFit()
34+
.frame(width: 40, height: 40)
35+
.mask(RoundedRectangle(cornerRadius: 4))
36+
}
37+
38+
VStack(alignment: .leading, spacing: 6) {
39+
HStack {
40+
if let username = comment.member.username {
41+
UserName(username)
42+
}
43+
44+
if let created = comment.created {
45+
Text(Date(timeIntervalSince1970: TimeInterval(created)).fromNow())
46+
}
47+
}
48+
.foregroundColor(Color(NSColor.tertiaryLabelColor))
49+
50+
Markdown(
51+
comment.content
52+
.replacingOccurrences(
53+
of: #"https?.*"#,
54+
with: "[$0]($0)",
55+
options: .regularExpression,
56+
range: nil
57+
)
58+
.replacingOccurrences(
59+
of: #"@(\w+)"#,
60+
with: "[$0](https://www.v2ex.com/member/$1)",
61+
options: .regularExpression,
62+
range: nil
63+
)
64+
)
65+
.font(.body)
66+
}
5467
}
55-
}
56-
.foregroundColor(Color(NSColor.tertiaryLabelColor))
57-
58-
Markdown(
59-
comment.content
60-
.replacingOccurrences(
61-
of: #"https?.*"#,
62-
with: "[$0]($0)",
63-
options: .regularExpression,
64-
range: nil
65-
)
66-
.replacingOccurrences(
67-
of: #"@(\w+)"#,
68-
with: "[$0](https://www.v2ex.com/member/$1)",
69-
options: .regularExpression,
70-
range: nil
71-
)
72-
)
73-
.font(.body)
74-
}
75-
}
68+
}
7669
}
77-
}
7870
}
79-
80-
}
8171
}
8272

8373
struct CommentListView_Previews: PreviewProvider {
84-
static var previews: some View {
85-
let commentList = [
86-
PreviewData.comment,
87-
PreviewData.comment,
88-
PreviewData.comment
89-
]
90-
CommentListView(commentList: commentList)
91-
.previewLayout(.fixed(width: 400, height: 200))
92-
}
74+
static var previews: some View {
75+
let commentList = [
76+
PreviewData.comment,
77+
PreviewData.comment,
78+
PreviewData.comment
79+
]
80+
CommentListView(commentList: commentList)
81+
.previewLayout(.fixed(width: 400, height: 200))
82+
}
9383
}
9484

0 commit comments

Comments
 (0)