[GH-ISSUE #23] 不希望一直清空控制台,至少可以有个参数控制 #96

Closed
opened 2026-03-01 17:27:32 +03:00 by kerem · 2 comments
Owner

Originally created by @ixi on GitHub (Jun 3, 2021).
Original GitHub issue: https://github.com/AEPKILL/devtools-detector/issues/23

不希望一直清空控制台,至少可以有个参数控制

Originally created by @ixi on GitHub (Jun 3, 2021). Original GitHub issue: https://github.com/AEPKILL/devtools-detector/issues/23 不希望一直清空控制台,至少可以有个参数控制
kerem 2026-03-01 17:27:32 +03:00
Author
Owner

@AEPKILL commented on GitHub (Jun 3, 2021):

为了检测控制台是否打开,打印频率还是比较频繁的,如果你是因为开发阶段干扰到你看调试信息的话,你可以这样做:

// __DEV__ 是 webpack 或者其他打包工具注入的一个值

if(!__DEV__){
  launch();
}
<!-- gh-comment-id:853589353 --> @AEPKILL commented on GitHub (Jun 3, 2021): 为了检测控制台是否打开,打印频率还是比较频繁的,如果你是因为开发阶段干扰到你看调试信息的话,你可以这样做: ```js // __DEV__ 是 webpack 或者其他打包工具注入的一个值 if(!__DEV__){ launch(); } ```
Author
Owner

@wzc570738205 commented on GitHub (Jun 29, 2021):

 if (process.env.NODE_ENV != "development") {
      // 1. add listener
      addListener(isOpen => {
        if (isOpen) {
          alert('请关闭浏览器控制台访问本网站')
          window.location.href = "https://www.xxx.com";
        }
      });
      // 2. launch detect
      launch();
 }
<!-- gh-comment-id:870306034 --> @wzc570738205 commented on GitHub (Jun 29, 2021): ```js if (process.env.NODE_ENV != "development") { // 1. add listener addListener(isOpen => { if (isOpen) { alert('请关闭浏览器控制台访问本网站') window.location.href = "https://www.xxx.com"; } }); // 2. launch detect launch(); } ```
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/devtools-detector#96
No description provided.