fix
This commit is contained in:
commit
03497ff5ca
|
|
@ -5,7 +5,7 @@ interface TimedNotificationdata extends NotificationData {
|
||||||
dieAt: number;
|
dieAt: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
let KILLER: number | undefined = undefined;
|
let KILLER: NodeJS.Timeout | undefined = undefined;
|
||||||
export default OakComponent({
|
export default OakComponent({
|
||||||
data: {
|
data: {
|
||||||
messages: [] as TimedNotificationdata[],
|
messages: [] as TimedNotificationdata[],
|
||||||
|
|
@ -37,7 +37,7 @@ export default OakComponent({
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof KILLER === 'number') {
|
if (KILLER) {
|
||||||
clearTimeout(KILLER);
|
clearTimeout(KILLER);
|
||||||
}
|
}
|
||||||
KILLER = setTimeout(
|
KILLER = setTimeout(
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ export default OakPage({
|
||||||
}
|
}
|
||||||
else if (this.counterHandler) {
|
else if (this.counterHandler) {
|
||||||
clearTimeout(this.couuterHandler);
|
clearTimeout(this.couuterHandler);
|
||||||
this.counterHandler = undefined;
|
this.counterHandler = undefined;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
|
|
@ -40,33 +40,47 @@ export default OakPage({
|
||||||
methods: {
|
methods: {
|
||||||
onInput(e: any) {
|
onInput(e: any) {
|
||||||
const { dataset, value } = this.resolveInput(e);
|
const { dataset, value } = this.resolveInput(e);
|
||||||
const{ attr } = dataset;
|
const { attr } = dataset;
|
||||||
this.setState({
|
this.setState({
|
||||||
[attr]: value,
|
[attr]: value,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
async sendCaptcha() {
|
async sendCaptcha() {
|
||||||
const { mobile } = this.state;
|
const { mobile } = this.state;
|
||||||
const result = await this.features.token.sendCaptcha(mobile);
|
try {
|
||||||
// 显示返回消息
|
const result = await this.features.token.sendCaptcha(mobile);
|
||||||
this.setState({
|
// 显示返回消息
|
||||||
oakError: {
|
this.setNotification({
|
||||||
type: 'success',
|
type: 'success',
|
||||||
msg: result,
|
content: result,
|
||||||
}
|
});
|
||||||
});
|
this.save(SEND_KEY, Date.now());
|
||||||
this.save(SEND_KEY, Date.now());
|
this.reRender();
|
||||||
this.reRender();
|
}
|
||||||
|
catch (err) {
|
||||||
|
this.setNotification({
|
||||||
|
type: 'error',
|
||||||
|
content: (err as Error).message,
|
||||||
|
});
|
||||||
|
}
|
||||||
},
|
},
|
||||||
async loginByMobile() {
|
async loginByMobile() {
|
||||||
const { eventLoggedIn } = this.props;
|
const { eventLoggedIn } = this.props;
|
||||||
const { mobile, password, captcha } = this.state;
|
const { mobile, password, captcha } = this.state;
|
||||||
await this.features.token.loginByMobile(mobile, password, captcha);
|
try {
|
||||||
if (eventLoggedIn) {
|
await this.features.token.loginByMobile(mobile, password, captcha);
|
||||||
this.pub(eventLoggedIn);
|
if (eventLoggedIn) {
|
||||||
|
this.pub(eventLoggedIn);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.navigateBack();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
catch (err) {
|
||||||
this.navigateBack();
|
this.setNotification({
|
||||||
|
type: 'error',
|
||||||
|
content: (err as Error).message,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,40 @@
|
||||||
|
import { WebEnv, WechatMpEnv } from "general-app-domain/Token/Schema";
|
||||||
|
import { AppType } from 'general-app-domain/Application/Schema';
|
||||||
|
import { EntityDict } from "general-app-domain";
|
||||||
|
import { QiniuUploadInfo } from "oak-frontend-base/src/types/Upload";
|
||||||
|
import { GeneralRuntimeContext } from "../RuntimeContext";
|
||||||
|
declare type GeneralAspectDict<ED extends EntityDict, Cxt extends GeneralRuntimeContext<ED>> = {
|
||||||
|
loginByMobile: (params: {
|
||||||
|
captcha?: string;
|
||||||
|
password?: string;
|
||||||
|
mobile: string;
|
||||||
|
env: WebEnv | WechatMpEnv;
|
||||||
|
}, context: Cxt) => Promise<string>;
|
||||||
|
loginMp: (params: {
|
||||||
|
code: string;
|
||||||
|
}, context: Cxt) => Promise<string>;
|
||||||
|
loginWechatMp: ({ code, env }: {
|
||||||
|
code: string;
|
||||||
|
env: WechatMpEnv;
|
||||||
|
}, context: Cxt) => Promise<string>;
|
||||||
|
syncUserInfoWechatMp: ({ nickname, avatarUrl, encryptedData, iv, signature }: {
|
||||||
|
nickname: string;
|
||||||
|
avatarUrl: string;
|
||||||
|
encryptedData: string;
|
||||||
|
iv: string;
|
||||||
|
signature: string;
|
||||||
|
}, context: Cxt) => Promise<void>;
|
||||||
|
getUploadInfo: (params: {
|
||||||
|
origin: string;
|
||||||
|
fileName: string;
|
||||||
|
}, context: Cxt) => Promise<QiniuUploadInfo>;
|
||||||
|
sendCaptcha: (params: {
|
||||||
|
mobile: string;
|
||||||
|
env: WechatMpEnv | WebEnv;
|
||||||
|
}) => Promise<string>;
|
||||||
|
getApplication: (params: {
|
||||||
|
type: AppType;
|
||||||
|
}, context: Cxt) => Promise<string>;
|
||||||
|
};
|
||||||
|
export declare type AspectDict<ED extends EntityDict, Cxt extends GeneralRuntimeContext<ED>> = GeneralAspectDict<ED, Cxt>;
|
||||||
|
export {};
|
||||||
|
|
@ -3,5 +3,4 @@ import { AppType } from "general-app-domain/Application/Schema";
|
||||||
import { GeneralRuntimeContext } from "../RuntimeContext";
|
import { GeneralRuntimeContext } from "../RuntimeContext";
|
||||||
export declare function getApplication<ED extends EntityDict, Cxt extends GeneralRuntimeContext<ED>>(params: {
|
export declare function getApplication<ED extends EntityDict, Cxt extends GeneralRuntimeContext<ED>>(params: {
|
||||||
type: AppType;
|
type: AppType;
|
||||||
url: string;
|
|
||||||
}, context: Cxt): Promise<string>;
|
}, context: Cxt): Promise<string>;
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ export declare class Application<ED extends EntityDict, Cxt extends GeneralRunti
|
||||||
private rwLock;
|
private rwLock;
|
||||||
private cache;
|
private cache;
|
||||||
private storage;
|
private storage;
|
||||||
constructor(aspectWrapper: AspectWrapper<ED, Cxt, AD>, type: AppType, url: string, cache: Cache<ED, Cxt, AD & CommonAspectDict<ED, Cxt>>, storage: LocalStorage<ED, Cxt, AD & CommonAspectDict<ED, Cxt>>, callback: (application: SelectRowShape<ED['application']['Schema'], typeof projection>) => void);
|
constructor(aspectWrapper: AspectWrapper<ED, Cxt, AD>, type: AppType, cache: Cache<ED, Cxt, AD & CommonAspectDict<ED, Cxt>>, storage: LocalStorage<ED, Cxt, AD & CommonAspectDict<ED, Cxt>>, callback: (application: SelectRowShape<ED['application']['Schema'], typeof projection>) => void);
|
||||||
private getApplicationFromCache;
|
private getApplicationFromCache;
|
||||||
private refresh;
|
private refresh;
|
||||||
getApplication(): Promise<SelectRowShape<ED["application"]["Schema"], {
|
getApplication(): Promise<SelectRowShape<ED["application"]["Schema"], {
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ class Application extends oak_frontend_base_1.Feature {
|
||||||
rwLock;
|
rwLock;
|
||||||
cache;
|
cache;
|
||||||
storage;
|
storage;
|
||||||
constructor(aspectWrapper, type, url, cache, storage, callback) {
|
constructor(aspectWrapper, type, cache, storage, callback) {
|
||||||
super(aspectWrapper);
|
super(aspectWrapper);
|
||||||
this.rwLock = new concurrent_1.RWLock();
|
this.rwLock = new concurrent_1.RWLock();
|
||||||
this.cache = cache;
|
this.cache = cache;
|
||||||
|
|
@ -37,7 +37,7 @@ class Application extends oak_frontend_base_1.Feature {
|
||||||
this.getApplicationFromCache(callback);
|
this.getApplicationFromCache(callback);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.refresh(type, url, callback);
|
this.refresh(type, callback);
|
||||||
}
|
}
|
||||||
this.rwLock.release();
|
this.rwLock.release();
|
||||||
}
|
}
|
||||||
|
|
@ -52,9 +52,8 @@ class Application extends oak_frontend_base_1.Feature {
|
||||||
this.application = result[0];
|
this.application = result[0];
|
||||||
callback(this.application);
|
callback(this.application);
|
||||||
}
|
}
|
||||||
async refresh(type, url, callback) {
|
async refresh(type, callback) {
|
||||||
const { result: applicationId } = await this.getAspectWrapper().exec('getApplication', {
|
const { result: applicationId } = await this.getAspectWrapper().exec('getApplication', {
|
||||||
url,
|
|
||||||
type,
|
type,
|
||||||
});
|
});
|
||||||
this.applicationId = applicationId;
|
this.applicationId = applicationId;
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ import { BasicFeatures } from 'oak-frontend-base';
|
||||||
import { AspectDict } from '../aspects/AspectDict';
|
import { AspectDict } from '../aspects/AspectDict';
|
||||||
import { AspectWrapper } from 'oak-domain/lib/types';
|
import { AspectWrapper } from 'oak-domain/lib/types';
|
||||||
import { AppType } from 'general-app-domain/Application/Schema';
|
import { AppType } from 'general-app-domain/Application/Schema';
|
||||||
export declare function initialize<ED extends EntityDict, Cxt extends GeneralRuntimeContext<ED>, AD extends AspectDict<ED, Cxt>>(aspectWrapper: AspectWrapper<ED, Cxt, AD & CommonAspectDict<ED, Cxt>>, basicFeatures: BasicFeatures<ED, Cxt, AD & CommonAspectDict<ED, Cxt>>, type: AppType, url: string, context: Cxt): {
|
export declare function initialize<ED extends EntityDict, Cxt extends GeneralRuntimeContext<ED>, AD extends AspectDict<ED, Cxt>>(aspectWrapper: AspectWrapper<ED, Cxt, AD & CommonAspectDict<ED, Cxt>>, basicFeatures: BasicFeatures<ED, Cxt, AD & CommonAspectDict<ED, Cxt>>, type: AppType, context: Cxt): {
|
||||||
token: Token<ED, Cxt, AD & CommonAspectDict<ED, Cxt>>;
|
token: Token<ED, Cxt, AD & CommonAspectDict<ED, Cxt>>;
|
||||||
extraFile: ExtraFile<ED, Cxt, AD & CommonAspectDict<ED, Cxt>>;
|
extraFile: ExtraFile<ED, Cxt, AD & CommonAspectDict<ED, Cxt>>;
|
||||||
application: Application<ED, Cxt, AD & CommonAspectDict<ED, Cxt>>;
|
application: Application<ED, Cxt, AD & CommonAspectDict<ED, Cxt>>;
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,8 @@ exports.initialize = void 0;
|
||||||
const token_1 = require("./token");
|
const token_1 = require("./token");
|
||||||
const extraFile_1 = require("./extraFile");
|
const extraFile_1 = require("./extraFile");
|
||||||
const application_1 = require("./application");
|
const application_1 = require("./application");
|
||||||
function initialize(aspectWrapper, basicFeatures, type, url, context) {
|
function initialize(aspectWrapper, basicFeatures, type, context) {
|
||||||
const application = new application_1.Application(aspectWrapper, type, url, basicFeatures.cache, basicFeatures.localStorage, (application) => context.setApplication(application));
|
const application = new application_1.Application(aspectWrapper, type, basicFeatures.cache, basicFeatures.localStorage, (application) => context.setApplication(application));
|
||||||
const token = new token_1.Token(aspectWrapper, basicFeatures.cache, basicFeatures.localStorage, context);
|
const token = new token_1.Token(aspectWrapper, basicFeatures.cache, basicFeatures.localStorage, context);
|
||||||
const extraFile = new extraFile_1.ExtraFile(aspectWrapper);
|
const extraFile = new extraFile_1.ExtraFile(aspectWrapper);
|
||||||
return {
|
return {
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,6 @@
|
||||||
"get:area": "ts-node ./scripts/getAmapArea.ts",
|
"get:area": "ts-node ./scripts/getAmapArea.ts",
|
||||||
"clean:dir": "ts-node ./scripts/cleanDtsAndJs",
|
"clean:dir": "ts-node ./scripts/cleanDtsAndJs",
|
||||||
"test": "ts-node ./test/test.ts",
|
"test": "ts-node ./test/test.ts",
|
||||||
"postinstall": "npm run prebuild",
|
|
||||||
"prepare": "rimraf node_modules/react & rimraf node_modules/react-dom & rimraf node_modules/react-router"
|
"prepare": "rimraf node_modules/react & rimraf node_modules/react-dom & rimraf node_modules/react-router"
|
||||||
},
|
},
|
||||||
"main": "src/index"
|
"main": "src/index"
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,6 @@ type GeneralAspectDict<ED extends EntityDict, Cxt extends GeneralRuntimeContext<
|
||||||
}) => Promise<string>,
|
}) => Promise<string>,
|
||||||
getApplication: (params: {
|
getApplication: (params: {
|
||||||
type: AppType;
|
type: AppType;
|
||||||
url: string;
|
|
||||||
}, context: Cxt) => Promise<string>;
|
}, context: Cxt) => Promise<string>;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@ import { GeneralRuntimeContext } from "../RuntimeContext";
|
||||||
|
|
||||||
export async function getApplication<ED extends EntityDict, Cxt extends GeneralRuntimeContext<ED>>(params: {
|
export async function getApplication<ED extends EntityDict, Cxt extends GeneralRuntimeContext<ED>>(params: {
|
||||||
type: AppType;
|
type: AppType;
|
||||||
url: string;
|
|
||||||
}, context: Cxt) {
|
}, context: Cxt) {
|
||||||
const { type } = params;
|
const { type } = params;
|
||||||
const appId = type === 'web' ? DEV_WEB_APPLICATION_ID : DEV_WECHATMP_APPLICATION_ID;
|
const appId = type === 'web' ? DEV_WEB_APPLICATION_ID : DEV_WECHATMP_APPLICATION_ID;
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,6 @@ export class Application<ED extends EntityDict, Cxt extends GeneralRuntimeContex
|
||||||
constructor(
|
constructor(
|
||||||
aspectWrapper: AspectWrapper<ED, Cxt, AD>,
|
aspectWrapper: AspectWrapper<ED, Cxt, AD>,
|
||||||
type: AppType,
|
type: AppType,
|
||||||
url: string,
|
|
||||||
cache: Cache<ED, Cxt, AD & CommonAspectDict<ED, Cxt>>,
|
cache: Cache<ED, Cxt, AD & CommonAspectDict<ED, Cxt>>,
|
||||||
storage: LocalStorage<ED, Cxt, AD & CommonAspectDict<ED, Cxt>>,
|
storage: LocalStorage<ED, Cxt, AD & CommonAspectDict<ED, Cxt>>,
|
||||||
callback: (application: SelectRowShape<ED['application']['Schema'], typeof projection>) => void) {
|
callback: (application: SelectRowShape<ED['application']['Schema'], typeof projection>) => void) {
|
||||||
|
|
@ -59,7 +58,7 @@ export class Application<ED extends EntityDict, Cxt extends GeneralRuntimeContex
|
||||||
this.getApplicationFromCache(callback);
|
this.getApplicationFromCache(callback);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.refresh(type, url, callback);
|
this.refresh(type, callback);
|
||||||
}
|
}
|
||||||
this.rwLock.release();
|
this.rwLock.release();
|
||||||
}
|
}
|
||||||
|
|
@ -76,9 +75,8 @@ export class Application<ED extends EntityDict, Cxt extends GeneralRuntimeContex
|
||||||
callback(this.application!);
|
callback(this.application!);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async refresh(type: AppType, url: string, callback: (application: SelectRowShape<ED['application']['Schema'], typeof projection>) => void) {
|
private async refresh(type: AppType, callback: (application: SelectRowShape<ED['application']['Schema'], typeof projection>) => void) {
|
||||||
const { result: applicationId } = await this.getAspectWrapper().exec('getApplication', {
|
const { result: applicationId } = await this.getAspectWrapper().exec('getApplication', {
|
||||||
url,
|
|
||||||
type,
|
type,
|
||||||
});
|
});
|
||||||
this.applicationId = applicationId;
|
this.applicationId = applicationId;
|
||||||
|
|
|
||||||
|
|
@ -13,11 +13,10 @@ export function initialize<ED extends EntityDict, Cxt extends GeneralRuntimeCont
|
||||||
aspectWrapper: AspectWrapper<ED, Cxt, AD & CommonAspectDict<ED, Cxt>>,
|
aspectWrapper: AspectWrapper<ED, Cxt, AD & CommonAspectDict<ED, Cxt>>,
|
||||||
basicFeatures: BasicFeatures<ED, Cxt, AD & CommonAspectDict<ED, Cxt>>,
|
basicFeatures: BasicFeatures<ED, Cxt, AD & CommonAspectDict<ED, Cxt>>,
|
||||||
type: AppType,
|
type: AppType,
|
||||||
url: string,
|
|
||||||
context: Cxt,
|
context: Cxt,
|
||||||
) {
|
) {
|
||||||
const application = new Application<ED, Cxt, AD & CommonAspectDict<ED, Cxt>>(
|
const application = new Application<ED, Cxt, AD & CommonAspectDict<ED, Cxt>>(
|
||||||
aspectWrapper, type, url, basicFeatures.cache, basicFeatures.localStorage, (application) => context.setApplication(application));
|
aspectWrapper, type, basicFeatures.cache, basicFeatures.localStorage, (application) => context.setApplication(application));
|
||||||
const token = new Token<ED, Cxt, AD & CommonAspectDict<ED, Cxt>>(aspectWrapper, basicFeatures.cache, basicFeatures.localStorage, context);
|
const token = new Token<ED, Cxt, AD & CommonAspectDict<ED, Cxt>>(aspectWrapper, basicFeatures.cache, basicFeatures.localStorage, context);
|
||||||
const extraFile = new ExtraFile<ED, Cxt, AD & CommonAspectDict<ED, Cxt>>(aspectWrapper);
|
const extraFile = new ExtraFile<ED, Cxt, AD & CommonAspectDict<ED, Cxt>>(aspectWrapper);
|
||||||
return {
|
return {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue