aspectwrapper的返回结构适配,以及token中loginWechat去更新用户信息

This commit is contained in:
Xu Chang 2023-02-09 14:37:59 +08:00
parent d95164a323
commit 224740cd26
13 changed files with 26 additions and 17 deletions

View File

@ -1025,7 +1025,12 @@ function loginWechat(_a, context) {
case 2:
_b = tslib_1.__read.apply(void 0, [_c.sent(), 1]), tokenInfo = _b[0];
(0, assert_1.assert)(tokenInfo.entity === 'wechatUser');
// await tryRefreshWechatPublicUserInfo<ED, Cxt>(tokenInfo.entityId!, context);
return [4 /*yield*/, context.setTokenValue(tokenId)];
case 3:
_c.sent();
return [4 /*yield*/, tryRefreshWechatPublicUserInfo(tokenInfo.entityId, context)];
case 4:
_c.sent();
return [2 /*return*/, tokenId];
}
});

View File

@ -61,7 +61,7 @@ var Application = /** @class */ (function (_super) {
domain: domain,
})];
case 1:
applicationId = _b.sent();
applicationId = (_b.sent()).result;
this.applicationId = applicationId;
this.getApplicationFromCache();
// 如果取得的type和当前环境不同则不缓存id(未来可能有type相同的appliction上线)

View File

@ -41,7 +41,7 @@ var ExtraFile = /** @class */ (function (_super) {
(0, assert_1.default)(origin && origin !== 'unknown');
return [4 /*yield*/, this.getUploadInfo(origin, key)];
case 1:
uploadInfo = _a.sent();
uploadInfo = (_a.sent()).result;
if (!(process.env.OAK_PLATFORM === 'wechatMp')) return [3 /*break*/, 3];
up = new upload_1.Upload();
return [4 /*yield*/, up.uploadFile(origin, extra1, uploadInfo)];

View File

@ -53,7 +53,7 @@ var Token = /** @class */ (function (_super) {
env: env,
})];
case 2:
result = _a.sent();
result = (_a.sent()).result;
this.tokenValue = result;
this.storage.save('token:token', result);
this.publish();
@ -75,7 +75,7 @@ var Token = /** @class */ (function (_super) {
env: env,
})];
case 2:
result = _a.sent();
result = (_a.sent()).result;
this.tokenValue = result;
this.storage.save('token:token', result);
this.publish();
@ -100,7 +100,7 @@ var Token = /** @class */ (function (_super) {
env: env,
})];
case 3:
result = _a.sent();
result = (_a.sent()).result;
this.tokenValue = result;
this.storage.save('token:token', result);
this.publish();
@ -208,7 +208,7 @@ var Token = /** @class */ (function (_super) {
env: env,
})];
case 2:
result = _a.sent();
result = (_a.sent()).result;
return [2 /*return*/, result];
}
});

View File

