From 063108a84654b4fc082caaef8e015b66f5bdc46c Mon Sep 17 00:00:00 2001 From: wolfcode <37436228+wolf-leo@users.noreply.github.com> Date: Tue, 22 Apr 2025 18:16:26 +0800 Subject: [PATCH] feat(easy-admin): dynamic theme color for xmSelect - Replace static color codes with dynamic theme color retrieval - Use getComputedStyle to fetch the '--ea8-theme-main-color' variable - Update xmSelect instances in easy-admin.js and goods.js to use dynamic color --- public/static/admin/js/mall/goods.js | 18 ++---------------- public/static/plugs/easy-admin/easy-admin.js | 3 ++- 2 files changed, 4 insertions(+), 17 deletions(-) diff --git a/public/static/admin/js/mall/goods.js b/public/static/admin/js/mall/goods.js index 6c7e7a8..aae212d 100644 --- a/public/static/admin/js/mall/goods.js +++ b/public/static/admin/js/mall/goods.js @@ -94,17 +94,10 @@ define(["jquery", "easy-admin"], function ($, ea) { }, }) - let colors = [ - '#f10f0f', // 红色 - '#ffaf00', // 橙色 - '#FF69B4', // 猛男粉 - '#0087ff', // 蓝色 - '#00ff00', // 青青草原 - ]; var demo1 = xmSelect.render({ el: '#demo1', name: 'xxx', // form表单提交的name - theme: {color: colors[Math.floor(Math.random() * colors.length)]}, + theme: {color: getComputedStyle(document.documentElement).getPropertyValue('--ea8-theme-main-color') || '#16b777'}, data: [ {name: 'Make', value: 1}, {name: 'PHP', value: 2}, @@ -123,17 +116,10 @@ define(["jquery", "easy-admin"], function ($, ea) { }, }) - let colors = [ - '#f10f0f', // 红色 - '#ffaf00', // 橙色 - '#FF69B4', // 猛男粉 - '#0087ff', // 蓝色 - '#00ff00', // 青青草原 - ]; var demo1 = xmSelect.render({ el: '#demo1', name: 'xxx', // form表单提交的name - theme: {color: colors[Math.floor(Math.random() * colors.length)]}, + theme: {color: getComputedStyle(document.documentElement).getPropertyValue('--ea8-theme-main-color') || '#16b777'}, data: [ {name: 'Make', value: 1}, {name: 'PHP', value: 2, selected: true,}, diff --git a/public/static/plugs/easy-admin/easy-admin.js b/public/static/plugs/easy-admin/easy-admin.js index b6d8dbb..cafbf80 100644 --- a/public/static/plugs/easy-admin/easy-admin.js +++ b/public/static/plugs/easy-admin/easy-admin.js @@ -879,7 +879,8 @@ define(["jquery", "tableSelect", "miniTheme", "xmSelect", "lazyload"], function }) init.xmSelectModel[index] = xmSelect.render({ el: '.xmSelect-' + index, language: 'zn', data: keysArray, name: index, - filterable: true, paging: true, pageSize: 10, theme: {color: '#16b777'}, toolbar: {show: true}, + filterable: true, paging: true, pageSize: 10, toolbar: {show: true}, + theme: {color: getComputedStyle(document.documentElement).getPropertyValue('--ea8-theme-main-color') || '#16b777'} }) }) }