Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adapt PWA title bar color #13780

Closed
BLumia opened this issue Jan 10, 2025 · 4 comments
Closed

Adapt PWA title bar color #13780

BLumia opened this issue Jan 10, 2025 · 4 comments
Assignees
Milestone

Comments

@BLumia
Copy link
Contributor

BLumia commented Jan 10, 2025

PWA 标题栏颜色应当匹配 SiYuan 当前主题的标题栏颜色

In what scenarios do you need this feature?

当使用 SiYuan 的 PWA 支持来访问 SiYuan 网页端时,PWA 的标题栏颜色可能会与 SiYuan 自身的标题栏部分的颜色不同,使得标题栏看上去略微怪异。

例如在暗色系统主题下使用亮色 SiYuan 主题,PWA 的标题栏/窗口装饰部分会仍然保持暗色,反之亦然。

image

又如在暗色主题下使用暗色 SiYuan 主题,PWA 的标题栏/窗口装饰背景色也会不一致。

image

Describe the optimal solution

最佳方案应该是在页面附带一个 "theme-color" <meta> 属性,将 content 值置为当前 SiYuan 主题下标题栏的实际背景颜色,例如默认的暗色主题下对应 <meta name="theme-color" content="#262626">

考虑到 SiYuan 允许第三方主题,这里可能需要动态更新此内容。

Describe the candidate solution

N/A

Other information

我在 #13779 中提及了这个问题,尽管我暂时没有计划提交与此问题相关的代码贡献。

PWA 的标题栏颜色存在多个方案来调整,包括上述的 “theme-color” meta 属性,或者在 PWA 的 Manifest 文件中添加对应的声明,但考虑到 SiYuan 的第三方主题支持,这里并不推荐后者而是相对更推荐前者。

@BLumia
Copy link
Contributor Author

BLumia commented Jan 16, 2025

https://developer.mozilla.org/zh-CN/docs/Web/HTML/Element/meta/name/theme-color

这个链接在 description 的 Other information 段落里有包含。

@heartacker
Copy link

heartacker commented Jan 19, 2025

本人不是很懂 html 前端,

但是用AI 问了一下,这个代码看起来是可以的

Image

效果

之前

Image

之后

Image

美中不足的是,这个还有一个空隙颜色还不一致(可能是第三方主题的的原因)

@BLumia
Copy link
Contributor Author

BLumia commented Jan 19, 2025

但是用AI 问了一下,这个代码看起来是可以的

.media 那部分其实没意义,因为 SiYuan 的主题本身是主动指定颜色的,本身就忽视了系统主题是亮色还是暗色,所以事实上直接指定 content 为当前所用的标题栏背景色就可以了。

美中不足的是,这个还有一个空隙颜色还不一致

如果配合 #13779 使用的话,应该不会存在空隙颜色问题(也是那个 PR 本意的一部分)。

顺带一提,我的那个 PR 并不打算解决 WCO 颜色问题的原因是,SiYuan 本身支持自定义主题,我也没研究过 SiYuan 的自定义主题支持是怎样的情况,不确定是否有比较干净的方式获取标题栏的实际背景色。粗暴一点的办法自然是有,但我觉得不见得会被接受,所以就只在那个 PR 处理了另一部分问题(标题栏分割线、潜在的缝隙问题)。

(可能是第三方主题的的原因)

缝隙过于明显的问题可能是第三方主题导致的,但我推测上述 PR 应该可以解决你的问题,不需要第三方主题做调整。

Vanessa219 added a commit that referenced this issue Jan 26, 2025
@Vanessa219 Vanessa219 self-assigned this Jan 26, 2025
@Vanessa219 Vanessa219 added this to the 3.1.21 milestone Jan 26, 2025
@88250 88250 changed the title PWA 标题栏颜色应当匹配 SiYuan 当前主题的标题栏颜色 Adapt PWA title bar color Jan 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants