Skip to content

feat: added dark mode toggle and mobile collapsible menu.#6

Open
ayyyyano wants to merge 2 commits into
TransHelper:mainfrom
ayyyyano:dark-mode
Open

feat: added dark mode toggle and mobile collapsible menu.#6
ayyyyano wants to merge 2 commits into
TransHelper:mainfrom
ayyyyano:dark-mode

Conversation

@ayyyyano

Copy link
Copy Markdown

描述

变更内容

本提交主要聚焦于日用体验优化,没有重大的功能更改。

  1. 顶栏添加深色模式开关,可以在不支持的设备上进行快速切换。
  2. 在主搜索框右侧新增快速清空按钮,便于进行多次搜索。
  3. 搜索结果上滑一定高度后,在右下角显示一个回顶按钮,可快速回到顶部查看较相关结果。
  4. 在宽度不足时引入菜单收纳,解决移动端可能因页面宽度不足而触发的显示问题。
  5. 向 .gitignore 中添加 frontend/.output/,避免意外导致的构建产物上传。

补充信息

可能存在的移动端问题

image

修复示例

image

@XFJ-YYQF XFJ-YYQF left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

好棒好棒,窝仔细看了喵,都是些很简单的无伤大雅的小问题喵

isDark.value = !isDark.value
}

// If no cookie set yet, use system preference on client

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

先通过CSS读浏览器深色偏好,优先跟随浏览器偏好,手动设置了再往cookie写

@apply bg-gray-50 text-gray-900 min-h-screen;
}

html.dark body {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

只改了背景,没有改控件,会出现比如侧边滚动条还是亮色的情况

Suggested change
html.dark body {
html.dark { color-scheme: dark; }

Comment thread frontend/pages/index.vue

function hideHistoryDelayed() {
hideHistoryTimer = setTimeout(() => { showHistory.value = false }, 200)
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

卸载时 clearTimeout;数据应该设置只保留字符串。

// On server: set html class from cookie before rendering
useHead({
htmlAttrs: computed(() => ({
class: darkMode.value === 'dark' ? 'dark' : '',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

合并 class,或者只 tiggle dark

@XFJ-YYQF

Copy link
Copy Markdown
Contributor

哦对了,移动端展开菜单收纳是不是还是横向排布比较好,这样感觉有点太占空间了(?

@ayyyyano

Copy link
Copy Markdown
Author

哦对了,移动端展开菜单收纳是不是还是横向排布比较好,这样感觉有点太占空间了(?

移动端竖放还是挺常见的 (参考P1) 横着放我觉得有点影响观感了 毕竟菜单可以折叠
我觉得理想的方案应该是把菜单集中在菜单按钮周围的区域 (参考P2) 但做出来效果似乎不大好

Screenshot_20260722-031006_Via.png

Screenshot_20260722-031501_Via.png

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants