feat(desktop): add default background
This commit is contained in:
parent
4e4729535e
commit
4bf7210512
2 changed files with 11 additions and 3 deletions
BIN
packages/desktop/src/renderer/default-background.avif
Normal file
BIN
packages/desktop/src/renderer/default-background.avif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 83 KiB |
|
|
@ -21,6 +21,7 @@ import { createMemoryHistory, MemoryRouter, type BaseRouterProps } from "@solidj
|
|||
import { createEffect, createMemo, createResource, createSignal, onCleanup, onMount, Show } from "solid-js"
|
||||
import { render } from "solid-js/web"
|
||||
import pkg from "../../package.json"
|
||||
import defaultBackground from "./default-background.avif"
|
||||
import { initI18n, t } from "./i18n"
|
||||
import { initializationData, initializationReady } from "./initialization"
|
||||
import { DesktopFirstLaunchOnboarding } from "./onboarding"
|
||||
|
|
@ -112,10 +113,11 @@ function DesktopMemoryRouter(props: BaseRouterProps & { windowID: string }) {
|
|||
|
||||
const createPlatform = (windowState: DesktopWindowState): Platform => {
|
||||
const attachmentPaths = new WeakMap<File, string>()
|
||||
const [backgroundImage, setBackgroundImage] = createSignal(false)
|
||||
const [backgroundImage, setBackgroundImage] = createSignal(true)
|
||||
const applyBackgroundImage = (image: Awaited<ReturnType<typeof window.api.loadBackgroundImage>>) => {
|
||||
setBackgroundImage(!!image)
|
||||
document.documentElement.toggleAttribute("data-background-image", !!image)
|
||||
const active = !!image || localStorage.getItem("background-image.default.dismissed") !== "true"
|
||||
setBackgroundImage(active)
|
||||
document.documentElement.toggleAttribute("data-background-image", active)
|
||||
if (image) {
|
||||
document.documentElement.style.setProperty(
|
||||
"--app-background-image",
|
||||
|
|
@ -123,6 +125,10 @@ const createPlatform = (windowState: DesktopWindowState): Platform => {
|
|||
)
|
||||
return true
|
||||
}
|
||||
if (active) {
|
||||
document.documentElement.style.setProperty("--app-background-image", `url("${defaultBackground}")`)
|
||||
return true
|
||||
}
|
||||
document.documentElement.style.removeProperty("--app-background-image")
|
||||
return false
|
||||
}
|
||||
|
|
@ -333,11 +339,13 @@ const createPlatform = (windowState: DesktopWindowState): Platform => {
|
|||
async selectBackgroundImage() {
|
||||
const image = await window.api.selectBackgroundImage()
|
||||
if (!image) return backgroundImage()
|
||||
localStorage.removeItem("background-image.default.dismissed")
|
||||
return applyBackgroundImage(image)
|
||||
},
|
||||
|
||||
async clearBackgroundImage() {
|
||||
await window.api.clearBackgroundImage()
|
||||
localStorage.setItem("background-image.default.dismissed", "true")
|
||||
applyBackgroundImage(null)
|
||||
},
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue