feat: use localStorage instead of sessionStorage and adjust styles for dark mode

- Replace sessionStorage with localStorage for saving background color ID
- Update CSS to improve dark mode styling:
  - Remove background color from layuimini-main
  - Add background color and other styles for tableSearch-xmSelect in dark mode
This commit is contained in:
wolfcode
2025-01-08 10:47:37 +08:00
parent 4c8d21fccf
commit 31c06cff69
2 changed files with 9 additions and 3 deletions

View File

@@ -22,7 +22,6 @@ body {
min-height: 250px;
padding: 15px;
margin: 0 auto;
background-color: var(--lay-color-white);
}
.layuimini-main {
@@ -138,6 +137,13 @@ body {
min-height: 30px !important;
line-height: 30px !important;
margin: 0 !important;
background-color: var(--lay-color-fill-2);
}
.elem-style-dark .tableSearch-xmSelect xm-select {
background-color: var(--lay-color-fill-2);
color: var(--lay-color-text-2);
border-color: var(--lay-color-border-1) !important;
}
/** 按钮背景色 */

View File

@@ -487,7 +487,7 @@ define(["jquery"], function ($) {
*/
buildBgColorHtml: function (options) {
options.bgColorDefault = options.bgColorDefault || 0;
var bgcolorId = parseInt(sessionStorage.getItem('layuiminiBgColorId'));
var bgcolorId = parseInt(localStorage.getItem('layuiminiBgColorId'));
if (isNaN(bgcolorId)) bgcolorId = options.bgColorDefault;
var bgColorConfig = miniTheme.config();
var html = '';
@@ -550,7 +550,7 @@ define(["jquery"], function ($) {
var bgcolorId = $(this).attr('data-select-bgcolor');
$('.layuimini-color .color-content ul .layui-this').attr('class', '');
$(this).attr('class', 'layui-this');
sessionStorage.setItem('layuiminiBgColorId', bgcolorId);
localStorage.setItem('layuiminiBgColorId', bgcolorId);
miniTheme.render({
bgColorDefault: bgcolorId,
listen: false,