feat: 允许没有背景#636
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
Summary by CodeRabbit发布说明
Walkthrough在 LogsSection.vue 添加不可见的触发元素与 7 次/3 秒的切换逻辑,状态用 localStorage 持久化并派发 变更开发者模式触发和背景绕过
Sequence DiagramsequenceDiagram
participant User
participant LogsSection
participant localStorage
participant Window
participant useBackground
participant document as document.body.style
User->>LogsSection: 点击隐藏触发器(最多 7 次)
LogsSection->>LogsSection: 累加点击计数并在 3s 内判断阈值
LogsSection->>localStorage: writeDevMode(enabled)
LogsSection->>Window: dispatchEvent('sunshine-background-bypass', {enabled})
Window->>useBackground: 事件到达
alt enabled = true
useBackground->>document: 清除内联 background
else enabled = false
useBackground->>useBackground: loadBackground() 重新应用
end
预估代码审查工作量🎯 3 (中等) | ⏱️ ~20 分钟 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint skipped: no ESLint configuration detected in root package.json. To enable, add Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
src_assets/common/assets/web/composables/useBackground.js (1)
198-205: ⚡ Quick win建议把 dev key 和事件名抽成共享常量,避免跨文件漂移
这里与
LogsSection.vue使用同一组字符串字面量;建议集中定义后统一引用,减少未来改名或拼写不一致导致的隐性故障。建议修复
+// src_assets/common/assets/web/constants/devMode.js +export const DEV_MODE_STORAGE_KEY = 'sunshine_dev_mode' +export const BACKGROUND_BYPASS_EVENT = 'sunshine-background-bypass'-const isDevMode = () => localStorage.getItem('sunshine_dev_mode') === '1' +import { DEV_MODE_STORAGE_KEY, BACKGROUND_BYPASS_EVENT } from '../constants/devMode' +const isDevMode = () => localStorage.getItem(DEV_MODE_STORAGE_KEY) === '1' @@ - if (localStorage.getItem('sunshine_dev_mode') === '1') { - localStorage.setItem('sunshine_dev_mode', '0') + if (localStorage.getItem(DEV_MODE_STORAGE_KEY) === '1') { + localStorage.setItem(DEV_MODE_STORAGE_KEY, '0') @@ - window.addEventListener('sunshine-background-bypass', onBackgroundBypass) + window.addEventListener(BACKGROUND_BYPASS_EVENT, onBackgroundBypass)As per coding guidelines
src_assets/**/*.{vue,js,html}: 基于 Vue.js 的 Web 配置面板。审查 XSS/CSRF 安全性、 组件设计、状态管理和可访问性。Also applies to: 340-346
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src_assets/common/assets/web/composables/useBackground.js` around lines 198 - 205, Extract the literal key and event name used for dev bypass into shared constants and update usages: create a small constants export (e.g., DEV_MODE_KEY and DEV_MODE_EVENT) and replace the string literals in useBackground.js (functions isDevMode and clearDevBypass) and in LogsSection.vue so both files import and reference the same symbols; ensure the constants file is co-located with other web composables and exported for reuse to avoid future drift and typos.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src_assets/common/assets/web/components/LogsSection.vue`:
- Around line 174-187: The code directly accesses localStorage in the devMode
initialization and inside handleDevTap (symbols: DEV_STORAGE_KEY, devMode,
handleDevTap, devTapTimer, DEV_TAP_TIMEOUT, DEV_TAP_THRESHOLD); wrap both the
read and write operations in try-catch blocks (or guard with a safe localStorage
helper) so SecurityError in privacy/locked environments won't throw—on read
return a safe default (devMode false) when access fails and on write silently
ignore failures (or update an in-memory fallback), keep the rest of handleDevTap
logic intact and still dispatch the toggle event after updating the safe state.
In `@src_assets/common/assets/web/composables/useBackground.js`:
- Around line 339-346: The global event listener ('sunshine-background-bypass')
and the MutationObserver created inside useBackground are not cleaned up,
causing leaks; update useBackground to store references to the
window.addEventListener handler and the MutationObserver instance and register a
cleanup using Vue's onScopeDispose: remove the window event listener via
window.removeEventListener('sunshine-background-bypass', handler) and call
observer.disconnect() inside the onScopeDispose callback so both the listener
and observer are properly released when the component using useBackground is
unmounted.
---
Nitpick comments:
In `@src_assets/common/assets/web/composables/useBackground.js`:
- Around line 198-205: Extract the literal key and event name used for dev
bypass into shared constants and update usages: create a small constants export
(e.g., DEV_MODE_KEY and DEV_MODE_EVENT) and replace the string literals in
useBackground.js (functions isDevMode and clearDevBypass) and in LogsSection.vue
so both files import and reference the same symbols; ensure the constants file
is co-located with other web composables and exported for reuse to avoid future
drift and typos.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: bd047fed-7b9f-49e8-9967-c160e0fa32e2
📒 Files selected for processing (2)
src_assets/common/assets/web/components/LogsSection.vuesrc_assets/common/assets/web/composables/useBackground.js
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Windows
🧰 Additional context used
📓 Path-based instructions (1)
src_assets/**/*.{vue,js,html}
⚙️ CodeRabbit configuration file
src_assets/**/*.{vue,js,html}: 基于 Vue.js 的 Web 配置面板。审查 XSS/CSRF 安全性、 组件设计、状态管理和可访问性。
Files:
src_assets/common/assets/web/components/LogsSection.vuesrc_assets/common/assets/web/composables/useBackground.js
🔇 Additional comments (1)
src_assets/common/assets/web/components/LogsSection.vue (1)
80-83: 阈值、超时和存储键提为常量是个不错的改动这段改动提升了可读性和后续调整成本。
|
@copilot 帮我解决一下在我仓库开个pr pr到这个分支 |
4db4aa3 to
e5579b9
Compare
No description provided.