fix(mini-user): use USER_MINI for WeChat SDK so OAuth token persists
CI / verify (pull_request) Has been cancelled
CI / verify (pull_request) Has been cancelled
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,9 +1,8 @@
|
|||||||
import Taro from '@tarojs/taro';
|
import Taro from '@tarojs/taro';
|
||||||
import { getWechatLocationDetailed } from '@dukang/weixin-sdk';
|
import { getWechatLocationDetailed } from '@dukang/weixin-sdk';
|
||||||
import { API_BASE, getToken, request } from './api';
|
import { API_BASE, CLIENT_APP, getToken, request } from './api';
|
||||||
import { DEFAULT_REGION, regionFromGeo, type RegionSelection } from './region-data';
|
import { DEFAULT_REGION, regionFromGeo, type RegionSelection } from './region-data';
|
||||||
import { FALLBACK_CITY_CODE } from './product-images';
|
import { FALLBACK_CITY_CODE } from './product-images';
|
||||||
import { ClientApp } from '@dukang/shared-types';
|
|
||||||
|
|
||||||
export const GPS_CITY_STORAGE_KEY = 'dukang_gps_city';
|
export const GPS_CITY_STORAGE_KEY = 'dukang_gps_city';
|
||||||
|
|
||||||
@@ -123,7 +122,7 @@ function getMiniLocation(): Promise<Taro.getLocation.SuccessCallbackResult> {
|
|||||||
async function resolveViaH5Jssdk(): Promise<ResolvedUserCity | null> {
|
async function resolveViaH5Jssdk(): Promise<ResolvedUserCity | null> {
|
||||||
const outcome = await getWechatLocationDetailed({
|
const outcome = await getWechatLocationDetailed({
|
||||||
apiBase: API_BASE,
|
apiBase: API_BASE,
|
||||||
clientApp: ClientApp.USER_H5,
|
clientApp: CLIENT_APP,
|
||||||
getAccessToken: () => getToken() || null,
|
getAccessToken: () => getToken() || null,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1,14 +1,16 @@
|
|||||||
import { ClientApp } from '@dukang/shared-types';
|
|
||||||
import { createWeixinSdk, isWechatEnv } from '@dukang/weixin-sdk';
|
import { createWeixinSdk, isWechatEnv } from '@dukang/weixin-sdk';
|
||||||
import { API_BASE, getToken } from './api';
|
import { API_BASE, CLIENT_APP, getToken } from './api';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* H5 公众号内 JSSDK(分享 / 定位等)走 USER_H5 对应的公众号 appId。
|
* H5 公众号内 JSSDK(分享 / OAuth / 支付)须与业务 API 使用同一 X-Client-App。
|
||||||
* 小程序原生能力不经此门面。
|
* mini-user 全端(含 H5 产物)统一为 USER_MINI,否则 OAuth 登录签发的 JWT
|
||||||
|
* 与本地请求头 USER_MINI 不匹配 → 401 清登录 → 反复拉起微信授权。
|
||||||
|
*
|
||||||
|
* (历史 h5-user 仍用 USER_H5;公众号能力由后端凭证配置,不依赖该 ClientApp 标签。)
|
||||||
*/
|
*/
|
||||||
export const weixinSdk = createWeixinSdk({
|
export const weixinSdk = createWeixinSdk({
|
||||||
apiBase: API_BASE,
|
apiBase: API_BASE,
|
||||||
clientApp: process.env.TARO_ENV === 'h5' ? ClientApp.USER_H5 : ClientApp.USER_MINI,
|
clientApp: CLIENT_APP,
|
||||||
getAccessToken: () => getToken() || null,
|
getAccessToken: () => getToken() || null,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user