Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fukuiretu/nuxt-user-agent
Nuxt.js module for handling User-Agent.
https://github.com/fukuiretu/nuxt-user-agent
js nuxt nuxt-module nuxtjs
Last synced: about 1 month ago
JSON representation
Nuxt.js module for handling User-Agent.
- Host: GitHub
- URL: https://github.com/fukuiretu/nuxt-user-agent
- Owner: fukuiretu
- Archived: true
- Created: 2018-04-13T15:41:10.000Z (over 6 years ago)
- Default Branch: develop
- Last Pushed: 2022-12-03T03:17:45.000Z (almost 2 years ago)
- Last Synced: 2024-09-27T02:18:36.612Z (about 2 months ago)
- Topics: js, nuxt, nuxt-module, nuxtjs
- Language: TypeScript
- Homepage:
- Size: 234 KB
- Stars: 124
- Watchers: 2
- Forks: 14
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# nuxt-user-agent
[Nuxt.js](https://nuxtjs.org/) module for handling User-Agent.
Inspired by [rack-user-agent](https://github.com/k0kubun/rack-user_agent) and, Thanks to [woothee](http://woothee.github.io/) :pray:
## Setup
Install with yarn:
`yarn add nuxt-user-agent`
Install with npm:
`npm install nuxt-user-agent`
nuxt.config.js
```js
module.exports = {
modules: [
'nuxt-user-agent',
]
}
```## Usage
### Component
##### asyncData
```js
asyncData(context) {
const deviceType = context.$ua.deviceType()
return { deviceType }
}
```##### methods/created/mounted/etc
```js
methods: {
something() {
const deviceType = this.$ua.deviceType()
this.deviceType = deviceType
}
}
```##### Store actions
```js
// In store
{
actions: {
getDeviceType ({ commit }) {
const deviceType = this.$ua.deviceType()
commit('SET_DEVICE_TYPE', deviceType)
}
}
}
```##### template
```vue
PC
Smartphone
Mobilephone
Tablet
Appliance
Crawler
```
## Methods
| method | type | example |
| :-----------------: | :-----: | :-----------: |
| deviceType | string | pc |
| os | string | Mac OSX |
| osVersion | string | 10.12.6 |
| browser | string | Chrome |
| browserVersion | string | 65.0.3325.181 |
| browserVendor | string | Google |
| isFromIphone | boolean | true |
| isFromIpad | boolean | true |
| isFromIpod | boolean | true |
| isFromIos | boolean | true |
| isFromAndroidMobile | boolean | true |
| isFromAndroidTablet | boolean | true |
| isFromAndroidOs | boolean | true |
| isFromWindowsPhone | boolean | true |
| isFromPc | boolean | true |
| isFromSmartphone | boolean | true |
| isFromMobilephone | boolean | true |
| isFromAppliance | boolean | true |
| isFromCrawler | boolean | true |
| isFromTablet | boolean | true |## TODO
- [ ] unit test## License
The npm is available as open source under the terms of the [MIT License.](https://opensource.org/licenses/MIT)