Skip to content

Jeff-Tian/egg-useragent

Repository files navigation

egg-useragent-ts

egg js useragent middleware TypeScript version, based on koa-useragent

NPM version Build Status codecov David deps Known Vulnerabilities npm download Git commit with emojis!

Example

Open https://uniheart.herokuapp.com/ to see the result.

Install

$ npm i egg-useragent-ts --save

Usage

// {app_root}/config/plugin.[t|j]s
exports.useragent = {
  enable: true,
  package: "egg-useragent-ts"
};

Configuration

This plugin need no configuration, you just enable it and you can use it by

ctx.userAgent.isWechat

Example

https://github.com/Jeff-Tian/alpha/blob/336003aca7199857b24f118c0ced66dc8afbbdea/app/view/index.pug#L12

case ctx.userAgent.isWechat
    when true
        a(href="/passport/wechat") Wechat
    when false
        a(href="/wechat-dev/qr-code?select=passportWechat", target="_blank", rel="noopener noreferrer") Wechat
    default
        a()

License

MIT

Test

npm run test-local

Release Notes:

Releases

No releases published

Sponsor this project

Packages

No packages published