feat: custom background image with frosted glass effect#51
Merged
Conversation
Closed
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
- Add background settings (enabled, url, imageData, blur, opacity) to settings.js - Add watchSettings same-tab reactivity via custom DOM event dispatch - Create BackgroundSettingsCard.vue with URL input, file upload, sliders, preview - Apply background layer in App.vue with blur filter and dark overlay - Add background settings tab to settings.vue navigation Agent-Logs-Url: https://github.com/ZeroCatDev/Classworks/sessions/6dfae4c0-df49-4612-88b8-9e31287538b0 Co-authored-by: Sunwuyuan <88357633+Sunwuyuan@users.noreply.github.com>
Deploying classworks with
|
| Latest commit: |
1f33d6d
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://d820541a.classworks.pages.dev |
| Branch Preview URL: | https://copilot-add-custom-backgroun.classworks.pages.dev |
- Use SETTINGS_CHANGED_EVENT constant to prevent typos - Enforce 2MB image size limit (block upload instead of warn) - Fix resetAll to force re-render SettingItem for enabled toggle - Optimize watchSettings callback to only reload on relevant key changes Agent-Logs-Url: https://github.com/ZeroCatDev/Classworks/sessions/6dfae4c0-df49-4612-88b8-9e31287538b0 Co-authored-by: Sunwuyuan <88357633+Sunwuyuan@users.noreply.github.com>
…r messages Agent-Logs-Url: https://github.com/ZeroCatDev/Classworks/sessions/6dfae4c0-df49-4612-88b8-9e31287538b0 Co-authored-by: Sunwuyuan <88357633+Sunwuyuan@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add custom background image feature
feat: custom background image with frosted glass effect
Apr 11, 2026
There was a problem hiding this comment.
Pull request overview
Adds a configurable custom background image feature to the app, wired through the existing settings system and surfaced in the Settings UI.
Changes:
- Added background-related settings definitions and extended
watchSettingsto also react to same-tab setting changes via a custom DOM event. - Introduced
BackgroundSettingsCard.vuefor configuring background source (URL/upload), blur, opacity, and preview. - Updated
App.vueandsettings.vueto render/apply the background layer and expose a new “背景” settings tab.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 7 comments.
| File | Description |
|---|---|
| src/utils/settings.js | Adds background settings keys; adds same-tab settings change notifications and updates watchSettings listeners. |
| src/pages/settings.vue | Adds a new “背景” tab and registers BackgroundSettingsCard. |
| src/components/settings/cards/BackgroundSettingsCard.vue | New UI card for background configuration, upload handling, and preview. |
| src/App.vue | Renders/apply background image + overlay and reacts to settings changes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const handler = (event) => { | ||
| const storageHandler = (event) => { | ||
| if (event.key === SETTINGS_STORAGE_KEY) { | ||
| this.settingsCache = JSON.parse(event.newValue); |
| <v-app> | ||
| <v-app :style="vAppStyle"> | ||
| <!-- 自定义背景层 --> | ||
| <template v-if="bgEnabled"> |
Comment on lines
+70
to
+76
| unwatchSettings = watchSettings((_, event) => { | ||
| // If event detail is available (same-tab change), only reload on background keys | ||
| const changedKey = event?.detail?.key; | ||
| if (!changedKey || changedKey.startsWith("background.") || changedKey === "theme.mode") { | ||
| loadBgSettings(); | ||
| theme.global.name.value = getSetting("theme.mode"); | ||
| } |
Comment on lines
+352
to
+362
|
|
||
| async saveAll() { | ||
| this.saving = true; | ||
| try { | ||
| // Determine which image source to persist | ||
| if (this.imageSource === 'upload') { | ||
| setSetting('background.imageData', this.localImageData || ''); | ||
| setSetting('background.url', ''); | ||
| } else { | ||
| setSetting('background.url', this.localUrl || ''); | ||
| setSetting('background.imageData', ''); |
Comment on lines
+327
to
+331
| processFile(file) { | ||
| this.uploadWarning = ''; | ||
|
|
||
| if (!file.type.startsWith('image/')) { | ||
| this.uploadWarning = '请选择图片文件'; |
Comment on lines
+334
to
+338
|
|
||
| const sizeMB = file.size / 1024 / 1024; | ||
| if (sizeMB > MAX_IMAGE_SIZE_MB) { | ||
| this.uploadWarning = `图片大小为 ${sizeMB.toFixed(1)}MB,超过 ${MAX_IMAGE_SIZE_MB}MB 限制,请压缩后重试`; | ||
| return; |
Comment on lines
+69
to
+73
| :class="{ 'upload-hover': isDragging }" | ||
| @dragover.prevent="isDragging = true" | ||
| @dragleave="isDragging = false" | ||
| @drop.prevent="handleDrop" | ||
| @click="triggerFileInput" |
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.
Users requested the ability to set a custom background image on the main view, with frosted glass (blur + dark overlay) controls.
Settings (
src/utils/settings.js)background.*:enabled,url,imageData(base64),blur(0–50 px),opacity(0–80%)SETTINGS_CHANGED_EVENT(classworks:settings:changed) — a custom DOM event dispatched fromsetSetting/resetSettingsowatchSettingscallbacks fire within the same tab, not just cross-tab viastoragewatchSettingscallback now receives the event as a second argument for key-based filteringNew component:
BackgroundSettingsCard.vueSettingItemMAX_IMAGE_SIZE_MB = 2)SettingItemto keep the toggle in syncApp-level background rendering (
src/App.vue)Two
position: fixed; z-index: -1divs injected at the root when the background is enabled:v-appbackground is set totransparentwhen active. ThewatchSettingscallback only reloads state when abackground.*ortheme.modekey changes.Settings page (
src/pages/settings.vue)Added "背景" tab (
mdi-image) wired toBackgroundSettingsCard.