Conversation
- 在 SwaggerModule 中注入 /swagger-ui/custom.css 与 /swagger-ui/theme-toggle.js,启用深色模式样式与主题切换脚本 - 添加/更新 wwwroot/swagger-ui/custom.css(优化深色配色与只覆盖颜色的策略) - 新增 theme-toggle.js 脚本以支持本地存储与系统主题检测的深/浅色切换 - 在应用初始化中启用静态文件中间件 (UseStaticFiles) 以对外提供上述静态资源 - 格式化 sample/WebApi.Test.Unit/Script.js(统一引号、缩进与样式)
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR adds dark theme support to Swagger UI with a theme toggle button, allowing users to switch between light and dark modes. The implementation includes localStorage persistence and system preference detection.
Key changes:
- Created a custom CSS file with comprehensive dark theme styling using GitHub Dark color scheme
- Implemented a JavaScript theme toggle with localStorage persistence and system preference detection
- Integrated the custom CSS and JavaScript into Swagger UI configuration
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
sample/WebApi.Test.Unit/wwwroot/swagger-ui/theme-toggle.js |
New JavaScript file implementing theme toggle functionality with localStorage persistence and system preference detection |
sample/WebApi.Test.Unit/wwwroot/swagger-ui/custom.css |
New CSS file defining dark theme styles for all Swagger UI components using CSS custom properties |
sample/WebApi.Test.Unit/ServiceModules/SwaggerModule.cs |
Updated Swagger configuration to inject custom CSS and JavaScript files |
sample/WebApi.Test.Unit/Script.js |
Code formatting changes (quotes, indentation) - no functional changes |
sample/WebApi.Test.Unit/AppWebModule.cs |
Added static file middleware to serve wwwroot files |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📝 描述 (Description)
为 Swagger UI 添加深色主题支持
🔗 相关问题 (Related Issues)
🏷️ 变更类型 (Type of Change)
✅ 检查清单 (Checklist)
🧪 测试 (Testing)
📸 截图 (如果适用) (Screenshots (if applicable))
🔍 附加说明 (Additional Notes)