@vnejs/module.components 0.0.4 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/modules/controller.js +3 -3
- package/modules/view.js +4 -21
- package/package.json +1 -1
package/modules/controller.js
CHANGED
|
@@ -47,13 +47,13 @@ export class ModuleController extends Module {
|
|
|
47
47
|
|
|
48
48
|
setShow = (value, isForce = false) => this.updateStateAndView({ isShow: value }, isForce);
|
|
49
49
|
|
|
50
|
-
loadImageMedia = (name, mediaType, quality, isTmp
|
|
50
|
+
loadImageMedia = (name, mediaType, quality, isTmp) => {
|
|
51
51
|
const [type, priority] = [this.CONST.MEDIA.TYPES.IMAGE, this.CONST.MEDIA.PRIORITIES.HIGH];
|
|
52
52
|
|
|
53
|
-
return this.emitOne(this.EVENTS.MEDIA.LOAD, { type, priority, quality, name, mediaType, isTmp
|
|
53
|
+
return this.emitOne(this.EVENTS.MEDIA.LOAD, { type, priority, quality, name, mediaType, isTmp });
|
|
54
54
|
};
|
|
55
55
|
loadBgMedia = () => {
|
|
56
|
-
const [layer, quality] = [this.CONST.
|
|
56
|
+
const [layer, quality] = [this.CONST.LAYER_BG.LAYER, this.shared.settings[this.SETTINGS.LAYER.QUALITY]];
|
|
57
57
|
|
|
58
58
|
return this.loadImageMedia(this.bgName, layer, quality, false, true);
|
|
59
59
|
};
|
package/modules/view.js
CHANGED
|
@@ -7,7 +7,6 @@ export class ModuleView extends Module {
|
|
|
7
7
|
renderFunc = null;
|
|
8
8
|
updateEvent = null;
|
|
9
9
|
updateHandler = null;
|
|
10
|
-
canvasInfo = null;
|
|
11
10
|
locLabel = null;
|
|
12
11
|
|
|
13
12
|
store = createStore(() => ({}));
|
|
@@ -16,23 +15,12 @@ export class ModuleView extends Module {
|
|
|
16
15
|
if (this.updateEvent && this.updateHandler) this.on(this.updateEvent, this.updateHandler);
|
|
17
16
|
};
|
|
18
17
|
|
|
19
|
-
init =
|
|
20
|
-
if (this.renderFunc) await this.regComponent();
|
|
21
|
-
if (this.canvasInfo) await this.regCanvas();
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
regCanvas = async () => {
|
|
25
|
-
if (this.canvasInfo) await this.emit(this.EVENTS.CANVAS.CANVAS_REG, this.canvasInfo);
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
regComponent = async () => {
|
|
29
|
-
this.component = await this.emitOne(this.EVENTS.COMPONENTS.REG, { name: this.name, renderFunc: this.renderFunc, store: this.store });
|
|
30
|
-
};
|
|
18
|
+
init = () => this.renderFunc && this.emitOne(this.EVENTS.COMPONENTS.REG, { name: this.name, renderFunc: this.renderFunc, store: this.store });
|
|
31
19
|
|
|
32
20
|
onUpdateStoreComponent = async (state = {}) => {
|
|
33
21
|
if (!this.isReady) await this.waitIsReady();
|
|
34
22
|
|
|
35
|
-
await this.
|
|
23
|
+
if (this.locLabel) state.locs = await this.emitOne(this.EVENTS.LOCS.GET, { label: this.locLabel });
|
|
36
24
|
|
|
37
25
|
return new Promise(async (resolve) => {
|
|
38
26
|
if (state.isForce) {
|
|
@@ -42,15 +30,10 @@ export class ModuleView extends Module {
|
|
|
42
30
|
await this.waitRerender();
|
|
43
31
|
return resolve();
|
|
44
32
|
}
|
|
45
|
-
|
|
33
|
+
|
|
34
|
+
await this.store.setState(state);
|
|
46
35
|
|
|
47
36
|
return state.isFast ? resolve() : setTimeout(resolve, this.animationTime);
|
|
48
37
|
});
|
|
49
38
|
};
|
|
50
|
-
|
|
51
|
-
insertExtraDataToState = async (state) => {
|
|
52
|
-
if (this.locLabel) state.locs = await this.emitOne(this.EVENTS.LOCS.GET, { label: this.locLabel, isConstant: true });
|
|
53
|
-
|
|
54
|
-
return state;
|
|
55
|
-
};
|
|
56
39
|
}
|