initialize content script vue/ui only if there's a need
This commit is contained in:
parent
9a2261faed
commit
4b177a9724
@ -10,6 +10,7 @@ class Logger {
|
|||||||
this.isBackgroundScript = true;
|
this.isBackgroundScript = true;
|
||||||
|
|
||||||
this.vuexStore = options?.vuexStore;
|
this.vuexStore = options?.vuexStore;
|
||||||
|
this.uwInstance = options?.uwInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
static saveConfig(conf) {
|
static saveConfig(conf) {
|
||||||
@ -120,6 +121,10 @@ class Logger {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setVuexStore(store) {
|
||||||
|
this.vuexStore = store;
|
||||||
|
}
|
||||||
|
|
||||||
clear() {
|
clear() {
|
||||||
this.log = [];
|
this.log = [];
|
||||||
this.startTime = performance.now();
|
this.startTime = performance.now();
|
||||||
@ -295,6 +300,10 @@ class Logger {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isLoggingAllowed() {
|
||||||
|
return this.conf.allowLogging;
|
||||||
|
}
|
||||||
|
|
||||||
isLoggingToFile() {
|
isLoggingToFile() {
|
||||||
return this.conf.allowLogging && this.conf.fileOptions?.enabled;
|
return this.conf.allowLogging && this.conf.fileOptions?.enabled;
|
||||||
}
|
}
|
||||||
@ -470,9 +479,14 @@ class Logger {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!this.vuexStore) {
|
if (!this.vuexStore) {
|
||||||
console.error("[info] No vue store. Log will not be exported.");
|
console.error("[info] No vue store.");
|
||||||
|
if (!this.uwInstance) {
|
||||||
|
console.error('[info] no vue instance either. Not logging.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
console.info("[info] Initializing vue and vuex instance ...");
|
||||||
|
this.uwInstance.initVue();
|
||||||
|
}
|
||||||
|
|
||||||
console.info('[info] vuex store present. Parsing logs.');
|
console.info('[info] vuex store present. Parsing logs.');
|
||||||
|
|
||||||
|
@ -41,6 +41,8 @@ class UW {
|
|||||||
this.actionHandler = undefined;
|
this.actionHandler = undefined;
|
||||||
this.logger = undefined;
|
this.logger = undefined;
|
||||||
this.vuexStore = {};
|
this.vuexStore = {};
|
||||||
|
this.uiInitiated = false;
|
||||||
|
this.vueInitiated = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
reloadSettings() {
|
reloadSettings() {
|
||||||
@ -87,9 +89,16 @@ class UW {
|
|||||||
'handleMouseMove': false
|
'handleMouseMove': false
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
this.logger = new Logger({vuexStore: this.vuexStore});
|
this.logger = new Logger();
|
||||||
await this.logger.init(loggingOptions);
|
await this.logger.init(loggingOptions);
|
||||||
|
|
||||||
|
if (this.logger.isLoggingAllowed()) {
|
||||||
|
console.info("[uw::init] Logging is allowed! Initalizing vue and UI!");
|
||||||
|
this.initVue();
|
||||||
|
this.initUi();
|
||||||
|
this.logger.setVuexStore(this.vuexStore);
|
||||||
|
}
|
||||||
|
|
||||||
// show popup if logging to file is enabled
|
// show popup if logging to file is enabled
|
||||||
if (this.logger.isLoggingToFile()) {
|
if (this.logger.isLoggingToFile()) {
|
||||||
console.info('[uw::init] Logging to file is enabled. Will show popup!');
|
console.info('[uw::init] Logging to file is enabled. Will show popup!');
|
||||||
@ -228,14 +237,23 @@ class UW {
|
|||||||
}
|
}
|
||||||
|
|
||||||
showLogger() {
|
showLogger() {
|
||||||
|
if (! this.vueInitiated) {
|
||||||
|
this.initVue();
|
||||||
|
}
|
||||||
|
if (!this.uiInitiated) {
|
||||||
|
this.initUi();
|
||||||
|
}
|
||||||
|
|
||||||
this.vuexStore.dispatch('uw-show-logger');
|
this.vuexStore.dispatch('uw-show-logger');
|
||||||
}
|
}
|
||||||
hideLogger() {
|
hideLogger() {
|
||||||
|
// if either of these two is false, then we know that UI doesn't exist
|
||||||
|
// since UI doesn't exist, we don't need to dispatch uw-hide-logger
|
||||||
|
if (this.vueInitiated && this.uiInitiated) {
|
||||||
this.vuexStore.dispatch('uw-hide-logger');
|
this.vuexStore.dispatch('uw-hide-logger');
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var main = new UW();
|
var main = new UW();
|
||||||
main.initVue();
|
|
||||||
main.initUi();
|
|
||||||
main.init();
|
main.init();
|
||||||
|
Loading…
Reference in New Issue
Block a user