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

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

View File

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

View File

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

View File

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

View File

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