mp-darkmode 1.0.9 → 1.1.0-beta.2
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/README.md +10 -0
- package/README_CN.md +16 -6
- package/dist/darkmode.js +842 -553
- package/dist/darkmode.js.map +1 -1
- package/dist/darkmode.min.js +1 -1
- package/doc/cn/API.md +26 -16
- package/doc/cn/plugins.md +108 -0
- package/doc/en/API.md +11 -1
- package/doc/en/plugins.md +110 -0
- package/doc/imgs/hooks.png +0 -0
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -59,6 +59,16 @@ Darkmode.run(document.body.querySelectorAll('*'), {
|
|
|
59
59
|
|
|
60
60
|
More detailed usage can refer to [API](./doc/en/API.md).
|
|
61
61
|
|
|
62
|
+
## Plugins
|
|
63
|
+
|
|
64
|
+
Plugins are supported since `v1.1.0`. Custom actions can be performed during transformation, such as filtering DOM attributes. How to use the plugin is as follows:
|
|
65
|
+
|
|
66
|
+
```javascript
|
|
67
|
+
Darkmode.extend([pluginA, pluginB, pluginC]);
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
If you want to write your own Dark Mode plugin, you can refer to [here](./doc/en/plugins.md)。
|
|
71
|
+
|
|
62
72
|
## Contribution
|
|
63
73
|
|
|
64
74
|
The algorithm is constantly updated and optimized. If you have a good idea, you can fork and submit your code. For specific development, please refer to [Development Guide](./doc/en/develop.md).
|
package/README_CN.md
CHANGED
|
@@ -43,13 +43,13 @@ Darkmode.run(document.body.querySelectorAll('*')); // 处理body下的所有DOM
|
|
|
43
43
|
|
|
44
44
|
### `Darkmode.run(nodes[, options])`
|
|
45
45
|
|
|
46
|
-
- `nodes` <DOM Object Array> 要进行Dark Mode转换的DOM节点数组。
|
|
47
|
-
- `options` <Object> Dark Mode转换算法配置项。
|
|
48
|
-
- `options.error` <Function> 发生error时触发的回调。
|
|
46
|
+
- `nodes` <DOM Object Array> 要进行 Dark Mode 转换的 DOM 节点数组。
|
|
47
|
+
- `options` <Object> Dark Mode 转换算法配置项。
|
|
48
|
+
- `options.error` <Function> 发生 error 时触发的回调。
|
|
49
49
|
- `err` <Error> 错误对象。
|
|
50
|
-
- `options.mode` <string> 强制指定的颜色模式(dark | light),指定了就不监听系统颜色。
|
|
50
|
+
- `options.mode` <string> 强制指定的颜色模式( dark | light ),指定了就不监听系统颜色。
|
|
51
51
|
|
|
52
|
-
运行Dark Mode转换算法。
|
|
52
|
+
运行 Dark Mode 转换算法。
|
|
53
53
|
|
|
54
54
|
```javascript
|
|
55
55
|
Darkmode.run(document.body.querySelectorAll('*'), {
|
|
@@ -57,7 +57,17 @@ Darkmode.run(document.body.querySelectorAll('*'), {
|
|
|
57
57
|
});
|
|
58
58
|
```
|
|
59
59
|
|
|
60
|
-
更多详细用法可参考[API](./doc/cn/API.md)。
|
|
60
|
+
更多详细用法可参考 [API](./doc/cn/API.md)。
|
|
61
|
+
|
|
62
|
+
## 插件
|
|
63
|
+
|
|
64
|
+
从 `v1.1.0` 开始支持插件,可以在转换过程中进行自定义操作,比如过滤 DOM 属性。插件的使用方法如下:
|
|
65
|
+
|
|
66
|
+
```javascript
|
|
67
|
+
Darkmode.extend([pluginA, pluginB, pluginC]);
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
如果你想编写自己的 Dark Mode 插件,可以参考[这里](./doc/cn/plugins.md)。
|
|
61
71
|
|
|
62
72
|
## 处理原则
|
|
63
73
|
|