support passing debug data between content script and UI

This commit is contained in:
Tamius Han 2020-12-16 00:19:02 +01:00
parent 3f8ea683ef
commit 7a5a4bddf8
2 changed files with 37 additions and 5 deletions

View File

@ -14,12 +14,18 @@ export default {
}, },
data() { data() {
return { return {
uiVisible: true uiVisible: true,
debugData: {
resizer: {},
player: {},
}
}; };
}, },
computed: { computed: {
...mapState([ ...mapState([
'showUi' 'showUi',
'resizerDebugData',
'playerDebugData'
]), ]),
}, },
watch: { watch: {
@ -27,6 +33,12 @@ export default {
if (visible !== undefined) { if (visible !== undefined) {
this.uiVisible = visible; this.uiVisible = visible;
} }
},
resizerDebugData(newData) {
this.debugData.resizer = newData;
},
playerDebugData(newData) {
this.debugData.player = newData;
} }
}, },
created() { created() {

View File

@ -40,7 +40,9 @@ class PlayerUi extends UI {
plugins: [ plugins: [
VuexWebExtensions({ VuexWebExtensions({
persistentStates: [ persistentStates: [
'showUi' 'showUi',
'resizerDebugData',
'playerDebugData',
], ],
}), }),
], ],
@ -53,7 +55,13 @@ class PlayerUi extends UI {
}, },
'uw-set-ui-visible'(state, payload) { 'uw-set-ui-visible'(state, payload) {
state['showUi'] = payload; state['showUi'] = payload;
} },
'uw-set-player-debug-data'(state, payload) {
state['playerDebugData'] = payload;
},
'uw-set-resizer-debug-data'(state, payload) {
state['resizerDebugData'] = payload;
},
}, },
actions: { actions: {
'uw-set-ui-visible'({commit}, payload) { 'uw-set-ui-visible'({commit}, payload) {
@ -62,7 +70,13 @@ class PlayerUi extends UI {
}, },
'uw-toggle-ui'({commit}) { 'uw-toggle-ui'({commit}) {
commit('uw-toggle-ui'); commit('uw-toggle-ui');
} },
'uw-set-player-debug-data'({commit}, payload) {
commit('uw-set-player-debug-data ', payload);
},
'uw-set-resizer-debug-data'({commit}, payload) {
commit('uw-set-resizer-debug-data ', payload);
},
} }
}; };
} }
@ -90,6 +104,12 @@ class PlayerUi extends UI {
super.replace(this.getUiConfig(playerElement)); super.replace(this.getUiConfig(playerElement));
} }
//#endregion //#endregion
//#region debug methods
updateDebugInfo(component, data) {
this.vuexStore?.dispatch(`uw-set-${component}-debug-data`, data);
}
//#endregion
} }
if (process.env.CHANNEL !== 'stable'){ if (process.env.CHANNEL !== 'stable'){