split popup into ts
This commit is contained in:
parent
8cefa4af2f
commit
73eb5ffe93
@ -195,8 +195,8 @@
|
|||||||
:settings="settings"
|
:settings="settings"
|
||||||
:site="selectedSite"
|
:site="selectedSite"
|
||||||
/>
|
/>
|
||||||
<PerformancePanel v-if="selectedTab === 'performance-metrics'"
|
<!-- <PerformancePanel v-if="selectedTab === 'performance-metrics'"
|
||||||
:performance="performance" />
|
:performance="performance" /> -->
|
||||||
<WhatsNewPanel v-if="selectedTab === 'whats-new'" />
|
<WhatsNewPanel v-if="selectedTab === 'whats-new'" />
|
||||||
<AboutPanel v-if="selectedTab === 'about'" />
|
<AboutPanel v-if="selectedTab === 'about'" />
|
||||||
<Donate v-if="selectedTab === 'donate'" />
|
<Donate v-if="selectedTab === 'donate'" />
|
||||||
@ -205,39 +205,23 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script lang="ts">
|
||||||
import Icon from '../common/components/Icon.vue'
|
|
||||||
import WhatsNewPanel from './panels/WhatsNewPanel.vue';
|
|
||||||
import SiteDetailsPanel from './panels/SiteDetailsPanel.vue';
|
|
||||||
import Donate from '../common/misc/Donate.vue';
|
|
||||||
import Debug from '../ext/conf/Debug';
|
|
||||||
import BrowserDetect from '../ext/conf/BrowserDetect';
|
|
||||||
import Comms from '../ext/lib/comms/Comms';
|
|
||||||
import VideoPanel from './panels/VideoPanel';
|
|
||||||
import PerformancePanel from './panels/PerformancePanel';
|
|
||||||
import Settings from '../ext/lib/Settings';
|
|
||||||
import ExecAction from './js/ExecAction.js';
|
|
||||||
import DefaultSettingsPanel from './panels/DefaultSettingsPanel';
|
|
||||||
import AboutPanel from './panels/AboutPanel';
|
|
||||||
import ExtensionMode from '../common/enums/ExtensionMode.enum';
|
|
||||||
import Logger from '../ext/lib/Logger';
|
|
||||||
import {ChromeShittinessMitigations as CSM} from '../common/js/ChromeShittinessMitigations';
|
|
||||||
|
|
||||||
export default {
|
|
||||||
data () {
|
export default Vue.extend({
|
||||||
|
data () {
|
||||||
return {
|
return {
|
||||||
selectedTab: 'video',
|
selectedTab: 'video',
|
||||||
selectedFrame: '__all',
|
selectedFrame: '__all',
|
||||||
selectedSite: '',
|
selectedSite: '',
|
||||||
activeFrames: [],
|
activeFrames: [],
|
||||||
activeSites: [],
|
activeSites: [],
|
||||||
comms: new Comms(),
|
|
||||||
frameStore: {},
|
frameStore: {},
|
||||||
frameStoreCount: 0,
|
frameStoreCount: 0,
|
||||||
performance: {},
|
performance: {},
|
||||||
site: null,
|
site: null,
|
||||||
currentZoom: 1,
|
currentZoom: 1,
|
||||||
execAction: new ExecAction(),
|
execAction: new ExecAction(null, null),
|
||||||
settings: {},
|
settings: {},
|
||||||
settingsInitialized: false,
|
settingsInitialized: false,
|
||||||
logger: {},
|
logger: {},
|
||||||
@ -260,9 +244,10 @@ export default {
|
|||||||
await this.settings.init();
|
await this.settings.init();
|
||||||
this.settingsInitialized = true;
|
this.settingsInitialized = true;
|
||||||
|
|
||||||
const port = BrowserDetect.firefox ? browser.runtime.connect({name: 'popup-port'}) : chrome.runtime.connect({name: 'popup-port'});
|
const port = browser.runtime.connect(null, {name: 'popup-port'});
|
||||||
port.onMessage.addListener( (m,p) => this.processReceivedMessage(m,p));
|
// port.onMessage.addListener( (m,p) => this.processReceivedMessage(m,p));
|
||||||
CSM.setProperty('port', port);
|
|
||||||
|
// CSM.setProperty('port', port);
|
||||||
|
|
||||||
this.execAction.setSettings(this.settings);
|
this.execAction.setSettings(this.settings);
|
||||||
|
|
||||||
@ -272,12 +257,12 @@ export default {
|
|||||||
cmd: 'unmark-player',
|
cmd: 'unmark-player',
|
||||||
forwardToAll: true,
|
forwardToAll: true,
|
||||||
});
|
});
|
||||||
if (BrowserDetect.anyChromium) {
|
// if (BrowserDetect.anyChromium) {
|
||||||
chrome.extension.getBackgroundPage().sendUnmarkPlayer({
|
// chrome.extension.getBackgroundPage().sendUnmarkPlayer({
|
||||||
cmd: 'unmark-player',
|
// cmd: 'unmark-player',
|
||||||
forwardToAll: true,
|
// forwardToAll: true,
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
});
|
});
|
||||||
|
|
||||||
// get info about current site from background script
|
// get info about current site from background script
|
||||||
@ -307,7 +292,6 @@ export default {
|
|||||||
components: {
|
components: {
|
||||||
VideoPanel,
|
VideoPanel,
|
||||||
DefaultSettingsPanel,
|
DefaultSettingsPanel,
|
||||||
PerformancePanel,
|
|
||||||
Debug,
|
Debug,
|
||||||
BrowserDetect,
|
BrowserDetect,
|
||||||
AboutPanel,
|
AboutPanel,
|
||||||
@ -318,7 +302,7 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
async sleep(t) {
|
async sleep(t) {
|
||||||
return new Promise( (resolve,reject) => {
|
return new Promise<void>( (resolve,reject) => {
|
||||||
setTimeout(() => resolve(), t);
|
setTimeout(() => resolve(), t);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@ -333,20 +317,6 @@ export default {
|
|||||||
this.logger.log('error','popup','[popup::getSite] sending get-current-site failed for some reason. Reason:', e);
|
this.logger.log('error','popup','[popup::getSite] sending get-current-site failed for some reason. Reason:', e);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
getRandomColor() {
|
|
||||||
return `rgb(${Math.floor(Math.random() * 128)}, ${Math.floor(Math.random() * 128)}, ${Math.floor(Math.random() * 128)})`;
|
|
||||||
},
|
|
||||||
selectTab(tab) {
|
|
||||||
this.selectedTab = tab;
|
|
||||||
if (tab === 'whats-new') {
|
|
||||||
this.settings.active.whatsNewChecked = true;
|
|
||||||
this.settings.save();
|
|
||||||
}
|
|
||||||
this.toggleSideMenu(false);
|
|
||||||
},
|
|
||||||
selectFrame(frame) {
|
|
||||||
this.selectedFrame = frame;
|
|
||||||
},
|
|
||||||
async updateConfig() {
|
async updateConfig() {
|
||||||
// when this runs, a site could have been enabled or disabled
|
// when this runs, a site could have been enabled or disabled
|
||||||
// this means we must update canShowVideoTab
|
// this means we must update canShowVideoTab
|
||||||
@ -387,7 +357,7 @@ export default {
|
|||||||
if (this.site) {
|
if (this.site) {
|
||||||
if (!this.site.host) {
|
if (!this.site.host) {
|
||||||
// dunno why this fix is needed, but sometimes it is
|
// dunno why this fix is needed, but sometimes it is
|
||||||
this.site.host = site.tabHostname;
|
this.site.host = message.site.tabHostname;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!this.site || this.site.host !== message.site.host) {
|
if (!this.site || this.site.host !== message.site.host) {
|
||||||
@ -529,7 +499,7 @@ export default {
|
|||||||
// update whether video tab can be shown
|
// update whether video tab can be shown
|
||||||
this.updateCanShowVideoTab();
|
this.updateCanShowVideoTab();
|
||||||
},
|
},
|
||||||
getRandomColor() {
|
getRandomColor(): string {
|
||||||
return `rgb(${Math.floor(Math.random() * 128)}, ${Math.floor(Math.random() * 128)}, ${Math.floor(Math.random() * 128)})`;
|
return `rgb(${Math.floor(Math.random() * 128)}, ${Math.floor(Math.random() * 128)}, ${Math.floor(Math.random() * 128)})`;
|
||||||
},
|
},
|
||||||
setCurrentZoom(nz) {
|
setCurrentZoom(nz) {
|
||||||
@ -538,8 +508,16 @@ export default {
|
|||||||
updateZoom(nz){
|
updateZoom(nz){
|
||||||
this.currentZoom = nz;
|
this.currentZoom = nz;
|
||||||
},
|
},
|
||||||
selectFrame(id){
|
selectTab(tab) {
|
||||||
this.selectedFrame = id;
|
this.selectedTab = tab;
|
||||||
|
if (tab === 'whats-new') {
|
||||||
|
this.settings.active.whatsNewChecked = true;
|
||||||
|
this.settings.save();
|
||||||
|
}
|
||||||
|
this.toggleSideMenu(false);
|
||||||
|
},
|
||||||
|
selectFrame(frame) {
|
||||||
|
this.selectedFrame = frame;
|
||||||
},
|
},
|
||||||
selectSite(host) {
|
selectSite(host) {
|
||||||
this.selectedSite = host;
|
this.selectedSite = host;
|
||||||
@ -548,7 +526,7 @@ export default {
|
|||||||
this.sideMenuVisible = visible ?? !this.sideMenuVisible;
|
this.sideMenuVisible = visible ?? !this.sideMenuVisible;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style src="../res/css/font/overpass.css"></style>
|
<style src="../res/css/font/overpass.css"></style>
|
10
src/popup/Popup.ts
Normal file
10
src/popup/Popup.ts
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
import { createApp } from 'vue'
|
||||||
|
import App from './ExtensionActionButtonApp.vue';
|
||||||
|
|
||||||
|
class Popup {
|
||||||
|
static createApp() {
|
||||||
|
createApp(App).mount('#app');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Popup;
|
@ -1,4 +1,3 @@
|
|||||||
import { createApp } from 'vue'
|
import Popup from './Popup';
|
||||||
import App from './App';
|
|
||||||
|
|
||||||
createApp(App).mount('#app');
|
Popup.createApp();
|
||||||
|
Loading…
Reference in New Issue
Block a user