@ -23,6 +23,7 @@
}
}
}
.noData {
display: flex;
flex-direction: column;

View File

@ -9,7 +9,7 @@ function render(props) {
var _this = this;
var _a = props.data, mobiles = _a.mobiles, allowRemove = _a.allowRemove;
var _b = props.methods, goAddMobile = _b.goAddMobile, removeItem = _b.removeItem, execute = _b.execute;
return ((0, jsx_runtime_1.jsxs)("div", tslib_1.__assign({ className: mobile_module_less_1.default.container }, { children: [(mobiles === null || mobiles === void 0 ? void 0 : mobiles.length) > 0 ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(antd_mobile_1.List, tslib_1.__assign({ className: mobile_module_less_1.default.list }, { children: mobiles === null || mobiles === void 0 ? void 0 : mobiles.map(function (ele, index) { return ((0, jsx_runtime_1.jsx)(antd_mobile_1.List.Item, tslib_1.__assign({ prefix: (0, jsx_runtime_1.jsx)(icons_1.MobileOutlined, {}), extra: allowRemove && ((0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ onClick: function () { return tslib_1.__awaiter(_this, void 0, void 0, function () {
return ((0, jsx_runtime_1.jsxs)("div", tslib_1.__assign({ className: mobile_module_less_1.default.container }, { children: [mobiles && mobiles.length > 0 ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(antd_mobile_1.List, tslib_1.__assign({ className: mobile_module_less_1.default.list }, { children: mobiles === null || mobiles === void 0 ? void 0 : mobiles.map(function (ele, index) { return ((0, jsx_runtime_1.jsx)(antd_mobile_1.List.Item, tslib_1.__assign({ prefix: (0, jsx_runtime_1.jsx)(icons_1.MobileOutlined, {}), extra: allowRemove && ((0, jsx_runtime_1.jsx)("div", tslib_1.__assign({ onClick: function () { return tslib_1.__awaiter(_this, void 0, void 0, function () {
var result;
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {

View File

@ -84,6 +84,7 @@ export declare type Config = {
qrCodeApplicationId?: string;
qrCodePublicForMpId?: string;
mpShareImageUrl?: string;
mergeUserDirectly?: boolean;
};
};
export declare type Origin = 'ali' | 'tencent' | 'qiniu' | 'amap';

View File

@ -820,7 +820,8 @@ export async function loginWechat<ED extends EntityDict, Cxt extends BackendRunt
const tokenId = await loginLogic();
const [tokenInfo] = await loadTokenInfo<ED, Cxt>(tokenId, context);
assert(tokenInfo.entity === 'wechatUser');
// await tryRefreshWechatPublicUserInfo<ED, Cxt>(tokenInfo.entityId!, context);
await context.setTokenValue(tokenId);
await tryRefreshWechatPublicUserInfo<ED, Cxt>(tokenInfo.entityId!, context);
return tokenId;
}

View File

@ -52,7 +52,7 @@ export class Application<
`refresh:applicationId${this.applicationId}没有取到有效数据`
);
this.application = data[0];
if (this.application.type !== this.type) {
if (this.application!.type !== this.type) {
this.storage.remove('application:applicationId');
}
}
@ -72,7 +72,7 @@ export class Application<
}
private async loadApplicationInfo(type: AppType, domain: string) {
const applicationId = await this.cache.exec('getApplication', {
const { result: applicationId } = await this.cache.exec('getApplication', {
type,
domain,
});

View File

@ -44,7 +44,7 @@ export class ExtraFile<
// 构造文件上传所需的key
const key = `${entity ? entity + '/' : ''}${objectId}.${extension}`;
assert(origin && origin !== 'unknown');
const uploadInfo = await this.getUploadInfo(origin, key);
const { result: uploadInfo } = await this.getUploadInfo(origin, key);
if (process.env.OAK_PLATFORM === 'wechatMp') {
// 微信小程序使用wx.uploadFile, 封装upload上传源为origin

View File

@ -45,7 +45,7 @@ export class Token<
async loginByMobile(mobile: string, password?: string, captcha?: string) {
const env = await getEnv();
const result = await this.cache.exec('loginByMobile', {
const { result } = await this.cache.exec('loginByMobile', {
password,
mobile,
captcha,
@ -58,7 +58,7 @@ export class Token<
async loginWechat(code: string) {
const env = await getEnv();
const result = await this.cache.exec('loginWechat', {
const { result } = await this.cache.exec('loginWechat', {
code,
env: env as WebEnv,
});
@ -71,7 +71,7 @@ export class Token<
const { code } = await wx.login();
const env = await getEnv();
const result = await this.cache.exec('loginWechatMp', {
const { result } = await this.cache.exec('loginWechatMp', {
code,
env: env as WechatMpEnv,
});
@ -172,7 +172,7 @@ export class Token<
async sendCaptcha(mobile: string) {
const env = await getEnv();
const result = await this.cache.exec('sendCaptcha', {
const { result } = await this.cache.exec('sendCaptcha', {
mobile,
env: env as WebEnv,
});

View File

@ -23,7 +23,7 @@ export default function render(
const { goAddMobile, removeItem, execute } = props.methods;
return (
<div className={Style.container}>
{mobiles?.length > 0 ? (
{mobiles && mobiles.length > 0 ? (
<>
<List className={Style.list}>
{mobiles?.map((ele, index) => (

View File

@ -100,6 +100,7 @@ export type Config = {
qrCodeApplicationId?: string; // 生成二维码时优先使用的appId
qrCodePublicForMpId?: string; // 如果qrCodeType是wechatPublicForMp在此指明关联的小程序appId
mpShareImageUrl?: string; // 小程序分享时的imageUrl使用网络图片54
mergeUserDirectly?: boolean; // 当发现用户具有相同的特征时直接合并
};
};