Commit e74399ed authored by limingzhe's avatar limingzhe

fix: 断线 重连 改用storeData

parent 5f8cd4e2
......@@ -157,6 +157,7 @@ export class PlayComponent implements OnInit, OnDestroy {
if (aspect) {
console.log('aspect : ', aspect);
this.initPageData(aspect);
this.initStoreData(aspect);
}
if (data && typeof data == 'object') {
......@@ -185,6 +186,50 @@ export class PlayComponent implements OnInit, OnDestroy {
}
// 用于存储私有数据 当翻页时清空
storeData;
initStoreData(aspect) {
const storeDataStr = aspect?.user_aspect;
if (!storeDataStr) {
this.storeData = {};
} else {
this.storeData = JSON.parse(storeDataStr);
}
console.log('this.storeData: ', this.storeData);
}
setStoreData(key, value, isSend=true) {
if (this.storeData) {
console.log('this.storeData: ', this.storeData);
this.storeData[key] = value;
if (isSend) {
this.sendStoreData();
}
}
}
getStoreData(key) {
return this.storeData && this.storeData[key];
}
sendStoreData() {
const data = this.storeData;
if (window && window['courseware']) {
let storeAspect = window['courseware'].storeAspect;
if (storeAspect) {
storeAspect(data);
}
}
}
// 用于存储公共数据 当翻页时清空
pageData;
initPageData(aspect) {
......@@ -502,6 +547,9 @@ export class PlayComponent implements OnInit, OnDestroy {
c.onEvent('game_start', (data, next) => {
this.setStoreData('progress', '1');
this.gameStart();
if (next) {
next();
......@@ -558,6 +606,12 @@ export class PlayComponent implements OnInit, OnDestroy {
}
_initView() {
// const spr = new MySprite()
// spr.init(this.images.get("result_panel_item"));
......@@ -684,7 +738,7 @@ export class PlayComponent implements OnInit, OnDestroy {
relink() {
const progress = this.getPageData('progress');
const progress = this.getStoreData('progress');
if (this.isTeacher) {
if (progress != null) {
......@@ -699,7 +753,7 @@ export class PlayComponent implements OnInit, OnDestroy {
this.gameStart();
const resultData = this.getPageData('resultData')
const resultData = this.getStoreData('resultData')
if (resultData) {
this.initResultView(resultData);
return;
......@@ -770,7 +824,7 @@ export class PlayComponent implements OnInit, OnDestroy {
} else {
const resultData = this.getResultData();
this.sendResult(resultData);
this.setPageData('resultData', resultData);
this.setStoreData('resultData', resultData);
}
......@@ -1560,7 +1614,7 @@ export class PlayComponent implements OnInit, OnDestroy {
if (this.sendBtn && this.sendBtn.visible) {
if (this.checkClickTargetSv(this.sendBtn)) {
this.sendServerEvent('game_start', {});
this.setPageData('progress', '1');
// this.setPageData('progress', '1');
this.playAudio('submit', true);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment