├── .all-contributorsrc ├── .browserslistrc ├── .eslintrc.js ├── .gitignore ├── .snyk ├── .travis.yml ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md ├── LICENSE ├── README.md ├── babel.config.js ├── package-lock.json ├── package.json ├── postcss.config.js ├── src ├── main.ts ├── shims-tsx.d.ts └── shims-vue.d.ts ├── tsconfig.json └── types ├── main.d.ts └── vue.d.ts /.all-contributorsrc: -------------------------------------------------------------------------------- 1 | { 2 | "projectName": "vue-DeviceDetector", 3 | "projectOwner": "dreambo8563", 4 | "repoType": "github", 5 | "repoHost": "https://github.com", 6 | "files": [ 7 | "README.md" 8 | ], 9 | "imageSize": 100, 10 | "commit": false, 11 | "contributors": [ 12 | { 13 | "login": "dreambo8563", 14 | "name": "Vincent Guo", 15 | "avatar_url": "https://avatars2.githubusercontent.com/u/6948318?v=4", 16 | "profile": "https://dreambo8563.github.io/", 17 | "contributions": [ 18 | "code", 19 | "doc", 20 | "infra" 21 | ] 22 | } 23 | ], 24 | "contributorsPerLine": 7 25 | } 26 | -------------------------------------------------------------------------------- /.browserslistrc: -------------------------------------------------------------------------------- 1 | > 1% 2 | last 2 versions 3 | not ie <= 8 4 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | env: { 4 | node: true 5 | }, 6 | extends: ["plugin:vue/essential", "@vue/prettier", "@vue/typescript"], 7 | rules: { 8 | "no-console": process.env.NODE_ENV === "production" ? "error" : "off", 9 | "no-debugger": process.env.NODE_ENV === "production" ? "error" : "off" 10 | }, 11 | parserOptions: { 12 | parser: "@typescript-eslint/parser" 13 | } 14 | }; 15 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | /dist 4 | 5 | # local env files 6 | .env.local 7 | .env.*.local 8 | 9 | # Log files 10 | npm-debug.log* 11 | yarn-debug.log* 12 | yarn-error.log* 13 | 14 | # Editor directories and files 15 | .idea 16 | .vscode 17 | *.suo 18 | *.ntvs* 19 | *.njsproj 20 | *.sln 21 | *.sw* 22 | -------------------------------------------------------------------------------- /.snyk: -------------------------------------------------------------------------------- 1 | # Snyk (https://snyk.io) policy file, patches or ignores known vulnerabilities. 2 | version: v1.16.0 3 | ignore: {} 4 | # patches apply the minimum changes required to fix a vulnerability 5 | patch: 6 | SNYK-JS-LODASH-567746: 7 | - commitizen > cz-conventional-changelog > @commitlint/load > lodash: 8 | patched: '2020-07-09T01:21:15.187Z' 9 | - commitizen > cz-conventional-changelog > @commitlint/load > @commitlint/resolve-extends > lodash: 10 | patched: '2020-07-09T01:21:15.187Z' 11 | - commitizen > lodash: 12 | patched: '2020-07-09T01:21:15.187Z' 13 | - commitizen > inquirer > lodash: 14 | patched: '2020-07-09T01:21:15.187Z' 15 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - "lts/*" 4 | before_install: 5 | - npm i -g npm@latest 6 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | 2 | ## [1.1.6](https://github.com/dreambo8563/vue-DeviceDetector/compare/v1.1.5...v1.1.6) (2020-10-16) 3 | 4 | 5 | ### Bug Fixes 6 | 7 | * **ipad detect:** change way to detect ipad ([1352877](https://github.com/dreambo8563/vue-DeviceDetector/commit/1352877)) 8 | * package.json & package-lock.json to reduce vulnerabilities ([c074872](https://github.com/dreambo8563/vue-DeviceDetector/commit/c074872)) 9 | * package.json, package-lock.json & .snyk to reduce vulnerabilities ([5a9ccee](https://github.com/dreambo8563/vue-DeviceDetector/commit/5a9ccee)) 10 | 11 | 12 | 13 | 14 | ## [1.1.5](https://github.com/dreambo8563/vue-DeviceDetector/compare/v1.1.4...v1.1.5) (2020-07-08) 15 | 16 | 17 | ### Features 18 | 19 | * **miniapp:** add wechat miniapp ([535931d](https://github.com/dreambo8563/vue-DeviceDetector/commit/535931d)) 20 | 21 | 22 | 23 | 24 | ## [1.1.4](https://github.com/dreambo8563/vue-DeviceDetector/compare/v1.1.3...v1.1.4) (2020-07-08) 25 | 26 | 27 | 28 | 29 | ## [1.1.3](https://github.com/dreambo8563/vue-DeviceDetector/compare/v1.1.2...v1.1.3) (2019-05-28) 30 | 31 | 32 | 33 | 34 | ## [1.1.2](https://github.com/dreambo8563/vue-DeviceDetector/compare/v1.1.1...v1.1.2) (2019-03-14) 35 | 36 | 37 | ### Bug Fixes 38 | 39 | * **dingtalk:** match lower case ([e2a2fb4](https://github.com/dreambo8563/vue-DeviceDetector/commit/e2a2fb4)) 40 | 41 | 42 | 43 | 44 | # [1.1.0](https://github.com/dreambo8563/vue-DeviceDetector/compare/v1.0.0...v1.1.0) (2019-03-11) 45 | 46 | 47 | ### Features 48 | 49 | * **wechat:** add wechat ([b0c7e28](https://github.com/dreambo8563/vue-DeviceDetector/commit/b0c7e28)) 50 | 51 | 52 | 53 | 54 | # [1.0.0](https://github.com/dreambo8563/vue-DeviceDetector/compare/v0.1.8...v1.0.0) (2019-03-11) 55 | 56 | 57 | ### Bug Fixes 58 | 59 | * **typings:** fix typings ([02b42c7](https://github.com/dreambo8563/vue-DeviceDetector/commit/02b42c7)) 60 | * **typings:** plugin install ([f784db1](https://github.com/dreambo8563/vue-DeviceDetector/commit/f784db1)) 61 | 62 | 63 | ### Features 64 | 65 | * **dingding:** add dingding detect ([b03caac](https://github.com/dreambo8563/vue-DeviceDetector/commit/b03caac)) 66 | 67 | 68 | 69 | 70 | ## [0.1.1](https://github.com/dreambo8563/vue-DeviceDetector/compare/caeb361...v0.1.1) (2019-03-08) 71 | 72 | 73 | ### Features 74 | 75 | * **basic implement:** add types, and source file ([caeb361](https://github.com/dreambo8563/vue-DeviceDetector/commit/caeb361)) 76 | 77 | 78 | 79 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as 6 | contributors and maintainers pledge to making participation in our project and 7 | our community a harassment-free experience for everyone, regardless of age, body 8 | size, disability, ethnicity, sex characteristics, gender identity and expression, 9 | level of experience, education, socio-economic status, nationality, personal 10 | appearance, race, religion, or sexual identity and orientation. 11 | 12 | ## Our Standards 13 | 14 | Examples of behavior that contributes to creating a positive environment 15 | include: 16 | 17 | * Using welcoming and inclusive language 18 | * Being respectful of differing viewpoints and experiences 19 | * Gracefully accepting constructive criticism 20 | * Focusing on what is best for the community 21 | * Showing empathy towards other community members 22 | 23 | Examples of unacceptable behavior by participants include: 24 | 25 | * The use of sexualized language or imagery and unwelcome sexual attention or 26 | advances 27 | * Trolling, insulting/derogatory comments, and personal or political attacks 28 | * Public or private harassment 29 | * Publishing others' private information, such as a physical or electronic 30 | address, without explicit permission 31 | * Other conduct which could reasonably be considered inappropriate in a 32 | professional setting 33 | 34 | ## Our Responsibilities 35 | 36 | Project maintainers are responsible for clarifying the standards of acceptable 37 | behavior and are expected to take appropriate and fair corrective action in 38 | response to any instances of unacceptable behavior. 39 | 40 | Project maintainers have the right and responsibility to remove, edit, or 41 | reject comments, commits, code, wiki edits, issues, and other contributions 42 | that are not aligned to this Code of Conduct, or to ban temporarily or 43 | permanently any contributor for other behaviors that they deem inappropriate, 44 | threatening, offensive, or harmful. 45 | 46 | ## Scope 47 | 48 | This Code of Conduct applies both within project spaces and in public spaces 49 | when an individual is representing the project or its community. Examples of 50 | representing a project or community include using an official project e-mail 51 | address, posting via an official social media account, or acting as an appointed 52 | representative at an online or offline event. Representation of a project may be 53 | further defined and clarified by project maintainers. 54 | 55 | ## Enforcement 56 | 57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 58 | reported by contacting the project team at dreambo8563@outlook.com. All 59 | complaints will be reviewed and investigated and will result in a response that 60 | is deemed necessary and appropriate to the circumstances. The project team is 61 | obligated to maintain confidentiality with regard to the reporter of an incident. 62 | Further details of specific enforcement policies may be posted separately. 63 | 64 | Project maintainers who do not follow or enforce the Code of Conduct in good 65 | faith may face temporary or permanent repercussions as determined by other 66 | members of the project's leadership. 67 | 68 | ## Attribution 69 | 70 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, 71 | available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html 72 | 73 | [homepage]: https://www.contributor-covenant.org 74 | 75 | For answers to common questions about this code of conduct, see 76 | https://www.contributor-covenant.org/faq 77 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Vincent Guo 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Codacy Badge](https://api.codacy.com/project/badge/Grade/38f22883688b438db21d672e1d4d3daf)](https://www.codacy.com/app/dreambo8563/vue-DeviceDetector?utm_source=github.com&utm_medium=referral&utm_content=dreambo8563/vue-DeviceDetector&utm_campaign=Badge_Grade) 2 | [![All Contributors](https://img.shields.io/badge/all_contributors-1-orange.svg?style=flat-square)](#contributors) 3 | [![Build Status](https://travis-ci.com/dreambo8563/vue-DeviceDetector.svg?branch=master)](https://travis-ci.com/dreambo8563/vue-DeviceDetector) 4 | [![Greenkeeper badge](https://badges.greenkeeper.io/dreambo8563/vue-DeviceDetector.svg)](https://greenkeeper.io/) 5 | [![Known Vulnerabilities](https://snyk.io/test/github/dreambo8563/vue-DeviceDetector/badge.svg?targetFile=package.json)](https://snyk.io/test/github/dreambo8563/vue-DeviceDetector?targetFile=package.json) 6 | [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) 7 | ![npm type definitions](https://img.shields.io/npm/types/vue-device-detector.svg?style=flat) 8 | ![npm](https://img.shields.io/npm/dt/vue-device-detector.svg?style=flat) 9 | [![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fdreambo8563%2Fvue-DeviceDetector.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Fdreambo8563%2Fvue-DeviceDetector?ref=badge_shield) 10 | 11 | # vue-device-detector ([for Vue 3](https://github.com/dreambo8563/next-vue-device-detector)) 12 | 13 | ![](https://raw.githubusercontent.com/dreambo8563/static-assets/master/watcher2.png) 14 | 15 | **vue-device-detector** is a simple vue plugin to inspect the device type. 16 | 17 | - focus on mobile 18 | - vue friendly 19 | - strong typed 20 | 21 | TODO: 22 | 23 | - [x] add dingding api 24 | - [x] add weixin api 25 | 26 | ### Install 27 | 28 | ```cmd 29 | npm install vue-device-detector --save 30 | ``` 31 | 32 | ### Quick Start 33 | 34 | ```js 35 | import device from "vue-device-detector" 36 | Vue.use(device) 37 | ``` 38 | 39 | ### Methods 40 | 41 | - this.\$device in Component context. 42 | - Vue.\$device in global. 43 | 44 | ### API list 45 | 46 | you can get the following properties under this.\$device 47 | 48 | ```ts 49 | interface IDeviceDetector { 50 | ios: Boolean 51 | iphone: Boolean 52 | iphoneX: Boolean 53 | iPhoneXR: Boolean 54 | iPhoneXSMax: Boolean 55 | ipod: Boolean 56 | ipad: Boolean 57 | android: Boolean 58 | androidPhone: Boolean 59 | windows: Boolean 60 | mobile: Boolean 61 | dingding: Boolean //钉钉 62 | wechat: Boolean, // 微信 63 | wechatMiniApp: Boolean //微信小程序 64 | } 65 | ``` 66 | 67 | eg. 68 | on iphoneX 69 | 70 | ```js 71 | console.log(this.$device.iphoneX) // true 72 | console.log(this.$device.ios) // true 73 | console.log(this.$device.android) // false 74 | ``` 75 | 76 | ## License 77 | 78 | [![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fdreambo8563%2Fvue-DeviceDetector.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2Fdreambo8563%2Fvue-DeviceDetector?ref=badge_large) 79 | 80 | ## Contributors 81 | 82 | Thanks goes to these wonderful people ([emoji key](https://github.com/all-contributors/all-contributors#emoji-key)): 83 | 84 | 85 | 86 | | [Vincent Guo
Vincent Guo](https://dreambo8563.github.io/)
[💻](https://github.com/dreambo8563/vue-DeviceDetector/commits?author=dreambo8563 "Code") [📖](https://github.com/dreambo8563/vue-DeviceDetector/commits?author=dreambo8563 "Documentation") [🚇](#infra-dreambo8563 "Infrastructure (Hosting, Build-Tools, etc)") | 87 | | :---: | 88 | 89 | 90 | 91 | This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome! 92 | -------------------------------------------------------------------------------- /babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: ["@vue/cli-plugin-babel/preset"] 3 | }; 4 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vue-device-detector", 3 | "version": "1.1.6", 4 | "private": false, 5 | "description": "A tiny device detector plugin of vue for mobile", 6 | "author": "dreambo8563", 7 | "scripts": { 8 | "serve": "vue-cli-service serve", 9 | "build": "vue-cli-service build", 10 | "lint": "vue-cli-service lint", 11 | "build-bundle": "npm run lint && vue-cli-service build --target lib --name vue-device-detector ./src/main.ts", 12 | "prepare": "npm run snyk-protect", 13 | "report": "npm run lint && vue-cli-service build --report --target lib --name vue-device-detector ./src/main.ts", 14 | "snyk-protect": "snyk protect", 15 | "test": "npm run build-bundle", 16 | "version": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0" 17 | }, 18 | "main": "dist/vue-device-detector.umd.min.js", 19 | "files": [ 20 | "dist/*", 21 | "src/*", 22 | "types/*.d.ts", 23 | "package.json", 24 | "*.js", 25 | "README.md" 26 | ], 27 | "dependencies": { 28 | "core-js": "^3.6.5", 29 | "vue": "^2.5.22" 30 | }, 31 | "devDependencies": { 32 | "commitizen": "^4.1.3", 33 | "snyk": "^1.360.0", 34 | "@typescript-eslint/eslint-plugin": "^2.33.0", 35 | "@typescript-eslint/parser": "^2.33.0", 36 | "@vue/cli-plugin-babel": "^4.5.7", 37 | "@vue/cli-plugin-eslint": "^4.5.7", 38 | "@vue/cli-plugin-typescript": "^4.5.7", 39 | "@vue/cli-service": "^4.5.7", 40 | "@vue/eslint-config-prettier": "^6.0.0", 41 | "@vue/eslint-config-typescript": "^5.0.2", 42 | "babel-eslint": "^10.0.1", 43 | "cz-conventional-changelog": "^3.0.0", 44 | "eslint": "^6.7.2", 45 | "eslint-plugin-prettier": "^3.1.3", 46 | "eslint-plugin-vue": "^6.2.2", 47 | "prettier": "^1.19.1", 48 | "typescript": "~3.9.3", 49 | "vue-template-compiler": "^2.5.21" 50 | }, 51 | "bugs": { 52 | "url": "https://github.com/dreambo8563/vue-DeviceDetector/issues" 53 | }, 54 | "config": { 55 | "commitizen": { 56 | "path": "./node_modules/cz-conventional-changelog" 57 | } 58 | }, 59 | "keywords": [ 60 | "vue", 61 | "device", 62 | "mobile", 63 | "useragent" 64 | ], 65 | "license": "MIT", 66 | "repository": { 67 | "type": "git", 68 | "url": "https://github.com/dreambo8563/vue-DeviceDetector.git" 69 | }, 70 | "snyk": true, 71 | "typings": "types/main.d.ts" 72 | } 73 | -------------------------------------------------------------------------------- /postcss.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | plugins: { 3 | autoprefixer: {} 4 | } 5 | }; 6 | -------------------------------------------------------------------------------- /src/main.ts: -------------------------------------------------------------------------------- 1 | import Vue, { VueConstructor } from "vue"; 2 | 3 | // The client user agent string. 4 | // Lowercase, so we can use the more efficient indexOf(), instead of Regex 5 | const userAgent = window.navigator.userAgent.toLowerCase(); 6 | const devicePixelRatio = window.devicePixelRatio || 1; 7 | const iPadOS13Up = 8 | window.navigator.platform === "MacIntel" && 9 | window.navigator.maxTouchPoints > 1; 10 | class DeviceDetector { 11 | windows: Boolean; 12 | ipod: Boolean; 13 | ipad: Boolean; 14 | iphone: Boolean; 15 | 16 | iphoneX: Boolean; 17 | iPhoneXR: Boolean; 18 | iPhoneXSMax: Boolean; 19 | 20 | ios: Boolean; 21 | android: Boolean; 22 | androidPhone: Boolean; 23 | mobile: Boolean; 24 | dingding: Boolean; 25 | wechat: Boolean; 26 | wechatMiniApp: boolean; 27 | constructor() { 28 | this.windows = this.find("windows"); 29 | this.ipod = this.find("ipod"); 30 | this.ipad = this.find("ipad") || iPadOS13Up; 31 | this.dingding = this.find("dingtalk"); 32 | this.wechat = this.find("micromessenger"); 33 | this.wechatMiniApp = this.find("miniprogram"); 34 | this.iphone = !this.windows && this.find("iphone"); 35 | this.iphoneX = 36 | this.iphone && 37 | devicePixelRatio === 3 && 38 | window.screen.width === 375 && 39 | window.screen.height === 812; 40 | 41 | this.iPhoneXR = 42 | this.iphone && 43 | devicePixelRatio === 2 && 44 | window.screen.width === 414 && 45 | window.screen.height === 896; 46 | 47 | this.iPhoneXSMax = 48 | this.iphone && 49 | devicePixelRatio === 3 && 50 | window.screen.width === 414 && 51 | window.screen.height === 896; 52 | 53 | this.ios = this.iphone || this.ipod || this.ipad; 54 | this.android = !this.windows && this.find("android"); 55 | this.androidPhone = this.android && this.find("mobile"); 56 | this.mobile = this.androidPhone || this.iphone || this.ipod; 57 | } 58 | 59 | private find(needle: string) { 60 | return userAgent.indexOf(needle) !== -1; 61 | } 62 | } 63 | 64 | interface IDeviceDetector { 65 | ios: Boolean; 66 | iphone: Boolean; 67 | iphoneX: Boolean; 68 | iPhoneXR: Boolean; 69 | iPhoneXSMax: Boolean; 70 | ipod: Boolean; 71 | ipad: Boolean; 72 | android: Boolean; 73 | androidPhone: Boolean; 74 | windows: Boolean; 75 | mobile: Boolean; 76 | dingding: Boolean; 77 | wechat: Boolean; 78 | wechatMiniApp: boolean; 79 | } 80 | export type deviceDetectorPlugin = { 81 | install(vue: VueConstructor, options?: any): void; 82 | }; 83 | const instantce: deviceDetectorPlugin = { 84 | install(vue, options) { 85 | const alias = "$device"; 86 | const deviceDetector = new DeviceDetector() as IDeviceDetector; 87 | vue.prototype[alias] = deviceDetector; 88 | Object.defineProperty(Vue, `${alias}`, { 89 | get() { 90 | return deviceDetector; 91 | } 92 | }); 93 | } 94 | }; 95 | 96 | export default instantce; 97 | export { IDeviceDetector }; 98 | -------------------------------------------------------------------------------- /src/shims-tsx.d.ts: -------------------------------------------------------------------------------- 1 | import Vue, { VNode } from "vue"; 2 | 3 | declare global { 4 | namespace JSX { 5 | // tslint:disable no-empty-interface 6 | interface Element extends VNode {} 7 | // tslint:disable no-empty-interface 8 | interface ElementClass extends Vue {} 9 | interface IntrinsicElements { 10 | [elem: string]: any; 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/shims-vue.d.ts: -------------------------------------------------------------------------------- 1 | declare module "*.vue" { 2 | import Vue from "vue"; 3 | export default Vue; 4 | } 5 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "module": "esnext", 5 | "strict": true, 6 | "jsx": "preserve", 7 | "importHelpers": true, 8 | "moduleResolution": "node", 9 | "esModuleInterop": true, 10 | "allowSyntheticDefaultImports": true, 11 | "sourceMap": true, 12 | "baseUrl": ".", 13 | "types": ["webpack-env"], 14 | "declaration": true, 15 | "typeRoots": ["types"], 16 | "outDir": "./types", 17 | "paths": { 18 | "@/*": ["src/*"] 19 | }, 20 | "lib": ["esnext", "dom", "dom.iterable", "scripthost"] 21 | }, 22 | "include": [ 23 | "src/**/*.ts", 24 | "src/**/*.tsx", 25 | "src/**/*.vue", 26 | "tests/**/*.ts", 27 | "tests/**/*.tsx" 28 | ], 29 | "exclude": ["node_modules"] 30 | } 31 | -------------------------------------------------------------------------------- /types/main.d.ts: -------------------------------------------------------------------------------- 1 | import Vue, { VueConstructor } from "./vue"; 2 | interface IDeviceDetector { 3 | ios: Boolean; 4 | iphone: Boolean; 5 | iphoneX: Boolean; 6 | iPhoneXR: Boolean; 7 | iPhoneXSMax: Boolean; 8 | ipod: Boolean; 9 | ipad: Boolean; 10 | android: Boolean; 11 | androidPhone: Boolean; 12 | windows: Boolean; 13 | mobile: Boolean; 14 | dingding: Boolean; 15 | wechat: Boolean; 16 | wechatMiniApp: boolean; 17 | } 18 | export declare type deviceDetectorPlugin = { 19 | install(vue: VueConstructor, options?: any): void; 20 | }; 21 | declare const instantce: deviceDetectorPlugin; 22 | export default instantce; 23 | export { IDeviceDetector }; 24 | -------------------------------------------------------------------------------- /types/vue.d.ts: -------------------------------------------------------------------------------- 1 | import Vue, { VueConstructor } from "vue"; 2 | import { IDeviceDetector } from "./main"; 3 | declare module "vue/types/vue" { 4 | interface Vue { 5 | $device: IDeviceDetector; 6 | } 7 | interface VueConstructor { 8 | $device: IDeviceDetector; 9 | } 10 | } 11 | 12 | declare module "vue/types/options" { 13 | interface ComponentOptions { 14 | $device?: IDeviceDetector; 15 | } 16 | } 17 | 18 | export { VueConstructor }; 19 | export default Vue; 20 | --------------------------------------------------------------------------------