Files
dukang/apps/mini-user/src/lib/weixin.ts
T
2026-08-04 21:38:49 +08:00

17 lines
536 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { createWeixinSdk, isWechatEnv } from '@dukang/weixin-sdk';
import { API_BASE, CLIENT_APP, getToken } from './api';
/**
* H5 与业务 API 共用 CLIENT_APP
* - H5 → USER_H5(公众号 OAuth openId + 公众号支付 appId
* - 小程序 → USER_MINI
* 须与 JWT 签发一致,才能同时避免「反复授权」与「appid/openid 不匹配」。
*/
export const weixinSdk = createWeixinSdk({
apiBase: API_BASE,
clientApp: CLIENT_APP,
getAccessToken: () => getToken() || null,
});
export { isWechatEnv };