优化用户查找逻辑,新增根据微信 UnionId 查找用户的方法,简化数据库查询

This commit is contained in:
2026-02-07 02:36:29 +08:00
parent 885e04e301
commit 0be7627bd1
6 changed files with 72 additions and 72 deletions

View File

@@ -3,11 +3,15 @@ import { useConfig } from '@kevisual/use-config';
export const config = useConfig()
const wxOpen = {
// @ts-ignore
appId: config.WX_OPEN_APP_ID,
// @ts-ignore
appSecret: config.WX_OPEN_APP_SECRET,
}
const wx = {
// @ts-ignore
appId: config.WX_MP_APP_ID,
// @ts-ignore
appSecret: config.WX_MP_APP_SECRET,
}
export type WxTokenResponse = {
@@ -139,7 +143,8 @@ type RefreshToken = {
scope: string;
};
export const refreshToken = async (refreshToken: string): Promise<RefreshToken> => {
const { appId } = config.wx;
// @ts-ignore
const { appId } = config?.wx;
const refreshUrl = `https://api.weixin.qq.com/sns/oauth2/refresh_token?appid=${appId}&grant_type=refresh_token&refresh_token=${refreshToken}`;
const res = await fetch(refreshUrl);
const data = await res.json();