Skip to content

bitnpc/Smth

Repository files navigation

Smth

基于 SwiftUI 打造的水木社区多端客户端(iOS / iPadOS / macOS)。采用 MVVM + Repository 架构,支持依赖注入、分页加载和多平台适配。 项目详细介绍可以查看我的博客文章 Smth 客户端开发:从 MVVM 架构到多平台适配的 SwiftUI 实践

📱 功能亮点

核心功能

  • 热门话题浏览 - 瀑布流展示,支持分页加载
  • 版面导航 - 层级式版面/子版面导航
  • 话题详情 - 完整的话题内容与楼层回复展示
  • 图片查看器 - 支持多图片滑动浏览、缩放、双击放大(iOS 基于 UIKit,macOS 基于 SwiftUI)
  • 用户登录 - 基于 WebView 的登录认证
  • 收藏管理 - 收藏版面与话题,支持分类查看
  • 消息中心 - 收件箱、@我的、回复我的、Like我的
  • 个人中心 - 个人资料、我的话题、草稿、关注/粉丝、浏览历史
  • 搜索功能 - 版面与话题搜索

用户体验

  • 🎨 现代化 UI - 统一的主题系统,支持深色模式
  • 📱 多平台适配 - iOS、iPadOS、macOS 原生体验
  • 🔄 响应式布局 - 自适应不同屏幕尺寸
  • 流畅交互 - 优化的加载状态与错误处理
  • 💾 本地缓存 - 浏览历史与草稿本地存储

🏗️ 项目架构

采用 MVVM + Repository 架构模式:

View (SwiftUI) → ViewModel → Repository → APIService

核心组件

  • Core: 认证、数据库、依赖注入、网络层、工具类
  • Modules: 首页、收藏、消息、个人中心、搜索(MVVM 结构)
  • Components: 可复用 UI 组件(包括图片查看器)
  • Model: 数据模型和 DTO

多平台适配

  • iOS: TabView 底部导航
  • iPadOS: NavigationSplitView 侧边栏布局
  • macOS: NavigationSplitView 侧边栏 + 内容区

📸 应用截图

首页 收藏 消息
首页 收藏 消息
个人中心 设置 登录
个人中心 设置 登录

🎯 已实现功能

首页模块

  • 热门话题列表(瀑布流)
  • 版面选择器
  • 话题详情页
  • 文章回复展示
  • 图片附件展示
  • 下拉刷新

收藏模块

  • 收藏版面列表
  • 收藏话题列表
  • 版面/话题切换
  • 版面层级导航

消息模块

  • 收件箱、@我的、回复我的、Like我的
  • 会话详情
  • 消息分页加载

个人中心模块

  • 用户登录(WebView)
  • 个人资料展示
  • 我的话题列表
  • 草稿管理
  • 关注列表
  • 粉丝列表
  • 浏览历史
  • 设置页面

搜索模块

  • 版面搜索
  • 话题搜索

通用功能

  • 图片缓存
  • 图片查看器(支持多图滑动、缩放、双击放大)
  • 浏览历史本地存储
  • 字体大小设置
  • 深色模式支持
  • 错误处理与重试

🚧 待实现功能

内容交互

  • 翻页功能 - 话题详情页的翻页导航(上一页/下一页)
  • 发帖功能 - 发布新话题
  • 评论功能 - 回复话题和楼层
  • 点赞功能 - 对话题和回复进行点赞/取消点赞

社交功能

  • 关注功能 - 关注/取消关注用户(目前仅支持查看关注列表)
  • 黑名单功能 - 管理黑名单用户

账户管理

  • 修改密码 - 账户密码修改
  • 绑定手机号 - 手机号绑定与验证

其他功能

  • 编辑帖子 - 编辑已发布的帖子
  • 删除帖子 - 删除自己发布的帖子
  • 举报功能 - 举报不当内容
  • 私信功能 - 用户间私信交流
  • 推送通知 - 消息推送提醒

🖥️ 平台适配

平台 最低版本 状态
iOS 18.0+ ✅ 完全支持
iPadOS 18.0+ ✅ 完全支持
macOS 15.0+ ✅ 完全支持

🚀 快速开始

环境要求

  • Xcode 15.0+
  • Swift 5.9+
  • iOS 18.0+ / macOS 15.0+

安装步骤

# 克隆项目
git clone <repository-url>
cd Smth

# 打开项目
open Smth.xcodeproj

# 构建并运行 (Cmd + R)

依赖通过 Swift Package Manager 管理,会自动下载。

开发指南

# 代码规范检查
swiftlint --config swiftlint.yml

# 构建项目
xcodebuild -scheme Smth -project Smth.xcodeproj \
  -destination 'platform=iOS Simulator,name=iPhone 16' build

# 运行测试
xcodebuild test -scheme Smth -destination 'platform=iOS Simulator,name=iPhone 16'

📦 依赖管理

  • SwiftSoup (2.6.1) - HTML 解析
  • Alamofire (5.8.0) - HTTP 网络请求

🧪 测试

  • ✅ ViewModel 单元测试
  • ✅ Repository 测试
  • ✅ 数据模型测试
  • ⏳ UI 测试(待完善)

🤝 贡献指南

