Skip to content

Commit

Permalink
feat(utils): 新增 getWechatPublicAccountQrcodeUrl
Browse files Browse the repository at this point in the history
  • Loading branch information
fjc0k committed Jul 18, 2020
1 parent 9cff86c commit 398c886
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/utils/getWechatPublicAccountQrcodeUrl.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { getWechatPublicAccountQrcodeUrl } from './getWechatPublicAccountQrcodeUrl'

describe('getWechatPublicAccountQrcodeUrl', () => {
test('表现正常', () => {
expect(getWechatPublicAccountQrcodeUrl('rmrbwx')).toBe(
'https://open.weixin.qq.com/qr/code?username=rmrbwx',
)
})
})
14 changes: 14 additions & 0 deletions src/utils/getWechatPublicAccountQrcodeUrl.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/**
* 获取微信公众号的二维码链接。
*
* @param accountId 公众号 ID
* @returns 返回二维码链接
* @example
* ```typescript
* getWechatPublicAccountQrcodeUrl('rmrbwx')
* // => https://open.weixin.qq.com/qr/code?username=rmrbwx
* ```
*/
export function getWechatPublicAccountQrcodeUrl(accountId: string): string {
return `https://open.weixin.qq.com/qr/code?username=${accountId}`
}
1 change: 1 addition & 0 deletions src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export * from './bindEvent'
export * from './dedent'
export * from './EventBus'
export * from './formatNumber'
export * from './getWechatPublicAccountQrcodeUrl'
export * from './inAndroid'
export * from './inBrowser'
export * from './inDeno'
Expand Down

0 comments on commit 398c886

Please sign in to comment.