From f05f37841a7935216c62b91efbaf7e736fff41e6 Mon Sep 17 00:00:00 2001 From: Tamius Han Date: Tue, 1 Dec 2020 00:20:10 +0100 Subject: [PATCH] Fix logger UI --- src/ext/lib/Logger.js | 8 ++++++-- src/ext/uw-ui.js | 34 ++++++++++++++++++---------------- 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/src/ext/lib/Logger.js b/src/ext/lib/Logger.js index 2e85119..6478202 100644 --- a/src/ext/lib/Logger.js +++ b/src/ext/lib/Logger.js @@ -486,10 +486,14 @@ class Logger { saveViaBgScript() { console.info('[info] will attempt to save. Issuing "show-logger"'); - if (!this.conf?.fileOptions?.enabled || this.isBackgroundScript) { - console.info('[info] Logging to file is either disabled or we\'re not on the content script. Not saving.'); + if (this.isBackgroundScript) { + console.info('[info] Background script cannot display logger UI.'); return; } + // if (!this.conf?.fileOptions?.enabled) { + // console.info('[info] Logging to file is disabled. Logger won\'t get shown.'); + // return; + // } Comms.sendMessage({cmd: 'show-logger', forwardToSameFramePort: true, port: 'content-ui-port'}); diff --git a/src/ext/uw-ui.js b/src/ext/uw-ui.js index a1c9efc..5d995de 100644 --- a/src/ext/uw-ui.js +++ b/src/ext/uw-ui.js @@ -1,6 +1,6 @@ // vue dependency imports -import {createApp} from 'vue'; -import Vuex from 'vuex'; +import { createApp } from 'vue'; +import { createStore } from 'vuex'; import VuexWebExtensions from 'vuex-webextensions'; import LoggerUi from '../csui/LoggerUi'; @@ -124,18 +124,19 @@ class UwUi { } try { - Vue.prototype.$browser = global.browser; - Vue.use(Vuex); - + // Vue.prototype.$browser = global.browser; + // Vue.use(Vuex); - this.vuexStore = new Vuex.Store({ - plugins: [VuexWebExtensions({ - persistentStates: [ - 'uwLog', - 'showLogger', - 'loggingEnded', - ], - })], + this.vuexStore = createStore({ + plugins: [ + VuexWebExtensions({ + persistentStates: [ + 'uwLog', + 'showLogger', + 'loggingEnded', + ], + }), + ], state: { uwLog: '', showLogger: false, @@ -186,18 +187,17 @@ class UwUi { const uwid = `uw-ui-root-${random}`; const rootDiv = document.createElement('div'); - rootDiv.setAttribute("style", "position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; z-index: 999999; background-color: #ff0000;"); + rootDiv.setAttribute("style", "position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; z-index: 999999;"); rootDiv.setAttribute("id", uwid); document.body.appendChild(rootDiv); try { - createApp('logger-ui') + createApp(LoggerUi) .component('LoggerUi', LoggerUi) .use(this.vuexStore) .mount(`#${uwid}`); - // new Vue({ // el: `#${uwid}`, // components: { @@ -216,12 +216,14 @@ class UwUi { } async showLogger() { + console.log("show logger?") if (!this.loggerUiInitiated) { await this.initLoggerUi(); } try { + console.log("will show logger") this.vuexStore.dispatch('uw-show-logger'); } catch (e) { console.error('Failed to dispatch vuex store', e)