Skip to content

Commit

Permalink
feat: add system info
Browse files Browse the repository at this point in the history
  • Loading branch information
AEPKILL committed May 8, 2021
1 parent 8b1fcb2 commit dee53c9
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 5 deletions.
4 changes: 3 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{
"cSpell.words": [
"iphone",
"ipad",
"devtools"
]
}
}
1 change: 1 addition & 0 deletions example/normal.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
<div id="checker" class="line"></div>
<div id="ua" class="line"></div>
<div id="versionMap" class="line"></div>
<div>2333</div>
<script>
devtoolsDetector.addListener(function (isOpen, detail) {
if (isOpen) {
Expand Down
7 changes: 4 additions & 3 deletions src/checkers/function-to-string.checker.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { DevtoolsStatusChecker } from '../types/devtools-status-checker.type';
import { isFirefox, isWebkit } from '../shared/browser-info';
import { isFirefox, isWebkit, isChrome } from '../shared/browser-info';
import { clear, log } from '../shared/console';
import { isMobile } from '../shared/platform-info';
import { isIpad, isIphone } from '../shared/system-info';

function devtoolsTestFunction() {
// nothing todo
Expand Down Expand Up @@ -30,8 +31,8 @@ export const functionToStringChecker: DevtoolsStatusChecker = {
return false;
}

// 不支持移动端 Webkit
if (isWebkit && isMobile) {
// ipad & iphone 上的 chrome 始终为 true
if ((isIpad || isIphone) && isChrome) {
return false;
}

Expand Down
3 changes: 2 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export { DevtoolsDetectorListener } from './types/devtools-detector-listener.typ
export { DevtoolsStatusChecker } from './types/devtools-status-checker.type';

export * from './shared/browser-info';
export * from './shared/console'
export * from './shared/console';
export * from './shared/platform-info';
export * from './shared/version-map';
export * from './shared/system-info';
2 changes: 2 additions & 0 deletions src/shared/browser-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ export const isEdge = /edge/i.test(ua);

/** webkit */
export const isWebkit = /webkit/i.test(ua) && !isEdge;

export const isChrome = /chrome/i.test(ua);
11 changes: 11 additions & 0 deletions src/shared/system-info.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const ua = navigator.userAgent;

export const isIpad = /ipad/i.test(ua);

export const isMac = /macintosh/i.test(ua);

export const isIphone = /iphone/i.test(ua);

export const isAndroid = /android/i.test(ua);

export const isWindows = /windows/i.test(ua);

0 comments on commit dee53c9

Please sign in to comment.