微信公众号登陆修复处理图片

This commit is contained in:
wangwenchen 2024-02-02 12:04:42 +08:00
parent 791b89288a
commit c86b55d952
5 changed files with 17 additions and 13 deletions

View File

@ -531,6 +531,7 @@ export async function loginByMobile(params, context) {
}
async function setUserInfoFromWechat(user, userInfo, context) {
const application = context.getApplication();
const applicationId = context.getApplicationId();
const config = application?.system?.config || application?.system?.platform?.config;
const { nickname, gender, avatar } = userInfo;
const { nickname: originalNickname, gender: originalGender, extraFile$entity, } = user;
@ -564,6 +565,7 @@ async function setUserInfoFromWechat(user, userInfo, context) {
type: 'image',
filename: '',
bucket: '',
applicationId: applicationId,
}),
},
];
@ -1328,7 +1330,6 @@ function checkTokenEnvConsistency(env1, env2) {
return false;
}
}
return true;
}
export async function refreshToken(params, context) {
const { env, tokenValue } = params;

View File

@ -17,8 +17,8 @@ export default OakComponent({
this.setState({
loading: true,
});
const { features, t } = this;
const token = features.token.getToken(true);
// const { features, t } = this;
const token = this.features.token.getToken(true);
const url = window.location.href;
const urlParse = new URL(url);
//格式 xx?code=xx&state=/xx/xx?d=xx
@ -27,7 +27,7 @@ export default OakComponent({
const wechatLoginId = urlParse?.searchParams?.get('wechatLoginId');
if (!code) {
this.setState({
error: t('missingCodeParameter'),
error: this.t('missingCodeParameter'),
loading: false,
});
return;
@ -42,7 +42,7 @@ export default OakComponent({
else {
try {
// web微信扫码跟公众号授权
await features.token.loginWechat(code, {
await this.features.token.loginWechat(code, {
wechatLoginId,
});
this.setState({
@ -52,7 +52,7 @@ export default OakComponent({
}
catch (err) {
this.setState({
error: t('weChatLoginFailed'),
error: this.t('weChatLoginFailed'),
loading: false,
});
throw err;

View File

@ -535,6 +535,7 @@ async function loginByMobile(params, context) {
exports.loginByMobile = loginByMobile;
async function setUserInfoFromWechat(user, userInfo, context) {
const application = context.getApplication();
const applicationId = context.getApplicationId();
const config = application?.system?.config || application?.system?.platform?.config;
const { nickname, gender, avatar } = userInfo;
const { nickname: originalNickname, gender: originalGender, extraFile$entity, } = user;
@ -568,6 +569,7 @@ async function setUserInfoFromWechat(user, userInfo, context) {
type: 'image',
filename: '',
bucket: '',
applicationId: applicationId,
}),
},
];

View File

@ -742,6 +742,7 @@ async function setUserInfoFromWechat<
context: Cxt
) {
const application = context.getApplication();
const applicationId = context.getApplicationId();
const config =
application?.system?.config || application?.system?.platform?.config;
const { nickname, gender, avatar } = userInfo;
@ -782,6 +783,7 @@ async function setUserInfoFromWechat<
type: 'image',
filename: '',
bucket: '',
applicationId: applicationId!,
}),
},
];
@ -1899,7 +1901,7 @@ export async function refreshToken<
) {
const { env, tokenValue } = params;
const fn = context.openRootMode();
let [ token ] = await context.select('token', {
let [token] = await context.select('token', {
data: Object.assign({
env: 1,
...tokenProjection,
@ -1936,7 +1938,7 @@ export async function refreshToken<
filter: {
id: token.id,
}
}, { });
}, {});
fn();
return newValue;
}

View File

@ -18,8 +18,7 @@ export default OakComponent({
this.setState({
loading: true,
});
const { features, t } = this;
const token = features.token.getToken(true);
const token = this.features.token.getToken(true);
const url = window.location.href;
const urlParse = new URL(url);
//格式 xx?code=xx&state=/xx/xx?d=xx
@ -28,7 +27,7 @@ export default OakComponent({
const wechatLoginId = urlParse?.searchParams?.get('wechatLoginId') as string;
if (!code) {
this.setState({
error: t('missingCodeParameter'),
error: this.t('missingCodeParameter'),
loading: false,
});
return;
@ -45,7 +44,7 @@ export default OakComponent({
} else {
try {
// web微信扫码跟公众号授权
await features.token.loginWechat(code, {
await this.features.token.loginWechat(code, {
wechatLoginId,
});
this.setState({
@ -54,7 +53,7 @@ export default OakComponent({
this.go(state);
} catch (err) {
this.setState({
error: t('weChatLoginFailed'),
error: this.t('weChatLoginFailed'),
loading: false,
});
throw err;