Skip to content

Commit

Permalink
Merge pull request #511 from Tencent/dev
Browse files Browse the repository at this point in the history
v3.12.0
  • Loading branch information
Maizify authored Feb 17, 2022
2 parents 6ecc8ca + 19ce1fa commit 992ad71
Show file tree
Hide file tree
Showing 31 changed files with 917 additions and 193 deletions.
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
English | [简体中文](./CHANGELOG_CN.md)

## 3.12.0 (2022-02-17)

- `Feat(Core)` Add new static property `VConsole.instance` to get the singleton instance.
- `Feat(Core)` Add new options `storage.defaultStorages`, see [Public Properties & Methods](./doc/public_properties_methods.md).
- `Feat(Core)` New way of using `vConsole.setOption()`: `setOption('log.maxLogNumber', 20)` to set `maxLogNumber` field only, and `setOption({ log: { maxLogNumber: 20 }})` to overwrite `log` object.
- `Feat(Core)` Deprecated some options, see below.
- `Fix(Plugin)` Fix the bug that event `renderTab` doesn't render plugin view.
- `Fix(Storage)` Fix cookie parse error in some bad cases. (issue #508, #509)

**Deprecated Options:**

- `maxLogNumber`: Use `option.log.maxLogNumber` instead.
- `maxNetworkNumber`: Use `option.network.maxNetworkNumber` instead.
- `onClearLog`: Removed.


## 3.11.2 (2022-01-20)

- `Feat(Storage)` Added "Clear" button to batch delete all storage items. (issue #499)
Expand Down
16 changes: 16 additions & 0 deletions CHANGELOG_CN.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
[English](./CHANGELOG.md) | 简体中文

## 3.12.0 (2022-02-17)

- `Feat(Core)` 新增静态属性 `VConsole.instance` 以获取实例化后的单例 vConsole 对象。
- `Feat(Core)` 新增配置项 `storage.defaultStorages`,见 [公共属性及方法](./doc/public_properties_methods_CN.md)
- `Feat(Core)` 更新 `vConsole.setOption()` 用法:通过 `setOption('log.maxLogNumber', 20)` 来单独设置 `maxLogNumber` 字段,或通过 `setOption({ log: { maxLogNumber: 20 }})` 来覆盖 `log` 对象。
- `Feat(Core)` 废弃一些配置项,参见下面。
- `Fix(Plugin)` 修复插件事件 `renderTab` 没有渲染出视图的 bug。
- `Fix(Storage)` 修复某些情况下的 Cookie 解析错误问题。 (issue #508, #509)

**废弃的配置项:**

- `maxLogNumber`:用 `option.log.maxLogNumber` 替代。
- `maxNetworkNumber`:用 `option.network.maxNetworkNumber` 替代。
- `onClearLog`:移除。


## 3.11.2 (2022-01-20)

- `Feat(Storage)` 增加 "Clear" 按钮以批量删除所有 storage。 (issue #499)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ import VConsole from 'vconsole';

const vConsole = new VConsole();
// or init with options
const vConsole = new VConsole({ maxLogNumber: 1000 });
const vConsole = new VConsole({ theme: 'dark' });

// call `console` methods as usual
console.log('Hello world');
Expand Down
2 changes: 1 addition & 1 deletion README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ import VConsole from 'vconsole';

const vConsole = new VConsole();
// 或者使用配置参数来初始化,详情见文档
const vConsole = new VConsole({ maxLogNumber: 1000 });
const vConsole = new VConsole({ theme: 'dark' });

// 接下来即可照常使用 `console` 等方法
console.log('Hello world');
Expand Down
19 changes: 18 additions & 1 deletion dev/common.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
<a onclick="toggleVConsole()" href="javascript:;" class="weui_btn weui_btn_default">vConsole: show/hide</a>
<a onclick="toggleSwitch()" href="javascript:;" class="weui_btn weui_btn_default">Switch: show/hide</a>
<a onclick="switchPosition()" href="javascript:;" class="weui_btn weui_btn_default">Switch: setPosition</a>
<a onclick="setOption()" href="javascript:;" class="weui_btn weui_btn_default">setOption</a>
<a onclick="destroy()" href="javascript:;" class="weui_btn weui_btn_default">Destroy</a>
<a onclick="newVConsole()" href="javascript:;" class="weui_btn weui_btn_default">new VConsole</a>
</div>
</body>
</html>
Expand All @@ -26,7 +28,7 @@
import '../dist/vconsole.min.js';

window.vConsole = new window.VConsole({
maxLogNumber: 1000,
// maxLogNumber: 1000,
// disableLogScrolling: true,
// theme: 'dark',
onReady: function() {
Expand Down Expand Up @@ -84,6 +86,21 @@
console.info('vConsole switch position:', 20, 20);
}

function setOption() {
vConsole.setOption('log.a.maxLogNumber', 20);
vConsole.setOption('log.maxLogNumber', 20);
vConsole.setOption({ network: { maxNetworkNumber: 30 }});
vConsole.setOption({ network: { b: 123 }}); // overwrite previous line
console.log(vConsole.option);
}

function newVConsole() {
const vc = new window.VConsole();
window.vConsole = vc;
console.log('newVConsole:', vc);
console.log('VConsole.instance:', window.VConsole.instance === vc, window.VConsole.instance);
}

function destroy() {
window.vConsole.destroy();
console.log('vConsole is destroyed');
Expand Down
14 changes: 7 additions & 7 deletions dev/log.html
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
import '../dist/vconsole.min.js';

window.vConsole = new window.VConsole({
maxLogNumber: 25,
log: { maxLogNumber: 25 },
// target: '#page',
// target: document.getElementById('page'),
// disableLogScrolling: true,
Expand All @@ -78,9 +78,6 @@
onReady: function() {
console.log('vConsole: onReady');
},
onClearLog: function() {
console.log('vConsole: onClearLog');
},
});
</script>

Expand Down Expand Up @@ -344,13 +341,16 @@
}

function scrolling() {
vConsole.setOption('maxLogNumber', 500);
const m = 100;
vConsole.setOption('log.maxLogNumber', m);
let n = 0
let t = setInterval(() => {
n++;
if (n > 500) {
if (n > m) {
vConsole.setOption('log.maxLogNumber', 25);
}
if (n > m + 10) {
clearInterval(t);
vConsole.setOption('maxLogNumber', 25);
}
console.log('scrolling', n);
}, 150);
Expand Down
Loading

0 comments on commit 992ad71

Please sign in to comment.