欢迎贡献代码!请遵循以下步骤:

  1. Fork 项目
  2. 创建功能分支 (git checkout -b feature/AmazingFeature)
  3. 提交更改 (git commit -m 'Add some AmazingFeature')
  4. 推送到分支 (git push origin feature/AmazingFeature)
  5. 开启 Pull Request

代码规范

  • 遵循 SwiftLint 规则
  • 使用清晰的提交信息
  • 为新功能添加测试

📄 许可证

本项目采用 MIT 许可证。详见 LICENSE 文件。

🙏 致谢

  • 感谢水木社区论坛
  • 感谢所有贡献者的支持

📮 联系方式

如有问题或建议,请通过以下方式联系:


注意: 本项目仅供学习交流使用,请遵守水木社区的使用条款。


Smth

A modern SwiftUI client for NewSMTH forum (iOS / iPadOS / macOS). Built with MVVM + Repository architecture, featuring dependency injection, pagination support, and seamless multi-platform compatibility.

📱 Features

Core Features

  • Topic Browsing - Hot topics with pagination
  • Board Navigation - Hierarchical board/sub-board navigation
  • Topic Details - Complete topic content and replies
  • Image Viewer - Multi-image browsing with swipe, zoom, and double-tap to zoom (UIKit on iOS, SwiftUI on macOS)
  • User Login - WebView-based authentication
  • Favorites - Favorite boards and topics management
  • Messages - Inbox, mentions, replies, and likes
  • Profile - User profile, topics, drafts, followers/following, browsing history
  • Search - Board and topic search

User Experience

  • 🎨 Modern UI with unified theme system and dark mode
  • 📱 Native experience on iOS, iPadOS, and macOS
  • 🔄 Responsive layout for different screen sizes
  • ⚡ Optimized loading states and error handling
  • 💾 Local caching for browsing history and drafts

🏗️ Architecture

Built with MVVM + Repository pattern:

View (SwiftUI) → ViewModel → Repository → APIService

Key Components

  • Core: Authentication, Database, Dependency Injection, Networking, Utils
  • Modules: Home, Favorite, Message, Profile, Search (MVVM structure)
  • Components: Reusable UI components (including image viewer)
  • Model: Data models and DTOs

Multi-Platform Support

  • iOS: TabView navigation
  • iPadOS: NavigationSplitView with sidebar
  • macOS: NavigationSplitView with sidebar and content area

📸 Screenshots

Home Favorites Messages
首页 收藏 消息
Profile Settings Login
个人中心 设置 登录

🎯 Implemented Features

Home Module

  • Hot topics list with pagination
  • Board selector
  • Topic detail page
  • Article replies display
  • Image attachments
  • Pull to refresh

Favorite Module

  • Favorite boards and topics
  • Board/topic switching
  • Hierarchical board navigation

Message Module

  • Inbox, mentions, replies, likes
  • Conversation details
  • Message pagination

Profile Module

  • User login (WebView)
  • Profile display
  • My topics, drafts
  • Followers/following lists
  • Browsing history
  • Settings

Search Module

  • Board and topic search

Common Features

  • Image caching
  • Image viewer (multi-image swipe, zoom, double-tap to zoom)
  • Local storage (browsing history)
  • Font size settings
  • Dark mode support
  • Error handling and retry

🚧 Planned Features

Content Interaction

  • Page navigation (prev/next page)
  • Post new topics
  • Reply to topics and posts
  • Like/unlike functionality

Social Features

  • Follow/unfollow users
  • Blacklist management

Account Management

  • Change password
  • Bind phone number

Other Features

  • Edit/delete posts
  • Report content
  • Private messages
  • Push notifications

🖥️ Platform Support

Platform Min Version Status
iOS 18.0+ ✅ Fully Supported
iPadOS 18.0+ ✅ Fully Supported
macOS 15.0+ ✅ Fully Supported

🚀 Quick Start

Requirements

  • Xcode 15.0+
  • Swift 5.9+
  • iOS 18.0+ / macOS 15.0+

Installation

# Clone the repository
git clone <repository-url>
cd Smth

# Open in Xcode
open Smth.xcodeproj

# Build and run (Cmd + R)

Dependencies are managed via Swift Package Manager and will be automatically resolved.

Development

# Code linting
swiftlint --config swiftlint.yml

# Build
xcodebuild -scheme Smth -project Smth.xcodeproj \
  -destination 'platform=iOS Simulator,name=iPhone 16' build

# Run tests
xcodebuild test -scheme Smth -destination 'platform=iOS Simulator,name=iPhone 16'

📦 Dependencies

  • SwiftSoup (2.6.1) - HTML parsing
  • Alamofire (5.8.0) - HTTP networking

🧪 Testing

  • ✅ ViewModel unit tests
  • ✅ Repository tests
  • ✅ Data model tests
  • ⏳ UI tests (pending)

🤝 Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

Code Style

  • Follow SwiftLint rules
  • Write clear commit messages
  • Add tests for new features

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

🙏 Acknowledgments

  • Thanks to NewSMTH forum
  • Thanks to all contributors

📮 Contact

For questions or suggestions:


Note: This project is for educational purposes only. Please comply with NewSMTH forum's terms of use.

About

基于 SwiftUI 打造的水木社区论坛客户端(支持 iOS / iPadOS / macOS)

Topics

Resources

License

Stars

Watchers

Forks