Skip to content

Commit

Permalink
完善类型
Browse files Browse the repository at this point in the history
  • Loading branch information
saqqdy committed Sep 2, 2021
1 parent 41b22de commit af088cf
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 14 deletions.
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"pub": "git add . && git commit -m $npm_package_version && git pull && git push"
},
"dependencies": {
"core-js": "^3.16.3"
"core-js": "^3.17.1"
},
"devDependencies": {
"@babel/cli": "^7.12.13",
Expand All @@ -46,9 +46,9 @@
"@rollup/plugin-commonjs": "^20.0.0",
"@rollup/plugin-node-resolve": "^13.0.4",
"@saqqdy/prettier-config": "^1.0.4",
"@types/node": "^16.7.2",
"@typescript-eslint/eslint-plugin": "^4.29.3",
"@typescript-eslint/parser": "^4.29.3",
"@types/node": "14.17.3",
"@typescript-eslint/eslint-plugin": "^4.30.0",
"@typescript-eslint/parser": "^4.30.0",
"babel-loader": "^8.2.2",
"eslint": "^7.32.0",
"eslint-config-sets": "^1.4.0",
Expand All @@ -59,10 +59,10 @@
"rollup": "^2.56.3",
"rollup-plugin-terser": "^7.0.2",
"rollup-plugin-typescript2": "^0.30.0",
"typedoc": "^0.21.7",
"typedoc": "^0.21.9",
"typedoc-plugin-markdown": "^3.10.4",
"typescript": "^4.4.2",
"webpack": "^5.51.1",
"webpack": "^5.51.2",
"webpack-cli": "^4.8.0",
"webpack-merge": "^5.8.0",
"webpack-node-externals": "^3.0.0"
Expand Down
9 changes: 3 additions & 6 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@ const client = (name = '', userAgent = navigator.appVersion) => {
return userAgent.indexOf(name) > -1
} else {
return {
// @ts-ignore
IE: userAgentL.indexOf('msie') > -1 && !userAgentL.indexOf('opera') > -1,
// @ts-ignore
GECKO: userAgentL.indexOf('gecko') > -1 && !userAgentL.indexOf('khtml') > -1, // 火狐内核
IE: userAgentL.indexOf('msie') > -1 && userAgentL.indexOf('opera') === -1,
GECKO: userAgentL.indexOf('gecko') > -1 && userAgentL.indexOf('khtml') === -1, // 火狐内核
WEBKIT: userAgentL.indexOf('applewebkit') > -1, // 苹果、谷歌内核
OPERA: userAgentL.indexOf('opera') > -1 && userAgentL.indexOf('presto') > -1, // opera内核
TRIDENT: userAgentL.indexOf('trident') > -1, // IE内核
Expand All @@ -27,8 +25,7 @@ const client = (name = '', userAgent = navigator.appVersion) => {
// WEBAPP: !userAgent.indexOf('Safari') > -1, //是否web应该程序,没有头部与底部
QQBROWSER: userAgent.indexOf('QQBrowser') > -1, // 是否QQ浏览器
WEIXIN: userAgent.indexOf('MicroMessenger') > -1, // 是否微信
// @ts-ignore
QQ: userAgent.match(/\sQQ/i) === ' qq' // 是否QQ
QQ: userAgent.match(/\sQQ/i) // 是否QQ
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/getType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @returns 类型
*/
function getType(target: any): string {
let type: any = {
let type = {
'[object Array]': 'array',
'[object Boolean]': 'boolean',
'[object Date]': 'date',
Expand All @@ -14,7 +14,7 @@ function getType(target: any): string {
'[object Object]': 'object',
'[object RegExp]': 'regexp',
'[object String]': 'string'
}
} as any

if (target === null) return target + ''
return typeof target === 'object' || typeof target === 'function' ? type[Object.prototype.toString.call(target)] || 'object' : typeof target
Expand Down

0 comments on commit af088cf

Please sign in to comment.