mp-darkmode 1.2.3-beta.3 → 1.2.3-beta.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/darkmode.js +21 -10
- package/dist/darkmode.js.map +1 -1
- package/dist/darkmode.min.js +1 -1
- package/package.json +1 -1
package/dist/darkmode.js
CHANGED
|
@@ -3425,6 +3425,11 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
|
|
|
3425
3425
|
|
|
3426
3426
|
// 节点相关操作工具API
|
|
3427
3427
|
|
|
3428
|
+
var isImageUrlKey = function isImageUrlKey(key, value) {
|
|
3429
|
+
var isBackgroundAttr = /^background/.test(key);
|
|
3430
|
+
var isBorderImageAttr = /^(-webkit-)?border-image/.test(key);
|
|
3431
|
+
return (isBackgroundAttr || isBorderImageAttr) && /url\([^)]*\)/i.test(value);
|
|
3432
|
+
};
|
|
3428
3433
|
var SDK = /*#__PURE__*/function () {
|
|
3429
3434
|
// 当前是否需要运行Darkmode处理
|
|
3430
3435
|
|
|
@@ -3497,11 +3502,11 @@ var SDK = /*#__PURE__*/function () {
|
|
|
3497
3502
|
isTextColor: true,
|
|
3498
3503
|
parentElementBgColorStr: newColor || color
|
|
3499
3504
|
}, isUpdate, needReset);
|
|
3500
|
-
|
|
3501
|
-
|
|
3502
|
-
|
|
3503
|
-
|
|
3504
|
-
}
|
|
3505
|
+
extStyle += _global__WEBPACK_IMPORTED_MODULE_4__.cssUtils.genCssKV('color', ret.newColor || parentTextColor);
|
|
3506
|
+
(0,_domUtils__WEBPACK_IMPORTED_MODULE_5__.getChildrenAndIt)(el).forEach(function (dom) {
|
|
3507
|
+
dom[_constant__WEBPACK_IMPORTED_MODULE_2__.COLORATTR] = ret.newColor || parentTextColor;
|
|
3508
|
+
dom[_constant__WEBPACK_IMPORTED_MODULE_2__.ORIGINAL_COLORATTR] = parentTextColor;
|
|
3509
|
+
});
|
|
3505
3510
|
}
|
|
3506
3511
|
}
|
|
3507
3512
|
} else if (options.isTextColor || options.isBorderColor) {
|
|
@@ -3612,6 +3617,7 @@ var SDK = /*#__PURE__*/function () {
|
|
|
3612
3617
|
value: function _updateBgWithGradient(gradientColor, el, className, cssKVList, hasInlineColor, isUpdate, needReset) {
|
|
3613
3618
|
var newBgColor = (0,_color__WEBPACK_IMPORTED_MODULE_1__.mixColors)([el[_constant__WEBPACK_IMPORTED_MODULE_2__.BGCOLORATTR] || _config__WEBPACK_IMPORTED_MODULE_3__["default"].defaultDarkBgColor, gradientColor], 'normal');
|
|
3614
3619
|
var newOriginalBgColor = (el[_constant__WEBPACK_IMPORTED_MODULE_2__.ORIGINAL_BGCOLORATTR] || _config__WEBPACK_IMPORTED_MODULE_3__["default"].defaultLightBgColor).split(_constant__WEBPACK_IMPORTED_MODULE_2__.BG_COLOR_DELIMITER).concat(gradientColor.toString()).join(_constant__WEBPACK_IMPORTED_MODULE_2__.BG_COLOR_DELIMITER);
|
|
3620
|
+
// TODO: 问题出在这里,el[BGCOLORATTR]里有正确的背景色,然后被gradientColor覆盖了,导致字体颜色计算错误
|
|
3615
3621
|
(0,_domUtils__WEBPACK_IMPORTED_MODULE_5__.getChildrenAndIt)(el).forEach(function (dom) {
|
|
3616
3622
|
dom[_constant__WEBPACK_IMPORTED_MODULE_2__.BGCOLORATTR] = newBgColor;
|
|
3617
3623
|
dom[_constant__WEBPACK_IMPORTED_MODULE_2__.ORIGINAL_BGCOLORATTR] = newOriginalBgColor;
|
|
@@ -3913,9 +3919,7 @@ var SDK = /*#__PURE__*/function () {
|
|
|
3913
3919
|
if (!(el instanceof SVGElement)) {
|
|
3914
3920
|
// 先不处理SVG
|
|
3915
3921
|
// 背景图片、边框图片
|
|
3916
|
-
|
|
3917
|
-
var isBorderImageAttr = /^(-webkit-)?border-image/.test(key);
|
|
3918
|
-
if ((isBackgroundAttr || isBorderImageAttr) && /url\([^)]*\)/i.test(value)) {
|
|
3922
|
+
if (isImageUrlKey(key, value)) {
|
|
3919
3923
|
cssChange = true;
|
|
3920
3924
|
var imgBgColor = (0,_color__WEBPACK_IMPORTED_MODULE_1__.mixColors)((el[_constant__WEBPACK_IMPORTED_MODULE_2__.ORIGINAL_BGCOLORATTR] || _config__WEBPACK_IMPORTED_MODULE_3__["default"].defaultLightBgColor).split(_constant__WEBPACK_IMPORTED_MODULE_2__.BG_COLOR_DELIMITER), 'normal').toString();
|
|
3921
3925
|
// const imgBgColor = el[BGCOLORATTR] || config.defaultLightBgColor;
|
|
@@ -3934,7 +3938,7 @@ var SDK = /*#__PURE__*/function () {
|
|
|
3934
3938
|
}
|
|
3935
3939
|
|
|
3936
3940
|
// background-image
|
|
3937
|
-
if (
|
|
3941
|
+
if (/^background/.test(key)) {
|
|
3938
3942
|
tmpCssKvStr = _global__WEBPACK_IMPORTED_MODULE_4__.cssUtils.genCssKV(key, imgBgColor ? "".concat(newValue, ",linear-gradient(").concat(imgBgColor, ", ").concat(imgBgColor, ")") : newValue);
|
|
3939
3943
|
if (elBackgroundPositionAttr) {
|
|
3940
3944
|
cssKV += _global__WEBPACK_IMPORTED_MODULE_4__.cssUtils.genCssKV('background-position', elBackgroundPositionAttr);
|
|
@@ -4018,7 +4022,14 @@ var SDK = /*#__PURE__*/function () {
|
|
|
4018
4022
|
noColor = false;
|
|
4019
4023
|
_global__WEBPACK_IMPORTED_MODULE_4__.cssUtils.unwatch('color');
|
|
4020
4024
|
}
|
|
4021
|
-
|
|
4025
|
+
if (cssChange) {
|
|
4026
|
+
cssKV += _global__WEBPACK_IMPORTED_MODULE_4__.cssUtils.genCssKV(key, value);
|
|
4027
|
+
} else {
|
|
4028
|
+
if (!(el instanceof SVGElement && isImageUrlKey(key, value))) {
|
|
4029
|
+
// SVG的图片不需要覆写
|
|
4030
|
+
cssKV += _global__WEBPACK_IMPORTED_MODULE_4__.cssUtils.genCssKV(key, el.style[key]);
|
|
4031
|
+
}
|
|
4032
|
+
}
|
|
4022
4033
|
}
|
|
4023
4034
|
}
|
|
4024
4035
|
});
|