Commit cd9f3a4f authored by KesaubeEire's avatar KesaubeEire

feat: windows chrome 滑动条消失, 不占用侧向空间.

parent da2826ee
...@@ -144,6 +144,60 @@ ...@@ -144,6 +144,60 @@
// 2. 检测 darkreader 是否开启 // 2. 检测 darkreader 是否开启
const has_darkreader = document.querySelector('.darkreader'); const has_darkreader = document.querySelector('.darkreader');
if (has_darkreader) toast.push('检测到 dark reader, 建议关闭当前网站的 darkreader, 可点击导航栏的主题更改相应的主题', { initial: 0 }); if (has_darkreader) toast.push('检测到 dark reader, 建议关闭当前网站的 darkreader, 可点击导航栏的主题更改相应的主题', { initial: 0 });
// 3. 检测设备平台 - windows 加入滑动条消失
const UA = window.navigator.userAgent.toLowerCase();
const cssString = `
body {
overflow-y: scroll;
overflow-x: hidden;
width: 100%;
/* height: 100%; */
/* width: 100vw; */
/* height: 100vh; */
/* padding-right: 7px; */
}
/* 隐藏垂直滚动条 */
body::-webkit-scrollbar {
display: none;
/* 隐藏 Chrome、Safari 滚动条 */
}
body {
-ms-overflow-style: none;
/* 隐藏 IE/Edge 滚动条 */
scrollbar-width: none;
/* 隐藏 Firefox 滚动条 */
}
/* 隐藏水平滚动条 */
body::-webkit-scrollbar-horizontal {
display: none;
/* 隐藏 Chrome、Safari 水平滚动条 */
}
body::-webkit-scrollbar-thumb {
display: none;
/* 隐藏 Chrome、Safari 滚动条拇指 */
}`;
// toast.push(UA);
if (UA.includes('windows')) {
// 创建一个<style>元素
const styleElement = document.createElement('style');
styleElement.type = 'text/css';
// 将CSS样式字符串添加到<style>元素中
styleElement.appendChild(document.createTextNode(cssString));
// 将<style>元素添加到<body>元素中
document.body.appendChild(styleElement);
}
}); });
</script> </script>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment